Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / apple / Passwords / CredentialProvider.swift

CredentialProvider.swift56 lines · 2.8 KiBRaw
1// EverySync Passwords — Credential Provider extension.
2//
3// `ASCredentialProviderViewController` subclass. Reads credentials over XPC
4// from the containing app (App-Group container + `NSFileCoordinator` — see
5// `PasswordsXPCService.swift`); candidate ranking via XCFramework
6// `DomainMatch` — NO Swift matching logic. The extension never touches the
7// relay, never merges, never hashes, never encrypts.
8//
9// Flow:
10// 1. `prepareCredentialList(for:)` — asks the host XPC service for the
11// vault's password/passkey envelopes, projects display rows
12// (service name + username only), and returns matching
13// `ASPasswordCredentialIdentity` items. Matching =
14// `DomainMatch.normalizeSite` + `isSameSiteOrSubdomain` in the XCFramework.
15// 2. `provideCredentialWithoutUserInteraction(for:)` — returns the stored
16// `ASPasswordCredential` for a previously-selected identity.
17// 3. `prepareInterfaceToProvideCredential(for:)` — presents confirmation UI,
18// then provides the credential.
19//
20// MAC-CHECK (needs xcodebuild on a Mac):
21// - Extension target links the same `EverysyncCore.xcframework`.
22// - `com.apple.developer.authentication-services.autofill-credential-provider`
23// entitlement = YES on the extension target only.
24// - Shared Keychain group with the containing app (see
25// `Passwords.entitlements.reference`).
26
27import AuthenticationServices
28import EverysyncCore
29
30/// Autofill extension. All candidates come from the host app over XPC;
31///
32/// `DomainMatch` ranking stays in the XCFramework.
33final class EverySyncCredentialProvider: ASCredentialProviderViewController {
34 /// XPC connection to the containing app's envelope service. The extension
35 /// process cannot assume direct store access, so EVERY read goes through
36 /// `com.vayunmathur.everysync.envelope-ipc` (see `PasswordsXPCService.swift`).
37 private var xpc: NSXPCConnection?
38
39 override func prepareCredentialList(for serviceIdentifiers: [ASCredentialServiceIdentifier]) {
40 // TODO(Mac): open the XPC connection; fetch envelope rows for the
41 // active vault; rank via XCFramework `DomainMatch` over each stored
42 // `websites[]` / `rpId`; reply with matching identities.
43 // No Swift matching logic — call the XCFramework.
44 }
45
46 override func provideCredentialWithoutUserInteraction(for credentialIdentity: ASPasswordCredentialIdentity) {
47 // TODO(Mac): fetch the single envelope by syncId over XPC; reply with
48 // `ASPasswordCredential(user:username, password:password)`.
49 // Never log or cache the secret outside this call.
50 }
51
52 override func prepareInterfaceToProvideCredential(for credentialIdentity: ASPasswordCredentialIdentity) {
53 // TODO(Mac): present confirmation UI (Face ID gate via
54 // `NSFaceIDUsageDescription`), then provide the credential as above.
55 }
56}