Skip to content

Commit c7003b6

Browse files
authored
[LocalAuthentication] Implement Xcode 16.0 beta 1-6 changes. (#20891)
Note: there were no changes in beta 2, beta 3, beta 4, beta 5 or beta 6.
1 parent 34dfc2c commit c7003b6

12 files changed

+269
-229
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#if !WATCH && !TV
2+
using Foundation;
3+
4+
namespace LocalAuthentication {
5+
public partial class LADomainStateCompanion {
6+
/// <summary>Returns all the companions paired with this device, as a bitmask of <see cref="LACompanionType" />.</summary>
7+
public LACompanionType AvailableCompanionTypes {
8+
get {
9+
var setOfCompanions = WeakAvailableCompanionTypes;
10+
var rv = default (LACompanionType);
11+
foreach (var value in setOfCompanions) {
12+
var companion = (LACompanionType) (long) value.LongValue;
13+
rv |= companion;
14+
}
15+
return rv;
16+
}
17+
}
18+
}
19+
}
20+
#endif // !WATCH && !TV

src/LocalAuthentication/LAEnums.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@ public enum LAPolicy : long {
1313
[MacCatalyst (13, 1)]
1414
DeviceOwnerAuthenticationWithBiometrics = 1,
1515
DeviceOwnerAuthentication = 2,
16+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'DeviceOwnerAuthenticationWithCompanion' instead.")]
1617
[NoiOS]
1718
[NoWatch]
1819
[NoMacCatalyst]
1920
DeviceOwnerAuthenticationWithWatch = 3,
21+
[NoWatch, NoTV, MacCatalyst (18, 0), Mac (15, 0), iOS (18, 0)]
22+
DeviceOwnerAuthenticationWithCompanion = 3,
23+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'DeviceOwnerAuthenticationWithBiometricsOrCompanion' instead.")]
2024
[NoiOS]
2125
[NoWatch]
2226
[NoMacCatalyst]
2327
DeviceOwnerAuthenticationWithBiometricsOrWatch = 4,
28+
[NoWatch, NoTV, MacCatalyst (18, 0), Mac (15, 0), iOS (18, 0)]
29+
DeviceOwnerAuthenticationWithBiometricsOrCompanion = 4,
2430
[Obsolete ("Use DeviceOwnerAuthenticationWithBiometricsOrWatch enum value instead.")]
2531
[NoiOS]
2632
[NoWatch]
@@ -65,6 +71,7 @@ public enum LAStatus : long {
6571
#endif
6672
AppCancel = -9,
6773
InvalidContext = -10,
74+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'CompanionNotAvailable' instead.")]
6875
[NoiOS, NoWatch, NoMacCatalyst]
6976
WatchNotAvailable = -11,
7077
[NoiOS, NoWatch, NoMacCatalyst]
@@ -83,6 +90,8 @@ public enum LAStatus : long {
8390
[MacCatalyst (13, 1)]
8491
BiometryLockout = -8,
8592
NotInteractive = -1004,
93+
[NoWatch]
94+
CompanionNotAvailable = -11,
8695
}
8796

8897
/// <summary>Enumerates local authentication credential types.</summary>

src/frameworks.sources

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,9 @@ JAVASCRIPTCORE_SOURCES = \
11201120
LOCALAUTHENTICATION_API_SOURCES = \
11211121
LocalAuthentication/LAEnums.cs \
11221122

1123+
LOCALAUTHENTICATION_SOURCES = \
1124+
LocalAuthentication/LADomainStateCompanion.cs \
1125+
11231126
# MapKit
11241127

11251128
MAPKIT_API_SOURCES = \

src/localauthentication.cs

Lines changed: 158 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace LocalAuthentication {
1111

1212
/// <summary>Enumerates supported biometric authentication types.</summary>
13-
[NoWatch]
13+
[Watch (11, 0)]
1414
[NoTV]
1515
[MacCatalyst (13, 1)]
1616
[Native]
@@ -77,7 +77,9 @@ interface LAContext {
7777
[Export ("evaluateAccessControl:operation:localizedReason:reply:")]
7878
void EvaluateAccessControl (SecAccessControl accessControl, LAAccessControlOperation operation, string localizedReason, Action<bool, NSError> reply);
7979

80-
80+
[Deprecated (PlatformName.iOS, 18, 0, message: "Use 'LADomainStateBiometry.StateHash' instead.")]
81+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'LADomainStateBiometry.StateHash' instead.")]
82+
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use 'LADomainStateBiometry.StateHash' instead.")]
8183
[MacCatalyst (13, 1)]
8284
[Export ("evaluatedPolicyDomainState")]
8385
[NullAllowed]
@@ -119,6 +121,10 @@ interface LAContext {
119121
[MacCatalyst (13, 1)]
120122
[Export ("biometryType")]
121123
LABiometryType BiometryType { get; }
124+
125+
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), NoWatch]
126+
[Export ("domainState")]
127+
LADomainState DomainState { get; }
122128
}
123129

124130
[Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), NoWatch, NoTV]
@@ -294,4 +300,154 @@ interface LASecret {
294300
[Export ("loadDataWithCompletion:")]
295301
void LoadData (LASecretCompletionHandler handler);
296302
}
303+
304+
[Flags]
305+
[Native]
306+
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0), NoTV]
307+
enum LACompanionType : long {
308+
None = 0,
309+
[NoiOS, NoWatch, NoTV, NoMacCatalyst]
310+
Watch = 1 << 0,
311+
[NoMac, NoWatch, NoTV]
312+
Mac = 1 << 1,
313+
}
314+
315+
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), NoWatch]
316+
[BaseType (typeof (NSObject))]
317+
[DisableDefaultCtor]
318+
interface LADomainStateBiometry {
319+
[Export ("biometryType")]
320+
LABiometryType BiometryType { get; }
321+
322+
[Export ("stateHash"), NullAllowed]
323+
NSData StateHash { get; }
324+
}
325+
326+
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), NoWatch]
327+
[BaseType (typeof (NSObject))]
328+
[DisableDefaultCtor]
329+
interface LADomainStateCompanion {
330+
[Export ("availableCompanionTypes")]
331+
NSSet<NSNumber> WeakAvailableCompanionTypes { get; }
332+
333+
[Export ("stateHash"), NullAllowed]
334+
NSData StateHash { get; }
335+
336+
[Export ("stateHashForCompanionType:")]
337+
[return: NullAllowed]
338+
NSData GetStateHash (LACompanionType companionType);
339+
}
340+
341+
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), NoWatch]
342+
[BaseType (typeof (NSObject))]
343+
[DisableDefaultCtor]
344+
interface LADomainState {
345+
[Export ("biometry")]
346+
LADomainStateBiometry Biometry { get; }
347+
348+
[Export ("companion")]
349+
LADomainStateCompanion Companion { get; }
350+
351+
[Export ("stateHash"), NullAllowed]
352+
NSData StateHash { get; }
353+
}
354+
355+
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
356+
[BaseType (typeof (NSObject))]
357+
[DisableDefaultCtor]
358+
interface LAEnvironment {
359+
[Export ("addObserver:")]
360+
void AddObserver (ILAEnvironmentObserver observer);
361+
362+
[Export ("removeObserver:")]
363+
void RemoveObserver (ILAEnvironmentObserver observer);
364+
365+
[Static]
366+
[Export ("currentUser")]
367+
LAEnvironment CurrentUser { get; }
368+
369+
[Export ("state")]
370+
LAEnvironmentState State { get; }
371+
}
372+
373+
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
374+
[Protocol (BackwardsCompatibleCodeGeneration = false), Model]
375+
[BaseType (typeof (NSObject))]
376+
interface LAEnvironmentObserver {
377+
[Export ("environment:stateDidChangeFromOldState:")]
378+
void StateDidChangeFromOldState (LAEnvironment environment, LAEnvironmentState oldState);
379+
}
380+
381+
interface ILAEnvironmentObserver { }
382+
383+
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
384+
[BaseType (typeof (NSObject))]
385+
[DisableDefaultCtor]
386+
interface LAEnvironmentMechanism {
387+
[Export ("isUsable")]
388+
bool IsUsable { get; }
389+
390+
[Export ("localizedName")]
391+
string LocalizedName { get; }
392+
393+
[Export ("iconSystemName")]
394+
string IconSystemName { get; }
395+
}
396+
397+
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
398+
[BaseType (typeof (LAEnvironmentMechanism))]
399+
[DisableDefaultCtor]
400+
interface LAEnvironmentMechanismBiometry {
401+
[Export ("biometryType")]
402+
LABiometryType BiometryType { get; }
403+
404+
[Export ("isEnrolled")]
405+
bool IsEnrolled { get; }
406+
407+
[Export ("isLockedOut")]
408+
bool IsLockedOut { get; }
409+
410+
[Export ("stateHash")]
411+
NSData StateHash { get; }
412+
413+
[Export ("builtInSensorInaccessible")]
414+
bool BuiltInSensorInaccessible { get; }
415+
}
416+
417+
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
418+
[BaseType (typeof (LAEnvironmentMechanism))]
419+
[DisableDefaultCtor]
420+
interface LAEnvironmentMechanismCompanion {
421+
[Export ("type")]
422+
LACompanionType Type { get; }
423+
424+
[Export ("stateHash"), NullAllowed]
425+
NSData StateHash { get; }
426+
}
427+
428+
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
429+
[BaseType (typeof (LAEnvironmentMechanism))]
430+
[DisableDefaultCtor]
431+
interface LAEnvironmentMechanismUserPassword {
432+
[Export ("isSet")]
433+
bool IsSet { get; }
434+
}
435+
436+
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
437+
[BaseType (typeof (NSObject))]
438+
[DisableDefaultCtor]
439+
interface LAEnvironmentState : NSCopying {
440+
[Export ("biometry"), NullAllowed]
441+
LAEnvironmentMechanismBiometry Biometry { get; }
442+
443+
[Export ("userPassword"), NullAllowed]
444+
LAEnvironmentMechanismUserPassword UserPassword { get; }
445+
446+
[NoWatch]
447+
[Export ("companions")]
448+
LAEnvironmentMechanismCompanion [] Companions { get; }
449+
450+
[Export ("allMechanisms")]
451+
LAEnvironmentMechanism [] AllMechanisms { get; }
452+
}
297453
}

