diff --git a/apps/desktop/src/main/capture/auth.test.ts b/apps/desktop/src/main/capture/auth.test.ts index 1a84c2310..474cd9e83 100644 --- a/apps/desktop/src/main/capture/auth.test.ts +++ b/apps/desktop/src/main/capture/auth.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest' -import { validateCaptureRequest } from './auth' +import { validateCaptureRequest, isExtensionOrigin } from './auth' const TOKEN = 'a'.repeat(64) const allow = (o: string | undefined) => o === 'chrome-extension://abc' @@ -40,3 +40,19 @@ describe('validateCaptureRequest', () => { ).toBe(false) }) }) + +describe('isExtensionOrigin', () => { + it('accepts a Safari web-extension origin', () => { + expect(isExtensionOrigin('safari-web-extension://A1B2C3D4-0000-0000-0000-000000000000')).toBe( + true + ) + }) + it('accepts chrome and firefox extension origins', () => { + expect(isExtensionOrigin('chrome-extension://abc')).toBe(true) + expect(isExtensionOrigin('moz-extension://abc')).toBe(true) + }) + it('rejects a web origin and undefined', () => { + expect(isExtensionOrigin('https://evil.com')).toBe(false) + expect(isExtensionOrigin(undefined)).toBe(false) + }) +}) diff --git a/apps/desktop/src/main/capture/auth.ts b/apps/desktop/src/main/capture/auth.ts index fa51e4349..4950e10a1 100644 --- a/apps/desktop/src/main/capture/auth.ts +++ b/apps/desktop/src/main/capture/auth.ts @@ -8,6 +8,20 @@ export interface CaptureAuthHeaders { type Result = { ok: true } | { ok: false; reason: string } +// Capture pairing accepts browser-extension origins only — Chromium (chrome-extension://), +// Firefox (moz-extension://), and Safari (safari-web-extension://). Single source of truth +// so the two pairing guards can't drift. +const EXTENSION_ORIGIN_PREFIXES = [ + 'chrome-extension://', + 'moz-extension://', + 'safari-web-extension://' +] + +export function isExtensionOrigin(origin: string | undefined): boolean { + if (!origin) return false + return EXTENSION_ORIGIN_PREFIXES.some((prefix) => origin.startsWith(prefix)) +} + function tokenEquals(a: string, b: string): boolean { const ab = Buffer.from(a) const bb = Buffer.from(b) diff --git a/apps/extension/README.md b/apps/extension/README.md index 190789578..94421754b 100644 --- a/apps/extension/README.md +++ b/apps/extension/README.md @@ -20,6 +20,17 @@ pnpm --filter @memry/extension lint 3. **Load unpacked** → select `apps/extension/.output/chrome-mv3`. 4. Keep the load path stable so the extension ID (and pairing) survives reloads. +## Build for Safari (macOS) + +Safari ships the extension inside a native macOS app. WXT builds the bundle; Xcode wraps it. + +1. `pnpm --filter @memry/extension build:safari` → `.output/safari-mv3` (MV3, matching the + Chrome/Firefox source). +2. Wrap it into the macOS container app (see the Xcode project at `apps/extension/safari/`). + +`build:safari` only produces the web bundle — the native app, signing, and App Store +submission are covered by the Safari release runbook below. + ## Manual QA (the Phase-3 acceptance gate — human-required) Run the desktop app first: `pnpm dev`. diff --git a/apps/extension/package.json b/apps/extension/package.json index 591b7e04c..5e817f7ed 100644 --- a/apps/extension/package.json +++ b/apps/extension/package.json @@ -7,6 +7,9 @@ "dev": "wxt", "build": "wxt build", "zip": "wxt zip", + "dev:safari": "wxt -b safari --mv3", + "build:safari": "wxt build -b safari --mv3", + "zip:safari": "wxt zip -b safari --mv3", "submit": "wxt submit --chrome-zip .output/*-chrome.zip", "release": "pnpm version --tag-version-prefix=extension-v --message \"chore(extension): release v%s\" && git push --follow-tags", "typecheck": "wxt prepare && tsc --noEmit", diff --git a/apps/extension/safari/.gitignore b/apps/extension/safari/.gitignore new file mode 100644 index 000000000..a3705188c --- /dev/null +++ b/apps/extension/safari/.gitignore @@ -0,0 +1,10 @@ +# Xcode per-user state +xcuserdata/ +*.xcuserstate +.DS_Store + +# Web extension bundle copied in by the converter (--copy-resources). +# Regenerate before archiving: +# pnpm --filter @memry/extension build:safari +# xcrun safari-web-extension-converter --rebuild-project "MemryNote Web Clipper" --macos-only +MemryNote Web Clipper/MemryNote Web Clipper Extension/Resources/ diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper Extension/Info.plist b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper Extension/Info.plist new file mode 100644 index 000000000..9ee504dc5 --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper Extension/Info.plist @@ -0,0 +1,13 @@ + + + + + NSExtension + + NSExtensionPointIdentifier + com.apple.Safari.web-extension + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).SafariWebExtensionHandler + + + diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper Extension/SafariWebExtensionHandler.swift b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper Extension/SafariWebExtensionHandler.swift new file mode 100644 index 000000000..cc8fb8c8e --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper Extension/SafariWebExtensionHandler.swift @@ -0,0 +1,42 @@ +// +// SafariWebExtensionHandler.swift +// MemryNote Web Clipper Extension +// +// Created by Kaan Karaca on 1.07.2026. +// + +import SafariServices +import os.log + +class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { + + func beginRequest(with context: NSExtensionContext) { + let request = context.inputItems.first as? NSExtensionItem + + let profile: UUID? + if #available(iOS 17.0, macOS 14.0, *) { + profile = request?.userInfo?[SFExtensionProfileKey] as? UUID + } else { + profile = request?.userInfo?["profile"] as? UUID + } + + let message: Any? + if #available(iOS 15.0, macOS 11.0, *) { + message = request?.userInfo?[SFExtensionMessageKey] + } else { + message = request?.userInfo?["message"] + } + + os_log(.default, "Received message from browser.runtime.sendNativeMessage: %@ (profile: %@)", String(describing: message), profile?.uuidString ?? "none") + + let response = NSExtensionItem() + if #available(iOS 15.0, macOS 11.0, *) { + response.userInfo = [ SFExtensionMessageKey: [ "echo": message ] ] + } else { + response.userInfo = [ "message": [ "echo": message ] ] + } + + context.completeRequest(returningItems: [ response ], completionHandler: nil) + } + +} diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper.xcodeproj/project.pbxproj b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper.xcodeproj/project.pbxproj new file mode 100644 index 000000000..1b852eacb --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper.xcodeproj/project.pbxproj @@ -0,0 +1,649 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + B8E407402FF4859E00366F6F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8E4073F2FF4859E00366F6F /* AppDelegate.swift */; }; + B8E407442FF4859E00366F6F /* Main.html in Resources */ = {isa = PBXBuildFile; fileRef = B8E407422FF4859E00366F6F /* Main.html */; }; + B8E407462FF4859E00366F6F /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = B8E407452FF4859E00366F6F /* Icon.png */; }; + B8E407482FF4859E00366F6F /* Style.css in Resources */ = {isa = PBXBuildFile; fileRef = B8E407472FF4859E00366F6F /* Style.css */; }; + B8E4074A2FF4859E00366F6F /* Script.js in Resources */ = {isa = PBXBuildFile; fileRef = B8E407492FF4859E00366F6F /* Script.js */; }; + B8E4074C2FF4859E00366F6F /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8E4074B2FF4859E00366F6F /* ViewController.swift */; }; + B8E4074F2FF4859E00366F6F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B8E4074D2FF4859E00366F6F /* Main.storyboard */; }; + B8E407512FF4859F00366F6F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B8E407502FF4859F00366F6F /* Assets.xcassets */; }; + B8E407582FF4859F00366F6F /* MemryNote Web Clipper Extension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = B8E407572FF4859F00366F6F /* MemryNote Web Clipper Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + B8E4075D2FF4859F00366F6F /* SafariWebExtensionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8E4075C2FF4859F00366F6F /* SafariWebExtensionHandler.swift */; }; + B8E407722FF4859F00366F6F /* background.js in Resources */ = {isa = PBXBuildFile; fileRef = B8E407692FF4859F00366F6F /* background.js */; }; + B8E407732FF4859F00366F6F /* popup.html in Resources */ = {isa = PBXBuildFile; fileRef = B8E4076A2FF4859F00366F6F /* popup.html */; }; + B8E407742FF4859F00366F6F /* chunks in Resources */ = {isa = PBXBuildFile; fileRef = B8E4076B2FF4859F00366F6F /* chunks */; }; + B8E407752FF4859F00366F6F /* content-scripts in Resources */ = {isa = PBXBuildFile; fileRef = B8E4076C2FF4859F00366F6F /* content-scripts */; }; + B8E407762FF4859F00366F6F /* manifest.json in Resources */ = {isa = PBXBuildFile; fileRef = B8E4076D2FF4859F00366F6F /* manifest.json */; }; + B8E407772FF4859F00366F6F /* options.html in Resources */ = {isa = PBXBuildFile; fileRef = B8E4076E2FF4859F00366F6F /* options.html */; }; + B8E407782FF4859F00366F6F /* icon in Resources */ = {isa = PBXBuildFile; fileRef = B8E4076F2FF4859F00366F6F /* icon */; }; + B8E407792FF4859F00366F6F /* extension.png in Resources */ = {isa = PBXBuildFile; fileRef = B8E407702FF4859F00366F6F /* extension.png */; }; + B8E4077A2FF4859F00366F6F /* assets in Resources */ = {isa = PBXBuildFile; fileRef = B8E407712FF4859F00366F6F /* assets */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + B8E407592FF4859F00366F6F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B8E407342FF4859E00366F6F /* Project object */; + proxyType = 1; + remoteGlobalIDString = B8E407562FF4859F00366F6F; + remoteInfo = "MemryNote Web Clipper Extension"; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + B8E407642FF4859F00366F6F /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + B8E407582FF4859F00366F6F /* MemryNote Web Clipper Extension.appex in Embed Foundation Extensions */, + ); + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + B8E4073C2FF4859E00366F6F /* MemryNote Web Clipper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "MemryNote Web Clipper.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + B8E4073F2FF4859E00366F6F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + B8E407432FF4859E00366F6F /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = Base; path = Base.lproj/Main.html; sourceTree = ""; }; + B8E407452FF4859E00366F6F /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = ""; }; + B8E407472FF4859E00366F6F /* Style.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = Style.css; sourceTree = ""; }; + B8E407492FF4859E00366F6F /* Script.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = Script.js; sourceTree = ""; }; + B8E4074B2FF4859E00366F6F /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + B8E4074E2FF4859E00366F6F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + B8E407502FF4859F00366F6F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + B8E407522FF4859F00366F6F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B8E407572FF4859F00366F6F /* MemryNote Web Clipper Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "MemryNote Web Clipper Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; + B8E4075C2FF4859F00366F6F /* SafariWebExtensionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariWebExtensionHandler.swift; sourceTree = ""; }; + B8E4075E2FF4859F00366F6F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B8E407692FF4859F00366F6F /* background.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = background.js; path = Resources/background.js; sourceTree = ""; }; + B8E4076A2FF4859F00366F6F /* popup.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = popup.html; path = Resources/popup.html; sourceTree = ""; }; + B8E4076B2FF4859F00366F6F /* chunks */ = {isa = PBXFileReference; lastKnownFileType = folder; name = chunks; path = Resources/chunks; sourceTree = ""; }; + B8E4076C2FF4859F00366F6F /* content-scripts */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "content-scripts"; path = "Resources/content-scripts"; sourceTree = ""; }; + B8E4076D2FF4859F00366F6F /* manifest.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; name = manifest.json; path = Resources/manifest.json; sourceTree = ""; }; + B8E4076E2FF4859F00366F6F /* options.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = options.html; path = Resources/options.html; sourceTree = ""; }; + B8E4076F2FF4859F00366F6F /* icon */ = {isa = PBXFileReference; lastKnownFileType = folder; name = icon; path = Resources/icon; sourceTree = ""; }; + B8E407702FF4859F00366F6F /* extension.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = extension.png; path = Resources/extension.png; sourceTree = ""; }; + B8E407712FF4859F00366F6F /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = assets; path = Resources/assets; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + B8E407392FF4859E00366F6F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B8E407542FF4859F00366F6F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B8E407332FF4859E00366F6F = { + isa = PBXGroup; + children = ( + B8E4073E2FF4859E00366F6F /* MemryNote Web Clipper */, + B8E4075B2FF4859F00366F6F /* MemryNote Web Clipper Extension */, + B8E4073D2FF4859E00366F6F /* Products */, + ); + sourceTree = ""; + }; + B8E4073D2FF4859E00366F6F /* Products */ = { + isa = PBXGroup; + children = ( + B8E4073C2FF4859E00366F6F /* MemryNote Web Clipper.app */, + B8E407572FF4859F00366F6F /* MemryNote Web Clipper Extension.appex */, + ); + name = Products; + sourceTree = ""; + }; + B8E4073E2FF4859E00366F6F /* MemryNote Web Clipper */ = { + isa = PBXGroup; + children = ( + B8E4073F2FF4859E00366F6F /* AppDelegate.swift */, + B8E4074B2FF4859E00366F6F /* ViewController.swift */, + B8E4074D2FF4859E00366F6F /* Main.storyboard */, + B8E407502FF4859F00366F6F /* Assets.xcassets */, + B8E407522FF4859F00366F6F /* Info.plist */, + B8E407412FF4859E00366F6F /* Resources */, + ); + path = "MemryNote Web Clipper"; + sourceTree = ""; + }; + B8E407412FF4859E00366F6F /* Resources */ = { + isa = PBXGroup; + children = ( + B8E407422FF4859E00366F6F /* Main.html */, + B8E407452FF4859E00366F6F /* Icon.png */, + B8E407472FF4859E00366F6F /* Style.css */, + B8E407492FF4859E00366F6F /* Script.js */, + ); + path = Resources; + sourceTree = ""; + }; + B8E4075B2FF4859F00366F6F /* MemryNote Web Clipper Extension */ = { + isa = PBXGroup; + children = ( + B8E407682FF4859F00366F6F /* Resources */, + B8E4075C2FF4859F00366F6F /* SafariWebExtensionHandler.swift */, + B8E4075E2FF4859F00366F6F /* Info.plist */, + ); + path = "MemryNote Web Clipper Extension"; + sourceTree = ""; + }; + B8E407682FF4859F00366F6F /* Resources */ = { + isa = PBXGroup; + children = ( + B8E407692FF4859F00366F6F /* background.js */, + B8E4076A2FF4859F00366F6F /* popup.html */, + B8E4076B2FF4859F00366F6F /* chunks */, + B8E4076C2FF4859F00366F6F /* content-scripts */, + B8E4076D2FF4859F00366F6F /* manifest.json */, + B8E4076E2FF4859F00366F6F /* options.html */, + B8E4076F2FF4859F00366F6F /* icon */, + B8E407702FF4859F00366F6F /* extension.png */, + B8E407712FF4859F00366F6F /* assets */, + ); + name = Resources; + path = "MemryNote Web Clipper Extension"; + sourceTree = SOURCE_ROOT; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + B8E4073B2FF4859E00366F6F /* MemryNote Web Clipper */ = { + isa = PBXNativeTarget; + buildConfigurationList = B8E407652FF4859F00366F6F /* Build configuration list for PBXNativeTarget "MemryNote Web Clipper" */; + buildPhases = ( + B8E407382FF4859E00366F6F /* Sources */, + B8E407392FF4859E00366F6F /* Frameworks */, + B8E4073A2FF4859E00366F6F /* Resources */, + B8E407642FF4859F00366F6F /* Embed Foundation Extensions */, + ); + buildRules = ( + ); + dependencies = ( + B8E4075A2FF4859F00366F6F /* PBXTargetDependency */, + ); + name = "MemryNote Web Clipper"; + packageProductDependencies = ( + ); + productName = "MemryNote Web Clipper"; + productReference = B8E4073C2FF4859E00366F6F /* MemryNote Web Clipper.app */; + productType = "com.apple.product-type.application"; + }; + B8E407562FF4859F00366F6F /* MemryNote Web Clipper Extension */ = { + isa = PBXNativeTarget; + buildConfigurationList = B8E407612FF4859F00366F6F /* Build configuration list for PBXNativeTarget "MemryNote Web Clipper Extension" */; + buildPhases = ( + B8E407532FF4859F00366F6F /* Sources */, + B8E407542FF4859F00366F6F /* Frameworks */, + B8E407552FF4859F00366F6F /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "MemryNote Web Clipper Extension"; + packageProductDependencies = ( + ); + productName = "MemryNote Web Clipper Extension"; + productReference = B8E407572FF4859F00366F6F /* MemryNote Web Clipper Extension.appex */; + productType = "com.apple.product-type.app-extension"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B8E407342FF4859E00366F6F /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 2660; + LastUpgradeCheck = 2660; + TargetAttributes = { + B8E4073B2FF4859E00366F6F = { + CreatedOnToolsVersion = 26.6; + }; + B8E407562FF4859F00366F6F = { + CreatedOnToolsVersion = 26.6; + }; + }; + }; + buildConfigurationList = B8E407372FF4859E00366F6F /* Build configuration list for PBXProject "MemryNote Web Clipper" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = B8E407332FF4859E00366F6F; + minimizedProjectReferenceProxies = 1; + preferredProjectObjectVersion = 77; + productRefGroup = B8E4073D2FF4859E00366F6F /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B8E4073B2FF4859E00366F6F /* MemryNote Web Clipper */, + B8E407562FF4859F00366F6F /* MemryNote Web Clipper Extension */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + B8E4073A2FF4859E00366F6F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B8E407462FF4859E00366F6F /* Icon.png in Resources */, + B8E4074F2FF4859E00366F6F /* Main.storyboard in Resources */, + B8E4074A2FF4859E00366F6F /* Script.js in Resources */, + B8E407442FF4859E00366F6F /* Main.html in Resources */, + B8E407512FF4859F00366F6F /* Assets.xcassets in Resources */, + B8E407482FF4859E00366F6F /* Style.css in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B8E407552FF4859F00366F6F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B8E407742FF4859F00366F6F /* chunks in Resources */, + B8E407722FF4859F00366F6F /* background.js in Resources */, + B8E407782FF4859F00366F6F /* icon in Resources */, + B8E4077A2FF4859F00366F6F /* assets in Resources */, + B8E407762FF4859F00366F6F /* manifest.json in Resources */, + B8E407732FF4859F00366F6F /* popup.html in Resources */, + B8E407792FF4859F00366F6F /* extension.png in Resources */, + B8E407752FF4859F00366F6F /* content-scripts in Resources */, + B8E407772FF4859F00366F6F /* options.html in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + B8E407382FF4859E00366F6F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B8E4074C2FF4859E00366F6F /* ViewController.swift in Sources */, + B8E407402FF4859E00366F6F /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B8E407532FF4859F00366F6F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B8E4075D2FF4859F00366F6F /* SafariWebExtensionHandler.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + B8E4075A2FF4859F00366F6F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = B8E407562FF4859F00366F6F /* MemryNote Web Clipper Extension */; + targetProxy = B8E407592FF4859F00366F6F /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + B8E407422FF4859E00366F6F /* Main.html */ = { + isa = PBXVariantGroup; + children = ( + B8E407432FF4859E00366F6F /* Base */, + ); + name = Main.html; + sourceTree = ""; + }; + B8E4074D2FF4859E00366F6F /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + B8E4074E2FF4859E00366F6F /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + B8E4075F2FF4859F00366F6F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 26.5; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + B8E407602FF4859F00366F6F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 26.5; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + }; + name = Release; + }; + B8E407622FF4859F00366F6F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + ENABLE_APP_SANDBOX = YES; + ENABLE_HARDENED_RUNTIME = YES; + ENABLE_USER_SELECTED_FILES = readonly; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "MemryNote Web Clipper Extension/Info.plist"; + INFOPLIST_KEY_CFBundleDisplayName = "MemryNote Web Clipper Extension"; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@executable_path/../../../../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + MARKETING_VERSION = 1.0; + OTHER_LDFLAGS = ( + "-framework", + SafariServices, + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.memrynote.web-clipper.Extension"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + B8E407632FF4859F00366F6F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + ENABLE_APP_SANDBOX = YES; + ENABLE_HARDENED_RUNTIME = YES; + ENABLE_USER_SELECTED_FILES = readonly; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "MemryNote Web Clipper Extension/Info.plist"; + INFOPLIST_KEY_CFBundleDisplayName = "MemryNote Web Clipper Extension"; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@executable_path/../../../../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + MARKETING_VERSION = 1.0; + OTHER_LDFLAGS = ( + "-framework", + SafariServices, + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.memrynote.web-clipper.Extension"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + B8E407662FF4859F00366F6F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = TV343Q4W8A; + ENABLE_APP_SANDBOX = YES; + ENABLE_HARDENED_RUNTIME = YES; + ENABLE_INCOMING_NETWORK_CONNECTIONS = NO; + ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES; + ENABLE_RESOURCE_ACCESS_AUDIO_INPUT = NO; + ENABLE_RESOURCE_ACCESS_BLUETOOTH = NO; + ENABLE_RESOURCE_ACCESS_CALENDARS = NO; + ENABLE_RESOURCE_ACCESS_CAMERA = NO; + ENABLE_RESOURCE_ACCESS_CONTACTS = NO; + ENABLE_RESOURCE_ACCESS_LOCATION = NO; + ENABLE_RESOURCE_ACCESS_PRINTING = NO; + ENABLE_RESOURCE_ACCESS_USB = NO; + ENABLE_USER_SELECTED_FILES = readonly; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "MemryNote Web Clipper/Info.plist"; + INFOPLIST_KEY_CFBundleDisplayName = "MemryNote Web Clipper"; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_KEY_NSMainStoryboardFile = Main; + INFOPLIST_KEY_NSPrincipalClass = NSApplication; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MARKETING_VERSION = 1.0; + OTHER_LDFLAGS = ( + "-framework", + SafariServices, + "-framework", + WebKit, + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.memrynote.web-clipper"; + PRODUCT_NAME = "$(TARGET_NAME)"; + REGISTER_APP_GROUPS = YES; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + B8E407672FF4859F00366F6F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = TV343Q4W8A; + ENABLE_APP_SANDBOX = YES; + ENABLE_HARDENED_RUNTIME = YES; + ENABLE_INCOMING_NETWORK_CONNECTIONS = NO; + ENABLE_OUTGOING_NETWORK_CONNECTIONS = YES; + ENABLE_RESOURCE_ACCESS_AUDIO_INPUT = NO; + ENABLE_RESOURCE_ACCESS_BLUETOOTH = NO; + ENABLE_RESOURCE_ACCESS_CALENDARS = NO; + ENABLE_RESOURCE_ACCESS_CAMERA = NO; + ENABLE_RESOURCE_ACCESS_CONTACTS = NO; + ENABLE_RESOURCE_ACCESS_LOCATION = NO; + ENABLE_RESOURCE_ACCESS_PRINTING = NO; + ENABLE_RESOURCE_ACCESS_USB = NO; + ENABLE_USER_SELECTED_FILES = readonly; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "MemryNote Web Clipper/Info.plist"; + INFOPLIST_KEY_CFBundleDisplayName = "MemryNote Web Clipper"; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_KEY_NSMainStoryboardFile = Main; + INFOPLIST_KEY_NSPrincipalClass = NSApplication; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MARKETING_VERSION = 1.0; + OTHER_LDFLAGS = ( + "-framework", + SafariServices, + "-framework", + WebKit, + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.memrynote.web-clipper"; + PRODUCT_NAME = "$(TARGET_NAME)"; + REGISTER_APP_GROUPS = YES; + STRING_CATALOG_GENERATE_SYMBOLS = YES; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B8E407372FF4859E00366F6F /* Build configuration list for PBXProject "MemryNote Web Clipper" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B8E4075F2FF4859F00366F6F /* Debug */, + B8E407602FF4859F00366F6F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B8E407612FF4859F00366F6F /* Build configuration list for PBXNativeTarget "MemryNote Web Clipper Extension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B8E407622FF4859F00366F6F /* Debug */, + B8E407632FF4859F00366F6F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B8E407652FF4859F00366F6F /* Build configuration list for PBXNativeTarget "MemryNote Web Clipper" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B8E407662FF4859F00366F6F /* Debug */, + B8E407672FF4859F00366F6F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B8E407342FF4859E00366F6F /* Project object */; +} diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/AppDelegate.swift b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/AppDelegate.swift new file mode 100644 index 000000000..4ec43e382 --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/AppDelegate.swift @@ -0,0 +1,21 @@ +// +// AppDelegate.swift +// MemryNote Web Clipper +// +// Created by Kaan Karaca on 1.07.2026. +// + +import Cocoa + +@main +class AppDelegate: NSObject, NSApplicationDelegate { + + func applicationDidFinishLaunching(_ notification: Notification) { + // Override point for customization after application launch. + } + + func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } + +} diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AccentColor.colorset/Contents.json b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..0afb3cf0e --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors": [ + { + "idiom": "universal" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/Contents.json b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..50cb3489e --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images": [ + { + "size": "16x16", + "idiom": "mac", + "filename": "mac-icon-16@1x.png", + "scale": "1x" + }, + { + "size": "16x16", + "idiom": "mac", + "filename": "mac-icon-16@2x.png", + "scale": "2x" + }, + { + "size": "32x32", + "idiom": "mac", + "filename": "mac-icon-32@1x.png", + "scale": "1x" + }, + { + "size": "32x32", + "idiom": "mac", + "filename": "mac-icon-32@2x.png", + "scale": "2x" + }, + { + "size": "128x128", + "idiom": "mac", + "filename": "mac-icon-128@1x.png", + "scale": "1x" + }, + { + "size": "128x128", + "idiom": "mac", + "filename": "mac-icon-128@2x.png", + "scale": "2x" + }, + { + "size": "256x256", + "idiom": "mac", + "filename": "mac-icon-256@1x.png", + "scale": "1x" + }, + { + "size": "256x256", + "idiom": "mac", + "filename": "mac-icon-256@2x.png", + "scale": "2x" + }, + { + "size": "512x512", + "idiom": "mac", + "filename": "mac-icon-512@1x.png", + "scale": "1x" + }, + { + "size": "512x512", + "idiom": "mac", + "filename": "mac-icon-512@2x.png", + "scale": "2x" + } + ], + "info": { + "version": 1, + "author": "xcode" + } +} diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-128@1x.png b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-128@1x.png new file mode 100644 index 000000000..eb7276544 Binary files /dev/null and b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-128@1x.png differ diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-128@2x.png b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-128@2x.png new file mode 100644 index 000000000..bd6133ece Binary files /dev/null and b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-128@2x.png differ diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-16@1x.png b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-16@1x.png new file mode 100644 index 000000000..73e412b08 Binary files /dev/null and b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-16@1x.png differ diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-16@2x.png b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-16@2x.png new file mode 100644 index 000000000..5bd2bbd13 Binary files /dev/null and b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-16@2x.png differ diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-256@1x.png b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-256@1x.png new file mode 100644 index 000000000..bd6133ece Binary files /dev/null and b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-256@1x.png differ diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-256@2x.png b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-256@2x.png new file mode 100644 index 000000000..24febc8a4 Binary files /dev/null and b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-256@2x.png differ diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-32@1x.png b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-32@1x.png new file mode 100644 index 000000000..5bd2bbd13 Binary files /dev/null and b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-32@1x.png differ diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-32@2x.png b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-32@2x.png new file mode 100644 index 000000000..2def5282e Binary files /dev/null and b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-32@2x.png differ diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-512@1x.png b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-512@1x.png new file mode 100644 index 000000000..24febc8a4 Binary files /dev/null and b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-512@1x.png differ diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-512@2x.png b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-512@2x.png new file mode 100644 index 000000000..8caa06491 Binary files /dev/null and b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/AppIcon.appiconset/mac-icon-512@2x.png differ diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/Contents.json b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/Contents.json new file mode 100644 index 000000000..74d6a722c --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/LargeIcon.imageset/Contents.json b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/LargeIcon.imageset/Contents.json new file mode 100644 index 000000000..ae524e754 --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Assets.xcassets/LargeIcon.imageset/Contents.json @@ -0,0 +1,20 @@ +{ + "images": [ + { + "idiom": "universal", + "scale": "1x" + }, + { + "idiom": "universal", + "scale": "2x" + }, + { + "idiom": "universal", + "scale": "3x" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Base.lproj/Main.storyboard b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Base.lproj/Main.storyboard new file mode 100644 index 000000000..56a8174f8 --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Base.lproj/Main.storyboard @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Info.plist b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Info.plist new file mode 100644 index 000000000..8b8903f1d --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Info.plist @@ -0,0 +1,8 @@ + + + + + SFSafariWebExtensionConverterVersion + 26.6 + + diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Resources/Base.lproj/Main.html b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Resources/Base.lproj/Main.html new file mode 100644 index 000000000..17f0befb3 --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Resources/Base.lproj/Main.html @@ -0,0 +1,27 @@ + + + + + + + + + + + + + MemryNote Web Clipper Icon +

