Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(glance): ship the macOS widget app and claim the glance link natively on iOS
nirholas9527c2ff061a
diff --git a/apple/GlanceKit/GlanceConfig.swift b/apple/GlanceKit/GlanceConfig.swiftindex b7f4c24e2..836b79ae5 100644--- a/apple/GlanceKit/GlanceConfig.swift+++ b/apple/GlanceKit/GlanceConfig.swift@@ -25,8 +25,13 @@ enum GlanceConfig {/// The App Group container holding the last card. `nil` on a single-target/// development run, where the extension falls back to its own container and- /// simply cannot see what the app cached.- static var appGroup: String? { infoString("GlanceAppGroup") }+ /// simply cannot see what the app cached. A value starting with a dot means+ /// `DEVELOPMENT_TEAM` was not set when the Mac project was built, so the+ /// team prefix expanded to nothing and the identifier is not a real group.+ static var appGroup: String? {+ guard let raw = infoString("GlanceAppGroup"), !raw.hasPrefix(".") else { return nil }+ return raw+ }/// The shared keychain group. `nil` when `DEVELOPMENT_TEAM` was not set at/// build time, in which case the value expands to a bare `.ws.three.shared`diff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/AccentColor.colorset/Contents.json b/apple/macos/ThreeWSGlance/Assets.xcassets/AccentColor.colorset/Contents.jsonnew file mode 100644index 000000000..6522d0cd2--- /dev/null+++ b/apple/macos/ThreeWSGlance/Assets.xcassets/AccentColor.colorset/Contents.json@@ -0,0 +1,20 @@+{+ "colors" : [+ {+ "color" : {+ "color-space" : "srgb",+ "components" : {+ "alpha" : "1.000",+ "blue" : "0.898",+ "green" : "0.275",+ "red" : "0.310"+ }+ },+ "idiom" : "universal"+ }+ ],+ "info" : {+ "author" : "xcode",+ "version" : 1+ }+}diff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/Contents.json b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/Contents.jsonnew file mode 100644index 000000000..8815e3ec1--- /dev/null+++ b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/Contents.json@@ -0,0 +1,68 @@+{+ "images": [+ {+ "filename": "icon_16x16.png",+ "idiom": "mac",+ "scale": "1x",+ "size": "16x16"+ },+ {+ "filename": "[email protected]",+ "idiom": "mac",+ "scale": "2x",+ "size": "16x16"+ },+ {+ "filename": "icon_32x32.png",+ "idiom": "mac",+ "scale": "1x",+ "size": "32x32"+ },+ {+ "filename": "[email protected]",+ "idiom": "mac",+ "scale": "2x",+ "size": "32x32"+ },+ {+ "filename": "icon_128x128.png",+ "idiom": "mac",+ "scale": "1x",+ "size": "128x128"+ },+ {+ "filename": "[email protected]",+ "idiom": "mac",+ "scale": "2x",+ "size": "128x128"+ },+ {+ "filename": "icon_256x256.png",+ "idiom": "mac",+ "scale": "1x",+ "size": "256x256"+ },+ {+ "filename": "[email protected]",+ "idiom": "mac",+ "scale": "2x",+ "size": "256x256"+ },+ {+ "filename": "icon_512x512.png",+ "idiom": "mac",+ "scale": "1x",+ "size": "512x512"+ },+ {+ "filename": "[email protected]",+ "idiom": "mac",+ "scale": "2x",+ "size": "512x512"+ }+ ],+ "info": {+ "author": "xcode",+ "version": 1+ }+}diff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_128x128.png b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_128x128.pngnew file mode 100644index 000000000..1c39c7126Binary files /dev/null and b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_128x128.png differdiff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected] b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected]new file mode 100644index 000000000..672614fb8Binary files /dev/null and b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected] differdiff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_16x16.png b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_16x16.pngnew file mode 100644index 000000000..1b41a77ffBinary files /dev/null and b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_16x16.png differdiff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected] b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected]new file mode 100644index 000000000..6c230b3bbBinary files /dev/null and b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected] differdiff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_256x256.png b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_256x256.pngnew file mode 100644index 000000000..672614fb8Binary files /dev/null and b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_256x256.png differdiff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected] b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected]new file mode 100644index 000000000..cf572c39fBinary files /dev/null and b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected] differdiff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_32x32.png b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_32x32.pngnew file mode 100644index 000000000..6c230b3bbBinary files /dev/null and b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_32x32.png differdiff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected] b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected]new file mode 100644index 000000000..2dd3cbb57Binary files /dev/null and b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected] differdiff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_512x512.png b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_512x512.pngnew file mode 100644index 000000000..cf572c39fBinary files /dev/null and b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/icon_512x512.png differdiff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected] b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected]new file mode 100644index 000000000..29d3387b3Binary files /dev/null and b/apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset/[email protected] differdiff --git a/apple/macos/ThreeWSGlance/Assets.xcassets/Contents.json b/apple/macos/ThreeWSGlance/Assets.xcassets/Contents.jsonnew file mode 100644index 000000000..73c00596a--- /dev/null+++ b/apple/macos/ThreeWSGlance/Assets.xcassets/Contents.json@@ -0,0 +1,6 @@+{+ "info" : {+ "author" : "xcode",+ "version" : 1+ }+}diff --git a/apple/macos/ThreeWSGlance/Info.plist b/apple/macos/ThreeWSGlance/Info.plistnew file mode 100644index 000000000..57983866f--- /dev/null+++ b/apple/macos/ThreeWSGlance/Info.plist@@ -0,0 +1,57 @@+<?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>CFBundleDevelopmentRegion</key>+ <string>$(DEVELOPMENT_LANGUAGE)</string>+ <key>CFBundleDisplayName</key>+ <string>three.ws Glance</string>+ <key>CFBundleExecutable</key>+ <string>$(EXECUTABLE_NAME)</string>+ <key>CFBundleIdentifier</key>+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>+ <key>CFBundleInfoDictionaryVersion</key>+ <string>6.0</string>+ <key>CFBundleName</key>+ <string>$(PRODUCT_NAME)</string>+ <key>CFBundlePackageType</key>+ <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>+ <key>CFBundleShortVersionString</key>+ <string>$(MARKETING_VERSION)</string>+ <key>CFBundleVersion</key>+ <string>$(CURRENT_PROJECT_VERSION)</string>+ <key>LSMinimumSystemVersion</key>+ <string>$(MACOSX_DEPLOYMENT_TARGET)</string>+ <!--+ A menu bar app. No Dock icon and no menu bar of its own: the widget is+ the product and this app feeds it. The link window still opens at launch+ and from the menu bar item, so nothing is unreachable.+ -->+ <key>LSUIElement</key>+ <true/>+ <key>NSHumanReadableCopyright</key>+ <string>three.ws</string>+ <!--+ The scheme /api/glance/token builds its links.apple URL with. The token+ arrives as threews://glance/link?token=glw_... and is claimed natively in+ GlanceLinkModel, so it never reaches a web view or the pasteboard.+ -->+ <key>CFBundleURLTypes</key>+ <array>+ <dict>+ <key>CFBundleURLName</key>+ <string>ws.three.glance.link</string>+ <key>CFBundleURLSchemes</key>+ <array>+ <string>threews</string>+ </array>+ </dict>+ </array>+ <key>GlanceOrigin</key>+ <string>$(GLANCE_ORIGIN)</string>+ <key>GlanceAppGroup</key>+ <string>$(GLANCE_APP_GROUP)</string>+ <key>GlanceKeychainGroup</key>+ <string>$(GLANCE_KEYCHAIN_GROUP)</string>+</dict>+</plist>diff --git a/apple/macos/ThreeWSGlance/ThreeWSGlance.entitlements b/apple/macos/ThreeWSGlance/ThreeWSGlance.entitlementsnew file mode 100644index 000000000..497885440--- /dev/null+++ b/apple/macos/ThreeWSGlance/ThreeWSGlance.entitlements@@ -0,0 +1,24 @@+<?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.app-sandbox</key>+ <true/>+ <key>com.apple.security.network.client</key>+ <true/>+ <!--+ Shared with the widget extension: the App Group holds the last card, the+ keychain group holds the token. Both strings come from the project's+ build settings; on a Mac signed with a Developer ID they carry the team+ prefix, which is why they are not literals here.+ -->+ <key>com.apple.security.application-groups</key>+ <array>+ <string>$(GLANCE_APP_GROUP)</string>+ </array>+ <key>keychain-access-groups</key>+ <array>+ <string>$(GLANCE_KEYCHAIN_GROUP)</string>+ </array>+</dict>+</plist>diff --git a/apple/macos/project.yml b/apple/macos/project.ymlnew file mode 100644index 000000000..12ed4b318--- /dev/null+++ b/apple/macos/project.yml@@ -0,0 +1,90 @@+# XcodeGen spec for the three.ws Glance Mac app and its widget extension.+#+# brew install xcodegen # once+# cd apple/macos && xcodegen generate && open ThreeWSGlance.xcodeproj+#+# The project is generated rather than committed on purpose: a hand-maintained+# .xcodeproj is a merge conflict waiting to happen, and this file says what the+# two targets actually are in thirty readable lines. The iOS widget is the same+# extension sources laid into the Capacitor project instead, because that one is+# generated by Capacitor and already committed.+#+# Signing: set DEVELOPMENT_TEAM (Xcode's Signing and Capabilities tab, or+# `xcodebuild ... DEVELOPMENT_TEAM=XXXXXXXXXX`). It is not committed because it+# is per-account, and both the App Group and the keychain group are derived from+# it: on a Mac distributed with a Developer ID the App Group identifier must+# carry the team prefix, which is exactly the rule iOS does not have.+name: ThreeWSGlance+options:+ bundleIdPrefix: ws.three+ createIntermediateGroups: true+ deploymentTarget:+ macOS: "14.0"+ groupSortPosition: top++settings:+ base:+ CURRENT_PROJECT_VERSION: "1"+ MARKETING_VERSION: "1.0.0"+ SWIFT_VERSION: "5.9"+ CODE_SIGN_STYLE: Automatic+ ENABLE_HARDENED_RUNTIME: true+ SWIFT_STRICT_CONCURRENCY: minimal+ GLANCE_ORIGIN: https://three.ws+ # Both identifiers are team-prefixed here. On a Mac that is required+ # outside the Mac App Store; on iPhone it is forbidden, which is why+ # GlanceKit reads them from the Info.plist instead of hard coding either.+ GLANCE_APP_GROUP: $(DEVELOPMENT_TEAM).group.ws.three.glance+ GLANCE_KEYCHAIN_GROUP: $(DEVELOPMENT_TEAM).ws.three.shared++targets:+ ThreeWSGlance:+ type: application+ platform: macOS+ sources:+ - path: ThreeWSGlance+ - path: ../GlanceKit+ name: GlanceKit+ settings:+ base:+ PRODUCT_NAME: ThreeWSGlance+ PRODUCT_BUNDLE_IDENTIFIER: ws.three.glance+ INFOPLIST_FILE: ThreeWSGlance/Info.plist+ CODE_SIGN_ENTITLEMENTS: ThreeWSGlance/ThreeWSGlance.entitlements+ ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME: AccentColor+ COMBINE_HIDPI_IMAGES: true+ dependencies:+ - target: GlanceWidget+ embed: true+ codeSign: true++ GlanceWidget:+ type: app-extension+ platform: macOS+ sources:+ - path: ../GlanceWidget+ name: GlanceWidget+ - path: ../GlanceKit+ name: GlanceKit+ settings:+ base:+ PRODUCT_NAME: GlanceWidget+ PRODUCT_BUNDLE_IDENTIFIER: ws.three.glance.widget+ INFOPLIST_FILE: ../GlanceWidget/Info.plist+ CODE_SIGN_ENTITLEMENTS: ../GlanceWidget/GlanceWidget.entitlements+ SKIP_INSTALL: true+ dependencies:+ - sdk: WidgetKit.framework+ - sdk: SwiftUI.framework++schemes:+ ThreeWSGlance:+ build:+ targets:+ ThreeWSGlance: all+ GlanceWidget: all+ run:+ config: Debug+ archive:+ config: Releasediff --git a/apple/scripts/make-macos-icon.mjs b/apple/scripts/make-macos-icon.mjsnew file mode 100644index 000000000..ec83fee19--- /dev/null+++ b/apple/scripts/make-macos-icon.mjs@@ -0,0 +1,160 @@+#!/usr/bin/env node+/**+ * Generates the three.ws Glance macOS app icon from the brand mark.+ *+ * node apple/scripts/make-macos-icon.mjs [--check]+ *+ * Same reasoning as ios/scripts/make-icons.mjs: Xcode refuses to archive+ * without an app icon, and deriving it from the mark means one command re-cuts+ * every size when the mark changes. macOS differs from iOS in two ways that+ * matter here. It needs the whole ladder of sizes (16 through 512, at 1x and+ * 2x) rather than a single 1024 slot, and it draws the icon exactly as given,+ * so the rounded rectangle and the margin around it are ours to paint rather+ * than the system's to apply.+ *+ * --check verifies the committed assets match what this script would produce,+ * without writing, which is what keeps a hand-edited icon from drifting.+ */++import { createHash } from 'node:crypto';+import { readFileSync, existsSync, writeFileSync, mkdirSync } from 'node:fs';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';+import sharp from 'sharp';++const HERE = dirname(fileURLToPath(import.meta.url));+const REPO = resolve(HERE, '../..');+const ICONSET = join(REPO, 'apple/macos/ThreeWSGlance/Assets.xcassets/AppIcon.appiconset');+const SOURCE = join(REPO, 'public/pwa-512x512.png');++// The product's background, matched across the iOS icon, the launch screen and+// the widget's canvas in apple/GlanceKit/GlanceCardView.swift.+const BG_TOP = { r: 0x16, g: 0x16, b: 0x3a };+const BG_BASE = { r: 0x08, g: 0x08, b: 0x14 };++// Apple's macOS icon grid: the art sits inside about 80% of the canvas with a+// corner radius near a fifth of the art's edge. A full-bleed square reads as a+// mistake in the Dock next to every other app.+const INSET = 0.1;+const RADIUS = 0.185;+const MARK_COVERAGE = 0.56;++/** The radial the offline screen paints, as raw pixels. */+function backgroundPlate(size) {+ const px = Buffer.allocUnsafe(size * size * 3);+ const cx = size / 2;+ const rx = size * 1.2;+ const ry = size * 0.8;+ for (let y = 0; y < size; y++) {+ for (let x = 0; x < size; x++) {+ const dx = (x + 0.5 - cx) / rx;+ const dy = (y + 0.5) / ry;+ const t = Math.min(1, Math.sqrt(dx * dx + dy * dy));+ const i = (y * size + x) * 3;+ px[i] = Math.round(BG_TOP.r + (BG_BASE.r - BG_TOP.r) * t);+ px[i + 1] = Math.round(BG_TOP.g + (BG_BASE.g - BG_TOP.g) * t);+ px[i + 2] = Math.round(BG_TOP.b + (BG_BASE.b - BG_TOP.b) * t);+ }+ }+ return sharp(px, { raw: { width: size, height: size, channels: 3 } }).png().toBuffer();+}++/**+ * One icon: a rounded plate inset in a transparent canvas, with the mark+ * centred on it. macOS icons keep their alpha channel, unlike iOS ones.+ *+ * @param {number} size Output edge length in pixels.+ * @returns {Promise<Buffer>} PNG bytes.+ */+async function compose(size) {+ const art = Math.round(size * (1 - INSET * 2));+ const offset = Math.round((size - art) / 2);+ const radius = Math.round(art * RADIUS);++ const mask = Buffer.from(+ `<svg width="${art}" height="${art}"><rect width="${art}" height="${art}" rx="${radius}" ry="${radius}" fill="#fff"/></svg>`+ );+ const plate = await sharp(await backgroundPlate(art))+ .composite([{ input: mask, blend: 'dest-in' }])+ .png()+ .toBuffer();++ const mark = Math.max(1, Math.round(art * MARK_COVERAGE));+ const glyph = await sharp(SOURCE).resize(mark, mark, { fit: 'contain' }).png().toBuffer();+ const markOffset = offset + Math.round((art - mark) / 2);++ return sharp({+ create: { width: size, height: size, channels: 4, background: { r: 0, g: 0, b: 0, alpha: 0 } },+ })+ .composite([+ { input: plate, left: offset, top: offset },+ { input: glyph, left: markOffset, top: markOffset },+ ])+ .png({ compressionLevel: 9 })+ .toBuffer();+}++// The full macOS ladder. Every entry is one file and one Contents.json image.+const SIZES = [16, 32, 128, 256, 512];+const TARGETS = SIZES.flatMap((size) => [+ { size, scale: 1, pixels: size, file: `icon_${size}x${size}.png` },+ { size, scale: 2, pixels: size * 2, file: `icon_${size}x${size}@2x.png` },+]);++const contents = {+ images: TARGETS.map((t) => ({+ filename: t.file,+ idiom: 'mac',+ scale: `${t.scale}x`,+ size: `${t.size}x${t.size}`,+ })),+ info: { author: 'xcode', version: 1 },+};++const check = process.argv.includes('--check');++if (!existsSync(SOURCE)) {+ console.error(`[macos-icon] brand mark missing: ${SOURCE}`);+ process.exit(1);+}+if (!check) mkdirSync(ICONSET, { recursive: true });++const digest = (buf) => createHash('sha256').update(buf).digest('hex').slice(0, 12);+let drifted = 0;++for (const target of TARGETS) {+ const path = join(ICONSET, target.file);+ const produced = await compose(target.pixels);+ if (check) {+ const current = existsSync(path) ? readFileSync(path) : null;+ const same = current && digest(current) === digest(produced);+ if (!same) {+ drifted++;+ console.log(`[macos-icon] DRIFT ${target.file} (${target.pixels}px)`);+ }+ continue;+ }+ writeFileSync(path, produced);+ console.log(`[macos-icon] wrote ${target.file} ${target.pixels}x${target.pixels} (${produced.length} bytes)`);+}++const manifest = `${JSON.stringify(contents, null, 2)}\n`;+const manifestPath = join(ICONSET, 'Contents.json');+if (check) {+ const current = existsSync(manifestPath) ? readFileSync(manifestPath, 'utf8') : '';+ if (current !== manifest) {+ drifted++;+ console.log('[macos-icon] DRIFT Contents.json');+ }+} else {+ writeFileSync(manifestPath, manifest);+ console.log('[macos-icon] wrote Contents.json');+}++if (check) {+ if (drifted) {+ console.error(`[macos-icon] ${drifted} asset(s) differ from the brand mark. Run: node apple/scripts/make-macos-icon.mjs`);+ process.exit(1);+ }+ console.log(`[macos-icon] ok ${TARGETS.length} icons match the brand mark`);+}diff --git a/ios/native/App/App.xcodeproj/project.pbxproj b/ios/native/App/App.xcodeproj/project.pbxprojindex 02ddb8da8..5bd77059c 100644--- a/ios/native/App/App.xcodeproj/project.pbxproj+++ b/ios/native/App/App.xcodeproj/project.pbxproj@@ -19,8 +19,49 @@9582B6832FE993A70072D4E8 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9582B6822FE993A50072D4E8 /* SceneDelegate.swift */; };C4A11E0130A1000200000000 /* CarPlaySceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0130A1000100000000 /* CarPlaySceneDelegate.swift */; };C4A11E0130A1000400000000 /* DriveLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0130A1000300000000 /* DriveLink.swift */; };+ C4A11E0230B1003100000000 /* GlanceConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000100000000 /* GlanceConfig.swift */; };+ C4A11E0230B1004100000000 /* GlanceConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000100000000 /* GlanceConfig.swift */; };+ C4A11E0230B1003200000000 /* GlanceCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000200000000 /* GlanceCard.swift */; };+ C4A11E0230B1004200000000 /* GlanceCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000200000000 /* GlanceCard.swift */; };+ C4A11E0230B1003300000000 /* GlanceTokenStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000300000000 /* GlanceTokenStore.swift */; };+ C4A11E0230B1004300000000 /* GlanceTokenStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000300000000 /* GlanceTokenStore.swift */; };+ C4A11E0230B1003400000000 /* GlanceCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000400000000 /* GlanceCache.swift */; };+ C4A11E0230B1004400000000 /* GlanceCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000400000000 /* GlanceCache.swift */; };+ C4A11E0230B1004500000000 /* GlanceClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000500000000 /* GlanceClient.swift */; };+ C4A11E0230B1003500000000 /* GlanceLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000600000000 /* GlanceLink.swift */; };+ C4A11E0230B1004600000000 /* GlanceLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000600000000 /* GlanceLink.swift */; };+ C4A11E0230B1004700000000 /* GlanceImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000700000000 /* GlanceImage.swift */; };+ C4A11E0230B1004800000000 /* GlanceEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000800000000 /* GlanceEntry.swift */; };+ C4A11E0230B1004900000000 /* GlanceCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000900000000 /* GlanceCardView.swift */; };+ C4A11E0230B1004A00000000 /* GlanceProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000A00000000 /* GlanceProvider.swift */; };+ C4A11E0230B1004B00000000 /* AgentGlanceWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000B00000000 /* AgentGlanceWidget.swift */; };+ C4A11E0230B1005000000000 /* GlanceWidget.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = C4A11E0230B1000E00000000 /* GlanceWidget.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };/* End PBXBuildFile section */+/* Begin PBXContainerItemProxy section */+ C4A11E0230B1006600000000 /* PBXContainerItemProxy */ = {+ isa = PBXContainerItemProxy;+ containerPortal = 504EC2FC1FED79650016851F /* Project object */;+ proxyType = 1;+ remoteGlobalIDString = C4A11E0230B1006000000000;+ remoteInfo = GlanceWidgetExtension;+ };+/* End PBXContainerItemProxy section */++/* Begin PBXCopyFilesBuildPhase section */+ C4A11E0230B1006400000000 /* Embed Foundation Extensions */ = {+ isa = PBXCopyFilesBuildPhase;+ buildActionMask = 2147483647;+ dstPath = "";+ dstSubfolderSpec = 13;+ files = (+ C4A11E0230B1005000000000 /* GlanceWidget.appex in Embed Foundation Extensions */,+ );+ name = "Embed Foundation Extensions";+ runOnlyForDeploymentPostprocessing = 0;+ };+/* End PBXCopyFilesBuildPhase section */+/* Begin PBXFileReference section */2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = "<group>"; };50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = "<group>"; };@@ -36,6 +77,20 @@C4A11E0130A1000100000000 /* CarPlaySceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarPlaySceneDelegate.swift; sourceTree = "<group>"; };C4A11E0130A1000300000000 /* DriveLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DriveLink.swift; sourceTree = "<group>"; };958DCC722DB07C7200EA8C5F /* debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = debug.xcconfig; path = ../debug.xcconfig; sourceTree = SOURCE_ROOT; };+ C4A11E0230B1000100000000 /* GlanceConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlanceConfig.swift; sourceTree = "<group>"; };+ C4A11E0230B1000200000000 /* GlanceCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlanceCard.swift; sourceTree = "<group>"; };+ C4A11E0230B1000300000000 /* GlanceTokenStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlanceTokenStore.swift; sourceTree = "<group>"; };+ C4A11E0230B1000400000000 /* GlanceCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlanceCache.swift; sourceTree = "<group>"; };+ C4A11E0230B1000500000000 /* GlanceClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlanceClient.swift; sourceTree = "<group>"; };+ C4A11E0230B1000600000000 /* GlanceLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlanceLink.swift; sourceTree = "<group>"; };+ C4A11E0230B1000700000000 /* GlanceImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlanceImage.swift; sourceTree = "<group>"; };+ C4A11E0230B1000800000000 /* GlanceEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlanceEntry.swift; sourceTree = "<group>"; };+ C4A11E0230B1000900000000 /* GlanceCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlanceCardView.swift; sourceTree = "<group>"; };+ C4A11E0230B1000A00000000 /* GlanceProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlanceProvider.swift; sourceTree = "<group>"; };+ C4A11E0230B1000B00000000 /* AgentGlanceWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgentGlanceWidget.swift; sourceTree = "<group>"; };+ C4A11E0230B1000C00000000 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };+ C4A11E0230B1000D00000000 /* GlanceWidget.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GlanceWidget.entitlements; sourceTree = "<group>"; };+ C4A11E0230B1000E00000000 /* GlanceWidget.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = GlanceWidget.appex; sourceTree = BUILT_PRODUCTS_DIR; };/* End PBXFileReference section *//* Begin PBXFrameworksBuildPhase section */@@ -47,6 +102,13 @@);runOnlyForDeploymentPostprocessing = 0;};+ C4A11E0230B1006200000000 /* Frameworks */ = {+ isa = PBXFrameworksBuildPhase;+ buildActionMask = 2147483647;+ files = (+ );+ runOnlyForDeploymentPostprocessing = 0;+ };/* End PBXFrameworksBuildPhase section *//* Begin PBXGroup section */@@ -55,6 +117,7 @@children = (958DCC722DB07C7200EA8C5F /* debug.xcconfig */,504EC3061FED79650016851F /* App */,+ C4A11E0230B1002000000000 /* Glance */,504EC3051FED79650016851F /* Products */,);sourceTree = "<group>";@@ -63,6 +126,7 @@isa = PBXGroup;children = (504EC3041FED79650016851F /* App.app */,+ C4A11E0230B1000E00000000 /* GlanceWidget.appex */,);name = Products;sourceTree = "<group>";@@ -86,6 +150,44 @@path = App;sourceTree = "<group>";};+ C4A11E0230B1002000000000 /* Glance */ = {+ isa = PBXGroup;+ children = (+ C4A11E0230B1002100000000 /* GlanceKit */,+ C4A11E0230B1002200000000 /* GlanceWidget */,+ );+ name = Glance;+ sourceTree = "<group>";+ };+ C4A11E0230B1002100000000 /* GlanceKit */ = {+ isa = PBXGroup;+ children = (+ C4A11E0230B1000100000000 /* GlanceConfig.swift */,+ C4A11E0230B1000200000000 /* GlanceCard.swift */,+ C4A11E0230B1000300000000 /* GlanceTokenStore.swift */,+ C4A11E0230B1000400000000 /* GlanceCache.swift */,+ C4A11E0230B1000500000000 /* GlanceClient.swift */,+ C4A11E0230B1000600000000 /* GlanceLink.swift */,+ C4A11E0230B1000700000000 /* GlanceImage.swift */,+ C4A11E0230B1000800000000 /* GlanceEntry.swift */,+ C4A11E0230B1000900000000 /* GlanceCardView.swift */,+ );+ name = GlanceKit;+ path = ../../../apple/GlanceKit;+ sourceTree = SOURCE_ROOT;+ };+ C4A11E0230B1002200000000 /* GlanceWidget */ = {+ isa = PBXGroup;+ children = (+ C4A11E0230B1000A00000000 /* GlanceProvider.swift */,+ C4A11E0230B1000B00000000 /* AgentGlanceWidget.swift */,+ C4A11E0230B1000C00000000 /* Info.plist */,+ C4A11E0230B1000D00000000 /* GlanceWidget.entitlements */,+ );+ name = GlanceWidget;+ path = ../../../apple/GlanceWidget;+ sourceTree = SOURCE_ROOT;+ };/* End PBXGroup section *//* Begin PBXNativeTarget section */@@ -96,10 +198,12 @@504EC3001FED79650016851F /* Sources */,504EC3011FED79650016851F /* Frameworks */,504EC3021FED79650016851F /* Resources */,+ C4A11E0230B1006400000000 /* Embed Foundation Extensions */,);buildRules = ();dependencies = (+ C4A11E0230B1006500000000 /* PBXTargetDependency */,);name = App;packageProductDependencies = (@@ -109,6 +213,22 @@productReference = 504EC3041FED79650016851F /* App.app */;productType = "com.apple.product-type.application";};+ C4A11E0230B1006000000000 /* GlanceWidgetExtension */ = {+ isa = PBXNativeTarget;+ buildConfigurationList = C4A11E0230B1006700000000 /* Build configuration list for PBXNativeTarget "GlanceWidgetExtension" */;+ buildPhases = (+ C4A11E0230B1006100000000 /* Sources */,+ C4A11E0230B1006200000000 /* Frameworks */,+ );+ buildRules = (+ );+ dependencies = (+ );+ name = GlanceWidgetExtension;+ productName = GlanceWidget;+ productReference = C4A11E0230B1000E00000000 /* GlanceWidget.appex */;+ productType = "com.apple.product-type.app-extension";+ };/* End PBXNativeTarget section *//* Begin PBXProject section */@@ -123,6 +243,10 @@LastSwiftMigration = 1100;ProvisioningStyle = Automatic;};+ C4A11E0230B1006000000000 = {+ CreatedOnToolsVersion = 15.0;+ ProvisioningStyle = Automatic;+ };};};buildConfigurationList = 504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */;@@ -142,6 +266,7 @@projectRoot = "";targets = (504EC3031FED79650016851F /* App */,+ C4A11E0230B1006000000000 /* GlanceWidgetExtension */,);};/* End PBXProject section */@@ -172,11 +297,42 @@9582B6832FE993A70072D4E8 /* SceneDelegate.swift in Sources */,C4A11E0130A1000200000000 /* CarPlaySceneDelegate.swift in Sources */,C4A11E0130A1000400000000 /* DriveLink.swift in Sources */,+ C4A11E0230B1003100000000 /* GlanceConfig.swift in Sources */,+ C4A11E0230B1003200000000 /* GlanceCard.swift in Sources */,+ C4A11E0230B1003300000000 /* GlanceTokenStore.swift in Sources */,+ C4A11E0230B1003400000000 /* GlanceCache.swift in Sources */,+ C4A11E0230B1003500000000 /* GlanceLink.swift in Sources */,+ );+ runOnlyForDeploymentPostprocessing = 0;+ };+ C4A11E0230B1006100000000 /* Sources */ = {+ isa = PBXSourcesBuildPhase;+ buildActionMask = 2147483647;+ files = (+ C4A11E0230B1004100000000 /* GlanceConfig.swift in Sources */,+ C4A11E0230B1004200000000 /* GlanceCard.swift in Sources */,+ C4A11E0230B1004300000000 /* GlanceTokenStore.swift in Sources */,+ C4A11E0230B1004400000000 /* GlanceCache.swift in Sources */,+ C4A11E0230B1004500000000 /* GlanceClient.swift in Sources */,+ C4A11E0230B1004600000000 /* GlanceLink.swift in Sources */,+ C4A11E0230B1004700000000 /* GlanceImage.swift in Sources */,+ C4A11E0230B1004800000000 /* GlanceEntry.swift in Sources */,+ C4A11E0230B1004900000000 /* GlanceCardView.swift in Sources */,+ C4A11E0230B1004A00000000 /* GlanceProvider.swift in Sources */,+ C4A11E0230B1004B00000000 /* AgentGlanceWidget.swift in Sources */,);runOnlyForDeploymentPostprocessing = 0;};/* End PBXSourcesBuildPhase section */+/* Begin PBXTargetDependency section */+ C4A11E0230B1006500000000 /* PBXTargetDependency */ = {+ isa = PBXTargetDependency;+ target = C4A11E0230B1006000000000 /* GlanceWidgetExtension */;+ targetProxy = C4A11E0230B1006600000000 /* PBXContainerItemProxy */;+ };+/* End PBXTargetDependency section */+/* Begin PBXVariantGroup section */504EC30B1FED79650016851F /* Main.storyboard */ = {isa = PBXVariantGroup;@@ -314,6 +470,9 @@CODE_SIGN_STYLE = Automatic;CODE_SIGN_ENTITLEMENTS = App/App.entitlements;CURRENT_PROJECT_VERSION = 1;+ GLANCE_APP_GROUP = group.ws.three.app;+ GLANCE_KEYCHAIN_GROUP = "$(DEVELOPMENT_TEAM).ws.three.shared";+ GLANCE_ORIGIN = "https://three.ws";INFOPLIST_FILE = App/Info.plist;IPHONEOS_DEPLOYMENT_TARGET = 16.0;LD_RUNPATH_SEARCH_PATHS = (@@ -337,6 +496,9 @@CODE_SIGN_STYLE = Automatic;CODE_SIGN_ENTITLEMENTS = App/App.entitlements;CURRENT_PROJECT_VERSION = 1;+ GLANCE_APP_GROUP = group.ws.three.app;+ GLANCE_KEYCHAIN_GROUP = "$(DEVELOPMENT_TEAM).ws.three.shared";+ GLANCE_ORIGIN = "https://three.ws";INFOPLIST_FILE = App/Info.plist;IPHONEOS_DEPLOYMENT_TARGET = 16.0;LD_RUNPATH_SEARCH_PATHS = (@@ -352,6 +514,88 @@};name = Release;};+ C4A11E0230B1006800000000 /* Debug */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ALWAYS_SEARCH_USER_PATHS = NO;+ CLANG_ENABLE_MODULES = YES;+ CLANG_ENABLE_OBJC_ARC = YES;+ CODE_SIGN_ENTITLEMENTS = "../../../apple/GlanceWidget/GlanceWidget.entitlements";+ CODE_SIGN_STYLE = Automatic;+ CURRENT_PROJECT_VERSION = 1;+ ENABLE_USER_SCRIPT_SANDBOXING = NO;+ GENERATE_INFOPLIST_FILE = NO;+ /* The three values GlanceKit reads back out of the Info.plist at+ runtime. An App Group on iPhone must NOT carry the team prefix;+ the same group on the Mac app must. See apple/README.md. */+ GLANCE_APP_GROUP = group.ws.three.app;+ GLANCE_KEYCHAIN_GROUP = "$(DEVELOPMENT_TEAM).ws.three.shared";+ GLANCE_ORIGIN = "https://three.ws";+ INFOPLIST_FILE = "../../../apple/GlanceWidget/Info.plist";+ /* WidgetKit's containerBackground and contentMarginsDisabled are+ iOS 17. The host app stays on 16.0; an extension the system+ cannot run is simply not offered in the widget gallery. */+ IPHONEOS_DEPLOYMENT_TARGET = 17.0;+ LD_RUNPATH_SEARCH_PATHS = (+ "$(inherited)",+ "@executable_path/Frameworks",+ "@executable_path/../../Frameworks",+ );+ MARKETING_VERSION = 1.0;+ MTL_FAST_MATH = YES;+ PRODUCT_BUNDLE_IDENTIFIER = ws.three.app.glance;+ PRODUCT_NAME = GlanceWidget;+ SDKROOT = iphoneos;+ SKIP_INSTALL = YES;+ SWIFT_EMIT_LOC_STRINGS = YES;+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";+ SWIFT_VERSION = 5.0;+ TARGETED_DEVICE_FAMILY = "1,2";+ };+ name = Debug;+ };+ C4A11E0230B1006900000000 /* Release */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ALWAYS_SEARCH_USER_PATHS = NO;+ CLANG_ENABLE_MODULES = YES;+ CLANG_ENABLE_OBJC_ARC = YES;+ CODE_SIGN_ENTITLEMENTS = "../../../apple/GlanceWidget/GlanceWidget.entitlements";+ CODE_SIGN_STYLE = Automatic;+ CURRENT_PROJECT_VERSION = 1;+ ENABLE_USER_SCRIPT_SANDBOXING = NO;+ GENERATE_INFOPLIST_FILE = NO;+ /* The three values GlanceKit reads back out of the Info.plist at+ runtime. An App Group on iPhone must NOT carry the team prefix;+ the same group on the Mac app must. See apple/README.md. */+ GLANCE_APP_GROUP = group.ws.three.app;+ GLANCE_KEYCHAIN_GROUP = "$(DEVELOPMENT_TEAM).ws.three.shared";+ GLANCE_ORIGIN = "https://three.ws";+ INFOPLIST_FILE = "../../../apple/GlanceWidget/Info.plist";+ /* WidgetKit's containerBackground and contentMarginsDisabled are+ iOS 17. The host app stays on 16.0; an extension the system+ cannot run is simply not offered in the widget gallery. */+ IPHONEOS_DEPLOYMENT_TARGET = 17.0;+ LD_RUNPATH_SEARCH_PATHS = (+ "$(inherited)",+ "@executable_path/Frameworks",+ "@executable_path/../../Frameworks",+ );+ MARKETING_VERSION = 1.0;+ MTL_FAST_MATH = YES;+ PRODUCT_BUNDLE_IDENTIFIER = ws.three.app.glance;+ PRODUCT_NAME = GlanceWidget;+ SDKROOT = iphoneos;+ SKIP_INSTALL = YES;+ SWIFT_EMIT_LOC_STRINGS = YES;+ SWIFT_COMPILATION_MODE = wholemodule;+ SWIFT_OPTIMIZATION_LEVEL = "-O";+ SWIFT_VERSION = 5.0;+ TARGETED_DEVICE_FAMILY = "1,2";+ };+ name = Release;+ };/* End XCBuildConfiguration section *//* Begin XCConfigurationList section */@@ -373,6 +617,15 @@defaultConfigurationIsVisible = 0;defaultConfigurationName = Release;};+ C4A11E0230B1006700000000 /* Build configuration list for PBXNativeTarget "GlanceWidgetExtension" */ = {+ isa = XCConfigurationList;+ buildConfigurations = (+ C4A11E0230B1006800000000 /* Debug */,+ C4A11E0230B1006900000000 /* Release */,+ );+ defaultConfigurationIsVisible = 0;+ defaultConfigurationName = Release;+ };/* End XCConfigurationList section *//* Begin XCLocalSwiftPackageReference section */diff --git a/ios/native/App/App/App.entitlements b/ios/native/App/App/App.entitlementsindex 5c21787ec..8d3a90a76 100644--- a/ios/native/App/App/App.entitlements+++ b/ios/native/App/App/App.entitlements@@ -35,5 +35,20 @@--><key>com.apple.developer.carplay-voice-based-conversation</key><true/>+ <!--+ The Agent glance home screen widget. The App Group holds the last card+ the widget downloaded, so it keeps painting when the phone is offline,+ and the keychain group holds the widget token this app claims from+ threews://glance/link. Both are read-only reads of one endpoint; see+ docs/native-widgets.md.+ -->+ <key>com.apple.security.application-groups</key>+ <array>+ <string>$(GLANCE_APP_GROUP)</string>+ </array>+ <key>keychain-access-groups</key>+ <array>+ <string>$(GLANCE_KEYCHAIN_GROUP)</string>+ </array></dict></plist>diff --git a/ios/native/App/App/Info.plist b/ios/native/App/App/Info.plistindex 5594144e2..9dc2dbc7d 100644--- a/ios/native/App/App/Info.plist+++ b/ios/native/App/App/Info.plist@@ -165,5 +165,18 @@--><key>ITSAppUsesNonExemptEncryption</key><false/>+ <!--+ Read back by apple/GlanceKit/GlanceConfig.swift in both this app and the+ Agent glance widget extension. The values come from the target's build+ settings because the two Apple platforms need different strings: an App+ Group on iPhone must not carry the team prefix that the same group on a+ Developer ID Mac must. See apple/README.md.+ -->+ <key>GlanceOrigin</key>+ <string>$(GLANCE_ORIGIN)</string>+ <key>GlanceAppGroup</key>+ <string>$(GLANCE_APP_GROUP)</string>+ <key>GlanceKeychainGroup</key>+ <string>$(GLANCE_KEYCHAIN_GROUP)</string></dict></plist>diff --git a/ios/native/App/App/SceneDelegate.swift b/ios/native/App/App/SceneDelegate.swiftindex f352e1e95..3a524286c 100644--- a/ios/native/App/App/SceneDelegate.swift+++ b/ios/native/App/App/SceneDelegate.swift@@ -11,11 +11,24 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {window?.rootViewController = CAPBridgeViewController()window?.makeKeyAndVisible()+ // A cold launch straight from the widget link on three.ws/glance. The+ // token is claimed here so it never reaches the WebView; the URL is+ // still handed on, and native-bridge.js drops it for the same reason.+ for context in connectionOptions.urlContexts {+ GlanceLink.claim(context.url)+ }+SceneDelegateProxy.shared.scene(scene, willConnectTo: session, options: connectionOptions)}func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {- SceneDelegateProxy.shared.scene(scene, openURLContexts: URLContexts)+ // threews://glance/link?token=glw_... hands the home screen widget its+ // own revocable credential. It is stored in the shared keychain and the+ // widget's timelines are reloaded; anything else falls through to+ // Capacitor, which is what routes wallet and OAuth returns.+ let unclaimed = URLContexts.filter { GlanceLink.claim($0.url) == .notALinkURL }+ guard !unclaimed.isEmpty else { return }+ SceneDelegateProxy.shared.scene(scene, openURLContexts: unclaimed)}func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {diff --git a/ios/src/native-bridge.js b/ios/src/native-bridge.jsindex dd43bc4ab..028cea051 100644--- a/ios/src/native-bridge.js+++ b/ios/src/native-bridge.js@@ -294,6 +294,11 @@ function routeDeepLinks() {// first path segment in `hostname`, which is a URL parsing quirk and// not a host in any meaningful sense.const path = `${url.hostname ? `/${url.hostname}` : ''}${url.pathname}`;+ // threews://glance/link?token=glw_... is the home screen widget's+ // credential, and SceneDelegate.swift has already taken it into the+ // keychain. It is not a page, and navigating here would put a live+ // token in the address bar of a WebView, so it stops at this line.+ if (path === '/glance/link') return;target = `https://three.ws${path || '/'}${url.search}${url.hash}`;} else if (INTERNAL_HOSTS.has(url.hostname)) {target = url.href;diff --git a/scripts/check-apple-widget.mjs b/scripts/check-apple-widget.mjsnew file mode 100644index 000000000..e34649cf5--- /dev/null+++ b/scripts/check-apple-widget.mjs@@ -0,0 +1,231 @@+#!/usr/bin/env node+/**+ * Verifies the Apple Agent glance widget against the two things that can break+ * it from outside Xcode: the Xcode projects that build it, and the server+ * endpoint it reads.+ *+ * node scripts/check-apple-widget.mjs+ *+ * Why this exists. Nothing on a Linux build machine can compile Swift or open+ * an .xcodeproj, so the failures this catches would otherwise be found on+ * somebody's Mac, days later: a Swift file added to apple/GlanceKit and never+ * added to a target, an object id in project.pbxproj that no longer resolves,+ * an entitlement that names a build setting the project never defines, or the+ * quieter one, a header or a state string renamed in api/glance/mine.js while+ * the widget kept parsing the old name and silently drew the wrong card.+ *+ * It is a structural check, not a build. A green run means the projects are+ * internally consistent and the client and the server still agree on the wire;+ * it does not mean the Swift compiles.+ */++import { readFileSync, existsSync, readdirSync } from 'node:fs';+import { dirname, join, resolve, basename } from 'node:path';+import { fileURLToPath } from 'node:url';+import { parse as parseYaml } from 'yaml';++const REPO = resolve(dirname(fileURLToPath(import.meta.url)), '..');+const read = (rel) => readFileSync(join(REPO, rel), 'utf8');++const problems = [];+const fail = (msg) => problems.push(msg);+let checks = 0;+const pass = (msg) => {+ checks++;+ console.log(`[apple-widget] ok ${msg}`);+};++// The Swift files each target has to compile. GlanceKit is shared; the host+// apps take only the part that has no WidgetKit view in it, because the iOS app+// deploys to iOS 16 and the widget's SwiftUI needs 17.+const KIT_APP_FILES = [+ 'GlanceConfig.swift',+ 'GlanceCard.swift',+ 'GlanceTokenStore.swift',+ 'GlanceCache.swift',+ 'GlanceLink.swift',+];+const WIDGET_FILES = ['GlanceProvider.swift', 'AgentGlanceWidget.swift'];+const SETTINGS = ['GLANCE_ORIGIN', 'GLANCE_APP_GROUP', 'GLANCE_KEYCHAIN_GROUP'];++// ---------------------------------------------------------------- sources ---++const kitDir = join(REPO, 'apple/GlanceKit');+const kitFiles = readdirSync(kitDir).filter((f) => f.endsWith('.swift')).sort();+if (!kitFiles.length) fail('apple/GlanceKit holds no Swift sources');++for (const file of KIT_APP_FILES) {+ if (!kitFiles.includes(file)) fail(`apple/GlanceKit/${file} is missing but every host app compiles it`);+}+for (const file of WIDGET_FILES) {+ if (!existsSync(join(REPO, 'apple/GlanceWidget', file))) fail(`apple/GlanceWidget/${file} is missing`);+}+if (!problems.length) pass(`${kitFiles.length} shared sources and ${WIDGET_FILES.length} widget sources present`);++// -------------------------------------------------------------- iOS project ---++const pbx = read('ios/native/App/App.xcodeproj/project.pbxproj');++// Balanced object graph: every 24 character id used anywhere has a definition.+// A definition is an object at the top of a section; the project's own main+// group is the one that carries no trailing comment.+const defined = new Set([...pbx.matchAll(/^\t\t([0-9A-F]{24}) (?:\/\*|=)/gm)].map((m) => m[1]));+const referenced = new Set([...pbx.matchAll(/\b([0-9A-F]{24})\b/g)].map((m) => m[1]));+const dangling = [...referenced].filter((id) => !defined.has(id));+if (dangling.length) fail(`project.pbxproj references ${dangling.length} undefined object id(s): ${dangling.slice(0, 4).join(', ')}`);+else pass(`project.pbxproj resolves all ${referenced.size} object ids`);++const braces = (pbx.match(/{/g) || []).length - (pbx.match(/}/g) || []).length;+if (braces !== 0) fail(`project.pbxproj braces are unbalanced by ${braces}`);+else pass('project.pbxproj braces balance');++// Every file reference in the Glance groups points at a file that exists.+for (const [, path] of pbx.matchAll(/path = (\.\.\/\.\.\/\.\.\/apple\/[^;]+);/g)) {+ const clean = path.replace(/^"|"$/g, '');+ const onDisk = join(REPO, 'ios/native/App', clean);+ if (!existsSync(onDisk)) fail(`project.pbxproj points at ${clean}, which is not on disk`);+}+pass('every apple/ path in project.pbxproj resolves');++const requiredPbx = [+ ['GlanceWidgetExtension', 'the widget extension target'],+ ['com.apple.product-type.app-extension', 'the extension product type'],+ ['dstSubfolderSpec = 13', 'the Embed Foundation Extensions phase'],+ ['GlanceWidget.appex in Embed Foundation Extensions', 'the appex embedded in the app'],+ ['PRODUCT_BUNDLE_IDENTIFIER = ws.three.app.glance', 'the extension bundle id'],+ ['IPHONEOS_DEPLOYMENT_TARGET = 17.0', 'the extension deployment target'],+];+const missingPbx = requiredPbx.filter(([needle]) => !pbx.includes(needle));+for (const [needle, what] of missingPbx) fail(`project.pbxproj is missing ${what} (${needle})`);+if (!missingPbx.length) pass('the iOS widget target is wired and embedded');++// The app target compiles the shared half; the extension compiles all of it.+for (const file of [...KIT_APP_FILES, ...WIDGET_FILES, ...kitFiles]) {+ if (!pbx.includes(`/* ${file} in Sources */`)) fail(`${file} is in apple/ but no iOS target compiles it`);+}+for (const file of KIT_APP_FILES) {+ const count = (pbx.match(new RegExp(`/\\* ${file} in Sources \\*/ = `, 'g')) || []).length;+ if (count !== 2) fail(`${file} should be compiled by both iOS targets, found ${count} build files`);+}+pass('every shared source is a member of the iOS targets that need it');++for (const setting of SETTINGS) {+ // Once in each of the app's two configurations and the extension's two.+ const count = (pbx.match(new RegExp(`^\\s*${setting} = `, 'gm')) || []).length;+ if (count !== 4) fail(`${setting} is defined ${count} times in project.pbxproj, expected 4 (both targets, both configurations)`);+}+pass('the iOS project defines the three Glance build settings on both targets');++// ------------------------------------------------------------ macOS project ---++const mac = parseYaml(read('apple/macos/project.yml'));+const macTargets = Object.keys(mac.targets || {});+for (const target of ['ThreeWSGlance', 'GlanceWidget']) {+ if (!macTargets.includes(target)) fail(`apple/macos/project.yml has no ${target} target`);+}+for (const setting of SETTINGS) {+ if (!(setting in (mac.settings?.base || {}))) fail(`apple/macos/project.yml does not define ${setting}`);+}+const macSources = (mac.targets?.GlanceWidget?.sources || []).map((s) => s.path);+if (!macSources.includes('../GlanceWidget') || !macSources.includes('../GlanceKit')) {+ fail('the macOS widget target does not build both apple/GlanceWidget and apple/GlanceKit');+}+const embeds = (mac.targets?.ThreeWSGlance?.dependencies || []).some((d) => d.target === 'GlanceWidget' && d.embed);+if (!embeds) fail('the macOS app does not embed the widget extension');+pass('the macOS project builds and embeds the same sources');++// ---------------------------------------------------- plists and entitlements ---++const plists = [+ ['apple/GlanceWidget/Info.plist', ['GlanceOrigin', 'GlanceAppGroup', 'GlanceKeychainGroup', 'com.apple.widgetkit-extension']],+ ['apple/macos/ThreeWSGlance/Info.plist', ['GlanceOrigin', 'GlanceAppGroup', 'GlanceKeychainGroup', 'threews']],+ ['ios/native/App/App/Info.plist', ['GlanceOrigin', 'GlanceAppGroup', 'GlanceKeychainGroup', 'threews']],+ ['apple/GlanceWidget/GlanceWidget.entitlements', ['application-groups', 'keychain-access-groups']],+ ['apple/macos/ThreeWSGlance/ThreeWSGlance.entitlements', ['application-groups', 'keychain-access-groups']],+ ['ios/native/App/App/App.entitlements', ['application-groups', 'keychain-access-groups']],+];+for (const [file, keys] of plists) {+ const body = read(file);+ for (const key of keys) {+ if (!body.includes(key)) fail(`${file} is missing ${key}`);+ }+ // A plist that names a build setting nothing defines expands to an empty+ // string and the widget silently loses its container.+ for (const [, setting] of body.matchAll(/\$\((GLANCE_[A-Z_]+)\)/g)) {+ if (!SETTINGS.includes(setting)) fail(`${file} expands $(${setting}), which no project defines`);+ }+}+pass(`${plists.length} plists carry the keys the widget reads`);++// ------------------------------------------------------- the wire, both ends ---++const client = read('apple/GlanceKit/GlanceClient.swift');+const card = read('apple/GlanceKit/GlanceCard.swift');+const mine = read('api/glance/mine.js');+const png = read('api/_lib/glance-png.js');+const svg = read('api/_lib/glance-svg.js');+const token = read('api/glance/token.js');++if (!client.includes('api/glance/mine')) fail('the Swift client does not call /api/glance/mine');+for (const param of ['format', 'size', 'theme', 'scale']) {+ if (!client.includes(`name: "${param}"`)) fail(`the Swift client never sends ?${param}, which the server reads`);+}+pass('the Swift client calls the endpoint with the query the server reads');++// Header names, as the server sets them.+const headers = [...mine.matchAll(/setHeader\('(x-glance-[a-z]+)'/g)].map((m) => m[1]);+const usedByClient = headers.filter((h) => client.includes(`"${h}"`));+for (const needed of ['x-glance-state', 'x-glance-url', 'x-glance-name', 'x-glance-metric', 'x-glance-agent', 'x-glance-updated']) {+ if (!headers.includes(needed)) fail(`api/glance/mine.js no longer sets ${needed}, which the widget reads`);+ if (!usedByClient.includes(needed)) fail(`the Swift client no longer reads ${needed}`);+}+pass(`the client reads ${usedByClient.length} of the ${headers.length} headers the server sets`);++// State strings. Every state the server can answer has a Swift case.+const states = [...mine.matchAll(/^\t(\w+): '([a-z-]+)',$/gm)].map((m) => m[2]);+for (const state of states) {+ const cased = card.includes(`= "${state}"`) || card.includes(`case ${state}\n`) || new RegExp(`case ${state}\\b`).test(card);+ if (!cased) fail(`GlanceState has no case for the server state "${state}"`);+}+if (states.length !== 4) fail(`api/glance/mine.js declares ${states.length} states, expected 4`);+pass(`GlanceState covers all ${states.length} server states`);++// Sizes and scales.+const sizes = [...svg.matchAll(/^\t(small|medium|large):/gm)].map((m) => m[1]);+for (const size of sizes) {+ if (!new RegExp(`case ${size}\\b`).test(card)) fail(`GlanceSize has no case for the server size "${size}"`);+}+const scales = (png.match(/GLANCE_PNG_SCALES = \[([^\]]+)\]/) || [, ''])[1]+ .split(',')+ .map((n) => Number(n.trim()));+const swiftScales = [...card.matchAll(/\? (\d) : (\d)/g)].flatMap((m) => [Number(m[1]), Number(m[2])]);+for (const scale of swiftScales) {+ if (!scales.includes(scale)) fail(`the widget asks for scale=${scale}, which the server refuses (accepts ${scales.join(', ')})`);+}+pass(`sizes and scales agree with the server (${sizes.join(', ')} at ${swiftScales.join(' and ')}x)`);++// The deep link, both ends.+const link = read('apple/GlanceKit/GlanceLink.swift');+const appleUrl = (token.match(/return `(threews:\/\/[^`]+)`/) || [, ''])[1];+if (!appleUrl.startsWith('threews://glance/link?token=')) {+ fail(`api/glance/token.js builds an apple link the widget does not recognise: ${appleUrl || 'none'}`);+}+if (!link.includes('static let host = "glance"') || !link.includes('static let path = "/link"')) {+ fail('GlanceLink no longer claims threews://glance/link');+}+const serverPattern = (read('api/_lib/glance-tokens.js').match(/TOKEN_RE = \/\^(.+?)\$\//) || [, ''])[1];+const swiftPattern = (read('apple/GlanceKit/GlanceTokenStore.swift').match(/pattern = "\^(.+?)\$"/) || [, ''])[1];+if (!serverPattern || serverPattern !== swiftPattern) {+ fail(`the token shape differs: server /${serverPattern}/ against Swift /${swiftPattern}/`);+}+pass('the deep link and the token shape match the server');++// ----------------------------------------------------------------- verdict ---++if (problems.length) {+ console.error('');+ for (const problem of problems) console.error(`[apple-widget] FAIL ${problem}`);+ console.error(`\n[apple-widget] ${problems.length} problem(s). See apple/README.md.`);+ process.exit(1);+}+console.log(`[apple-widget] ${checks} checks passed`);diff --git a/tests/glance-tokens.test.js b/tests/glance-tokens.test.jsindex e86537236..bc6ce60ec 100644--- a/tests/glance-tokens.test.js+++ b/tests/glance-tokens.test.js@@ -2,7 +2,7 @@import { describe, it, expect } from 'vitest';import { mintPlaintext, looksLikeGlanceToken, prefixOf, GLANCE_TOKEN_PREFIX } from '../api/_lib/glance-tokens.js';-import { androidLinkUrl, ANDROID_PACKAGE } from '../api/glance/token.js';+import { androidLinkUrl, appleLinkUrl, ANDROID_PACKAGE } from '../api/glance/token.js';describe('glance widget tokens', () => {it('mint a prefixed, url-safe plaintext that the shape check accepts', () => {@@ -29,4 +29,24 @@ describe('glance widget tokens', () => {expect(url).toContain('S.browser_fallback_url=');expect(url).toContain(encodeURIComponent(token));});++ it('hand the token to an Apple app through the scheme both of them register', () => {+ const token = mintPlaintext();+ const url = appleLinkUrl(token);+ // The Mac app and the iPhone app claim this natively (see+ // apple/GlanceKit/GlanceLink.swift and ios/native/App/App/SceneDelegate.swift),+ // so the credential never reaches a web view.+ expect(url.startsWith('threews://glance/link?token=')).toBe(true);+ expect(url).toContain(encodeURIComponent(token));+ expect(new URL(url).searchParams.get('token')).toBe(token);+ });++ it('escape a token into both link URLs rather than pasting it raw', () => {+ // The plaintext is url-safe base64 by construction, so this is a+ // regression guard on the builders and not on the alphabet.+ const hostile = 'glw_' + 'a'.repeat(28) + '&x=1';+ expect(appleLinkUrl(hostile)).toContain(encodeURIComponent(hostile));+ expect(appleLinkUrl(hostile)).not.toContain('&x=1');+ expect(androidLinkUrl(hostile)).toContain(encodeURIComponent(hostile));+ });});