tests/cecil-tests/Documentation.KnownFailures.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13204,11 +13204,16 @@ F:LocalAuthentication.LABiometryType.FaceId
1320413204
F:LocalAuthentication.LABiometryType.None
1320513205
F:LocalAuthentication.LABiometryType.OpticId
1320613206
F:LocalAuthentication.LABiometryType.TouchId
13207+
F:LocalAuthentication.LACompanionType.Mac
13208+
F:LocalAuthentication.LACompanionType.None
13209+
F:LocalAuthentication.LACompanionType.Watch
1320713210
F:LocalAuthentication.LACredentialType.ApplicationPassword
1320813211
F:LocalAuthentication.LACredentialType.SmartCardPin
1320913212
F:LocalAuthentication.LAPolicy.DeviceOwnerAuthentication
1321013213
F:LocalAuthentication.LAPolicy.DeviceOwnerAuthenticationWithBiometrics
13214+
F:LocalAuthentication.LAPolicy.DeviceOwnerAuthenticationWithBiometricsOrCompanion
1321113215
F:LocalAuthentication.LAPolicy.DeviceOwnerAuthenticationWithBiometricsOrWatch
13216+
F:LocalAuthentication.LAPolicy.DeviceOwnerAuthenticationWithCompanion
1321213217
F:LocalAuthentication.LAPolicy.DeviceOwnerAuthenticationWithWatch
1321313218
F:LocalAuthentication.LAPolicy.DeviceOwnerAuthenticationWithWristDetection
1321413219
F:LocalAuthentication.LARightState.Authorized
@@ -13221,6 +13226,7 @@ F:LocalAuthentication.LAStatus.BiometryLockout
1322113226
F:LocalAuthentication.LAStatus.BiometryNotAvailable
1322213227
F:LocalAuthentication.LAStatus.BiometryNotEnrolled
1322313228
F:LocalAuthentication.LAStatus.BiometryNotPaired
13229+
F:LocalAuthentication.LAStatus.CompanionNotAvailable
1322413230
F:LocalAuthentication.LAStatus.InvalidContext
1322513231
F:LocalAuthentication.LAStatus.InvalidDimension
1322613232
F:LocalAuthentication.LAStatus.NotInteractive
@@ -38757,6 +38763,7 @@ M:LinkPresentation.LPMetadataProvider.StartFetchingMetadata(Foundation.NSUrl,Sys
3875738763
M:LinkPresentation.LPMetadataProvider.StartFetchingMetadata(Foundation.NSUrlRequest,System.Action{LinkPresentation.LPLinkMetadata,Foundation.NSError})
3875838764
M:LinkPresentation.LPMetadataProvider.StartFetchingMetadataAsync(Foundation.NSUrl)
3875938765
M:LinkPresentation.LPMetadataProvider.StartFetchingMetadataAsync(Foundation.NSUrlRequest)
38766+
M:LocalAuthentication.ILAEnvironmentObserver.StateDidChangeFromOldState(LocalAuthentication.LAEnvironment,LocalAuthentication.LAEnvironmentState)
3876038767
M:LocalAuthentication.LAAuthenticationRequirement.GetBiometryRequirement(LocalAuthentication.LABiometryFallbackRequirement)
3876138768
M:LocalAuthentication.LAContext.CanEvaluatePolicy(LocalAuthentication.LAPolicy,Foundation.NSError@)
3876238769
M:LocalAuthentication.LAContext.EvaluateAccessControl(Security.SecAccessControl,LocalAuthentication.LAAccessControlOperation,System.String,System.Action{System.Boolean,Foundation.NSError})
@@ -38765,6 +38772,11 @@ M:LocalAuthentication.LAContext.EvaluatePolicyAsync(LocalAuthentication.LAPolicy
3876538772
M:LocalAuthentication.LAContext.Invalidate
3876638773
M:LocalAuthentication.LAContext.IsCredentialSet(LocalAuthentication.LACredentialType)
3876738774
M:LocalAuthentication.LAContext.SetCredentialType(Foundation.NSData,LocalAuthentication.LACredentialType)
38775+
M:LocalAuthentication.LADomainStateCompanion.GetStateHash(LocalAuthentication.LACompanionType)
38776+
M:LocalAuthentication.LAEnvironment.AddObserver(LocalAuthentication.ILAEnvironmentObserver)
38777+
M:LocalAuthentication.LAEnvironment.RemoveObserver(LocalAuthentication.ILAEnvironmentObserver)
38778+
M:LocalAuthentication.LAEnvironmentObserver.StateDidChangeFromOldState(LocalAuthentication.LAEnvironment,LocalAuthentication.LAEnvironmentState)
38779+
M:LocalAuthentication.LAEnvironmentState.Copy(Foundation.NSZone)
3876838780
M:LocalAuthentication.LAPrivateKey.CanDecrypt(Security.SecKeyAlgorithm)
3876938781
M:LocalAuthentication.LAPrivateKey.CanExchangeKeys(Security.SecKeyAlgorithm)
3877038782
M:LocalAuthentication.LAPrivateKey.CanSign(Security.SecKeyAlgorithm)
@@ -68222,6 +68234,7 @@ P:LocalAuthentication.LAAuthenticationRequirement.DefaultRequirement
6822268234
P:LocalAuthentication.LABiometryFallbackRequirement.DefaultRequirement
6822368235
P:LocalAuthentication.LABiometryFallbackRequirement.DevicePasscodeRequirement
6822468236
P:LocalAuthentication.LAContext.BiometryType
68237+
P:LocalAuthentication.LAContext.DomainState
6822568238
P:LocalAuthentication.LAContext.EvaluatedPolicyDomainState
6822668239
P:LocalAuthentication.LAContext.InteractionNotAllowed
6822768240
P:LocalAuthentication.LAContext.LocalizedCancelTitle
@@ -68230,6 +68243,30 @@ P:LocalAuthentication.LAContext.LocalizedReason
6823068243
P:LocalAuthentication.LAContext.MaxBiometryFailures
6823168244
P:LocalAuthentication.LAContext.TouchIdAuthenticationAllowableReuseDuration
6823268245
P:LocalAuthentication.LAContext.TouchIdAuthenticationMaximumAllowableReuseDuration
68246+
P:LocalAuthentication.LADomainState.Biometry
68247+
P:LocalAuthentication.LADomainState.Companion
68248+
P:LocalAuthentication.LADomainState.StateHash
68249+
P:LocalAuthentication.LADomainStateBiometry.BiometryType
68250+
P:LocalAuthentication.LADomainStateBiometry.StateHash
68251+
P:LocalAuthentication.LADomainStateCompanion.StateHash
68252+
P:LocalAuthentication.LADomainStateCompanion.WeakAvailableCompanionTypes
68253+
P:LocalAuthentication.LAEnvironment.CurrentUser
68254+
P:LocalAuthentication.LAEnvironment.State
68255+
P:LocalAuthentication.LAEnvironmentMechanism.IconSystemName
68256+
P:LocalAuthentication.LAEnvironmentMechanism.IsUsable
68257+
P:LocalAuthentication.LAEnvironmentMechanism.LocalizedName
68258+
P:LocalAuthentication.LAEnvironmentMechanismBiometry.BiometryType
68259+
P:LocalAuthentication.LAEnvironmentMechanismBiometry.BuiltInSensorInaccessible
68260+
P:LocalAuthentication.LAEnvironmentMechanismBiometry.IsEnrolled
68261+
P:LocalAuthentication.LAEnvironmentMechanismBiometry.IsLockedOut
68262+
P:LocalAuthentication.LAEnvironmentMechanismBiometry.StateHash
68263+
P:LocalAuthentication.LAEnvironmentMechanismCompanion.StateHash
68264+
P:LocalAuthentication.LAEnvironmentMechanismCompanion.Type
68265+
P:LocalAuthentication.LAEnvironmentMechanismUserPassword.IsSet
68266+
P:LocalAuthentication.LAEnvironmentState.AllMechanisms
68267+
P:LocalAuthentication.LAEnvironmentState.Biometry
68268+
P:LocalAuthentication.LAEnvironmentState.Companions
68269+
P:LocalAuthentication.LAEnvironmentState.UserPassword
6823368270
P:LocalAuthentication.LAPersistedRight.Key
6823468271
P:LocalAuthentication.LAPersistedRight.Secret
6823568272
P:LocalAuthentication.LAPrivateKey.PublicKey
@@ -80723,8 +80760,20 @@ T:LinkPresentation.LPErrorCode
8072380760
T:LinkPresentation.LPLinkMetadata
8072480761
T:LinkPresentation.LPLinkView
8072580762
T:LinkPresentation.LPMetadataProvider
80763+
T:LocalAuthentication.ILAEnvironmentObserver
8072680764
T:LocalAuthentication.LAAuthenticationRequirement
8072780765
T:LocalAuthentication.LABiometryFallbackRequirement
80766+
T:LocalAuthentication.LACompanionType
80767+
T:LocalAuthentication.LADomainState
80768+
T:LocalAuthentication.LADomainStateBiometry
80769+
T:LocalAuthentication.LADomainStateCompanion
80770+
T:LocalAuthentication.LAEnvironment
80771+
T:LocalAuthentication.LAEnvironmentMechanism
80772+
T:LocalAuthentication.LAEnvironmentMechanismBiometry
80773+
T:LocalAuthentication.LAEnvironmentMechanismCompanion
80774+
T:LocalAuthentication.LAEnvironmentMechanismUserPassword
80775+
T:LocalAuthentication.LAEnvironmentObserver
80776+
T:LocalAuthentication.LAEnvironmentState
8072880777
T:LocalAuthentication.LAPersistedRight
8072980778
T:LocalAuthentication.LAPrivateKey
8073080779
T:LocalAuthentication.LAPrivateKeyCompletionHandler
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#if HAS_LOCALAUTHENTICATION
2+
using System;
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
6+
using NUnit.Framework;
7+
8+
using Foundation;
9+
using LocalAuthentication;
10+
11+
namespace MonoTouchFixtures.LocalAuthentication {
12+
13+
[TestFixture]
14+
[Preserve (AllMembers = true)]
15+
public class LADomainStateCompanionTest {
16+
17+
[Test]
18+
public void AvailableCompanionTypes ()
19+
{
20+
TestRuntime.AssertXcodeVersion (16, 0);
21+
22+
using var context = new LAContext ();
23+
Assert.IsNotNull (context.DomainState, "DomainState");
24+
Assert.IsNotNull (context.DomainState.Companion, "DomainState.Companion");
25+
Assert.IsNotNull (context.DomainState.Companion.WeakAvailableCompanionTypes, "DomainState.Companion.WeakAvailableCompanionTypes");
26+
Assert.AreEqual (LACompanionType.None, context.DomainState.Companion.AvailableCompanionTypes, "DomainState.Companion.AvailableCompanionTypes");
27+
}
28+
}
29+
}
30+
#endif // HAS_LOCALAUTHENTICATION

0 commit comments

Comments
 (0)