mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-12 09:32:33 +00:00
Merge branch 'mac-os-fixes' of https://github.com/cake-tech/cake_wallet into dashboard-desktop-view
This commit is contained in:
commit
6b2bf313a3
13 changed files with 169 additions and 21 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -137,4 +137,6 @@ assets/images/app_logo.png
|
|||
/android/app/src/main/AndroidManifest.xml
|
||||
|
||||
|
||||
macos/Runner/Info.plist
|
||||
macos/Runner/Info.plist
|
||||
macos/Runner/DebugProfile.entitlements
|
||||
macos/Runner/Release.entitlements
|
16
macos/CakeWallet/decrypt.swift
Normal file
16
macos/CakeWallet/decrypt.swift
Normal file
|
@ -0,0 +1,16 @@
|
|||
import Foundation
|
||||
import CryptoSwift
|
||||
|
||||
func decrypt(data: Data, key: String, salt: String) -> String? {
|
||||
let keyBytes = key.data(using: .utf8)?.bytes ?? []
|
||||
let saltBytes = salt.data(using: .utf8)?.bytes ?? []
|
||||
|
||||
guard let PBKDF2key = try? PKCS5.PBKDF2(password: keyBytes, salt: saltBytes, iterations: 4096, variant: .sha256).calculate(),
|
||||
let cipher = try? Blowfish(key: PBKDF2key, padding: .pkcs7),
|
||||
let decryptedBytes = try? cipher.decrypt(data.bytes) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let decryptedData = Data(decryptedBytes)
|
||||
return String(data: decryptedData, encoding: .utf8)
|
||||
}
|
12
macos/CakeWallet/secRandom.swift
Normal file
12
macos/CakeWallet/secRandom.swift
Normal file
|
@ -0,0 +1,12 @@
|
|||
import Foundation
|
||||
|
||||
func secRandom(count: Int) -> Data? {
|
||||
var bytes = [Int8](repeating: 0, count: count)
|
||||
let status = SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes)
|
||||
|
||||
if status == errSecSuccess {
|
||||
return Data(bytes: bytes, count: bytes.count)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -21,7 +21,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
|||
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
|
||||
CwMoneroPlugin.register(with: registry.registrar(forPlugin: "CwMoneroPlugin"))
|
||||
DevicelocalePlugin.register(with: registry.registrar(forPlugin: "DevicelocalePlugin"))
|
||||
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
||||
FlutterSecureStorageMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStorageMacosPlugin"))
|
||||
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
PlatformDeviceIdMacosPlugin.register(with: registry.registrar(forPlugin: "PlatformDeviceIdMacosPlugin"))
|
||||
|
|
|
@ -31,6 +31,11 @@ target 'Runner' do
|
|||
use_modular_headers!
|
||||
|
||||
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
|
||||
|
||||
# Cake Wallet (Legacy)
|
||||
pod 'CryptoSwift'
|
||||
# Not supported on macos
|
||||
# pod 'UnstoppableDomainsResolution', '~> 5.0.0'
|
||||
end
|
||||
|
||||
post_install do |installer|
|
||||
|
|
|
@ -2,6 +2,7 @@ PODS:
|
|||
- connectivity_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
- Reachability
|
||||
- CryptoSwift (1.3.1)
|
||||
- cw_monero (0.0.1):
|
||||
- cw_monero/Boost (= 0.0.1)
|
||||
- cw_monero/Monero (= 0.0.1)
|
||||
|
@ -21,7 +22,7 @@ PODS:
|
|||
- FlutterMacOS
|
||||
- devicelocale (0.0.1):
|
||||
- FlutterMacOS
|
||||
- flutter_secure_storage_macos (6.1.1):
|
||||
- flutter_secure_storage_macos (3.3.1):
|
||||
- FlutterMacOS
|
||||
- FlutterMacOS (1.0.0)
|
||||
- package_info (0.0.1):
|
||||
|
@ -43,6 +44,7 @@ PODS:
|
|||
|
||||
DEPENDENCIES:
|
||||
- connectivity_macos (from `Flutter/ephemeral/.symlinks/plugins/connectivity_macos/macos`)
|
||||
- CryptoSwift
|
||||
- cw_monero (from `Flutter/ephemeral/.symlinks/plugins/cw_monero/macos`)
|
||||
- devicelocale (from `Flutter/ephemeral/.symlinks/plugins/devicelocale/macos`)
|
||||
- flutter_secure_storage_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos`)
|
||||
|
@ -57,6 +59,7 @@ DEPENDENCIES:
|
|||
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- CryptoSwift
|
||||
- Reachability
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
|
@ -87,9 +90,10 @@ EXTERNAL SOURCES:
|
|||
|
||||
SPEC CHECKSUMS:
|
||||
connectivity_macos: 5dae6ee11d320fac7c05f0d08bd08fc32b5514d9
|
||||
CryptoSwift: f12f037f6d0fcd6d48c96db0071b653de64e6c4d
|
||||
cw_monero: f8b7f104508efba2591548e76b5c058d05cba3f0
|
||||
devicelocale: 9f0f36ac651cabae2c33f32dcff4f32b61c38225
|
||||
flutter_secure_storage_macos: 75c8cadfdba05ca007c0fa4ea0c16e5cf85e521b
|
||||
flutter_secure_storage_macos: 6ceee8fbc7f484553ad17f79361b556259df89aa
|
||||
FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811
|
||||
package_info: 6eba2fd8d3371dda2d85c8db6fe97488f24b74b2
|
||||
path_provider_macos: 05fb0ef0cedf3e5bd179b9e41a638682b37133ea
|
||||
|
@ -98,8 +102,8 @@ SPEC CHECKSUMS:
|
|||
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
|
||||
share_plus_macos: 853ee48e7dce06b633998ca0735d482dd671ade4
|
||||
shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca
|
||||
url_launcher_macos: 597e05b8e514239626bcf4a850fcf9ef5c856ec3
|
||||
url_launcher_macos: c04e4fa86382d4f94f6b38f14625708be3ae52e2
|
||||
|
||||
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
|
||||
PODFILE CHECKSUM: 95c2abf1742d9564d190610743847d385992e6cc
|
||||
|
||||
COCOAPODS: 1.11.3
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
|
||||
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
|
||||
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
|
||||
9F3F7550298098120030A1D7 /* secRandom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F3F754D298098120030A1D7 /* secRandom.swift */; };
|
||||
9F3F7551298098120030A1D7 /* decrypt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F3F754E298098120030A1D7 /* decrypt.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
|
@ -72,6 +74,8 @@
|
|||
359F2F22842E234537DED5E3 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
|
||||
9F3F754D298098120030A1D7 /* secRandom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = secRandom.swift; path = CakeWallet/secRandom.swift; sourceTree = "<group>"; };
|
||||
9F3F754E298098120030A1D7 /* decrypt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = decrypt.swift; path = CakeWallet/decrypt.swift; sourceTree = "<group>"; };
|
||||
C84AA35EA80D710889C68D81 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
FF499CFF131B036E3C5638D0 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
@ -102,6 +106,8 @@
|
|||
33CC10E42044A3C60003C045 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9F3F754E298098120030A1D7 /* decrypt.swift */,
|
||||
9F3F754D298098120030A1D7 /* secRandom.swift */,
|
||||
33FAB671232836740065AC1E /* Runner */,
|
||||
33CEB47122A05771004F2AC0 /* Flutter */,
|
||||
33CC10EE2044A3C60003C045 /* Products */,
|
||||
|
@ -338,6 +344,8 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9F3F7550298098120030A1D7 /* secRandom.swift in Sources */,
|
||||
9F3F7551298098120030A1D7 /* decrypt.swift in Sources */,
|
||||
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */,
|
||||
33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */,
|
||||
335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */,
|
||||
|
@ -430,7 +438,7 @@
|
|||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 11;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
|
@ -560,7 +568,7 @@
|
|||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 11;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
|
@ -584,7 +592,7 @@
|
|||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 11;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
|
|
|
@ -1,9 +1,101 @@
|
|||
import Cocoa
|
||||
import FlutterMacOS
|
||||
import IOKit.pwr_mgt
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: FlutterAppDelegate {
|
||||
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
return true
|
||||
}
|
||||
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
var assertionID: IOPMAssertionID = 0
|
||||
|
||||
override func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
let controller : FlutterViewController = mainFlutterWindow?.contentViewController as! FlutterViewController
|
||||
let legacyMigrationChannel = FlutterMethodChannel(
|
||||
name: "com.cakewallet.cakewallet/legacy_wallet_migration",
|
||||
binaryMessenger: controller.engine.binaryMessenger)
|
||||
legacyMigrationChannel.setMethodCallHandler({
|
||||
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
|
||||
|
||||
switch call.method {
|
||||
case "decrypt":
|
||||
guard let args = call.arguments as? Dictionary<String, Any>,
|
||||
let data = args["bytes"] as? FlutterStandardTypedData,
|
||||
let key = args["key"] as? String,
|
||||
let salt = args["salt"] as? String else {
|
||||
result(nil)
|
||||
return
|
||||
}
|
||||
|
||||
let content = decrypt(data: data.data, key: key, salt: salt)
|
||||
result(content)
|
||||
case "read_user_defaults":
|
||||
guard let args = call.arguments as? Dictionary<String, Any>,
|
||||
let key = args["key"] as? String,
|
||||
let type = args["type"] as? String else {
|
||||
result(nil)
|
||||
return
|
||||
}
|
||||
|
||||
var value: Any?
|
||||
|
||||
switch (type) {
|
||||
case "string":
|
||||
value = UserDefaults.standard.string(forKey: key)
|
||||
case "int":
|
||||
value = UserDefaults.standard.integer(forKey: key)
|
||||
case "bool":
|
||||
value = UserDefaults.standard.bool(forKey: key)
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
result(value)
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
})
|
||||
|
||||
let utilsChannel = FlutterMethodChannel(
|
||||
name: "com.cake_wallet/native_utils",
|
||||
binaryMessenger: controller.engine.binaryMessenger)
|
||||
utilsChannel.setMethodCallHandler({ [weak self] (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
|
||||
switch call.method {
|
||||
case "sec_random":
|
||||
guard let args = call.arguments as? Dictionary<String, Any>,
|
||||
let count = args["count"] as? Int else {
|
||||
result(nil)
|
||||
return
|
||||
}
|
||||
|
||||
result(secRandom(count: count))
|
||||
case "getUnstoppableDomainAddress":
|
||||
// Not supported on macos
|
||||
result(nil)
|
||||
case "enableWakeScreen":
|
||||
result(self?.enableWakeScreen())
|
||||
|
||||
case "disableWakeScreen":
|
||||
result(self?.disableWakeScreen())
|
||||
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
func enableWakeScreen(reason: String = "Disabling display sleep") -> Bool{
|
||||
return IOPMAssertionCreateWithName( kIOPMAssertionTypeNoDisplaySleep as CFString,
|
||||
IOPMAssertionLevel(kIOPMAssertionLevelOn),
|
||||
reason as CFString,
|
||||
&assertionID) == kIOReturnSuccess
|
||||
}
|
||||
|
||||
func disableWakeScreen() -> Bool{
|
||||
IOPMAssertionRelease(assertionID)
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<true/>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>$(AppIdentifierPrefix)com.cakewallet.macos</string>
|
||||
<string>$(AppIdentifierPrefix)${BUNDLE_ID}</string>
|
||||
</array>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
|
@ -6,7 +6,7 @@
|
|||
<true/>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>$(AppIdentifierPrefix)com.cakewallet.macos</string>
|
||||
<string>$(AppIdentifierPrefix)${BUNDLE_ID}</string>
|
||||
</array>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
|
@ -9,13 +9,12 @@ dependencies:
|
|||
qr: ^3.0.1
|
||||
uuid: 3.0.6
|
||||
shared_preferences: ^2.0.15
|
||||
flutter_secure_storage: ^7.0.1
|
||||
# flutter_secure_storage:
|
||||
# git:
|
||||
# url: https://github.com/cake-tech/flutter_secure_storage.git
|
||||
# path: flutter_secure_storage
|
||||
# ref: cake-6.0.0
|
||||
# version: 6.0.0
|
||||
flutter_secure_storage:
|
||||
git:
|
||||
url: https://github.com/cake-tech/flutter_secure_storage.git
|
||||
path: flutter_secure_storage
|
||||
ref: cake-6.0.0
|
||||
version: 6.0.0
|
||||
# provider: ^6.0.3
|
||||
rxdart: ^0.27.4
|
||||
yaml: ^3.1.1
|
||||
|
|
|
@ -13,6 +13,12 @@ cp -rf ./macos/Runner/InfoBase.plist ./macos/Runner/Info.plist
|
|||
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier ${APP_MACOS_BUNDLE_ID}" ./macos/Runner/Info.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${APP_MACOS_VERSION}" ./macos/Runner/Info.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${APP_MACOS_BUILD_NUMBER}" ./macos/Runner/Info.plist
|
||||
|
||||
# Fill entitlements Bundle ID
|
||||
cp -rf ./macos/Runner/DebugProfileBase.entitlements ./macos/Runner/DebugProfile.entitlements
|
||||
cp -rf ./macos/Runner/ReleaseBase.entitlements ./macos/Runner/Release.entitlements
|
||||
sed -i '' "s/\${BUNDLE_ID}/${APP_MACOS_BUNDLE_ID}/g" ./macos/Runner/DebugProfile.entitlements
|
||||
sed -i '' "s/\${BUNDLE_ID}/${APP_MACOS_BUNDLE_ID}/g" ./macos/Runner/Release.entitlements
|
||||
CONFIG_ARGS=""
|
||||
|
||||
case $APP_MACOS_TYPE in
|
||||
|
|
|
@ -32,6 +32,10 @@ export CMAKE_INCLUDE_PATH="${PREFIX}/include"
|
|||
export CMAKE_LIBRARY_PATH="${PREFIX}/lib"
|
||||
rm -r monero/build > /dev/null
|
||||
|
||||
if [ "${ARCH}" == "x86_64" ]; then
|
||||
ARCH="x86-64"
|
||||
fi
|
||||
|
||||
mkdir -p monero/build/${BUILD_TYPE}
|
||||
pushd monero/build/${BUILD_TYPE}
|
||||
cmake -DARCH=${ARCH} \
|
||||
|
|
Loading…
Reference in a new issue