+ You can turn on MemryNote Web Clipper’s extension in Safari Extensions preferences. +

+

+ MemryNote Web Clipper’s extension is currently on. You can turn it off in Safari Extensions + preferences. +

+

+ MemryNote Web Clipper’s extension is currently off. You can turn it on in Safari Extensions + preferences. +

+ + + diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Resources/Icon.png b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Resources/Icon.png new file mode 100644 index 000000000..ef58e7326 Binary files /dev/null and b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Resources/Icon.png differ diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Resources/Script.js b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Resources/Script.js new file mode 100644 index 000000000..3a11ff362 --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Resources/Script.js @@ -0,0 +1,26 @@ +function show(enabled, useSettingsInsteadOfPreferences) { + if (useSettingsInsteadOfPreferences) { + document.getElementsByClassName('state-on')[0].innerText = + 'MemryNote Web Clipper’s extension is currently on. You can turn it off in the Extensions section of Safari Settings.' + document.getElementsByClassName('state-off')[0].innerText = + 'MemryNote Web Clipper’s extension is currently off. You can turn it on in the Extensions section of Safari Settings.' + document.getElementsByClassName('state-unknown')[0].innerText = + 'You can turn on MemryNote Web Clipper’s extension in the Extensions section of Safari Settings.' + document.getElementsByClassName('open-preferences')[0].innerText = + 'Quit and Open Safari Settings…' + } + + if (typeof enabled === 'boolean') { + document.body.classList.toggle(`state-on`, enabled) + document.body.classList.toggle(`state-off`, !enabled) + } else { + document.body.classList.remove(`state-on`) + document.body.classList.remove(`state-off`) + } +} + +function openPreferences() { + webkit.messageHandlers.controller.postMessage('open-preferences') +} + +document.querySelector('button.open-preferences').addEventListener('click', openPreferences) diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Resources/Style.css b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Resources/Style.css new file mode 100644 index 000000000..ef4dcde33 --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/Resources/Style.css @@ -0,0 +1,45 @@ +* { + -webkit-user-select: none; + -webkit-user-drag: none; + cursor: default; +} + +:root { + color-scheme: light dark; + + --spacing: 20px; +} + +html { + height: 100%; +} + +body { + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; + + gap: var(--spacing); + margin: 0 calc(var(--spacing) * 2); + height: 100%; + + font: -apple-system-short-body; + text-align: center; +} + +body:not(.state-on, .state-off) :is(.state-on, .state-off) { + display: none; +} + +body.state-on :is(.state-off, .state-unknown) { + display: none; +} + +body.state-off :is(.state-on, .state-unknown) { + display: none; +} + +button { + font-size: 1em; +} diff --git a/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/ViewController.swift b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/ViewController.swift new file mode 100644 index 000000000..848df2e81 --- /dev/null +++ b/apps/extension/safari/MemryNote Web Clipper/MemryNote Web Clipper/ViewController.swift @@ -0,0 +1,57 @@ +// +// ViewController.swift +// MemryNote Web Clipper +// +// Created by Kaan Karaca on 1.07.2026. +// + +import Cocoa +import SafariServices +import WebKit + +let extensionBundleIdentifier = "com.memrynote.web-clipper.Extension" + +class ViewController: NSViewController, WKNavigationDelegate, WKScriptMessageHandler { + + @IBOutlet var webView: WKWebView! + + override func viewDidLoad() { + super.viewDidLoad() + + self.webView.navigationDelegate = self + + self.webView.configuration.userContentController.add(self, name: "controller") + + self.webView.loadFileURL(Bundle.main.url(forResource: "Main", withExtension: "html")!, allowingReadAccessTo: Bundle.main.resourceURL!) + } + + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { + SFSafariExtensionManager.getStateOfSafariExtension(withIdentifier: extensionBundleIdentifier) { (state, error) in + guard let state = state, error == nil else { + // Insert code to inform the user that something went wrong. + return + } + + DispatchQueue.main.async { + if #available(macOS 13, *) { + webView.evaluateJavaScript("show(\(state.isEnabled), true)") + } else { + webView.evaluateJavaScript("show(\(state.isEnabled), false)") + } + } + } + } + + func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { + if (message.body as! String != "open-preferences") { + return; + } + + SFSafariApplication.showPreferencesForExtension(withIdentifier: extensionBundleIdentifier) { error in + DispatchQueue.main.async { + NSApplication.shared.terminate(nil) + } + } + } + +} diff --git a/docs/superpowers/plans/2026-07-01-safari-web-clipper.md b/docs/superpowers/plans/2026-07-01-safari-web-clipper.md new file mode 100644 index 000000000..fc29e4910 --- /dev/null +++ b/docs/superpowers/plans/2026-07-01-safari-web-clipper.md @@ -0,0 +1,318 @@ +# Safari Web Clipper Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Ship the existing MemryNote Web Clipper as a Safari Web Extension on macOS, distributed through the Mac App Store inside a native container app. + +**Architecture:** Reuse the current WXT MV3 extension bundle unchanged. The only product code change is adding the `safari-web-extension://` origin scheme to the desktop capture server's allowlist. Safari packaging is a committed Xcode container-app project generated once with `safari-web-extension-packager`; distribution is manual Apple-portal work documented as a runbook. + +**Tech Stack:** WXT (web extension build), Vitest (unit tests), Xcode `safari-web-extension-packager` (native wrap), App Store Connect (distribution). + +## Global Constraints + +- Container app bundle id: `com.memrynote.web-clipper`; extension target: `com.memrynote.web-clipper.extension`. Same Apple Developer team as the desktop app (`com.memrynote.memry`). +- Build Safari as **MV3** (`--mv3`) to match the Chrome/Firefox source. Requires Safari 16.4+. +- Extension origin is `safari-web-extension://`, stable per install. +- App Store distribution requires App Sandbox; the loopback `fetch` needs `com.apple.security.network.client`. +- Code style: single quotes, no semicolons, 100-char width, no trailing commas. +- macOS-only. No iOS. No custom container app UI beyond the generated enable screen + icon. + +--- + +### Task 1: Add the Safari origin scheme to the capture server allowlist + +**Files:** +- Modify: `apps/desktop/src/main/capture/auth.ts:13` +- Test: `apps/desktop/src/main/capture/auth.test.ts` + +**Interfaces:** +- Consumes: nothing (first task). +- Produces: `isExtensionOrigin(origin: string | undefined): boolean` now returns `true` for `safari-web-extension://*`. No signature change. `EXTENSION_ORIGIN_PREFIXES` gains a third entry. + +- [ ] **Step 1: Write the failing test** + +Add this block to the end of `apps/desktop/src/main/capture/auth.test.ts`, and add `isExtensionOrigin` to the existing import on line 2 (`import { validateCaptureRequest, isExtensionOrigin } from './auth'`): + +```ts +describe('isExtensionOrigin', () => { + it('accepts a Safari web-extension origin', () => { + expect(isExtensionOrigin('safari-web-extension://A1B2C3D4-0000-0000-0000-000000000000')).toBe( + true + ) + }) + it('accepts chrome and firefox extension origins', () => { + expect(isExtensionOrigin('chrome-extension://abc')).toBe(true) + expect(isExtensionOrigin('moz-extension://abc')).toBe(true) + }) + it('rejects a web origin and undefined', () => { + expect(isExtensionOrigin('https://evil.com')).toBe(false) + expect(isExtensionOrigin(undefined)).toBe(false) + }) +}) +``` + +- [ ] **Step 2: Run test to verify it fails** + +Run: `pnpm --filter @memry/desktop test:main auth.test.ts` +Expected: FAIL on "accepts a Safari web-extension origin" — `expected false to be true` (the other cases pass). + +- [ ] **Step 3: Add the Safari scheme** + +In `apps/desktop/src/main/capture/auth.ts`, replace the `EXTENSION_ORIGIN_PREFIXES` definition (line 13) and its comment so it reads: + +```ts +// Capture pairing accepts browser-extension origins only — Chromium (chrome-extension://), +// Firefox (moz-extension://), and Safari (safari-web-extension://). Single source of truth +// so the two pairing guards can't drift. +const EXTENSION_ORIGIN_PREFIXES = [ + 'chrome-extension://', + 'moz-extension://', + 'safari-web-extension://' +] +``` + +- [ ] **Step 4: Run test to verify it passes** + +Run: `pnpm --filter @memry/desktop test:main auth.test.ts` +Expected: PASS — all `validateCaptureRequest` and `isExtensionOrigin` cases green. + +- [ ] **Step 5: Commit** + +```bash +git add apps/desktop/src/main/capture/auth.ts apps/desktop/src/main/capture/auth.test.ts +git commit -m "feat(capture): allow safari-web-extension origins" +``` + +--- + +### Task 2: Add WXT Safari build scripts + +**Files:** +- Modify: `apps/extension/package.json:8-15` (scripts block) +- Modify: `apps/extension/README.md` (add a Safari build section) + +**Interfaces:** +- Consumes: nothing from earlier tasks. +- Produces: `pnpm --filter @memry/extension build:safari` emits an MV3 bundle at `apps/extension/.output/safari-mv3/`. Later tasks (native wrap) consume that directory. + +- [ ] **Step 1: Add the Safari scripts** + +In `apps/extension/package.json`, add these three lines to the `scripts` block, immediately after the matching `:firefox` scripts (`dev:firefox`, `build:firefox`, `zip:firefox`): + +```jsonc +"dev:safari": "wxt -b safari --mv3", +"build:safari": "wxt build -b safari --mv3", +"zip:safari": "wxt zip -b safari --mv3", +``` + +- [ ] **Step 2: Run the build** + +Run: `pnpm --filter @memry/extension build:safari` +Expected: build succeeds; `apps/extension/.output/safari-mv3/manifest.json` exists. Watch the build output for any WXT warning about an unsupported manifest key on the Safari target (`storage`, `activeTab`, `alarms`, `host_permissions`, `commands`). Note any warning for the open-items follow-up; do not change the manifest unless WXT errors. + +- [ ] **Step 3: Verify the manifest is MV3** + +Run: `node -e "console.log(require('./apps/extension/.output/safari-mv3/manifest.json').manifest_version)"` +Expected: prints `3`. + +- [ ] **Step 4: Document the Safari build** + +Add a "## Build for Safari (macOS)" section to `apps/extension/README.md` after the Edge section: + +```markdown +## Build for Safari (macOS) + +Safari ships the extension inside a native macOS app. WXT builds the bundle; Xcode wraps it. + +1. `pnpm --filter @memry/extension build:safari` → `.output/safari-mv3` (MV3, matching the + Chrome/Firefox source). +2. Wrap it into the macOS container app (see the Xcode project at `apps/extension/safari/`). + +`build:safari` only produces the web bundle — the native app, signing, and App Store +submission are covered by the Safari release runbook below. +``` + +- [ ] **Step 5: Commit** + +```bash +git add apps/extension/package.json apps/extension/README.md +git commit -m "build(extension): add Safari MV3 build scripts" +``` + +--- + +### Task 3: Generate, brand, and entitle the macOS container app (manual — macOS + Xcode) + +> Human-run on macOS with Xcode installed. Not an agent TDD task. The deliverable is the committed Xcode project; a reviewer accepts or rejects it as a whole. + +**Files:** +- Create: `apps/extension/safari/**` (generated Xcode project — committed) +- Modify: the extension target's `.entitlements` inside that project + +**Interfaces:** +- Consumes: `apps/extension/.output/safari-mv3/` from Task 2. +- Produces: an Xcode project that builds a macOS app `MemryNote Web Clipper` (`com.memrynote.web-clipper`) containing the extension target (`com.memrynote.web-clipper.extension`) with the network-client entitlement. + +- [ ] **Step 1: Generate the wrapper** + +```bash +pnpm --filter @memry/extension build:safari +cd apps/extension +xcrun safari-web-extension-packager .output/safari-mv3 \ + --macos-only \ + --app-name "MemryNote Web Clipper" \ + --bundle-identifier com.memrynote.web-clipper \ + --copy-resources \ + --no-open \ + --force +``` +Expected: a new `MemryNote Web Clipper/` Xcode project is created. Move/rename it to `apps/extension/safari/` so the path matches this plan. + +- [ ] **Step 2: Set bundle ids and team** + +Open `apps/extension/safari/*.xcodeproj` in Xcode. Set: +- App target bundle id → `com.memrynote.web-clipper` +- Extension target bundle id → `com.memrynote.web-clipper.extension` +- Both targets' Team → the MemryNote Apple Developer team (same as `com.memrynote.memry`). + +- [ ] **Step 3: Add the network-client entitlement** + +In the **extension** target's `.entitlements` file, add (keep the sandbox key the template already added): + +```xml +com.apple.security.app-sandbox + +com.apple.security.network.client + +``` +Verify in Xcode → extension target → Signing & Capabilities that **App Sandbox** is present and **Outgoing Connections (Client)** is checked. + +- [ ] **Step 4: Brand the enable screen + icon** + +Replace the generated app icon set with the MemryNote icon. Edit the generated container app's HTML/strings so the enable-instructions text reads for MemryNote (the "Turn on MemryNote Web Clipper in Safari Settings" screen). No other container UI. + +- [ ] **Step 5: Confirm it builds** + +In Xcode, select the app scheme → Product → Build. +Expected: build succeeds for both targets, signed with the development certificate. + +- [ ] **Step 6: Commit** + +```bash +git add apps/extension/safari +git commit -m "build(extension): add Safari macOS container app project" +``` + +--- + +### Task 4: Acceptance gate — verify loopback capture works in Safari (manual QA, go/no-go) + +> Human-run on macOS. This is the known risk and gates all distribution work. Do it before Task 5. + +**Files:** none (verification only). + +**Interfaces:** +- Consumes: the dev-signed build from Task 3 and the running desktop app. + +- [ ] **Step 1: Run the desktop app** + +Run: `pnpm dev` (and once on macOS dev: `pnpm --filter @memry/desktop dev:protocol` so `memry://` is registered). + +- [ ] **Step 2: Install + enable the Safari extension** + +In Xcode, Run the container app. Then Safari → Settings → Extensions → enable **MemryNote Web Clipper** → grant access to `127.0.0.1` / websites when prompted. + +- [ ] **Step 3: Pair and capture** + +Open the popup on a real article → click **Add to Memry** → click **Allow** in the desktop pairing dialog the first time → confirm the capture lands in the inbox. + +- [ ] **Step 4: Verify the Origin header + loopback (the risk)** + +In Safari → Develop → Web Extension Background Content → Network (or the desktop logs for `/capture`), confirm: +- the background `fetch` to `127.0.0.1` is sent (not blocked by sandbox/ATS), and +- it carries `Origin: safari-web-extension://`. + +Expected: `/capture` returns 200 and the item appears in the inbox. + +**Go/no-go:** if Safari strips the `Origin` header or blocks the loopback request, STOP — this is a design pivot (different auth signal or transport). Record the finding and do not proceed to Task 5. + +- [ ] **Step 5: Re-run the full manual QA gate** + +Run the 6-step acceptance gate from `apps/extension/README.md` in Safari: app-closed, pairing, capture, failed extraction, launch-when-closed, origin-header check. All must pass. + +--- + +### Task 5: App Store distribution + install docs (manual Apple portal + doc) + +> Steps 1–4 are human-run Apple-portal work. Step 5 (docs) is agent-runnable. + +**Files:** +- Modify: `apps/extension/README.md` (install flow + release runbook) + +**Interfaces:** +- Consumes: the verified build from Task 4. + +- [ ] **Step 1: Signing assets** + +Create an App Store Distribution certificate and provisioning profiles for both the app and the extension targets in the Apple Developer portal. Select them in Xcode → Signing & Capabilities (Release). + +- [ ] **Step 2: Archive + upload** + +Xcode → Product → Archive → Organizer → Distribute App → App Store Connect (or `xcrun notarytool` + Transporter). Expected: the build appears in App Store Connect. + +- [ ] **Step 3: App Store Connect listing** + +Create the app record: name, description, screenshots, and a **privacy nutrition label of "Data Not Collected"** (captures stay local). + +- [ ] **Step 4: Submit for review.** + +- [ ] **Step 5: Document install flow + runbook** + +Add to `apps/extension/README.md` a "## Install (Safari, Mac App Store)" section: + +```markdown +## Install (Safari, Mac App Store) + +1. Install **MemryNote Web Clipper** from the Mac App Store. +2. Open the app once → "Enable me in Safari" screen. +3. Safari → Settings → Extensions → toggle MemryNote on → grant access to `127.0.0.1` / + websites. +4. First capture triggers the same in-app **Allow** pairing dialog as Chrome/Firefox. + +## Safari release runbook + +1. `pnpm --filter @memry/extension build:safari`, then re-run the packager (or copy + `.output/safari-mv3` over `apps/extension/safari` resources). +2. Bump the version in the Xcode project. +3. Archive → upload to App Store Connect → submit for review. +``` + +Then verify the keyboard command caveat: if `Cmd+Shift+S` does not fire in Safari (it may be reserved), add a one-line note pointing users to Safari's shortcut settings, mirroring the Firefox caveat. The popup button works regardless. + +- [ ] **Step 6: Commit** + +```bash +git add apps/extension/README.md +git commit -m "docs(extension): add Safari install flow and release runbook" +``` + +--- + +## Self-Review + +**Spec coverage:** +- §1 allowlist change → Task 1 ✓ +- §2 build scripts → Task 2 ✓ +- §3 native wrap → Task 3 ✓ +- §4 entitlements → Task 3 Step 3 ✓ +- §5 distribution → Task 5 ✓ +- §6 install flow → Task 5 Step 5 ✓ +- Acceptance gate → Task 4 ✓ +- Open items (Cmd+Shift+S caveat, WXT manifest warnings) → Task 5 Step 5 + Task 2 Step 2 ✓ +- Unit + manual testing → Task 1 + Task 4 ✓ + +**Placeholder scan:** no TBD/TODO; all code and commands are concrete. + +**Type consistency:** `isExtensionOrigin` / `EXTENSION_ORIGIN_PREFIXES` names match Task 1 and the existing source. Bundle ids consistent across Global Constraints, Task 3, and Task 5. + +**Note on task type:** Tasks 1–2 and Task 5 Step 5 are agent-runnable. Tasks 3, 4, and Task 5 Steps 1–4 are human-run macOS/Xcode/Apple-portal steps with observation-based verification — they cannot run in an agent TDD loop. diff --git a/docs/superpowers/specs/2026-07-01-safari-web-clipper-design.md b/docs/superpowers/specs/2026-07-01-safari-web-clipper-design.md new file mode 100644 index 000000000..ef9ba9fa3 --- /dev/null +++ b/docs/superpowers/specs/2026-07-01-safari-web-clipper-design.md @@ -0,0 +1,195 @@ +# Safari Web Clipper (macOS, Mac App Store) + +Date: 2026-07-01 +Status: Design approved, pending spec review + +## Summary + +Ship the existing MemryNote Web Clipper as a **Safari Web Extension on macOS**, +distributed through the **Mac App Store** inside a native container app. Reuse the +current WXT MV3 bundle unchanged. The only product code change is adding the Safari +extension-origin scheme to the desktop capture server's allowlist. Everything else is +build/packaging (Xcode) and distribution (signing, notarization, App Store Connect). + +Out of scope: iOS/iPadOS (no local desktop app to reach over loopback — would require a +separate sync-server upload path), and a custom container app UI. + +## Background + +The clipper (`apps/extension`, WXT) reads the current page into a readable article and +`POST`s it to the desktop app's localhost capture server (`http://127.0.0.1`, ports +7849–7856). Requests are authorized by: + +- a bearer token minted in the desktop keychain and stored in the extension's + `storage.local` after pairing, and +- an `Origin` header allowlist. `EXTENSION_ORIGIN_PREFIXES` in + `apps/desktop/src/main/capture/auth.ts` currently accepts `chrome-extension://` and + `moz-extension://`. The exact paired origin is stored (`captureAllowedOrigins`) and + matched on every `/capture`. + +Chrome, Edge, and Firefox all run from the one WXT source. Safari is the same +WebExtension API surface, but Apple requires it to be delivered as a macOS app. + +## Why Safari is different + +- There is **no standalone Safari extension store**. A Safari extension ships inside a + macOS `.app` (the "container app"). Users install the app from the Mac App Store, open + it once, then enable the extension in Safari → Settings → Extensions. +- WXT can **build** a Safari target (`wxt build -b safari`) but cannot **publish** it. + Packaging into the native app is done with Apple's Xcode CLI + (`xcrun safari-web-extension-packager`). +- The extension's origin is `safari-web-extension://`, where the UUID is assigned + at install and is **stable for the life of that install** — so the existing + token + stored-origin pairing model works without change. + +## Approach + +Reuse the WXT bundle; commit one generated Xcode wrapper. + +- Add `dev:safari` / `build:safari` / `zip:safari` scripts mirroring the existing + Firefox scripts. Build MV3 (`--mv3`) so `browser.action`, `host_permissions`, and the + service worker match the Chrome/Firefox source. Safari 16.4+ supports MV3. +- Run `safari-web-extension-packager` **once** to generate the macOS container app + + extension target into `apps/extension/safari/`, then commit it. Icons, entitlements, + and signing config live there and are maintained by hand from then on. +- Add `safari-web-extension://` to the server allowlist. + +Rejected alternatives: + +- **Separate `apps/safari` package + CI notarize lane** — more infrastructure than a + per-release native build needs. +- **Regenerate the Xcode project on every build** — would discard icons, entitlements, + and signing config each regen; hostile to a signed App Store target. + +## Changes + +### 1. Capture server origin allowlist (the only product code change) + +`apps/desktop/src/main/capture/auth.ts`: + +```ts +const EXTENSION_ORIGIN_PREFIXES = [ + 'chrome-extension://', + 'moz-extension://', + 'safari-web-extension://' +] +``` + +No other change in `auth.ts`, `pairing.ts`, or `server.ts`. `isExtensionOrigin` gates +`/pair/request` and `/pair/claim`; `isOriginAllowed` stores and matches the exact +`safari-web-extension://` after the user clicks Allow. The "single source of truth" +comment on `EXTENSION_ORIGIN_PREFIXES` continues to hold. + +Test: extend `apps/desktop/src/main/capture/auth.test.ts` to assert a +`safari-web-extension://` origin passes `isExtensionOrigin` and that pairing + +`validateCaptureRequest` accept it end to end. + +### 2. Build scripts + +`apps/extension/package.json` — add, mirroring the `:firefox` scripts: + +```jsonc +"dev:safari": "wxt -b safari --mv3", +"build:safari": "wxt build -b safari --mv3", +"zip:safari": "wxt zip -b safari --mv3" +``` + +Output: `.output/safari-mv3`. No `wxt.config.ts` change expected — the existing manifest +(`storage`, `activeTab`, `alarms`, `host_permissions: http://127.0.0.1/*`, the +`capture-page` command) is valid for Safari. Confirm during build that WXT does not warn +on any of these for the Safari target; adjust per-browser via WXT's manifest hook only if +it does. + +### 3. Native wrap (run once, then committed) + +```sh +pnpm --filter @memry/extension build:safari +xcrun safari-web-extension-packager .output/safari-mv3 \ + --macos-only \ + --app-name "MemryNote Web Clipper" \ + --bundle-identifier com.memrynote.web-clipper \ + --copy-resources +``` + +- Container app bundle id: `com.memrynote.web-clipper`; extension target: + `com.memrynote.web-clipper.extension`. Same Apple Developer team as the desktop app + (`com.memrynote.memry`). +- `--copy-resources` copies the built bundle into the Xcode project so it is + self-contained at archive time. +- Lightly brand the generated "enable me in Safari Settings" screen and add an app icon. + No further container UI. +- Output project committed at `apps/extension/safari/`. + +Re-release flow: `build:safari` → re-run the packager (or copy `.output/safari-mv3` over +the project's resources) → bump version → archive. + +### 4. App Store entitlements (required, non-obvious) + +App Store distribution requires the App Sandbox. The extension's background `fetch` to +`127.0.0.1` is an outbound connection and is **blocked under the sandbox without the +network-client entitlement**. The extension target's entitlements must include: + +```xml +com.apple.security.app-sandbox +com.apple.security.network.client +``` + +No App Group is needed — the extension talks only to localhost, not to the container app. + +### 5. Distribution (Mac App Store) + +Mostly manual Apple-portal work, documented as a release runbook in +`apps/extension/README.md`: + +1. App Store Distribution certificate + provisioning profiles for both the app and the + extension target. +2. Xcode archive → upload via Organizer (or `xcrun notarytool` + Transporter). +3. App Store Connect record: description, screenshots, and a **privacy nutrition label of + "Data Not Collected"** — captures stay local, which matches the MemryNote privacy + story. +4. Submit for review. + +### 6. User install flow (documented in README) + +1. Install **MemryNote Web Clipper** from the Mac App Store. +2. Open the app once → "Enable me in Safari" screen. +3. Safari → Settings → Extensions → toggle MemryNote on → grant access to `127.0.0.1` / + websites. +4. First capture triggers the same in-app **Allow** pairing dialog as Chrome/Firefox; + captures then land in the inbox. + +## Acceptance gate (the known risk — validate first) + +Mirrors the Chrome `Origin`-header risk already noted in `apps/extension/README.md`. +Before any App Store work, validate on real Safari with a **locally dev-signed** build +that the background `fetch` to the capture server: + +1. attaches `Origin: safari-web-extension://`, and +2. is permitted to reach loopback HTTP under the App Sandbox / App Transport Security. + +If Safari strips the `Origin` header or blocks the loopback request, this is a design +pivot (e.g. a different auth signal or a transport change) — so it gates everything +downstream. + +## Open items to resolve in the plan + +- Whether the `Cmd+Shift+S` (`capture-page`) command needs the same "may clash, rebind in + settings" caveat Firefox has, or fires cleanly in Safari. The popup button works + regardless. +- Whether WXT emits any Safari-target manifest warnings that need a per-browser manifest + hook. + +## Testing + +- **Unit:** `isExtensionOrigin` / pairing / `validateCaptureRequest` accept the Safari + scheme (`auth.test.ts`). +- **Manual QA (human-required):** re-run the 6-step acceptance gate in + `apps/extension/README.md` in Safari — app-closed, pairing, capture, failed extraction, + launch-when-closed, and the Origin-header check. + +## Distinguishing code vs. manual work + +- **Code/automatable:** allowlist line + test, build scripts, committed Xcode project, + entitlements, README runbook. +- **Manual (Apple portal / human):** certificates, archive upload, App Store Connect + listing, screenshots, privacy label, review, and the Safari manual-QA gate.