From d4c030919f3d7d89fdf3922beee000c9efb9e575 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sat, 15 Jun 2024 13:05:54 -0400 Subject: [PATCH 1/2] ADD: View Payment Code on Watch app --- components/WatchConnectivity.ios.js | 3 + ios/BlueWallet.xcodeproj/project.pbxproj | 55 ++- .../xcshareddata/swiftpm/Package.resolved | 42 ++ .../InterfaceController.swift | 10 +- .../Objects/ReceiveInterfaceMode.swift | 13 + .../Objects/ReceiveMethod.swift | 13 + .../Objects/ReceiveType.swift | 13 + .../Objects/Transaction.swift | 4 +- .../Objects/Wallet.swift | 13 +- .../Objects/WatchDataSource.swift | 13 +- .../ReceiveInterfaceController.swift | 19 +- .../ReceivePageInterfaceController.swift | 29 ++ .../ViewQRCodefaceController.swift | 2 +- .../WalletDetailsInterfaceController.swift | 6 +- .../Base.lproj/Interface.storyboard | 12 +- ios/KeychainSwiftDistrib.swift | 454 ------------------ 16 files changed, 199 insertions(+), 502 deletions(-) create mode 100644 ios/BlueWallet.xcworkspace/xcshareddata/swiftpm/Package.resolved create mode 100644 ios/BlueWalletWatch Extension/Objects/ReceiveInterfaceMode.swift create mode 100644 ios/BlueWalletWatch Extension/Objects/ReceiveMethod.swift create mode 100644 ios/BlueWalletWatch Extension/Objects/ReceiveType.swift create mode 100644 ios/BlueWalletWatch Extension/ReceivePageInterfaceController.swift delete mode 100644 ios/KeychainSwiftDistrib.swift diff --git a/components/WatchConnectivity.ios.js b/components/WatchConnectivity.ios.js index 880d54eee..65a5efcae 100644 --- a/components/WatchConnectivity.ios.js +++ b/components/WatchConnectivity.ios.js @@ -232,6 +232,9 @@ function WatchConnectivity() { if (wallet.chain === Chain.ONCHAIN && wallet.type !== MultisigHDWallet.type) { walletInformation.xpub = wallet.getXpub() ? wallet.getXpub() : wallet.getSecret(); } + if (wallet?.allowBIP47() && wallet.isBIP47Enabled()) { + walletInformation.paymentCode = wallet.getBIP47PaymentCode(); + } walletsToProcess.push(walletInformation); } return { wallets: walletsToProcess, randomID: Math.floor(Math.random() * 11) }; diff --git a/ios/BlueWallet.xcodeproj/project.pbxproj b/ios/BlueWallet.xcodeproj/project.pbxproj index c45c4e887..d42a8f0c9 100644 --- a/ios/BlueWallet.xcodeproj/project.pbxproj +++ b/ios/BlueWallet.xcodeproj/project.pbxproj @@ -58,7 +58,6 @@ B40D4E602258425500428FCC /* SpecifyInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40D4E582258425400428FCC /* SpecifyInterfaceController.swift */; }; B40D4E632258425500428FCC /* ReceiveInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40D4E5B2258425500428FCC /* ReceiveInterfaceController.swift */; }; B40D4E642258425500428FCC /* WalletDetailsInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40D4E5C2258425500428FCC /* WalletDetailsInterfaceController.swift */; }; - B40D4E682258426B00428FCC /* KeychainSwiftDistrib.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40D4E672258426B00428FCC /* KeychainSwiftDistrib.swift */; }; B40FC3FA29CCD1D00007EBAC /* SwiftTCPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40FC3F829CCD1AC0007EBAC /* SwiftTCPClient.swift */; }; B41B76852B66B2FF002C48D5 /* Bugsnag in Frameworks */ = {isa = PBXBuildFile; productRef = B41B76842B66B2FF002C48D5 /* Bugsnag */; }; B41B76872B66B2FF002C48D5 /* BugsnagNetworkRequestPlugin in Frameworks */ = {isa = PBXBuildFile; productRef = B41B76862B66B2FF002C48D5 /* BugsnagNetworkRequestPlugin */; }; @@ -146,6 +145,7 @@ B461B852299599F800E431AA /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = B461B851299599F800E431AA /* AppDelegate.mm */; }; B47462D02C1538D800100825 /* CustomSegmentedControlManager.m in Sources */ = {isa = PBXBuildFile; fileRef = B45010A52C1507DE00619044 /* CustomSegmentedControlManager.m */; }; B47B21EC2B2128B8001F6690 /* BlueWalletUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B47B21EB2B2128B8001F6690 /* BlueWalletUITests.swift */; }; + B48A6A292C1DF01000030AB9 /* KeychainSwift in Frameworks */ = {isa = PBXBuildFile; productRef = B48A6A282C1DF01000030AB9 /* KeychainSwift */; }; B49038D92B8FBAD300A8164A /* BlueWalletUITest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B49038D82B8FBAD300A8164A /* BlueWalletUITest.swift */; }; B4A29A2C2B55C990002A67DF /* EventEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D32C5C52596CE3A008C077C /* EventEmitter.m */; }; B4A29A2D2B55C990002A67DF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; @@ -163,9 +163,13 @@ B4B1A4622BFA73110072E3BB /* WidgetHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B1A4612BFA73110072E3BB /* WidgetHelper.swift */; }; B4B1A4642BFA73110072E3BB /* WidgetHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B1A4612BFA73110072E3BB /* WidgetHelper.swift */; }; B4B1A4652BFA73110072E3BB /* WidgetHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B1A4612BFA73110072E3BB /* WidgetHelper.swift */; }; + B4D0B2622C1DEA11006B6B1B /* ReceivePageInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D0B2612C1DEA11006B6B1B /* ReceivePageInterfaceController.swift */; }; + B4D0B2642C1DEA99006B6B1B /* ReceiveType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D0B2632C1DEA99006B6B1B /* ReceiveType.swift */; }; + B4D0B2662C1DEB7F006B6B1B /* ReceiveInterfaceMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D0B2652C1DEB7F006B6B1B /* ReceiveInterfaceMode.swift */; }; + B4D0B2682C1DED67006B6B1B /* ReceiveMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D0B2672C1DED67006B6B1B /* ReceiveMethod.swift */; }; B4EE583C226703320003363C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B40D4E35225841ED00428FCC /* Assets.xcassets */; }; C59F90CE0D04D3E4BB39BC5D /* libPods-BlueWalletUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F02C2F7CA3591E4E0B06EBA /* libPods-BlueWalletUITests.a */; }; - C978A716948AB7DEC5B6F677 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; }; + C978A716948AB7DEC5B6F677 /* (null) in Frameworks */ = {isa = PBXBuildFile; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -422,7 +426,6 @@ B40D4E582258425400428FCC /* SpecifyInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpecifyInterfaceController.swift; sourceTree = ""; }; B40D4E5B2258425500428FCC /* ReceiveInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReceiveInterfaceController.swift; sourceTree = ""; }; B40D4E5C2258425500428FCC /* WalletDetailsInterfaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalletDetailsInterfaceController.swift; sourceTree = ""; }; - B40D4E672258426B00428FCC /* KeychainSwiftDistrib.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeychainSwiftDistrib.swift; sourceTree = SOURCE_ROOT; }; B40FC3F829CCD1AC0007EBAC /* SwiftTCPClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftTCPClient.swift; sourceTree = ""; }; B41C2E552BB3DCB8000FE097 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; B43B69BA225C46D800925B1E /* libRCTLinking.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libRCTLinking.a; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -458,6 +461,10 @@ B4A29A462B55C990002A67DF /* BlueWallet-NoLDK.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "BlueWallet-NoLDK.plist"; sourceTree = ""; }; B4AB225C2B02AD12001F4328 /* XMLParserDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLParserDelegate.swift; sourceTree = ""; }; B4B1A4612BFA73110072E3BB /* WidgetHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetHelper.swift; sourceTree = ""; }; + B4D0B2612C1DEA11006B6B1B /* ReceivePageInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceivePageInterfaceController.swift; sourceTree = ""; }; + B4D0B2632C1DEA99006B6B1B /* ReceiveType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceiveType.swift; sourceTree = ""; }; + B4D0B2652C1DEB7F006B6B1B /* ReceiveInterfaceMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceiveInterfaceMode.swift; sourceTree = ""; }; + B4D0B2672C1DED67006B6B1B /* ReceiveMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReceiveMethod.swift; sourceTree = ""; }; B4D3235A177F4580BA52F2F9 /* libRNCSlider.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNCSlider.a; sourceTree = ""; }; B642AFB13483418CAB6FF25E /* libRCTQRCodeLocalImage.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTQRCodeLocalImage.a; sourceTree = ""; }; B68F8552DD4428F64B11DCFB /* Pods-BlueWallet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BlueWallet.debug.xcconfig"; path = "Target Support Files/Pods-BlueWallet/Pods-BlueWallet.debug.xcconfig"; sourceTree = ""; }; @@ -484,7 +491,7 @@ files = ( 782F075B5DD048449E2DECE9 /* libz.tbd in Frameworks */, 764B49B1420D4AEB8109BF62 /* libsqlite3.0.tbd in Frameworks */, - C978A716948AB7DEC5B6F677 /* BuildFile in Frameworks */, + C978A716948AB7DEC5B6F677 /* (null) in Frameworks */, 773E382FE62E836172AAB98B /* libPods-BlueWallet.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -518,6 +525,7 @@ files = ( B41B76852B66B2FF002C48D5 /* Bugsnag in Frameworks */, B41B76872B66B2FF002C48D5 /* BugsnagNetworkRequestPlugin in Frameworks */, + B48A6A292C1DF01000030AB9 /* KeychainSwift in Frameworks */, 6DFC807024EA0B6C007B8700 /* EFQRCode in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -771,7 +779,6 @@ children = ( 32F0A24F2310B0700095C559 /* BlueWalletWatch Extension.entitlements */, B43D03242258474500FBAA95 /* Objects */, - B40D4E672258426B00428FCC /* KeychainSwiftDistrib.swift */, 32F0A2992311DBB20095C559 /* ComplicationController.swift */, B40D4E43225841ED00428FCC /* ExtensionDelegate.swift */, B40D4E45225841ED00428FCC /* NotificationController.swift */, @@ -783,6 +790,7 @@ B40D4E5C2258425500428FCC /* WalletDetailsInterfaceController.swift */, B40D4E49225841ED00428FCC /* Info.plist */, B40D4E4A225841ED00428FCC /* PushNotificationPayload.apns */, + B4D0B2612C1DEA11006B6B1B /* ReceivePageInterfaceController.swift */, ); path = "BlueWalletWatch Extension"; sourceTree = ""; @@ -828,6 +836,9 @@ B43D0377225847C500FBAA95 /* WalletInformation.swift */, B43D0373225847C500FBAA95 /* WatchDataSource.swift */, 849047C92702A32A008EE567 /* Handoff.swift */, + B4D0B2632C1DEA99006B6B1B /* ReceiveType.swift */, + B4D0B2652C1DEB7F006B6B1B /* ReceiveInterfaceMode.swift */, + B4D0B2672C1DED67006B6B1B /* ReceiveMethod.swift */, ); path = Objects; sourceTree = ""; @@ -1021,6 +1032,7 @@ 6DFC806F24EA0B6C007B8700 /* EFQRCode */, B41B76842B66B2FF002C48D5 /* Bugsnag */, B41B76862B66B2FF002C48D5 /* BugsnagNetworkRequestPlugin */, + B48A6A282C1DF01000030AB9 /* KeychainSwift */, ); productName = "BlueWalletWatch Extension"; productReference = B40D4E3C225841ED00428FCC /* BlueWalletWatch Extension.appex */; @@ -1152,8 +1164,9 @@ ); mainGroup = 83CBB9F61A601CBA00E9B192; packageReferences = ( - 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode.git" */, + 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */, B41B76832B66B2FF002C48D5 /* XCRemoteSwiftPackageReference "bugsnag-cocoa" */, + B48A6A272C1DF01000030AB9 /* XCRemoteSwiftPackageReference "keychain-swift" */, ); productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; projectDirPath = ""; @@ -1611,10 +1624,12 @@ B43D037A225847C500FBAA95 /* Transaction.swift in Sources */, 32F0A29A2311DBB20095C559 /* ComplicationController.swift in Sources */, B40D4E602258425500428FCC /* SpecifyInterfaceController.swift in Sources */, + B4D0B2642C1DEA99006B6B1B /* ReceiveType.swift in Sources */, B43D0379225847C500FBAA95 /* WatchDataSource.swift in Sources */, B450109F2C0FCDA500619044 /* Utilities.swift in Sources */, B44033D42BCC368800162242 /* UserDefaultsGroupKey.swift in Sources */, B44034012BCC37F800162242 /* Bundle+decode.swift in Sources */, + B4D0B2682C1DED67006B6B1B /* ReceiveMethod.swift in Sources */, 849047CA2702A32A008EE567 /* Handoff.swift in Sources */, B44033EA2BCC371A00162242 /* MarketData.swift in Sources */, B44033CB2BCC350A00162242 /* Currency.swift in Sources */, @@ -1623,12 +1638,12 @@ B40D4E5D2258425500428FCC /* InterfaceController.swift in Sources */, B44033FA2BCC379200162242 /* WidgetDataStore.swift in Sources */, B44033DE2BCC36C300162242 /* LatestTransaction.swift in Sources */, + B4D0B2662C1DEB7F006B6B1B /* ReceiveInterfaceMode.swift in Sources */, B43D037B225847C500FBAA95 /* TransactionTableRow.swift in Sources */, B43D037D225847C500FBAA95 /* WalletInformation.swift in Sources */, 6D4AF15925D21172009DD853 /* MarketAPI.swift in Sources */, B40D4E642258425500428FCC /* WalletDetailsInterfaceController.swift in Sources */, B40D4E44225841ED00428FCC /* ExtensionDelegate.swift in Sources */, - B40D4E682258426B00428FCC /* KeychainSwiftDistrib.swift in Sources */, 6D4AF16D25D21192009DD853 /* Placeholders.swift in Sources */, B44033DB2BCC369B00162242 /* Colors.swift in Sources */, B40D4E632258425500428FCC /* ReceiveInterfaceController.swift in Sources */, @@ -1636,6 +1651,7 @@ B44033C02BCC32F800162242 /* BitcoinUnit.swift in Sources */, B44033E52BCC36FF00162242 /* WalletData.swift in Sources */, B44033EF2BCC374500162242 /* Numeric+abbreviated.swift in Sources */, + B4D0B2622C1DEA11006B6B1B /* ReceivePageInterfaceController.swift in Sources */, B44033D02BCC352F00162242 /* UserDefaultsGroup.swift in Sources */, B44033C52BCC332400162242 /* Balance.swift in Sources */, 6D4AF18425D215D1009DD853 /* UserDefaultsExtension.swift in Sources */, @@ -2250,7 +2266,7 @@ SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 6.0; + WATCHOS_DEPLOYMENT_TARGET = 7.0; }; name = Debug; }; @@ -2299,7 +2315,7 @@ SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 6.0; + WATCHOS_DEPLOYMENT_TARGET = 7.0; }; name = Release; }; @@ -2346,7 +2362,7 @@ SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 6.0; + WATCHOS_DEPLOYMENT_TARGET = 7.0; }; name = Debug; }; @@ -2393,7 +2409,7 @@ SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 4; - WATCHOS_DEPLOYMENT_TARGET = 6.0; + WATCHOS_DEPLOYMENT_TARGET = 7.0; }; name = Release; }; @@ -2671,7 +2687,7 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode.git" */ = { + 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/EFPrefix/EFQRCode.git"; requirement = { @@ -2687,12 +2703,20 @@ version = 6.28.1; }; }; + B48A6A272C1DF01000030AB9 /* XCRemoteSwiftPackageReference "keychain-swift" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/evgenyneu/keychain-swift.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 24.0.0; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ 6DFC806F24EA0B6C007B8700 /* EFQRCode */ = { isa = XCSwiftPackageProductDependency; - package = 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode.git" */; + package = 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */; productName = EFQRCode; }; B41B76842B66B2FF002C48D5 /* Bugsnag */ = { @@ -2705,6 +2729,11 @@ package = B41B76832B66B2FF002C48D5 /* XCRemoteSwiftPackageReference "bugsnag-cocoa" */; productName = BugsnagNetworkRequestPlugin; }; + B48A6A282C1DF01000030AB9 /* KeychainSwift */ = { + isa = XCSwiftPackageProductDependency; + package = B48A6A272C1DF01000030AB9 /* XCRemoteSwiftPackageReference "keychain-swift" */; + productName = KeychainSwift; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; diff --git a/ios/BlueWallet.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ios/BlueWallet.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 000000000..dc603f84c --- /dev/null +++ b/ios/BlueWallet.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,42 @@ +{ + "originHash" : "52530e6b1e3a85c8854952ef703a6d1bbe1acd82713be2b3166476b9b277db23", + "pins" : [ + { + "identity" : "bugsnag-cocoa", + "kind" : "remoteSourceControl", + "location" : "https://github.com/bugsnag/bugsnag-cocoa", + "state" : { + "revision" : "16b9145fc66e5296f16e733f6feb5d0e450574e8", + "version" : "6.28.1" + } + }, + { + "identity" : "efqrcode", + "kind" : "remoteSourceControl", + "location" : "https://github.com/EFPrefix/EFQRCode.git", + "state" : { + "revision" : "2991c2f318ad9529d93b2a73a382a3f9c72c64ce", + "version" : "6.2.2" + } + }, + { + "identity" : "keychain-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/evgenyneu/keychain-swift.git", + "state" : { + "revision" : "5e1b02b6a9dac2a759a1d5dbc175c86bd192a608", + "version" : "24.0.0" + } + }, + { + "identity" : "swift_qrcodejs", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ApolloZhu/swift_qrcodejs.git", + "state" : { + "revision" : "374dc7f7b9e76c6aeb393f6a84590c6d387e1ecb", + "version" : "2.2.2" + } + } + ], + "version" : 3 +} diff --git a/ios/BlueWalletWatch Extension/InterfaceController.swift b/ios/BlueWalletWatch Extension/InterfaceController.swift index 14ee85498..bec0e10ef 100644 --- a/ios/BlueWalletWatch Extension/InterfaceController.swift +++ b/ios/BlueWalletWatch Extension/InterfaceController.swift @@ -15,9 +15,7 @@ class InterfaceController: WKInterfaceController, WCSessionDelegate { @IBOutlet weak var noWalletsAvailableLabel: WKInterfaceLabel! override func awake(withContext context: Any?) { - super.awake(withContext: context) setupSession() - processContextData(context) } override func willActivate() { @@ -63,6 +61,8 @@ class InterfaceController: WKInterfaceController, WCSessionDelegate { func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : Any]) { WatchDataSource.shared.processData(data: applicationContext) } + + func session(_ session: WCSession, didReceiveUserInfo userInfo: [String : Any] = [:]) { WatchDataSource.shared.processData(data: userInfo) @@ -70,7 +70,7 @@ class InterfaceController: WKInterfaceController, WCSessionDelegate { func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) { if activationState == .activated { - WatchDataSource.shared.processWalletsData(walletsInfo: WCSession.default.applicationContext) + WatchDataSource.shared.loadKeychainData() } } @@ -78,8 +78,4 @@ class InterfaceController: WKInterfaceController, WCSessionDelegate { WatchDataSource.shared.processData(data: message) } - override func didDeactivate() { - WCSession.default.activate() - } - } diff --git a/ios/BlueWalletWatch Extension/Objects/ReceiveInterfaceMode.swift b/ios/BlueWalletWatch Extension/Objects/ReceiveInterfaceMode.swift new file mode 100644 index 000000000..3daf911f7 --- /dev/null +++ b/ios/BlueWalletWatch Extension/Objects/ReceiveInterfaceMode.swift @@ -0,0 +1,13 @@ +// +// ReceiveInterfaceMode.swift +// BlueWalletWatch Extension +// +// Created by Marcos Rodriguez on 6/15/24. +// Copyright © 2024 BlueWallet. All rights reserved. +// + +import Foundation + +enum ReceiveInterfaceMode { + case Address, QRCode +} diff --git a/ios/BlueWalletWatch Extension/Objects/ReceiveMethod.swift b/ios/BlueWalletWatch Extension/Objects/ReceiveMethod.swift new file mode 100644 index 000000000..ea7c29ebe --- /dev/null +++ b/ios/BlueWalletWatch Extension/Objects/ReceiveMethod.swift @@ -0,0 +1,13 @@ +// +// ReceiveMethod.swift +// BlueWalletWatch Extension +// +// Created by Marcos Rodriguez on 6/15/24. +// Copyright © 2024 BlueWallet. All rights reserved. +// + +import Foundation + +enum ReceiveMethod { + case Onchain, CreateInvoice +} diff --git a/ios/BlueWalletWatch Extension/Objects/ReceiveType.swift b/ios/BlueWalletWatch Extension/Objects/ReceiveType.swift new file mode 100644 index 000000000..119bedc2d --- /dev/null +++ b/ios/BlueWalletWatch Extension/Objects/ReceiveType.swift @@ -0,0 +1,13 @@ +// +// ReceiveType.swift +// BlueWalletWatch Extension +// +// Created by Marcos Rodriguez on 6/15/24. +// Copyright © 2024 BlueWallet. All rights reserved. +// + +import Foundation + +enum ReceiveType { + case Address, PaymentCode +} diff --git a/ios/BlueWalletWatch Extension/Objects/Transaction.swift b/ios/BlueWalletWatch Extension/Objects/Transaction.swift index 6db26b74e..e0d092527 100644 --- a/ios/BlueWalletWatch Extension/Objects/Transaction.swift +++ b/ios/BlueWalletWatch Extension/Objects/Transaction.swift @@ -8,7 +8,9 @@ import Foundation -class Transaction: NSObject, NSCoding { +class Transaction: NSObject, NSSecureCoding { + static var supportsSecureCoding: Bool = true + static let identifier: String = "Transaction" let time: String diff --git a/ios/BlueWalletWatch Extension/Objects/Wallet.swift b/ios/BlueWalletWatch Extension/Objects/Wallet.swift index 62e541892..7b4f44fc3 100644 --- a/ios/BlueWalletWatch Extension/Objects/Wallet.swift +++ b/ios/BlueWalletWatch Extension/Objects/Wallet.swift @@ -8,11 +8,10 @@ import Foundation -enum InterfaceMode { - case Address, QRCode -} +class Wallet: NSObject, NSSecureCoding { + + static var supportsSecureCoding: Bool = true -class Wallet: NSObject, NSCoding { static let identifier: String = "Wallet" var identifier: Int? @@ -24,8 +23,9 @@ class Wallet: NSObject, NSCoding { let transactions: [Transaction] let xpub: String? let hideBalance: Bool + let paymentCode: String? - init(label: String, balance: String, type: String, preferredBalanceUnit: String, receiveAddress: String, transactions: [Transaction], identifier: Int, xpub: String?, hideBalance: Bool = false) { + init(label: String, balance: String, type: String, preferredBalanceUnit: String, receiveAddress: String, transactions: [Transaction], identifier: Int, xpub: String?, hideBalance: Bool = false, paymentCode: String?) { self.label = label self.balance = balance self.type = type @@ -35,6 +35,7 @@ class Wallet: NSObject, NSCoding { self.identifier = identifier self.xpub = xpub self.hideBalance = hideBalance + self.paymentCode = paymentCode } func encode(with aCoder: NSCoder) { @@ -47,6 +48,7 @@ class Wallet: NSObject, NSCoding { aCoder.encode(identifier, forKey: "identifier") aCoder.encode(xpub, forKey: "xpub") aCoder.encode(hideBalance, forKey: "hideBalance") + aCoder.encode(paymentCode, forKey: "paymentCode") } required init?(coder aDecoder: NSCoder) { @@ -58,6 +60,7 @@ class Wallet: NSObject, NSCoding { transactions = aDecoder.decodeObject(forKey: "transactions") as? [Transaction] ?? [Transaction]() xpub = aDecoder.decodeObject(forKey: "xpub") as? String hideBalance = aDecoder.decodeObject(forKey: "hideBalance") as? Bool ?? false + paymentCode = aDecoder.decodeObject(forKey: "paymentCode") as? String } } diff --git a/ios/BlueWalletWatch Extension/Objects/WatchDataSource.swift b/ios/BlueWalletWatch Extension/Objects/WatchDataSource.swift index 6ddfa10ce..3a29a7008 100644 --- a/ios/BlueWalletWatch Extension/Objects/WatchDataSource.swift +++ b/ios/BlueWalletWatch Extension/Objects/WatchDataSource.swift @@ -9,6 +9,7 @@ import Foundation import WatchConnectivity +import KeychainSwift class WatchDataSource: NSObject { struct NotificationName { @@ -27,8 +28,12 @@ class WatchDataSource: NSObject { override init() { super.init() - if let existingData = keychain.getData(Wallet.identifier), let walletData = ((try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(existingData) as? [Wallet]) as [Wallet]??) { - guard let walletData = walletData, walletData != self.wallets else { return } + loadKeychainData() + } + + func loadKeychainData() { + if let existingData = keychain.getData(Wallet.identifier), let walletData = try? NSKeyedUnarchiver.unarchivedArrayOfObjects(ofClass: Wallet.self, from: existingData) { + guard walletData != self.wallets else { return } wallets = walletData WatchDataSource.postDataUpdatedNotification() } @@ -38,7 +43,7 @@ class WatchDataSource: NSObject { if let walletsToProcess = walletsInfo["wallets"] as? [[String: Any]] { wallets.removeAll(); for (index, entry) in walletsToProcess.enumerated() { - guard let label = entry["label"] as? String, let balance = entry["balance"] as? String, let type = entry["type"] as? String, let preferredBalanceUnit = entry["preferredBalanceUnit"] as? String, let transactions = entry["transactions"] as? [[String: Any]] else { + guard let label = entry["label"] as? String, let balance = entry["balance"] as? String, let type = entry["type"] as? String, let preferredBalanceUnit = entry["preferredBalanceUnit"] as? String, let transactions = entry["transactions"] as? [[String: Any]], let paymentCode = entry["paymentCode"] as? String else { continue } @@ -51,7 +56,7 @@ class WatchDataSource: NSObject { let receiveAddress = entry["receiveAddress"] as? String ?? "" let xpub = entry["xpub"] as? String ?? "" let hideBalance = entry["hideBalance"] as? Bool ?? false - let wallet = Wallet(label: label, balance: balance, type: type, preferredBalanceUnit: preferredBalanceUnit, receiveAddress: receiveAddress, transactions: transactionsProcessed, identifier: index, xpub: xpub, hideBalance: hideBalance) + let wallet = Wallet(label: label, balance: balance, type: type, preferredBalanceUnit: preferredBalanceUnit, receiveAddress: receiveAddress, transactions: transactionsProcessed, identifier: index, xpub: xpub, hideBalance: hideBalance, paymentCode: paymentCode) wallets.append(wallet) } diff --git a/ios/BlueWalletWatch Extension/ReceiveInterfaceController.swift b/ios/BlueWalletWatch Extension/ReceiveInterfaceController.swift index 9477b9888..06223b8ec 100644 --- a/ios/BlueWalletWatch Extension/ReceiveInterfaceController.swift +++ b/ios/BlueWalletWatch Extension/ReceiveInterfaceController.swift @@ -9,17 +9,13 @@ import WatchConnectivity import Foundation import EFQRCode -import WatchKit -import WatchConnectivity -import Foundation -import EFQRCode - class ReceiveInterfaceController: WKInterfaceController { static let identifier = "ReceiveInterfaceController" private var wallet: Wallet? - private var receiveMethod: String = "receive" - private var interfaceMode: InterfaceMode = .Address + private var receiveMethod: ReceiveMethod = .Onchain + private var interfaceMode: ReceiveInterfaceMode = .Address + var receiveType: ReceiveType = .Address @IBOutlet weak var addressLabel: WKInterfaceLabel! @IBOutlet weak var loadingIndicator: WKInterfaceGroup! @IBOutlet weak var imageInterface: WKInterfaceImage! @@ -35,18 +31,19 @@ class ReceiveInterfaceController: WKInterfaceController { override func awake(withContext context: Any?) { super.awake(withContext: context) - guard let passedContext = context as? (Int, String) else { + guard let passedContext = context as? (Int, ReceiveMethod, ReceiveType) else { pop() return } let wallet = WatchDataSource.shared.wallets[passedContext.0] self.wallet = wallet receiveMethod = passedContext.1 + receiveType = passedContext.2 setupView() } private func setupView() { - if receiveMethod == "createInvoice" && (wallet?.type == WalletGradient.LightningCustodial.rawValue || wallet?.type == WalletGradient.LightningLDK.rawValue) { + if receiveMethod == .CreateInvoice && (wallet?.type == WalletGradient.LightningCustodial.rawValue || wallet?.type == WalletGradient.LightningLDK.rawValue) { presentController(withName: SpecifyInterfaceController.identifier, context: wallet?.identifier) } else { setupQRCode() @@ -55,7 +52,7 @@ class ReceiveInterfaceController: WKInterfaceController { } private func setupQRCode() { - guard let address = wallet?.receiveAddress else { return } + guard let address = receiveType == .Address ? wallet?.receiveAddress : wallet?.paymentCode else { return } addressLabel.setText(address) generateQRCode(from: address) } @@ -95,7 +92,7 @@ class ReceiveInterfaceController: WKInterfaceController { } private func isCreatingInvoice() -> Bool { - return receiveMethod == "createInvoice" && (wallet?.type == WalletGradient.LightningCustodial.rawValue || wallet?.type == WalletGradient.LightningLDK.rawValue) + return receiveMethod == .CreateInvoice && (wallet?.type == WalletGradient.LightningCustodial.rawValue || wallet?.type == WalletGradient.LightningLDK.rawValue) } override func didDeactivate() { diff --git a/ios/BlueWalletWatch Extension/ReceivePageInterfaceController.swift b/ios/BlueWalletWatch Extension/ReceivePageInterfaceController.swift new file mode 100644 index 000000000..fe55a4143 --- /dev/null +++ b/ios/BlueWalletWatch Extension/ReceivePageInterfaceController.swift @@ -0,0 +1,29 @@ +// +// ReceivePageViewController.swift +// BlueWalletWatch Extension +// +// Created by Marcos Rodriguez on 6/15/24. +// Copyright © 2024 BlueWallet. All rights reserved. +// + +import Foundation +import WatchKit + +class ReceivePageInterfaceController: WKInterfaceController { + static let identifier = "ReceivePageInterfaceController" + var pageNames = ["Address", "Payment Code"] + var pageControllers = ["ReceiveInterfaceController", "ReceiveInterfaceController"] + + override func awake(withContext context: Any?) { + super.awake(withContext: context) + + let wallet = context as? Wallet + + WKInterfaceController.reloadRootPageControllers( + withNames: pageControllers, + contexts: [(wallet,ReceiveMethod.Onchain , ReceiveType.Address), (wallet, ReceiveMethod.Onchain, ReceiveType.PaymentCode)], + orientation: .horizontal, + pageIndex: 0 + ) + } +} diff --git a/ios/BlueWalletWatch Extension/ViewQRCodefaceController.swift b/ios/BlueWalletWatch Extension/ViewQRCodefaceController.swift index f25878477..be326619d 100644 --- a/ios/BlueWalletWatch Extension/ViewQRCodefaceController.swift +++ b/ios/BlueWalletWatch Extension/ViewQRCodefaceController.swift @@ -19,7 +19,7 @@ class ViewQRCodefaceController: WKInterfaceController { } } - private var interfaceMode = InterfaceMode.Address + private var interfaceMode = ReceiveInterfaceMode.Address private let userActivity: NSUserActivity = NSUserActivity(activityType: HandoffIdentifier.Xpub.rawValue) override func awake(withContext context: Any?) { diff --git a/ios/BlueWalletWatch Extension/WalletDetailsInterfaceController.swift b/ios/BlueWalletWatch Extension/WalletDetailsInterfaceController.swift index 1263d0085..d349a7d64 100644 --- a/ios/BlueWalletWatch Extension/WalletDetailsInterfaceController.swift +++ b/ios/BlueWalletWatch Extension/WalletDetailsInterfaceController.swift @@ -111,13 +111,13 @@ class WalletDetailsInterfaceController: WKInterfaceController { @IBAction func receiveMenuItemTapped() { guard let wallet = wallet else { return } - presentController(withName: ReceiveInterfaceController.identifier, context: (wallet, "receive")) + presentController(withName: ReceivePageInterfaceController.identifier, context: (wallet, ReceiveMethod.Onchain)) } @IBAction func createInvoiceTapped() { if WatchDataSource.shared.companionWalletsInitialized { guard let wallet = wallet else { return } - pushController(withName: ReceiveInterfaceController.identifier, context: (wallet.identifier, "createInvoice")) + pushController(withName: ReceiveInterfaceController.identifier, context: (wallet.identifier, ReceiveMethod.CreateInvoice)) } else { WKInterfaceDevice.current().play(.failure) presentAlert(withTitle: "Error", message: "Unable to create invoice. Please open BlueWallet on your iPhone and unlock your wallets.", preferredStyle: .alert, actions: [WKAlertAction(title: "OK", style: .default, handler: { [weak self] in @@ -128,7 +128,7 @@ class WalletDetailsInterfaceController: WKInterfaceController { override func contextForSegue(withIdentifier segueIdentifier: String) -> Any? { guard let wallet = wallet else { return nil } - return (wallet.identifier, "receive") + return (wallet.identifier, ReceiveMethod.Onchain) } } diff --git a/ios/BlueWalletWatch/Base.lproj/Interface.storyboard b/ios/BlueWalletWatch/Base.lproj/Interface.storyboard index 2fbb377a4..a7fc234d3 100644 --- a/ios/BlueWalletWatch/Base.lproj/Interface.storyboard +++ b/ios/BlueWalletWatch/Base.lproj/Interface.storyboard @@ -1,10 +1,9 @@ - + - - + @@ -227,6 +226,13 @@ + + + + + + + diff --git a/ios/KeychainSwiftDistrib.swift b/ios/KeychainSwiftDistrib.swift deleted file mode 100644 index 6287bcf82..000000000 --- a/ios/KeychainSwiftDistrib.swift +++ /dev/null @@ -1,454 +0,0 @@ -// -// Keychain helper for iOS/Swift. -// -// https://github.com/evgenyneu/keychain-swift -// -// This file was automatically generated by combining multiple Swift source files. -// - - -// ---------------------------- -// -// KeychainSwift.swift -// -// ---------------------------- - -import Security -import Foundation - -/** - -A collection of helper functions for saving text and data in the keychain. - -*/ -open class KeychainSwift { - - var lastQueryParameters: [String: Any]? // Used by the unit tests - - /// Contains result code from the last operation. Value is noErr (0) for a successful result. - open var lastResultCode: OSStatus = noErr - - var keyPrefix = "" // Can be useful in test. - - /** - - Specify an access group that will be used to access keychain items. Access groups can be used to share keychain items between applications. When access group value is nil all application access groups are being accessed. Access group name is used by all functions: set, get, delete and clear. - - */ - open var accessGroup: String? - - - /** - - Specifies whether the items can be synchronized with other devices through iCloud. Setting this property to true will - add the item to other devices with the `set` method and obtain synchronizable items with the `get` command. Deleting synchronizable items will remove them from all devices. In order for keychain synchronization to work the user must enable "Keychain" in iCloud settings. - - Does not work on macOS. - - */ - open var synchronizable: Bool = false - - private let readLock = NSLock() - - /// Instantiate a KeychainSwift object - public init() { } - - /** - - - parameter keyPrefix: a prefix that is added before the key in get/set methods. Note that `clear` method still clears everything from the Keychain. - - */ - public init(keyPrefix: String) { - self.keyPrefix = keyPrefix - } - - /** - - Stores the text value in the keychain item under the given key. - - - parameter key: Key under which the text value is stored in the keychain. - - parameter value: Text string to be written to the keychain. - - parameter withAccess: Value that indicates when your app needs access to the text in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user. - - - returns: True if the text was successfully written to the keychain. - - */ - @discardableResult - open func set(_ value: String, forKey key: String, - withAccess access: KeychainSwiftAccessOptions? = nil) -> Bool { - - if let value = value.data(using: String.Encoding.utf8) { - return set(value, forKey: key, withAccess: access) - } - - return false - } - - /** - - Stores the data in the keychain item under the given key. - - - parameter key: Key under which the data is stored in the keychain. - - parameter value: Data to be written to the keychain. - - parameter withAccess: Value that indicates when your app needs access to the text in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user. - - - returns: True if the text was successfully written to the keychain. - - */ - @discardableResult - open func set(_ value: Data, forKey key: String, - withAccess access: KeychainSwiftAccessOptions? = nil) -> Bool { - - delete(key) // Delete any existing key before saving it - - let accessible = access?.value ?? KeychainSwiftAccessOptions.defaultOption.value - - let prefixedKey = keyWithPrefix(key) - - var query: [String : Any] = [ - KeychainSwiftConstants.klass : kSecClassGenericPassword, - KeychainSwiftConstants.attrAccount : prefixedKey, - KeychainSwiftConstants.valueData : value, - KeychainSwiftConstants.accessible : accessible - ] - - query = addAccessGroupWhenPresent(query) - query = addSynchronizableIfRequired(query, addingItems: true) - lastQueryParameters = query - - lastResultCode = SecItemAdd(query as CFDictionary, nil) - - return lastResultCode == noErr - } - - /** - - Stores the boolean value in the keychain item under the given key. - - - parameter key: Key under which the value is stored in the keychain. - - parameter value: Boolean to be written to the keychain. - - parameter withAccess: Value that indicates when your app needs access to the value in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user. - - - returns: True if the value was successfully written to the keychain. - - */ - @discardableResult - open func set(_ value: Bool, forKey key: String, - withAccess access: KeychainSwiftAccessOptions? = nil) -> Bool { - - let bytes: [UInt8] = value ? [1] : [0] - let data = Data(bytes) - - return set(data, forKey: key, withAccess: access) - } - - /** - - Retrieves the text value from the keychain that corresponds to the given key. - - - parameter key: The key that is used to read the keychain item. - - returns: The text value from the keychain. Returns nil if unable to read the item. - - */ - open func get(_ key: String) -> String? { - if let data = getData(key) { - - if let currentString = String(data: data, encoding: .utf8) { - return currentString - } - - lastResultCode = -67853 // errSecInvalidEncoding - } - - return nil - } - - /** - - Retrieves the data from the keychain that corresponds to the given key. - - - parameter key: The key that is used to read the keychain item. - - returns: The text value from the keychain. Returns nil if unable to read the item. - - */ - open func getData(_ key: String) -> Data? { - // The lock prevents the code to be run simlultaneously - // from multiple threads which may result in crashing - readLock.lock() - defer { readLock.unlock() } - - let prefixedKey = keyWithPrefix(key) - - var query: [String: Any] = [ - KeychainSwiftConstants.klass : kSecClassGenericPassword, - KeychainSwiftConstants.attrAccount : prefixedKey, - KeychainSwiftConstants.returnData : kCFBooleanTrue!, - KeychainSwiftConstants.matchLimit : kSecMatchLimitOne - ] - - query = addAccessGroupWhenPresent(query) - query = addSynchronizableIfRequired(query, addingItems: false) - lastQueryParameters = query - - var result: AnyObject? - - lastResultCode = withUnsafeMutablePointer(to: &result) { - SecItemCopyMatching(query as CFDictionary, UnsafeMutablePointer($0)) - } - - if lastResultCode == noErr { return result as? Data } - - return nil - } - - /** - - Retrieves the boolean value from the keychain that corresponds to the given key. - - - parameter key: The key that is used to read the keychain item. - - returns: The boolean value from the keychain. Returns nil if unable to read the item. - - */ - open func getBool(_ key: String) -> Bool? { - guard let data = getData(key) else { return nil } - guard let firstBit = data.first else { return nil } - return firstBit == 1 - } - - /** - - Deletes the single keychain item specified by the key. - - - parameter key: The key that is used to delete the keychain item. - - returns: True if the item was successfully deleted. - - */ - @discardableResult - open func delete(_ key: String) -> Bool { - let prefixedKey = keyWithPrefix(key) - - var query: [String: Any] = [ - KeychainSwiftConstants.klass : kSecClassGenericPassword, - KeychainSwiftConstants.attrAccount : prefixedKey - ] - - query = addAccessGroupWhenPresent(query) - query = addSynchronizableIfRequired(query, addingItems: false) - lastQueryParameters = query - - lastResultCode = SecItemDelete(query as CFDictionary) - - return lastResultCode == noErr - } - - /** - - Deletes all Keychain items used by the app. Note that this method deletes all items regardless of the prefix settings used for initializing the class. - - - returns: True if the keychain items were successfully deleted. - - */ - @discardableResult - open func clear() -> Bool { - var query: [String: Any] = [ kSecClass as String : kSecClassGenericPassword ] - query = addAccessGroupWhenPresent(query) - query = addSynchronizableIfRequired(query, addingItems: false) - lastQueryParameters = query - - lastResultCode = SecItemDelete(query as CFDictionary) - - return lastResultCode == noErr - } - - /// Returns the key with currently set prefix. - func keyWithPrefix(_ key: String) -> String { - return "\(keyPrefix)\(key)" - } - - func addAccessGroupWhenPresent(_ items: [String: Any]) -> [String: Any] { - guard let accessGroup = accessGroup else { return items } - - var result: [String: Any] = items - result[KeychainSwiftConstants.accessGroup] = accessGroup - return result - } - - /** - - Adds kSecAttrSynchronizable: kSecAttrSynchronizableAny` item to the dictionary when the `synchronizable` property is true. - - - parameter items: The dictionary where the kSecAttrSynchronizable items will be added when requested. - - parameter addingItems: Use `true` when the dictionary will be used with `SecItemAdd` method (adding a keychain item). For getting and deleting items, use `false`. - - - returns: the dictionary with kSecAttrSynchronizable item added if it was requested. Otherwise, it returns the original dictionary. - - */ - func addSynchronizableIfRequired(_ items: [String: Any], addingItems: Bool) -> [String: Any] { - if !synchronizable { return items } - var result: [String: Any] = items - result[KeychainSwiftConstants.attrSynchronizable] = addingItems == true ? true : kSecAttrSynchronizableAny - return result - } -} - - -// ---------------------------- -// -// TegKeychainConstants.swift -// -// ---------------------------- - -import Foundation -import Security - -/// Constants used by the library -public struct KeychainSwiftConstants { - /// Specifies a Keychain access group. Used for sharing Keychain items between apps. - public static var accessGroup: String { return toString(kSecAttrAccessGroup) } - - /** - - A value that indicates when your app needs access to the data in a keychain item. The default value is AccessibleWhenUnlocked. For a list of possible values, see KeychainSwiftAccessOptions. - - */ - public static var accessible: String { return toString(kSecAttrAccessible) } - - /// Used for specifying a String key when setting/getting a Keychain value. - public static var attrAccount: String { return toString(kSecAttrAccount) } - - /// Used for specifying synchronization of keychain items between devices. - public static var attrSynchronizable: String { return toString(kSecAttrSynchronizable) } - - /// An item class key used to construct a Keychain search dictionary. - public static var klass: String { return toString(kSecClass) } - - /// Specifies the number of values returned from the keychain. The library only supports single values. - public static var matchLimit: String { return toString(kSecMatchLimit) } - - /// A return data type used to get the data from the Keychain. - public static var returnData: String { return toString(kSecReturnData) } - - /// Used for specifying a value when setting a Keychain value. - public static var valueData: String { return toString(kSecValueData) } - - static func toString(_ value: CFString) -> String { - return value as String - } -} - - -// ---------------------------- -// -// KeychainSwiftAccessOptions.swift -// -// ---------------------------- - -import Security - -/** - -These options are used to determine when a keychain item should be readable. The default value is AccessibleWhenUnlocked. - -*/ -public enum KeychainSwiftAccessOptions { - - /** - - The data in the keychain item can be accessed only while the device is unlocked by the user. - - This is recommended for items that need to be accessible only while the application is in the foreground. Items with this attribute migrate to a new device when using encrypted backups. - - This is the default value for keychain items added without explicitly setting an accessibility constant. - - */ - case accessibleWhenUnlocked - - /** - - The data in the keychain item can be accessed only while the device is unlocked by the user. - - This is recommended for items that need to be accessible only while the application is in the foreground. Items with this attribute do not migrate to a new device. Thus, after restoring from a backup of a different device, these items will not be present. - - */ - case accessibleWhenUnlockedThisDeviceOnly - - /** - - The data in the keychain item cannot be accessed after a restart until the device has been unlocked once by the user. - - After the first unlock, the data remains accessible until the next restart. This is recommended for items that need to be accessed by background applications. Items with this attribute migrate to a new device when using encrypted backups. - - */ - case accessibleAfterFirstUnlock - - /** - - The data in the keychain item cannot be accessed after a restart until the device has been unlocked once by the user. - - After the first unlock, the data remains accessible until the next restart. This is recommended for items that need to be accessed by background applications. Items with this attribute do not migrate to a new device. Thus, after restoring from a backup of a different device, these items will not be present. - - */ - case accessibleAfterFirstUnlockThisDeviceOnly - - /** - - The data in the keychain item can always be accessed regardless of whether the device is locked. - - This is not recommended for application use. Items with this attribute migrate to a new device when using encrypted backups. - - */ - case accessibleAlways - - /** - - The data in the keychain can only be accessed when the device is unlocked. Only available if a passcode is set on the device. - - This is recommended for items that only need to be accessible while the application is in the foreground. Items with this attribute never migrate to a new device. After a backup is restored to a new device, these items are missing. No items can be stored in this class on devices without a passcode. Disabling the device passcode causes all items in this class to be deleted. - - */ - case accessibleWhenPasscodeSetThisDeviceOnly - - /** - - The data in the keychain item can always be accessed regardless of whether the device is locked. - - This is not recommended for application use. Items with this attribute do not migrate to a new device. Thus, after restoring from a backup of a different device, these items will not be present. - - */ - case accessibleAlwaysThisDeviceOnly - - static var defaultOption: KeychainSwiftAccessOptions { - return .accessibleWhenUnlocked - } - - var value: String { - switch self { - case .accessibleWhenUnlocked: - return toString(kSecAttrAccessibleWhenUnlocked) - - case .accessibleWhenUnlockedThisDeviceOnly: - return toString(kSecAttrAccessibleWhenUnlockedThisDeviceOnly) - - case .accessibleAfterFirstUnlock: - return toString(kSecAttrAccessibleAfterFirstUnlock) - - case .accessibleAfterFirstUnlockThisDeviceOnly: - return toString(kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly) - - case .accessibleAlways: - return toString(kSecAttrAccessibleAlways) - - case .accessibleWhenPasscodeSetThisDeviceOnly: - return toString(kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly) - - case .accessibleAlwaysThisDeviceOnly: - return toString(kSecAttrAccessibleAlwaysThisDeviceOnly) - } - } - - func toString(_ value: CFString) -> String { - return KeychainSwiftConstants.toString(value) - } -} - - From 3a652eead6283212a2ec1d078cd08edd09fd66bc Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sat, 15 Jun 2024 13:18:09 -0400 Subject: [PATCH 2/2] Update WatchConnectivity.ios.js --- components/WatchConnectivity.ios.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/WatchConnectivity.ios.js b/components/WatchConnectivity.ios.js index 65a5efcae..c62bdc55d 100644 --- a/components/WatchConnectivity.ios.js +++ b/components/WatchConnectivity.ios.js @@ -232,7 +232,7 @@ function WatchConnectivity() { if (wallet.chain === Chain.ONCHAIN && wallet.type !== MultisigHDWallet.type) { walletInformation.xpub = wallet.getXpub() ? wallet.getXpub() : wallet.getSecret(); } - if (wallet?.allowBIP47() && wallet.isBIP47Enabled()) { + if (wallet.allowBIP47() && wallet.isBIP47Enabled()) { walletInformation.paymentCode = wallet.getBIP47PaymentCode(); } walletsToProcess.push(walletInformation);