5 |
6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
7 | GtkApplication)
8 |
9 | /**
10 | * my_application_new:
11 | *
12 | * Creates a new Flutter-based application.
13 | *
14 | * Returns: a new #MyApplication.
15 | */
16 | MyApplication* my_application_new();
17 |
18 | #endif // FLUTTER_MY_APPLICATION_H_
19 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/dgph
7 | **/xcuserdata/
8 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Flutter/Flutter-Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "ephemeral/Flutter-Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Flutter/Flutter-Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "ephemeral/Flutter-Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 | import file_picker
9 | import flutter_secure_storage_macos
10 | import google_sign_in_ios
11 | import path_provider_foundation
12 | import shared_preferences_foundation
13 | import sign_in_with_apple
14 | import webview_flutter_wkwebview
15 |
16 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
17 | FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
18 | FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
19 | FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))
20 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
21 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
22 | SignInWithApplePlugin.register(with: registry.registrar(forPlugin: "SignInWithApplePlugin"))
23 | WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin"))
24 | }
25 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Podfile:
--------------------------------------------------------------------------------
1 | platform :osx, '10.14'
2 |
3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
5 |
6 | project 'Runner', {
7 | 'Debug' => :debug,
8 | 'Profile' => :release,
9 | 'Release' => :release,
10 | }
11 |
12 | def flutter_root
13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
14 | unless File.exist?(generated_xcode_build_settings_path)
15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
16 | end
17 |
18 | File.foreach(generated_xcode_build_settings_path) do |line|
19 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
20 | return matches[1].strip if matches
21 | end
22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
23 | end
24 |
25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
26 |
27 | flutter_macos_podfile_setup
28 |
29 | target 'Runner' do
30 | use_frameworks!
31 | use_modular_headers!
32 |
33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
34 | target 'RunnerTests' do
35 | inherit! :search_paths
36 | end
37 | end
38 |
39 | post_install do |installer|
40 | installer.pods_project.targets.each do |target|
41 | flutter_additional_macos_build_settings(target)
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
37 |
38 |
39 |
40 |
43 |
49 |
50 |
51 |
52 |
53 |
63 |
65 |
71 |
72 |
73 |
74 |
80 |
82 |
88 |
89 |
90 |
91 |
93 |
94 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | @main
5 | class AppDelegate: FlutterAppDelegate {
6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
7 | return true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "app_icon_16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "app_icon_32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "app_icon_32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "app_icon_64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "app_icon_128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "app_icon_256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "app_icon_256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "app_icon_512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "app_icon_512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "app_icon_1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Configs/AppInfo.xcconfig:
--------------------------------------------------------------------------------
1 | // Application-level settings for the Runner target.
2 | //
3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
4 | // future. If not, the values below would default to using the project name when this becomes a
5 | // 'flutter create' template.
6 |
7 | // The application's name. By default this is also the title of the Flutter window.
8 | PRODUCT_NAME = firebase_dart_admin_auth_sample_app
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = com.aortem.dartAdminAuthTestApp
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2024 com.aortem. All rights reserved.
15 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Configs/Warnings.xcconfig:
--------------------------------------------------------------------------------
1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
2 | GCC_WARN_UNDECLARED_SELECTOR = YES
3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
6 | CLANG_WARN_PRAGMA_PACK = YES
7 | CLANG_WARN_STRICT_PROTOTYPES = YES
8 | CLANG_WARN_COMMA = YES
9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES
10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
12 | GCC_WARN_SHADOW = YES
13 | CLANG_WARN_UNREACHABLE_CODE = YES
14 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/DebugProfile.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.cs.allow-jit
8 |
9 | com.apple.security.network.server
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | $(PRODUCT_COPYRIGHT)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | class MainFlutterWindow: NSWindow {
5 | override func awakeFromNib() {
6 | let flutterViewController = FlutterViewController()
7 | let windowFrame = self.frame
8 | self.contentViewController = flutterViewController
9 | self.setFrame(windowFrame, display: true)
10 |
11 | RegisterGeneratedPlugins(registry: flutterViewController)
12 |
13 | super.awakeFromNib()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/macos/RunnerTests/RunnerTests.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 | import XCTest
4 |
5 | class RunnerTests: XCTestCase {
6 |
7 | func testExample() {
8 | // If you add code to the Runner application, consider adding tests here.
9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest.
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/test/widget_test.dart:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/web/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/web/favicon.png
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/web/icons/Icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/web/icons/Icon-192.png
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/web/icons/Icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/web/icons/Icon-512.png
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/web/icons/Icon-maskable-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/web/icons/Icon-maskable-192.png
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/web/icons/Icon-maskable-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/web/icons/Icon-maskable-512.png
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firebase_dart_admin_auth_sample_app",
3 | "short_name": "firebase_dart_admin_auth_sample_app",
4 | "start_url": ".",
5 | "display": "standalone",
6 | "background_color": "#0175C2",
7 | "theme_color": "#0175C2",
8 | "description": "A new Flutter project.",
9 | "orientation": "portrait-primary",
10 | "prefer_related_applications": false,
11 | "icons": [
12 | {
13 | "src": "icons/Icon-192.png",
14 | "sizes": "192x192",
15 | "type": "image/png"
16 | },
17 | {
18 | "src": "icons/Icon-512.png",
19 | "sizes": "512x512",
20 | "type": "image/png"
21 | },
22 | {
23 | "src": "icons/Icon-maskable-192.png",
24 | "sizes": "192x192",
25 | "type": "image/png",
26 | "purpose": "maskable"
27 | },
28 | {
29 | "src": "icons/Icon-maskable-512.png",
30 | "sizes": "512x512",
31 | "type": "image/png",
32 | "purpose": "maskable"
33 | }
34 | ]
35 | }
36 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/web/oauth_redirect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | OAuth Redirect
6 |
25 |
26 |
27 | Authentication successful. You can close this window.
28 |
29 |
30 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.14)
3 |
4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5 |
6 | # Configuration provided via flutter tool.
7 | include(${EPHEMERAL_DIR}/generated_config.cmake)
8 |
9 | # TODO: Move the rest of this into files in ephemeral. See
10 | # https://github.com/flutter/flutter/issues/57146.
11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
12 |
13 | # Set fallback configurations for older versions of the flutter tool.
14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
15 | set(FLUTTER_TARGET_PLATFORM "windows-x64")
16 | endif()
17 |
18 | # === Flutter Library ===
19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
20 |
21 | # Published to parent scope for install step.
22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
26 |
27 | list(APPEND FLUTTER_LIBRARY_HEADERS
28 | "flutter_export.h"
29 | "flutter_windows.h"
30 | "flutter_messenger.h"
31 | "flutter_plugin_registrar.h"
32 | "flutter_texture_registrar.h"
33 | )
34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
35 | add_library(flutter INTERFACE)
36 | target_include_directories(flutter INTERFACE
37 | "${EPHEMERAL_DIR}"
38 | )
39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
40 | add_dependencies(flutter flutter_assemble)
41 |
42 | # === Wrapper ===
43 | list(APPEND CPP_WRAPPER_SOURCES_CORE
44 | "core_implementations.cc"
45 | "standard_codec.cc"
46 | )
47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
49 | "plugin_registrar.cc"
50 | )
51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
52 | list(APPEND CPP_WRAPPER_SOURCES_APP
53 | "flutter_engine.cc"
54 | "flutter_view_controller.cc"
55 | )
56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
57 |
58 | # Wrapper sources needed for a plugin.
59 | add_library(flutter_wrapper_plugin STATIC
60 | ${CPP_WRAPPER_SOURCES_CORE}
61 | ${CPP_WRAPPER_SOURCES_PLUGIN}
62 | )
63 | apply_standard_settings(flutter_wrapper_plugin)
64 | set_target_properties(flutter_wrapper_plugin PROPERTIES
65 | POSITION_INDEPENDENT_CODE ON)
66 | set_target_properties(flutter_wrapper_plugin PROPERTIES
67 | CXX_VISIBILITY_PRESET hidden)
68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
69 | target_include_directories(flutter_wrapper_plugin PUBLIC
70 | "${WRAPPER_ROOT}/include"
71 | )
72 | add_dependencies(flutter_wrapper_plugin flutter_assemble)
73 |
74 | # Wrapper sources needed for the runner.
75 | add_library(flutter_wrapper_app STATIC
76 | ${CPP_WRAPPER_SOURCES_CORE}
77 | ${CPP_WRAPPER_SOURCES_APP}
78 | )
79 | apply_standard_settings(flutter_wrapper_app)
80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter)
81 | target_include_directories(flutter_wrapper_app PUBLIC
82 | "${WRAPPER_ROOT}/include"
83 | )
84 | add_dependencies(flutter_wrapper_app flutter_assemble)
85 |
86 | # === Flutter tool backend ===
87 | # _phony_ is a non-existent file to force this command to run every time,
88 | # since currently there's no way to get a full input/output list from the
89 | # flutter tool.
90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
92 | add_custom_command(
93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
95 | ${CPP_WRAPPER_SOURCES_APP}
96 | ${PHONY_OUTPUT}
97 | COMMAND ${CMAKE_COMMAND} -E env
98 | ${FLUTTER_TOOL_ENVIRONMENT}
99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
100 | ${FLUTTER_TARGET_PLATFORM} $
101 | VERBATIM
102 | )
103 | add_custom_target(flutter_assemble DEPENDS
104 | "${FLUTTER_LIBRARY}"
105 | ${FLUTTER_LIBRARY_HEADERS}
106 | ${CPP_WRAPPER_SOURCES_CORE}
107 | ${CPP_WRAPPER_SOURCES_PLUGIN}
108 | ${CPP_WRAPPER_SOURCES_APP}
109 | )
110 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 |
11 | void RegisterPlugins(flutter::PluginRegistry* registry) {
12 | FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
13 | registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
14 | }
15 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void RegisterPlugins(flutter::PluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | flutter_secure_storage_windows
7 | )
8 |
9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
10 | )
11 |
12 | set(PLUGIN_BUNDLED_LIBRARIES)
13 |
14 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19 | endforeach(plugin)
20 |
21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24 | endforeach(ffi_plugin)
25 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.14)
2 | project(runner LANGUAGES CXX)
3 |
4 | # Define the application target. To change its name, change BINARY_NAME in the
5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
6 | # work.
7 | #
8 | # Any new source files that you add to the application should be added here.
9 | add_executable(${BINARY_NAME} WIN32
10 | "flutter_window.cpp"
11 | "main.cpp"
12 | "utils.cpp"
13 | "win32_window.cpp"
14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
15 | "Runner.rc"
16 | "runner.exe.manifest"
17 | )
18 |
19 | # Apply the standard set of build settings. This can be removed for applications
20 | # that need different build settings.
21 | apply_standard_settings(${BINARY_NAME})
22 |
23 | # Add preprocessor definitions for the build version.
24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
29 |
30 | # Disable Windows macros that collide with C++ standard library functions.
31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
32 |
33 | # Add dependency libraries and include directories. Add any application-specific
34 | # dependencies here.
35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
38 |
39 | # Run the Flutter tool portions of the build. This must not be removed.
40 | add_dependencies(${BINARY_NAME} flutter_assemble)
41 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/runner/Runner.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 | #include "resource.h"
5 |
6 | #define APSTUDIO_READONLY_SYMBOLS
7 | /////////////////////////////////////////////////////////////////////////////
8 | //
9 | // Generated from the TEXTINCLUDE 2 resource.
10 | //
11 | #include "winres.h"
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (United States) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_APP_ICON ICON "resources\\app_icon.ico"
56 |
57 |
58 | /////////////////////////////////////////////////////////////////////////////
59 | //
60 | // Version
61 | //
62 |
63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
65 | #else
66 | #define VERSION_AS_NUMBER 1,0,0,0
67 | #endif
68 |
69 | #if defined(FLUTTER_VERSION)
70 | #define VERSION_AS_STRING FLUTTER_VERSION
71 | #else
72 | #define VERSION_AS_STRING "1.0.0"
73 | #endif
74 |
75 | VS_VERSION_INFO VERSIONINFO
76 | FILEVERSION VERSION_AS_NUMBER
77 | PRODUCTVERSION VERSION_AS_NUMBER
78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
79 | #ifdef _DEBUG
80 | FILEFLAGS VS_FF_DEBUG
81 | #else
82 | FILEFLAGS 0x0L
83 | #endif
84 | FILEOS VOS__WINDOWS32
85 | FILETYPE VFT_APP
86 | FILESUBTYPE 0x0L
87 | BEGIN
88 | BLOCK "StringFileInfo"
89 | BEGIN
90 | BLOCK "040904e4"
91 | BEGIN
92 | VALUE "CompanyName", "com.aortem" "\0"
93 | VALUE "FileDescription", "firebase_dart_admin_auth_sample_app" "\0"
94 | VALUE "FileVersion", VERSION_AS_STRING "\0"
95 | VALUE "InternalName", "firebase_dart_admin_auth_sample_app" "\0"
96 | VALUE "LegalCopyright", "Copyright (C) 2024 com.aortem. All rights reserved." "\0"
97 | VALUE "OriginalFilename", "firebase_dart_admin_auth_sample_app.exe" "\0"
98 | VALUE "ProductName", "firebase_dart_admin_auth_sample_app" "\0"
99 | VALUE "ProductVersion", VERSION_AS_STRING "\0"
100 | END
101 | END
102 | BLOCK "VarFileInfo"
103 | BEGIN
104 | VALUE "Translation", 0x409, 1252
105 | END
106 | END
107 |
108 | #endif // English (United States) resources
109 | /////////////////////////////////////////////////////////////////////////////
110 |
111 |
112 |
113 | #ifndef APSTUDIO_INVOKED
114 | /////////////////////////////////////////////////////////////////////////////
115 | //
116 | // Generated from the TEXTINCLUDE 3 resource.
117 | //
118 |
119 |
120 | /////////////////////////////////////////////////////////////////////////////
121 | #endif // not APSTUDIO_INVOKED
122 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/runner/flutter_window.cpp:
--------------------------------------------------------------------------------
1 | #include "flutter_window.h"
2 |
3 | #include
4 |
5 | #include "flutter/generated_plugin_registrant.h"
6 |
7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project)
8 | : project_(project) {}
9 |
10 | FlutterWindow::~FlutterWindow() {}
11 |
12 | bool FlutterWindow::OnCreate() {
13 | if (!Win32Window::OnCreate()) {
14 | return false;
15 | }
16 |
17 | RECT frame = GetClientArea();
18 |
19 | // The size here must match the window dimensions to avoid unnecessary surface
20 | // creation / destruction in the startup path.
21 | flutter_controller_ = std::make_unique(
22 | frame.right - frame.left, frame.bottom - frame.top, project_);
23 | // Ensure that basic setup of the controller was successful.
24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) {
25 | return false;
26 | }
27 | RegisterPlugins(flutter_controller_->engine());
28 | SetChildContent(flutter_controller_->view()->GetNativeWindow());
29 |
30 | flutter_controller_->engine()->SetNextFrameCallback([&]() {
31 | this->Show();
32 | });
33 |
34 | // Flutter can complete the first frame before the "show window" callback is
35 | // registered. The following call ensures a frame is pending to ensure the
36 | // window is shown. It is a no-op if the first frame hasn't completed yet.
37 | flutter_controller_->ForceRedraw();
38 |
39 | return true;
40 | }
41 |
42 | void FlutterWindow::OnDestroy() {
43 | if (flutter_controller_) {
44 | flutter_controller_ = nullptr;
45 | }
46 |
47 | Win32Window::OnDestroy();
48 | }
49 |
50 | LRESULT
51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
52 | WPARAM const wparam,
53 | LPARAM const lparam) noexcept {
54 | // Give Flutter, including plugins, an opportunity to handle window messages.
55 | if (flutter_controller_) {
56 | std::optional result =
57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
58 | lparam);
59 | if (result) {
60 | return *result;
61 | }
62 | }
63 |
64 | switch (message) {
65 | case WM_FONTCHANGE:
66 | flutter_controller_->engine()->ReloadSystemFonts();
67 | break;
68 | }
69 |
70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
71 | }
72 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/runner/flutter_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_FLUTTER_WINDOW_H_
2 | #define RUNNER_FLUTTER_WINDOW_H_
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "win32_window.h"
10 |
11 | // A window that does nothing but host a Flutter view.
12 | class FlutterWindow : public Win32Window {
13 | public:
14 | // Creates a new FlutterWindow hosting a Flutter view running |project|.
15 | explicit FlutterWindow(const flutter::DartProject& project);
16 | virtual ~FlutterWindow();
17 |
18 | protected:
19 | // Win32Window:
20 | bool OnCreate() override;
21 | void OnDestroy() override;
22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
23 | LPARAM const lparam) noexcept override;
24 |
25 | private:
26 | // The project to run.
27 | flutter::DartProject project_;
28 |
29 | // The Flutter instance hosted by this window.
30 | std::unique_ptr flutter_controller_;
31 | };
32 |
33 | #endif // RUNNER_FLUTTER_WINDOW_H_
34 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/runner/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "flutter_window.h"
6 | #include "utils.h"
7 |
8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
9 | _In_ wchar_t *command_line, _In_ int show_command) {
10 | // Attach to console when present (e.g., 'flutter run') or create a
11 | // new console when running with a debugger.
12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
13 | CreateAndAttachConsole();
14 | }
15 |
16 | // Initialize COM, so that it is available for use in the library and/or
17 | // plugins.
18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
19 |
20 | flutter::DartProject project(L"data");
21 |
22 | std::vector command_line_arguments =
23 | GetCommandLineArguments();
24 |
25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
26 |
27 | FlutterWindow window(project);
28 | Win32Window::Point origin(10, 10);
29 | Win32Window::Size size(1280, 720);
30 | if (!window.Create(L"firebase_dart_admin_auth_sample_app", origin, size)) {
31 | return EXIT_FAILURE;
32 | }
33 | window.SetQuitOnClose(true);
34 |
35 | ::MSG msg;
36 | while (::GetMessage(&msg, nullptr, 0, 0)) {
37 | ::TranslateMessage(&msg);
38 | ::DispatchMessage(&msg);
39 | }
40 |
41 | ::CoUninitialize();
42 | return EXIT_SUCCESS;
43 | }
44 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/runner/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Runner.rc
4 | //
5 | #define IDI_APP_ICON 101
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 102
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/runner/resources/app_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/runner/resources/app_icon.ico
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/runner/runner.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PerMonitorV2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/runner/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | void CreateAndAttachConsole() {
11 | if (::AllocConsole()) {
12 | FILE *unused;
13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
14 | _dup2(_fileno(stdout), 1);
15 | }
16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
17 | _dup2(_fileno(stdout), 2);
18 | }
19 | std::ios::sync_with_stdio();
20 | FlutterDesktopResyncOutputStreams();
21 | }
22 | }
23 |
24 | std::vector GetCommandLineArguments() {
25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
26 | int argc;
27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
28 | if (argv == nullptr) {
29 | return std::vector();
30 | }
31 |
32 | std::vector command_line_arguments;
33 |
34 | // Skip the first argument as it's the binary name.
35 | for (int i = 1; i < argc; i++) {
36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
37 | }
38 |
39 | ::LocalFree(argv);
40 |
41 | return command_line_arguments;
42 | }
43 |
44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) {
45 | if (utf16_string == nullptr) {
46 | return std::string();
47 | }
48 | unsigned int target_length = ::WideCharToMultiByte(
49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
50 | -1, nullptr, 0, nullptr, nullptr)
51 | -1; // remove the trailing null character
52 | int input_length = (int)wcslen(utf16_string);
53 | std::string utf8_string;
54 | if (target_length == 0 || target_length > utf8_string.max_size()) {
55 | return utf8_string;
56 | }
57 | utf8_string.resize(target_length);
58 | int converted_length = ::WideCharToMultiByte(
59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
60 | input_length, utf8_string.data(), target_length, nullptr, nullptr);
61 | if (converted_length == 0) {
62 | return std::string();
63 | }
64 | return utf8_string;
65 | }
66 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/runner/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_UTILS_H_
2 | #define RUNNER_UTILS_H_
3 |
4 | #include
5 | #include
6 |
7 | // Creates a console for the process, and redirects stdout and stderr to
8 | // it for both the runner and the Flutter library.
9 | void CreateAndAttachConsole();
10 |
11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
12 | // encoded in UTF-8. Returns an empty std::string on failure.
13 | std::string Utf8FromUtf16(const wchar_t* utf16_string);
14 |
15 | // Gets the command line arguments passed in as a std::vector,
16 | // encoded in UTF-8. Returns an empty std::vector on failure.
17 | std::vector GetCommandLineArguments();
18 |
19 | #endif // RUNNER_UTILS_H_
20 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-mobile-app/windows/runner/win32_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_WIN32_WINDOW_H_
2 | #define RUNNER_WIN32_WINDOW_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be
11 | // inherited from by classes that wish to specialize with custom
12 | // rendering and input handling
13 | class Win32Window {
14 | public:
15 | struct Point {
16 | unsigned int x;
17 | unsigned int y;
18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {}
19 | };
20 |
21 | struct Size {
22 | unsigned int width;
23 | unsigned int height;
24 | Size(unsigned int width, unsigned int height)
25 | : width(width), height(height) {}
26 | };
27 |
28 | Win32Window();
29 | virtual ~Win32Window();
30 |
31 | // Creates a win32 window with |title| that is positioned and sized using
32 | // |origin| and |size|. New windows are created on the default monitor. Window
33 | // sizes are specified to the OS in physical pixels, hence to ensure a
34 | // consistent size this function will scale the inputted width and height as
35 | // as appropriate for the default monitor. The window is invisible until
36 | // |Show| is called. Returns true if the window was created successfully.
37 | bool Create(const std::wstring& title, const Point& origin, const Size& size);
38 |
39 | // Show the current window. Returns true if the window was successfully shown.
40 | bool Show();
41 |
42 | // Release OS resources associated with window.
43 | void Destroy();
44 |
45 | // Inserts |content| into the window tree.
46 | void SetChildContent(HWND content);
47 |
48 | // Returns the backing Window handle to enable clients to set icon and other
49 | // window properties. Returns nullptr if the window has been destroyed.
50 | HWND GetHandle();
51 |
52 | // If true, closing this window will quit the application.
53 | void SetQuitOnClose(bool quit_on_close);
54 |
55 | // Return a RECT representing the bounds of the current client area.
56 | RECT GetClientArea();
57 |
58 | protected:
59 | // Processes and route salient window messages for mouse handling,
60 | // size change and DPI. Delegates handling of these to member overloads that
61 | // inheriting classes can handle.
62 | virtual LRESULT MessageHandler(HWND window,
63 | UINT const message,
64 | WPARAM const wparam,
65 | LPARAM const lparam) noexcept;
66 |
67 | // Called when CreateAndShow is called, allowing subclass window-related
68 | // setup. Subclasses should return false if setup fails.
69 | virtual bool OnCreate();
70 |
71 | // Called when Destroy is called.
72 | virtual void OnDestroy();
73 |
74 | private:
75 | friend class WindowClassRegistrar;
76 |
77 | // OS callback called by message pump. Handles the WM_NCCREATE message which
78 | // is passed when the non-client area is being created and enables automatic
79 | // non-client DPI scaling so that the non-client area automatically
80 | // responds to changes in DPI. All other messages are handled by
81 | // MessageHandler.
82 | static LRESULT CALLBACK WndProc(HWND const window,
83 | UINT const message,
84 | WPARAM const wparam,
85 | LPARAM const lparam) noexcept;
86 |
87 | // Retrieves a class instance pointer for |window|
88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept;
89 |
90 | // Update the window frame's theme to match the system theme.
91 | static void UpdateTheme(HWND const window);
92 |
93 | bool quit_on_close_ = false;
94 |
95 | // window handle for top level window.
96 | HWND window_handle_ = nullptr;
97 |
98 | // window handle for hosted content.
99 | HWND child_content_ = nullptr;
100 | };
101 |
102 | #endif // RUNNER_WIN32_WINDOW_H_
103 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-web-app/placeholder.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-flutter-web-app/placeholder.txt
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-svelte-app/placeholder.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-svelte-app/placeholder.txt
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/example/magic-dart-auth-sdk-vue-app/placeholder.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aortem/magic-dart-auth-sdk/feed10b18aadc2f865f7bc05669bd77abe341447/magic-dart-auth-sdk/example/magic-dart-auth-sdk-vue-app/placeholder.txt
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/firebase.json:
--------------------------------------------------------------------------------
1 | {
2 | "emulators": {
3 | "auth": {
4 | "port": 9099
5 | },
6 | "functions": {
7 | "port": 5002
8 | },
9 | "ui": {
10 | "enabled": true,
11 | "port": 5003
12 | },
13 | "singleProjectMode": true
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/lib/magic_dart_auth_sdk.dart:
--------------------------------------------------------------------------------
1 | library;
2 |
3 | // Core
4 | export 'src/core/aortem_magic_api_key_manager.dart';
5 | export 'src/core/aortem_magic_constructor.dart';
6 |
7 | // Metadata
8 | export 'src/metadata/aortem_magic_issuer_metadata.dart';
9 | export 'src/metadata/aortem_magic_address_metadata.dart';
10 | export 'src/metadata/aortem_magic_token_metadata.dart';
11 |
12 | // Authentication
13 | export 'src/auth/aortem_magic_token_validation.dart';
14 | export 'src/auth/aortem_magic_token_decode.dart';
15 | export 'src/auth/aortem_magic_issuer.dart';
16 | export 'src/auth/aortem_magic_public_address.dart';
17 |
18 | // Logout
19 | export 'src/logout/aortem_magic_logout_issuer.dart';
20 | export 'src/logout/aortem_magic_logout_address.dart';
21 | export 'src/logout/aortem_magic_logout_token.dart';
22 |
23 | // Utilities
24 | export 'src/utils/aortem_magic_parse_auth_header.dart';
25 | export 'src/utils/aortem_magic_secure_storage.dart';
26 |
27 | // Multichain
28 | export 'src/multichain/aortem_magic_multichain_metadata.dart';
29 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/lib/src/auth/aortem_magic_issuer.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | /// A utility class for extracting the issuer (`iss`) field from a Decentralized Identifier (DID) Token.
4 | /// This class provides strict and loose validation modes to ensure the extracted issuer follows the expected format.
5 | ///
6 | /// ## Features:
7 | /// - Extracts the `iss` field from a DID Token (JWT format).
8 | /// - Supports strict validation mode (must be a valid URL format).
9 | /// - Supports loose validation mode (only checks for a recognizable domain format).
10 | /// - Throws an error if the token is invalid or the issuer format is incorrect.
11 | ///
12 | /// ## Usage Example:
13 | /// ```dart
14 | /// String didToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2V4YW1wbGUuY29tIn0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
15 | /// String issuer = AortemMagicIssuerExtractor.getIssuer(didToken, strict: true);
16 | /// print(issuer); // Outputs: https://example.com
17 | /// ```
18 |
19 | class AortemMagicIssuerExtractor {
20 | /// Extracts the issuer (`iss`) from a DID Token.
21 | /// - [didToken]: The DID Token (JWT format).
22 | /// - [strict]: If `true`, enforces strict validation (must be a valid URL format).
23 | ///
24 | /// Throws an error if the token is invalid or the issuer format is incorrect.
25 | static String getIssuer(String didToken, {bool strict = true}) {
26 | if (didToken.isEmpty) {
27 | throw ArgumentError('DID Token cannot be empty.');
28 | }
29 |
30 | try {
31 | // Decode JWT payload (second part of the token)
32 | Map payload = _decodeJwtPayload(didToken);
33 |
34 | // Extract issuer from "iss" field
35 | String? issuer = payload['iss'];
36 |
37 | if (issuer == null || issuer.isEmpty) {
38 | throw FormatException('Issuer (iss) is missing in the DID Token.');
39 | }
40 |
41 | // Validate based on strict or loose mode
42 | if (strict) {
43 | if (!_isValidStrictIssuer(issuer)) {
44 | throw FormatException('Invalid issuer format in strict mode.');
45 | }
46 | } else {
47 | if (!_isValidLooseIssuer(issuer)) {
48 | throw FormatException('Invalid issuer format in loose mode.');
49 | }
50 | }
51 |
52 | return issuer;
53 | } catch (e) {
54 | throw FormatException('Invalid DID Token: ${e.toString()}');
55 | }
56 | }
57 |
58 | /// Decodes a JWT and returns the payload as a Map.
59 | static Map _decodeJwtPayload(String token) {
60 | List parts = token.split('.');
61 | if (parts.length != 3) {
62 | throw FormatException('Invalid JWT format');
63 | }
64 |
65 | String payloadBase64 = parts[1];
66 | String normalized = base64.normalize(payloadBase64);
67 | String decoded = utf8.decode(base64Url.decode(normalized));
68 |
69 | return jsonDecode(decoded) as Map;
70 | }
71 |
72 | /// Strict validation: Must be a valid URL.
73 | static bool _isValidStrictIssuer(String issuer) {
74 | final uri = Uri.tryParse(issuer);
75 | return uri != null && uri.hasScheme && uri.hasAuthority;
76 | }
77 |
78 | /// Loose validation: Must be non-empty and contain a recognizable domain format.
79 | static bool _isValidLooseIssuer(String issuer) {
80 | return issuer.isNotEmpty && issuer.contains('.');
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/lib/src/auth/aortem_magic_public_address.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | /// AortemMagicPublicAddressExtractor
4 | ///
5 | /// A utility class for extracting the public address from a Decentralized Identifier (DID) Token.
6 | /// This class provides strict and loose validation modes to ensure the extracted address follows the expected format.
7 | ///
8 | /// ## Features:
9 | /// - Extracts the `sub` field from a DID Token (JWT format) to retrieve the public Ethereum address.
10 | /// - Supports strict validation mode (must be a valid Ethereum address format: `0x` followed by 40 hexadecimal characters).
11 | /// - Supports loose validation mode (only checks for the `0x` prefix and non-empty content).
12 | /// - Throws an error if the token is invalid or the address format is incorrect.
13 | ///
14 | /// ## Usage Example:
15 | /// ```dart
16 | /// String didToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIweDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWYwIn0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
17 | /// String publicAddress = AortemMagicPublicAddressExtractor.getPublicAddress(didToken, strict: true);
18 | /// print(publicAddress); // Outputs: 0x123456789abcdef0123456789abcdef0123456789
19 | /// ```
20 |
21 | class AortemMagicPublicAddressExtractor {
22 | /// Extracts the public address from a DID Token without external dependencies.
23 | /// - [didToken]: The DID Token (JWT format).
24 | /// - [strict]: If `true`, enforces strict Ethereum address validation.
25 | ///
26 | /// Throws an error if the token is invalid or the address format is incorrect.
27 | static String getPublicAddress(String didToken, {bool strict = true}) {
28 | if (didToken.isEmpty) {
29 | throw ArgumentError('DID Token cannot be empty.');
30 | }
31 |
32 | try {
33 | // Decode JWT payload (second part of the token)
34 | Map payload = _decodeJwtPayload(didToken);
35 |
36 | // Extract public address from "sub" field
37 | String? publicAddress = payload['sub'];
38 |
39 | if (publicAddress == null || publicAddress.isEmpty) {
40 | throw FormatException(
41 | 'Public address (sub) is missing in the DID Token.',
42 | );
43 | }
44 |
45 | // Validate based on strict or loose mode
46 | if (strict) {
47 | if (!_isValidStrictEthereumAddress(publicAddress)) {
48 | throw FormatException(
49 | 'Invalid Ethereum address format in strict mode.',
50 | );
51 | }
52 | } else {
53 | if (!_isValidLooseEthereumAddress(publicAddress)) {
54 | throw FormatException(
55 | 'Invalid Ethereum address format in loose mode.',
56 | );
57 | }
58 | }
59 |
60 | return publicAddress;
61 | } catch (e) {
62 | throw FormatException('Invalid DID Token: ${e.toString()}');
63 | }
64 | }
65 |
66 | /// Decodes a JWT and returns the payload as a Map.
67 | static Map _decodeJwtPayload(String token) {
68 | List parts = token.split('.');
69 | if (parts.length != 3) {
70 | throw FormatException('Invalid JWT format');
71 | }
72 |
73 | String payloadBase64 = parts[1];
74 | String normalized = base64.normalize(payloadBase64);
75 | String decoded = utf8.decode(base64Url.decode(normalized));
76 |
77 | return jsonDecode(decoded) as Map;
78 | }
79 |
80 | /// Strict validation: Must start with `0x` and be exactly 42 characters long (Ethereum address).
81 | static bool _isValidStrictEthereumAddress(String address) {
82 | final ethRegex = RegExp(r"^0x[a-fA-F0-9]{40}$");
83 | return ethRegex.hasMatch(address);
84 | }
85 |
86 | /// Loose validation: Must start with `0x` and be non-empty.
87 | static bool _isValidLooseEthereumAddress(String address) {
88 | return address.startsWith('0x') && address.length > 2;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/lib/src/auth/aortem_magic_token_decode.dart:
--------------------------------------------------------------------------------
1 |
2 |
3 | import 'dart:convert';
4 |
5 | /// AortemMagicTokenDecoder
6 | ///
7 | /// A utility class for decoding Decentralized Identifier (DID) Tokens (JWT format).
8 | /// It extracts the payload and optionally verifies required claims.
9 | ///
10 | /// ## Features:
11 | /// - Decodes the payload of a DID Token.
12 | /// - Supports optional verification to ensure required fields (`iss`, `sub`) are present.
13 | /// - Throws an error if the token format is invalid or required fields are missing.
14 | ///
15 | /// ## Usage Example:
16 | /// ```dart
17 | /// String didToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2V4YW1wbGUuY29tIiwic3ViIjoiMHgxMjM0NTY3ODlhYmNkZWYiLCJleHAiOjE2NjAwMDAwMDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
18 | /// Map payload = AortemMagicTokenDecoder.decode(didToken, verify: true);
19 | /// print(payload); // Outputs decoded payload
20 | /// ```
21 | class AortemMagicTokenDecoder {
22 | /// Decodes a DID Token (JWT format) and returns the payload as a Map.
23 | /// - [didToken]: The DID Token (JWT format).
24 | /// - [verify]: If `true`, ensures required fields (`iss`, `sub`) are present.
25 | ///
26 | /// Throws an error if the token is invalid or verification fails.
27 | static Map decode(String didToken, {bool verify = false}) {
28 | if (didToken.isEmpty) {
29 | throw ArgumentError('DID Token cannot be empty.');
30 | }
31 |
32 | try {
33 | // Decode JWT payload
34 | Map payload = _decodeJwtPayload(didToken);
35 |
36 | // Optional verification step
37 | if (verify) {
38 | _verifyRequiredFields(payload);
39 | }
40 |
41 | return payload;
42 | } catch (e) {
43 | throw FormatException('Invalid DID Token: ${e.toString()}');
44 | }
45 | }
46 |
47 | /// Decodes a JWT and returns the payload as a Map.
48 | static Map _decodeJwtPayload(String token) {
49 | List parts = token.split('.');
50 | if (parts.length != 3) {
51 | throw FormatException('Invalid JWT format');
52 | }
53 |
54 | String payloadBase64 = parts[1];
55 | String normalized = base64.normalize(payloadBase64);
56 | String decoded = utf8.decode(base64Url.decode(normalized));
57 |
58 | return jsonDecode(decoded) as Map;
59 | }
60 |
61 | /// Verifies that required claims (`iss`, `sub`) are present in the payload.
62 | static void _verifyRequiredFields(Map payload) {
63 | if (!payload.containsKey('iss') || payload['iss'].toString().isEmpty) {
64 | throw FormatException('Missing or empty "iss" field.');
65 | }
66 | if (!payload.containsKey('sub') || payload['sub'].toString().isEmpty) {
67 | throw FormatException('Missing or empty "sub" field.');
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/lib/src/core/aortem_magic_api_key_manager.dart:
--------------------------------------------------------------------------------
1 | import '../utils/aortem_magic_secure_storage.dart';
2 |
3 | /// AortemMagicAuthApiKeyManagement
4 | ///
5 | /// A class responsible for managing API keys securely within the Aortem Magic authentication system.
6 | /// It provides validation, hashing, and verification functionality.
7 | ///
8 | /// ## Features:
9 | /// - Stores API keys in a hashed format for security.
10 | /// - Validates API key format before storing.
11 | /// - Provides a method to verify if an input key matches the stored hash.
12 | ///
13 | /// ## Usage Example:
14 | /// ```dart
15 | /// var apiKeyManager = AortemMagicAuthApiKeyManagement('your-api-key');
16 | /// bool isValid = apiKeyManager.verifyApiKey('your-api-key');
17 | /// print(isValid); // Outputs: true if valid
18 | /// ```
19 |
20 | class AortemMagicAuthApiKeyManagement {
21 | /// Stores the hashed version of the API key.
22 | late String _hashedApiKey;
23 |
24 | /// Constructor to initialize with a validated API key.
25 | /// - [apiKey]: The API key to be stored securely.
26 | AortemMagicAuthApiKeyManagement(String apiKey) {
27 | setApiKey(apiKey);
28 | }
29 |
30 | /// Validates and sets a new API key in a hashed format.
31 | /// - Throws an [ArgumentError] if the API key is invalid.
32 | void setApiKey(String apiKey) {
33 | if (apiKey.isEmpty || !_validateApiKey(apiKey)) {
34 | throw ArgumentError('Invalid API key.');
35 | }
36 | _hashedApiKey = AortemMagicSecureStorage.hashApiKey(apiKey);
37 | }
38 |
39 | /// Verifies if the provided API key matches the stored hashed API key.
40 | /// - Returns `true` if the input key is valid, otherwise `false`.
41 | bool verifyApiKey(String inputKey) {
42 | return AortemMagicSecureStorage.validateApiKey(inputKey, _hashedApiKey);
43 | }
44 |
45 | /// Ensures the API key follows a strict format.
46 | /// - Returns `true` if the key follows the correct format, otherwise `false`.
47 | bool _validateApiKey(String key) {
48 | return RegExp(r'^[a-zA-Z0-9._-]+$').hasMatch(key);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/lib/src/core/aortem_magic_constructor.dart:
--------------------------------------------------------------------------------
1 | /// AortemMagicAuth
2 | ///
3 | /// A class responsible for handling API key authentication securely within the Aortem Magic authentication system.
4 | /// It ensures proper validation and allows secure storage and retrieval of API keys.
5 | ///
6 | /// ## Features:
7 | /// - Validates API keys against a defined pattern.
8 | /// - Stores API keys securely and allows updates.
9 | /// - Provides methods for retrieving and modifying API keys dynamically.
10 | ///
11 | /// ## Usage Example:
12 | /// ```dart
13 | /// var auth = AortemMagicAuth('your-api-key');
14 | /// print(auth.apiKey); // Outputs the stored API key
15 | /// auth.updateApiKey('new-api-key');
16 | /// ```
17 | class AortemMagicAuth {
18 | /// Stores the API key securely.
19 | late String _apiKey; // Use 'late' to ensure it gets initialized
20 |
21 | /// Regular expression pattern for validating API keys.
22 | static final RegExp _apiKeyPattern = RegExp(r'^[a-zA-Z0-9._-]+$');
23 |
24 | /// Constructor with API key validation.
25 | /// - Throws an [ArgumentError] if the API key is invalid.
26 | AortemMagicAuth(String apiKey) {
27 | if (apiKey.isEmpty || !_validateApiKey(apiKey)) {
28 | throw ArgumentError('Invalid API key.');
29 | }
30 | _apiKey = apiKey;
31 | }
32 |
33 | /// Validates the API key format.
34 | /// - Returns `true` if the key follows the correct format, otherwise `false`.
35 | bool _validateApiKey(String key) {
36 | return _apiKeyPattern.hasMatch(key);
37 | }
38 |
39 | /// Retrieves the stored API key securely.
40 | String get apiKey => _apiKey;
41 |
42 | /// Dynamically updates the API key with validation.
43 | /// - Throws an [ArgumentError] if the new key is invalid.
44 | void updateApiKey(String newKey) {
45 | if (newKey.isEmpty || !_validateApiKey(newKey)) {
46 | throw ArgumentError('Invalid API key.');
47 | }
48 | _apiKey = newKey;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/magic-dart-auth-sdk/lib/src/logout/aortem_magic_logout_address.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 | import 'package:ds_standard_features/ds_standard_features.dart' as http;
3 |
4 | /// AortemMagicLogoutByPublicAddress
5 | ///
6 | /// A class responsible for logging out users based on their public Ethereum-style address.
7 | /// It securely communicates with the Magic API to perform the logout operation.
8 | ///
9 | /// ## Features:
10 | /// - Validates public addresses before sending requests.
11 | /// - Supports an optional stub mode for testing.
12 | /// - Handles API responses and errors gracefully.
13 | ///
14 | /// ## Usage Example:
15 | /// ```dart
16 | /// var logoutHandler = AortemMagicLogoutByPublicAddress(apiKey: 'your-api-key');
17 | /// await logoutHandler.logoutByPublicAddress('0x1234567890abcdef1234567890abcdef12345678');
18 | /// ```
19 | class AortemMagicLogoutByPublicAddress {
20 | /// API key required for authentication.
21 | final String apiKey;
22 |
23 | /// Base URL of the API.
24 | final String apiBaseUrl;
25 |
26 | /// HTTP client for making API requests.
27 | final http.Client client;
28 |
29 | /// Flag to enable stub mode for testing without actual API calls.
30 | final bool useStub;
31 |
32 | /// Constructor for initializing the logout handler.
33 | /// - Accepts an optional `client` for dependency injection (useful for testing).
34 | /// - Defaults `apiBaseUrl` to "https://api.magic.com".
35 | AortemMagicLogoutByPublicAddress({
36 | required this.apiKey,
37 | this.apiBaseUrl = "https://api.magic.com",
38 | http.Client? client,
39 | this.useStub = false,
40 | }) : client = client ?? http.Client();
41 |
42 | /// Logs out a user based on their public Ethereum address.
43 | /// - Validates the address format before sending the request.
44 | /// - Uses a mock response if `useStub` is enabled.
45 | /// - Throws an exception if the API request fails.
46 | Future