Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Add encrypted iOS notification service extension (#13965)

aman-pilotf019cd0bb2ac
diff --git a/.github/workflows/photos-build.yml b/.github/workflows/photos-build.yml
index 232ed7662e..e6dbe26b57 100644
--- a/.github/workflows/photos-build.yml
+++ b/.github/workflows/photos-build.yml
@@ -282,6 +282,7 @@ jobs:
DEVELOPMENT_TEAM="${APPLE_TEAM_ID}" \
APP_STORE_PROFILE_SPECIFIER="Photos App Store" \
SHARE_EXTENSION_APP_STORE_PROFILE_SPECIFIER="Photos Share Extension App Store" \
+ NOTIFICATION_SERVICE_EXTENSION_APP_STORE_PROFILE_SPECIFIER="Photos Notification Service Extension App Store" \
ALBUM_WIDGET_APP_STORE_PROFILE_SPECIFIER="Photos Album Widget App Store" \
MEMORY_WIDGET_APP_STORE_PROFILE_SPECIFIER="Photos Memory Widget App Store" \
PEOPLE_WIDGET_APP_STORE_PROFILE_SPECIFIER="Photos People Widget App Store" \
diff --git a/mobile/apps/photos/changes/fix-ios-notification-key-logout.md b/mobile/apps/photos/changes/fix-ios-notification-key-logout.md
new file mode 100644
index 0000000000..2ac63c1bbf
--- /dev/null
+++ b/mobile/apps/photos/changes/fix-ios-notification-key-logout.md
@@ -0,0 +1 @@
+- Fixed iOS logout stopping when a notification key could not be deleted.
diff --git a/mobile/apps/photos/ios/Flutter/NotificationDebug.xcconfig b/mobile/apps/photos/ios/Flutter/NotificationDebug.xcconfig
new file mode 100644
index 0000000000..807eb6789e
--- /dev/null
+++ b/mobile/apps/photos/ios/Flutter/NotificationDebug.xcconfig
@@ -0,0 +1,2 @@
+#include "Pods/Target Support Files/Pods-NotificationServiceExtension/Pods-NotificationServiceExtension.debug.xcconfig"
+#include "Generated.xcconfig"
diff --git a/mobile/apps/photos/ios/Flutter/NotificationProfile.xcconfig b/mobile/apps/photos/ios/Flutter/NotificationProfile.xcconfig
new file mode 100644
index 0000000000..41d4edf381
--- /dev/null
+++ b/mobile/apps/photos/ios/Flutter/NotificationProfile.xcconfig
@@ -0,0 +1,2 @@
+#include "Pods/Target Support Files/Pods-NotificationServiceExtension/Pods-NotificationServiceExtension.profile.xcconfig"
+#include "Generated.xcconfig"
diff --git a/mobile/apps/photos/ios/Flutter/NotificationRelease.xcconfig b/mobile/apps/photos/ios/Flutter/NotificationRelease.xcconfig
new file mode 100644
index 0000000000..dc0025bf42
--- /dev/null
+++ b/mobile/apps/photos/ios/Flutter/NotificationRelease.xcconfig
@@ -0,0 +1,2 @@
+#include "Pods/Target Support Files/Pods-NotificationServiceExtension/Pods-NotificationServiceExtension.release.xcconfig"
+#include "Generated.xcconfig"
diff --git a/mobile/apps/photos/ios/NotificationServiceExtension/Generated/.gitignore b/mobile/apps/photos/ios/NotificationServiceExtension/Generated/.gitignore
new file mode 100644
index 0000000000..d6b7ef32c8
--- /dev/null
+++ b/mobile/apps/photos/ios/NotificationServiceExtension/Generated/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/mobile/apps/photos/ios/NotificationServiceExtension/Info.plist b/mobile/apps/photos/ios/NotificationServiceExtension/Info.plist
new file mode 100644
index 0000000000..57421ebf9b
--- /dev/null
+++ b/mobile/apps/photos/ios/NotificationServiceExtension/Info.plist
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>NSExtension</key>
+ <dict>
+ <key>NSExtensionPointIdentifier</key>
+ <string>com.apple.usernotifications.service</string>
+ <key>NSExtensionPrincipalClass</key>
+ <string>$(PRODUCT_MODULE_NAME).NotificationService</string>
+ </dict>
+</dict>
+</plist>
diff --git a/mobile/apps/photos/ios/NotificationServiceExtension/NotificationService.swift b/mobile/apps/photos/ios/NotificationServiceExtension/NotificationService.swift
new file mode 100644
index 0000000000..e32229f643
--- /dev/null
+++ b/mobile/apps/photos/ios/NotificationServiceExtension/NotificationService.swift
@@ -0,0 +1,61 @@
+import Foundation
+import UserNotifications
+
+final class NotificationService: UNNotificationServiceExtension {
+ private let lock = NSLock()
+ private var contentHandler: ((UNNotificationContent) -> Void)?
+ private var fallback: UNNotificationContent?
+
+ override func didReceive(_ request: UNNotificationRequest,
+ withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
+ guard request.content.userInfo["notificationCiphertext"] != nil,
+ let content = request.content.mutableCopy() as? UNMutableNotificationContent
+ else {
+ contentHandler(request.content)
+ return
+ }
+ content.title = "Ente"
+ content.subtitle = ""
+ content.body = "New activity"
+ lock.lock()
+ self.contentHandler = contentHandler
+ fallback = content.copy() as? UNNotificationContent
+ lock.unlock()
+
+ if let ciphertext = request.content.userInfo["notificationCiphertext"] as? String,
+ let recipient = try? NotificationKeyStore.read(),
+ let event = NotificationEvent.decrypt(ciphertext, recipient: recipient),
+ event.eventType == "album_shared" {
+ content.body = "An album was shared with you"
+ }
+ finish(content)
+ }
+
+ override func serviceExtensionTimeWillExpire() {
+ finish()
+ }
+
+ private func finish(_ content: UNNotificationContent? = nil) {
+ lock.lock()
+ let handler = contentHandler
+ let result = content ?? fallback
+ contentHandler = nil
+ fallback = nil
+ lock.unlock()
+ if let handler, let result { handler(result) }
+ }
+}
+
+private struct NotificationEvent: Decodable {
+ let eventType: String
+
+ static func decrypt(_ ciphertext: String, recipient: NotificationRecipient) -> Self? {
+ guard recipient.isValid, ciphertext.utf8.count <= 4096,
+ let ciphertext = Data(base64Encoded: ciphertext), ciphertext.count > 1136,
+ let privateKey = Data(base64Encoded: recipient.privateKey)
+ else { return nil }
+ guard let plaintext = try? decryptNotification(ciphertext: ciphertext, privateKey: privateKey)
+ else { return nil }
+ return try? JSONDecoder().decode(Self.self, from: plaintext)
+ }
+}
diff --git a/mobile/apps/photos/ios/NotificationServiceExtension/NotificationServiceExtension.entitlements b/mobile/apps/photos/ios/NotificationServiceExtension/NotificationServiceExtension.entitlements
new file mode 100644
index 0000000000..83b43ed65f
--- /dev/null
+++ b/mobile/apps/photos/ios/NotificationServiceExtension/NotificationServiceExtension.entitlements
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>com.apple.security.application-groups</key>
+ <array>
+ <string>group.io.ente.frame.NotificationServiceExtension</string>
+ </array>
+</dict>
+</plist>
diff --git a/mobile/apps/photos/ios/NotificationServiceExtension/ente_notification_uniffi.podspec b/mobile/apps/photos/ios/NotificationServiceExtension/ente_notification_uniffi.podspec
new file mode 100644
index 0000000000..212c484317
--- /dev/null
+++ b/mobile/apps/photos/ios/NotificationServiceExtension/ente_notification_uniffi.podspec
@@ -0,0 +1,24 @@
+Pod::Spec.new do |s|
+ s.name = 'ente_notification_uniffi'
+ s.version = '0.1.0'
+ s.summary = 'Native notification decryption for Ente Photos.'
+ s.homepage = 'https://github.com/ente/ente'
+ s.license = { :type => 'AGPL-3.0' }
+ s.author = 'Ente'
+ s.source = { :path => '.' }
+ s.platform = :ios, '15.1'
+ s.static_framework = true
+ s.source_files = 'Generated/ente_notification_uniffiFFI.h'
+
+ s.script_phase = {
+ :name => 'Build notification Rust library',
+ :script => 'sh "$(cd -P "$PODS_TARGET_SRCROOT" && pwd)/../../../../cargokit/build_pod.sh" ../../../../../rust/bindings/uniffi/notifications ente_notification_uniffi',
+ :execution_position => :before_compile,
+ :input_files => ['${BUILT_PRODUCTS_DIR}/cargokit_phony'],
+ :output_files => ['${PODS_CONFIGURATION_BUILD_DIR}/ente_notification_uniffi/libente_notification_uniffi.a'],
+ }
+ s.user_target_xcconfig = {
+ 'LIBRARY_SEARCH_PATHS' => '$(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ente_notification_uniffi"',
+ 'OTHER_LDFLAGS' => '$(inherited) -lente_notification_uniffi',
+ }
+end
diff --git a/mobile/apps/photos/ios/Podfile b/mobile/apps/photos/ios/Podfile
index 7e730426f6..0d7b1e1fe3 100644
--- a/mobile/apps/photos/ios/Podfile
+++ b/mobile/apps/photos/ios/Podfile
@@ -44,6 +44,11 @@ target 'Runner' do
end
end
+target 'NotificationServiceExtension' do
+ use_frameworks!
+ pod 'ente_notification_uniffi', :path => 'NotificationServiceExtension'
+end
+
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
diff --git a/mobile/apps/photos/ios/Podfile.lock b/mobile/apps/photos/ios/Podfile.lock
index 199adf831f..bd796a3bb3 100644
--- a/mobile/apps/photos/ios/Podfile.lock
+++ b/mobile/apps/photos/ios/Podfile.lock
@@ -17,6 +17,7 @@ PODS:
- Flutter
- ente_mail (0.0.1):
- Flutter
+ - ente_notification_uniffi (0.1.0)
- ente_panorama_viewer (0.0.1):
- Flutter
- ente_photos_frb (0.0.1):
@@ -247,6 +248,7 @@ DEPENDENCIES:
- ente_background_manager (from `.symlinks/plugins/ente_background_manager/ios`)
- ente_cast (from `.symlinks/plugins/ente_cast/ios`)
- ente_mail (from `.symlinks/plugins/ente_mail/ios`)
+ - ente_notification_uniffi (from `NotificationServiceExtension`)
- ente_panorama_viewer (from `.symlinks/plugins/ente_panorama_viewer/ios`)
- ente_photos_frb (from `.symlinks/plugins/ente_photos_frb/ios`)
- ente_photos_platform (from `.symlinks/plugins/ente_photos_platform/ios`)
@@ -334,6 +336,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/ente_cast/ios"
ente_mail:
:path: ".symlinks/plugins/ente_mail/ios"
+ ente_notification_uniffi:
+ :path: NotificationServiceExtension
ente_panorama_viewer:
:path: ".symlinks/plugins/ente_panorama_viewer/ios"
ente_photos_frb:
@@ -441,6 +445,7 @@ SPEC CHECKSUMS:
ente_background_manager: f10e3bd64ccd32a3232f0fbacabdd5545af8d81e
ente_cast: a25feb3127397e5fc6aff03a12120916707757d4
ente_mail: f0569c7ea17e8324ef28f36a93c49fa1f3de724f
+ ente_notification_uniffi: 51004b2f6928f8fa748c870298e3788b046ae59e
ente_panorama_viewer: 16357cfb314c3f3f6abc0374ce17bfe371e528c2
ente_photos_frb: c693c36243f0f65df25e7674552879cc74588fea
ente_photos_platform: 08757c7e4977863732f75ce0f85cc6144600e3d2
@@ -506,6 +511,6 @@ SPEC CHECKSUMS:
wakelock_plus: e29112ab3ef0b318e58cfa5c32326458be66b556
workmanager_apple: 904529ae31e97fc5be632cf628507652294a0778
-PODFILE CHECKSUM: 1e63981d1e734d82b86f2c648779cacefb592a64
+PODFILE CHECKSUM: 10bc57f7956b6938d90465bf024867307eb6f24d
COCOAPODS: 1.17.0
diff --git a/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj b/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj
index 39d82cec70..295a373af2 100644
--- a/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj
+++ b/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj
@@ -33,6 +33,8 @@
CEE6BE7C2D7AE7FE00E4048B /* EnteMemoryWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = CEE6BE6F2D7AE7FD00E4048B /* EnteMemoryWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
D3E09F452C70B1E300F01A01 /* FFmpegRuntime in Frameworks */ = {isa = PBXBuildFile; productRef = D3E09F452C70B1E300F01A03 /* FFmpegRuntime */; };
DA6BE5E826B3BC8600656280 /* BuildFile in Resources */ = {isa = PBXBuildFile; };
+ 074CAC9E3088DD8200DF0FD6 /* NotificationServiceExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 074CAC973088DD8200DF0FD6 /* NotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
+ 38B442BF75FB4064D4FB816E /* Pods_NotificationServiceExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DED740990C035FB879F4AB2 /* Pods_NotificationServiceExtension.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -64,6 +66,13 @@
remoteGlobalIDString = CEE6BE6E2D7AE7FD00E4048B;
remoteInfo = EnteMemoryWidgetExtension;
};
+ 074CAC9C3088DD8200DF0FD6 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 97C146E61CF9000F007C117D /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 074CAC963088DD8200DF0FD6;
+ remoteInfo = NotificationServiceExtension;
+ };
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -77,6 +86,7 @@
CEE166302DD5E7830012CF61 /* EnteAlbumWidgetExtension.appex in Embed Foundation Extensions */,
CEE6BE7C2D7AE7FE00E4048B /* EnteMemoryWidgetExtension.appex in Embed Foundation Extensions */,
CEE166882DD5F6F30012CF61 /* EntePeopleWidgetExtension.appex in Embed Foundation Extensions */,
+ 074CAC9E3088DD8200DF0FD6 /* NotificationServiceExtension.appex in Embed Foundation Extensions */,
);
name = "Embed Foundation Extensions";
runOnlyForDeploymentPostprocessing = 0;
@@ -113,6 +123,9 @@
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
+ A17E00000000000000000041 /* NotificationDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = NotificationDebug.xcconfig; path = Flutter/NotificationDebug.xcconfig; sourceTree = "<group>"; };
+ A17E00000000000000000042 /* NotificationRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = NotificationRelease.xcconfig; path = Flutter/NotificationRelease.xcconfig; sourceTree = "<group>"; };
+ A17E00000000000000000043 /* NotificationProfile.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = NotificationProfile.xcconfig; path = Flutter/NotificationProfile.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
@@ -133,6 +146,11 @@
D025F2F5A163F84B724D14D7 /* Pods_ShareExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ShareExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DA8D6672273BBB59007651D4 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
F82DAEEB9A7D9FD00E0FFA1E /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ 074CAC973088DD8200DF0FD6 /* NotificationServiceExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationServiceExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
+ 4DED740990C035FB879F4AB2 /* Pods_NotificationServiceExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NotificationServiceExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ 6ED373D1AC6D19CD79AD833F /* Pods-NotificationServiceExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationServiceExtension.release.xcconfig"; path = "Target Support Files/Pods-NotificationServiceExtension/Pods-NotificationServiceExtension.release.xcconfig"; sourceTree = "<group>"; };
+ B21A56DCD06AC3D46D32CBE6 /* Pods-NotificationServiceExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationServiceExtension.debug.xcconfig"; path = "Target Support Files/Pods-NotificationServiceExtension/Pods-NotificationServiceExtension.debug.xcconfig"; sourceTree = "<group>"; };
+ F7200DA71C0EF4D67BAF8476 /* Pods-NotificationServiceExtension.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationServiceExtension.profile.xcconfig"; path = "Target Support Files/Pods-NotificationServiceExtension/Pods-NotificationServiceExtension.profile.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
@@ -164,6 +182,15 @@
);
target = CEE6BE6E2D7AE7FD00E4048B /* EnteMemoryWidgetExtension */;
};
+ 074CACA23088DD8200DF0FD6 /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {
+ isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
+ membershipExceptions = (
+ Generated/.gitignore,
+ ente_notification_uniffi.podspec,
+ Info.plist,
+ );
+ target = 074CAC963088DD8200DF0FD6 /* NotificationServiceExtension */;
+ };
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
/* Begin PBXFileSystemSynchronizedRootGroup section */
@@ -215,6 +242,7 @@
path = EnteMemoryWidget;
sourceTree = "<group>";
};
+ 074CAC983088DD8200DF0FD6 /* NotificationServiceExtension */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (074CACA23088DD8200DF0FD6 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = NotificationServiceExtension; sourceTree = "<group>"; };
/* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */
@@ -263,6 +291,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 074CAC943088DD8200DF0FD6 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 38B442BF75FB4064D4FB816E /* Pods_NotificationServiceExtension.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@@ -272,6 +308,9 @@
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
+ A17E00000000000000000041 /* NotificationDebug.xcconfig */,
+ A17E00000000000000000042 /* NotificationRelease.xcconfig */,
+ A17E00000000000000000043 /* NotificationProfile.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
);
name = Flutter;
@@ -294,6 +333,7 @@
97C146EF1CF9000F007C117D /* Products */,
AC6CA265BB505D982CB00391 /* Pods */,
C6A22658E77FF012720BEDDA /* Frameworks */,
+ 074CAC983088DD8200DF0FD6 /* NotificationServiceExtension */,
);
sourceTree = "<group>";
};
@@ -305,6 +345,7 @@
CEE166232DD5E7820012CF61 /* EnteAlbumWidgetExtension.appex */,
CEE1667B2DD5F6F20012CF61 /* EntePeopleWidgetExtension.appex */,
54D121EC2F02675C00B8CC69 /* ShareExtension.appex */,
+ 074CAC973088DD8200DF0FD6 /* NotificationServiceExtension.appex */,
);
name = Products;
sourceTree = "<group>";
@@ -347,6 +388,9 @@
53DBFBDBE805FC6E13E3F31E /* Pods-ShareExtension.debug.xcconfig */,
C540B46EB90E9D7FDF10AC56 /* Pods-ShareExtension.release.xcconfig */,
AAB2B37A8A7F46DD9D1734DF /* Pods-ShareExtension.profile.xcconfig */,
+ B21A56DCD06AC3D46D32CBE6 /* Pods-NotificationServiceExtension.debug.xcconfig */,
+ 6ED373D1AC6D19CD79AD833F /* Pods-NotificationServiceExtension.release.xcconfig */,
+ F7200DA71C0EF4D67BAF8476 /* Pods-NotificationServiceExtension.profile.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
@@ -359,6 +403,7 @@
6DACD83C2B755B0600BA9516 /* WidgetKit.framework */,
6DACD83E2B755B0600BA9516 /* SwiftUI.framework */,
D025F2F5A163F84B724D14D7 /* Pods_ShareExtension.framework */,
+ 4DED740990C035FB879F4AB2 /* Pods_NotificationServiceExtension.framework */,
);
name = Frameworks;
sourceTree = "<group>";
@@ -409,6 +454,7 @@
CEE1662F2DD5E7830012CF61 /* PBXTargetDependency */,
CEE166872DD5F6F30012CF61 /* PBXTargetDependency */,
54D121F52F02675C00B8CC69 /* PBXTargetDependency */,
+ 074CAC9D3088DD8200DF0FD6 /* PBXTargetDependency */,
);
name = Runner;
packageProductDependencies = (
@@ -478,6 +524,29 @@
productReference = CEE6BE6F2D7AE7FD00E4048B /* EnteMemoryWidgetExtension.appex */;
productType = "com.apple.product-type.app-extension";
};
+ 074CAC963088DD8200DF0FD6 /* NotificationServiceExtension */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 074CACA33088DD8200DF0FD6 /* Build configuration list for PBXNativeTarget "NotificationServiceExtension" */;
+ buildPhases = (
+ E7BD861B2DAA578D401B7082 /* [CP] Check Pods Manifest.lock */,
+ 074CAC933088DD8200DF0FD6 /* Sources */,
+ 074CAC943088DD8200DF0FD6 /* Frameworks */,
+ 074CAC953088DD8200DF0FD6 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ fileSystemSynchronizedGroups = (
+ 074CAC983088DD8200DF0FD6 /* NotificationServiceExtension */,
+ );
+ name = NotificationServiceExtension;
+ packageProductDependencies = (
+ );
+ productName = NotificationServiceExtension;
+ productReference = 074CAC973088DD8200DF0FD6 /* NotificationServiceExtension.appex */;
+ productType = "com.apple.product-type.app-extension";
+ };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@@ -487,6 +556,9 @@
LastSwiftUpdateCheck = 2620;
LastUpgradeCheck = 1510;
TargetAttributes = {
+ 074CAC963088DD8200DF0FD6 = {
+ CreatedOnToolsVersion = 27.0;
+ };
54D121EB2F02675C00B8CC69 = {
CreatedOnToolsVersion = 26.2;
};
@@ -526,6 +598,7 @@
CEE166222DD5E7820012CF61 /* EnteAlbumWidgetExtension */,
CEE1667A2DD5F6F20012CF61 /* EntePeopleWidgetExtension */,
54D121EB2F02675C00B8CC69 /* ShareExtension */,
+ 074CAC963088DD8200DF0FD6 /* NotificationServiceExtension */,
);
};
/* End PBXProject section */
@@ -572,6 +645,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 074CAC953088DD8200DF0FD6 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
@@ -856,6 +936,28 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
+ E7BD861B2DAA578D401B7082 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-NotificationServiceExtension-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -900,6 +1002,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 074CAC933088DD8200DF0FD6 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
@@ -923,6 +1032,11 @@
target = CEE6BE6E2D7AE7FD00E4048B /* EnteMemoryWidgetExtension */;
targetProxy = CEE6BE7A2D7AE7FE00E4048B /* PBXContainerItemProxy */;
};
+ 074CAC9D3088DD8200DF0FD6 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 074CAC963088DD8200DF0FD6 /* NotificationServiceExtension */;
+ targetProxy = 074CAC9C3088DD8200DF0FD6 /* PBXContainerItemProxy */;
+ };
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
@@ -1755,6 +1869,92 @@
};
name = Profile;
};
+ 074CAC9F3088DD8200DF0FD6 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = A17E00000000000000000041 /* NotificationDebug.xcconfig */;
+ buildSettings = {
+ APPLICATION_EXTENSION_API_ONLY = YES;
+ CODE_SIGN_ENTITLEMENTS = NotificationServiceExtension/NotificationServiceExtension.entitlements;
+ CODE_SIGN_IDENTITY = "Apple Development";
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
+ DEAD_CODE_STRIPPING = YES;
+ DEVELOPMENT_TEAM = 6Z68YJY9Q2;
+ ENABLE_USER_SCRIPT_SANDBOXING = NO;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = NotificationServiceExtension/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 15.1;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
+ MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)";
+ OTHER_LDFLAGS = ("$(inherited)", "-framework", Security, );
+ PRODUCT_BUNDLE_IDENTIFIER = io.ente.frame.debug.NotificationServiceExtension;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
+ OTHER_SWIFT_FLAGS = "$(inherited) -Xcc -fmodule-map-file=$(SRCROOT)/NotificationServiceExtension/Generated/ente_notification_uniffiFFI.modulemap";
+ SWIFT_INCLUDE_PATHS = "$(inherited) $(SRCROOT)/NotificationServiceExtension/Generated";
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 074CACA03088DD8200DF0FD6 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = A17E00000000000000000042 /* NotificationRelease.xcconfig */;
+ buildSettings = {
+ APPLICATION_EXTENSION_API_ONLY = YES;
+ CODE_SIGN_ENTITLEMENTS = NotificationServiceExtension/NotificationServiceExtension.entitlements;
+ CODE_SIGN_IDENTITY = "Apple Development";
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
+ DEAD_CODE_STRIPPING = YES;
+ DEVELOPMENT_TEAM = 6Z68YJY9Q2;
+ ENABLE_USER_SCRIPT_SANDBOXING = NO;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = NotificationServiceExtension/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 15.1;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
+ MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)";
+ OTHER_LDFLAGS = ("$(inherited)", "-framework", Security, );
+ PRODUCT_BUNDLE_IDENTIFIER = io.ente.frame.NotificationServiceExtension;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ PROVISIONING_PROFILE_SPECIFIER = "$(NOTIFICATION_SERVICE_EXTENSION_APP_STORE_PROFILE_SPECIFIER)";
+ SKIP_INSTALL = YES;
+ OTHER_SWIFT_FLAGS = "$(inherited) -Xcc -fmodule-map-file=$(SRCROOT)/NotificationServiceExtension/Generated/ente_notification_uniffiFFI.modulemap";
+ SWIFT_INCLUDE_PATHS = "$(inherited) $(SRCROOT)/NotificationServiceExtension/Generated";
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
+ 074CACA13088DD8200DF0FD6 /* Profile */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = A17E00000000000000000043 /* NotificationProfile.xcconfig */;
+ buildSettings = {
+ APPLICATION_EXTENSION_API_ONLY = YES;
+ CODE_SIGN_ENTITLEMENTS = NotificationServiceExtension/NotificationServiceExtension.entitlements;
+ CODE_SIGN_IDENTITY = "Apple Development";
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
+ DEAD_CODE_STRIPPING = YES;
+ DEVELOPMENT_TEAM = 6Z68YJY9Q2;
+ ENABLE_USER_SCRIPT_SANDBOXING = NO;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = NotificationServiceExtension/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 15.1;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
+ MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)";
+ OTHER_LDFLAGS = ("$(inherited)", "-framework", Security, );
+ PRODUCT_BUNDLE_IDENTIFIER = io.ente.frame.NotificationServiceExtension;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ OTHER_SWIFT_FLAGS = "$(inherited) -Xcc -fmodule-map-file=$(SRCROOT)/NotificationServiceExtension/Generated/ente_notification_uniffiFFI.modulemap";
+ SWIFT_INCLUDE_PATHS = "$(inherited) $(SRCROOT)/NotificationServiceExtension/Generated";
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Profile;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -1818,6 +2018,16 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 074CACA33088DD8200DF0FD6 /* Build configuration list for PBXNativeTarget "NotificationServiceExtension" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 074CAC9F3088DD8200DF0FD6 /* Debug */,
+ 074CACA03088DD8200DF0FD6 /* Release */,
+ 074CACA13088DD8200DF0FD6 /* Profile */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
/* Begin XCLocalSwiftPackageReference section */
diff --git a/mobile/apps/photos/lib/core/configuration.dart b/mobile/apps/photos/lib/core/configuration.dart
index 0cf84558c6..801f69acd4 100644
--- a/mobile/apps/photos/lib/core/configuration.dart
+++ b/mobile/apps/photos/lib/core/configuration.dart
@@ -217,7 +217,12 @@ class Configuration implements LockScreenHost, AccountDeletionHost {
}
if (Platform.isIOS) {
- await NotificationKeyService.setNotificationPrivateKey(null);
+ try {
+ await NotificationKeyService.setNotificationPrivateKey(null);
+ } on PlatformException catch (e, s) {
+ if (e.code != 'notification_key_store') rethrow;
+ _logger.warning("Could not delete notification key", e, s);
+ }
}
await _clearTempFolderOnLogout();
diff --git a/mobile/apps/photos/lib/services/notification_key_service.dart b/mobile/apps/photos/lib/services/notification_key_service.dart
index 0b8e9d7309..645ed1b680 100644
--- a/mobile/apps/photos/lib/services/notification_key_service.dart
+++ b/mobile/apps/photos/lib/services/notification_key_service.dart
@@ -13,8 +13,7 @@ class NotificationKeyService {
static const _storageKey = 'notification_private_key';
static Future<String>? _pendingKey;
- static Future<String?> generateNotificationKey() {
- if (!Platform.isAndroid) return Future.value();
+ static Future<String> generateNotificationKey() {
return _pendingKey ??= _getOrCreateNotificationKey().whenComplete(() {
_pendingKey = null;
});
diff --git a/mobile/apps/photos/lib/services/push_service.dart b/mobile/apps/photos/lib/services/push_service.dart
index cef52e1419..ee4dfa029d 100644
--- a/mobile/apps/photos/lib/services/push_service.dart
+++ b/mobile/apps/photos/lib/services/push_service.dart
@@ -106,7 +106,10 @@ class PushService {
Future<void> _setPushTokenOnServer(String fcmToken, String? apnsToken) async {
String? notificationKey;
try {
- notificationKey = await NotificationKeyService.generateNotificationKey();
+ if (flagService.internalUser) {
+ notificationKey =
+ await NotificationKeyService.generateNotificationKey();
+ }
} catch (e, s) {
_logPushError("Could not prepare notification key", e, s);
}
diff --git a/mobile/apps/photos/scripts/ExportOptions-AppStore-CI.plist b/mobile/apps/photos/scripts/ExportOptions-AppStore-CI.plist
index 90cd4a79b1..0869e3fe28 100644
--- a/mobile/apps/photos/scripts/ExportOptions-AppStore-CI.plist
+++ b/mobile/apps/photos/scripts/ExportOptions-AppStore-CI.plist
@@ -20,6 +20,8 @@
<string>Photos App Store</string>
<key>io.ente.frame.ShareExtension</key>
<string>Photos Share Extension App Store</string>
+ <key>io.ente.frame.NotificationServiceExtension</key>
+ <string>Photos Notification Service Extension App Store</string>
<key>io.ente.frame.EnteAlbumWidget</key>
<string>Photos Album Widget App Store</string>
<key>io.ente.frame.EnteMemoryWidget</key>
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index e1a7678c53..64a5051cb3 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -2838,6 +2838,15 @@ dependencies = [
"usearch",
]
+[[package]]
+name = "ente-notification-uniffi"
+version = "0.0.0"
+dependencies = [
+ "ente-core",
+ "thiserror 2.0.21",
+ "uniffi",
+]
+
[[package]]
name = "ente-paste"
version = "0.0.0"
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index dd2797f511..f4367890d4 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -11,6 +11,7 @@ members = [
"bindings/uniffi/cast",
"bindings/uniffi/ensu",
"bindings/uniffi/log",
+ "bindings/uniffi/notifications",
"bindings/wasm/auth",
"bindings/wasm/cast",
"bindings/wasm/ensu",
diff --git a/rust/bindings/uniffi/notifications/Cargo.toml b/rust/bindings/uniffi/notifications/Cargo.toml
new file mode 100644
index 0000000000..00499b740c
--- /dev/null
+++ b/rust/bindings/uniffi/notifications/Cargo.toml
@@ -0,0 +1,14 @@
+[package]
+name = "ente-notification-uniffi"
+edition.workspace = true
+
+[lib]
+crate-type = ["staticlib", "cdylib"]
+
+[dependencies]
+ente-core.workspace = true
+thiserror.workspace = true
+uniffi.workspace = true
+
+[lints]
+workspace = true
diff --git a/rust/bindings/uniffi/notifications/cargokit.yaml b/rust/bindings/uniffi/notifications/cargokit.yaml
new file mode 100644
index 0000000000..bbbdfc63db
--- /dev/null
+++ b/rust/bindings/uniffi/notifications/cargokit.yaml
@@ -0,0 +1,7 @@
+cargo:
+ debug:
+ extra_flags: ["--locked"]
+ profile:
+ extra_flags: ["--locked"]
+ release:
+ extra_flags: ["--locked"]
diff --git a/rust/bindings/uniffi/notifications/src/lib.rs b/rust/bindings/uniffi/notifications/src/lib.rs
new file mode 100644
index 0000000000..f0576043c5
--- /dev/null
+++ b/rust/bindings/uniffi/notifications/src/lib.rs
@@ -0,0 +1,23 @@
+uniffi::setup_scaffolding!("ente_notification_uniffi");
+
+use ente_core::crypto::hpke;
+
+#[derive(Debug, thiserror::Error, uniffi::Error)]
+pub enum NotificationError {
+ #[error("Invalid notification payload")]
+ InvalidPayload,
+}
+
+#[uniffi::export]
+pub fn decrypt_notification(
+ ciphertext: Vec<u8>,
+ private_key: Vec<u8>,
+) -> Result<Vec<u8>, NotificationError> {
+ if ciphertext.len() <= hpke::OVERHEAD || ciphertext.len() > 4096 {
+ return Err(NotificationError::InvalidPayload);
+ }
+ let private_key = hpke::SecretKey::try_from_slice(&private_key)
+ .map_err(|_| NotificationError::InvalidPayload)?;
+ hpke::open(&ciphertext, &private_key, b"ente-push")
+ .map_err(|_| NotificationError::InvalidPayload)
+}
diff --git a/rust/tools/codegen/src/main.rs b/rust/tools/codegen/src/main.rs
index 03875dc3d1..e22e5e8410 100644
--- a/rust/tools/codegen/src/main.rs
+++ b/rust/tools/codegen/src/main.rs
@@ -219,6 +219,16 @@ fn generate_frb(target: FrbTarget) -> Result<(), DynError> {
shared_types.insert(name, types);
}
}
+ if apps.contains(&"photos") {
+ let notifications = UniffiCrate {
+ crate_name: "ente_notification_uniffi",
+ crate_dir: rust_root.join("bindings/uniffi/notifications"),
+ };
+ generate_swift(
+ &notifications,
+ "mobile/apps/photos/ios/NotificationServiceExtension/Generated",
+ )?;
+ }
format_frb_bindings(target)
}