-
Notifications
You must be signed in to change notification settings - Fork 514
/
localauthentication.cs
453 lines (361 loc) · 13.8 KB
/
localauthentication.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
using System;
using ObjCRuntime;
using Foundation;
using Security;
#if !NET
using NativeHandle = System.IntPtr;
#endif
namespace LocalAuthentication {
/// <summary>Enumerates supported biometric authentication types.</summary>
[Watch (11, 0)]
[NoTV]
[MacCatalyst (13, 1)]
[Native]
public enum LABiometryType : long {
None,
TouchId,
[MacCatalyst (13, 1)]
FaceId,
#if !NET
[NoMac]
[Obsolete ("Use 'FaceId' instead.")]
TypeFaceId = FaceId,
#endif
[iOS (17, 0), Mac (14, 0), MacCatalyst (17, 0)]
OpticId = 1L << 2,
}
/// <summary>Signature for a function to be invoked in response to a <see cref="M:LocalAuthentication.LAContext.EvaluatePolicy(LocalAuthentication.LAPolicy,System.String,LocalAuthentication.LAContextReplyHandler)" /> invocation.</summary>
/// <remarks>The method when invoked returns a boolean indicating if the policy evaluation was successful, and on failure a detailed description of the error in the error parameter.</remarks>
[MacCatalyst (13, 1)]
delegate void LAContextReplyHandler (bool success, NSError error);
/// <summary>The context in which authentication policies are evaluated.</summary>
///
/// <related type="externalDocumentation" href="https://developer.apple.com/library/ios/documentation/LocalAuthentication/Reference/LAContext_Class/index.html">Apple documentation for <c>LAContext</c></related>
[NoTV] // ".objc_class_name_LAContext", referenced from: '' not found
[MacCatalyst (13, 1)]
[BaseType (typeof (NSObject))]
interface LAContext {
[NoWatch]
[MacCatalyst (13, 1)]
[NullAllowed] // by default this property is null
[Export ("localizedFallbackTitle")]
string LocalizedFallbackTitle { get; set; }
#if !NET
[NoTV]
[Field ("LAErrorDomain")]
NSString ErrorDomain { get; }
#endif
[Export ("canEvaluatePolicy:error:")]
bool CanEvaluatePolicy (LAPolicy policy, out NSError error);
[Async]
[Export ("evaluatePolicy:localizedReason:reply:")]
void EvaluatePolicy (LAPolicy policy, string localizedReason, LAContextReplyHandler reply);
[MacCatalyst (13, 1)]
[Export ("invalidate")]
void Invalidate ();
[MacCatalyst (13, 1)]
[Export ("setCredential:type:")]
bool SetCredentialType ([NullAllowed] NSData credential, LACredentialType type);
[MacCatalyst (13, 1)]
[Export ("isCredentialSet:")]
bool IsCredentialSet (LACredentialType type);
[MacCatalyst (13, 1)]
[Export ("evaluateAccessControl:operation:localizedReason:reply:")]
void EvaluateAccessControl (SecAccessControl accessControl, LAAccessControlOperation operation, string localizedReason, Action<bool, NSError> reply);
[Deprecated (PlatformName.iOS, 18, 0, message: "Use 'LADomainStateBiometry.StateHash' instead.")]
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'LADomainStateBiometry.StateHash' instead.")]
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use 'LADomainStateBiometry.StateHash' instead.")]
[MacCatalyst (13, 1)]
[Export ("evaluatedPolicyDomainState")]
[NullAllowed]
NSData EvaluatedPolicyDomainState { get; }
[NoWatch]
[MacCatalyst (13, 1)]
[NullAllowed, Export ("localizedCancelTitle")]
string LocalizedCancelTitle { get; set; }
[NoWatch]
[MacCatalyst (13, 1)]
[Field ("LATouchIDAuthenticationMaximumAllowableReuseDuration")]
double /* NSTimeInterval */ TouchIdAuthenticationMaximumAllowableReuseDuration { get; }
[MacCatalyst (13, 1)]
[Export ("touchIDAuthenticationAllowableReuseDuration")]
double /* NSTimeInterval */ TouchIdAuthenticationAllowableReuseDuration { get; set; }
[Deprecated (PlatformName.iOS, 9, 0)]
[Deprecated (PlatformName.MacOSX, 10, 11)]
[MacCatalyst (13, 1)]
[Deprecated (PlatformName.MacCatalyst, 13, 1)]
[NullAllowed]
[Export ("maxBiometryFailures")]
NSNumber MaxBiometryFailures { get; set; }
[NoWatch, NoTV]
[MacCatalyst (13, 1)]
[Export ("localizedReason")]
string LocalizedReason { get; set; }
[Watch (9, 0), NoTV]
[MacCatalyst (13, 1)]
[Export ("interactionNotAllowed")]
bool InteractionNotAllowed { get; set; }
[NoWatch]
[MacCatalyst (13, 1)]
[Export ("biometryType")]
LABiometryType BiometryType { get; }
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), NoWatch]
[Export ("domainState")]
LADomainState DomainState { get; }
}
[Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), NoWatch, NoTV]
[BaseType (typeof (LARight))]
[DisableDefaultCtor]
interface LAPersistedRight {
[Export ("key")]
LAPrivateKey Key { get; }
[Export ("secret")]
LASecret Secret { get; }
}
delegate void LAPrivateKeyCompletionHandler ([NullAllowed] NSData data, [NullAllowed] NSError error);
[Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), NoWatch, NoTV]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface LAPrivateKey {
[Export ("publicKey")]
LAPublicKey PublicKey { get; }
[Async]
[Export ("signData:secKeyAlgorithm:completion:")]
void Sign (NSData data, SecKeyAlgorithm algorithm, LAPrivateKeyCompletionHandler handler);
[Export ("canSignUsingSecKeyAlgorithm:")]
bool CanSign (SecKeyAlgorithm algorithm);
[Async]
[Export ("decryptData:secKeyAlgorithm:completion:")]
void Decrypt (NSData data, SecKeyAlgorithm algorithm, LAPrivateKeyCompletionHandler handler);
[Export ("canDecryptUsingSecKeyAlgorithm:")]
bool CanDecrypt (SecKeyAlgorithm algorithm);
[Async]
[Export ("exchangeKeysWithPublicKey:secKeyAlgorithm:secKeyParameters:completion:")]
void ExchangeKeys (NSData publicKey, SecKeyAlgorithm algorithm, NSDictionary parameters, LAPrivateKeyCompletionHandler handler);
[Export ("canExchangeKeysUsingSecKeyAlgorithm:")]
bool CanExchangeKeys (SecKeyAlgorithm algorithm);
}
delegate void LAPublicKeyCompletionHandler ([NullAllowed] NSData data, [NullAllowed] NSError error);
delegate void LAPublicKeyVerifyDataCompletionHandler ([NullAllowed] NSError error);
[Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), NoWatch, NoTV]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface LAPublicKey {
[Async]
[Export ("exportBytesWithCompletion:")]
void ExportBytes (LAPublicKeyCompletionHandler handler);
[Async]
[Export ("encryptData:secKeyAlgorithm:completion:")]
void Encrypt (NSData data, SecKeyAlgorithm algorithm, LAPublicKeyCompletionHandler handler);
[Export ("canEncryptUsingSecKeyAlgorithm:")]
bool CanEncrypt (SecKeyAlgorithm algorithm);
[Async]
[Export ("verifyData:signature:secKeyAlgorithm:completion:")]
void Verify (NSData signedData, NSData signature, SecKeyAlgorithm algorithm, LAPublicKeyVerifyDataCompletionHandler handler);
[Export ("canVerifyUsingSecKeyAlgorithm:")]
bool CanVerify (SecKeyAlgorithm algorithm);
}
[Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), NoWatch, NoTV]
[BaseType (typeof (NSObject))]
interface LAAuthenticationRequirement {
[Static]
[Export ("defaultRequirement")]
LAAuthenticationRequirement DefaultRequirement { get; }
[Static]
[Export ("biometryRequirement")]
LAAuthenticationRequirement BiometryRequirement { get; }
[Static]
[Export ("biometryCurrentSetRequirement")]
LAAuthenticationRequirement BiometryCurrentSetRequirement { get; }
[Static]
[Export ("biometryRequirementWithFallback:")]
LAAuthenticationRequirement GetBiometryRequirement (LABiometryFallbackRequirement fallback);
}
[Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), NoWatch, NoTV]
[BaseType (typeof (NSObject))]
interface LABiometryFallbackRequirement {
[Static]
[Export ("defaultRequirement")]
LABiometryFallbackRequirement DefaultRequirement { get; }
[Static]
[Export ("devicePasscodeRequirement")]
LABiometryFallbackRequirement DevicePasscodeRequirement { get; }
}
delegate void LARightAuthorizeCompletionHandler ([NullAllowed] NSError error);
[Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), NoWatch, NoTV]
[BaseType (typeof (NSObject))]
interface LARight {
[Export ("state")]
LARightState State { get; }
[Export ("tag")]
nint Tag { get; set; }
[Export ("initWithRequirement:")]
NativeHandle Constructor (LAAuthenticationRequirement requirement);
[Async]
[Export ("authorizeWithLocalizedReason:completion:")]
void Authorize (string localizedReason, LARightAuthorizeCompletionHandler handler);
[Async]
[Export ("checkCanAuthorizeWithCompletion:")]
void CheckCanAuthorize (LARightAuthorizeCompletionHandler handler);
[Async]
[Export ("deauthorizeWithCompletion:")]
void Deauthorize (Action handler);
}
delegate void LARightStoreCompletionHandler ([NullAllowed] LAPersistedRight right, [NullAllowed] NSError error);
delegate void LARightStoreRemoveRightCompletionHandler ([NullAllowed] NSError error);
[Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), NoWatch, NoTV]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface LARightStore {
[Static]
[Export ("sharedStore")]
LARightStore SharedStore { get; }
[Async]
[Export ("rightForIdentifier:completion:")]
void Get (string identifier, LARightStoreCompletionHandler handler);
[Async]
[Export ("saveRight:identifier:completion:")]
void Save (LARight right, string identifier, LARightStoreCompletionHandler handler);
[Async]
[Export ("saveRight:identifier:secret:completion:")]
void Save (LARight right, string identifier, NSData secret, LARightStoreCompletionHandler handler);
[Async]
[Export ("removeRight:completion:")]
void Remove (LAPersistedRight right, LARightStoreRemoveRightCompletionHandler handler);
[Async]
[Export ("removeRightForIdentifier:completion:")]
void Remove (string identifier, LARightStoreRemoveRightCompletionHandler handler);
[Async]
[Export ("removeAllRightsWithCompletion:")]
void RemoveAll (LARightStoreRemoveRightCompletionHandler handler);
}
delegate void LASecretCompletionHandler ([NullAllowed] NSData data, [NullAllowed] NSError error);
[Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), NoWatch, NoTV]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface LASecret {
[Async]
[Export ("loadDataWithCompletion:")]
void LoadData (LASecretCompletionHandler handler);
}
[Flags]
[Native]
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0), NoTV]
enum LACompanionType : long {
None = 0,
[NoiOS, NoWatch, NoTV, NoMacCatalyst]
Watch = 1 << 0,
[NoMac, NoWatch, NoTV]
Mac = 1 << 1,
}
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), NoWatch]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface LADomainStateBiometry {
[Export ("biometryType")]
LABiometryType BiometryType { get; }
[Export ("stateHash"), NullAllowed]
NSData StateHash { get; }
}
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), NoWatch]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface LADomainStateCompanion {
[Export ("availableCompanionTypes")]
NSSet<NSNumber> WeakAvailableCompanionTypes { get; }
[Export ("stateHash"), NullAllowed]
NSData StateHash { get; }
[Export ("stateHashForCompanionType:")]
[return: NullAllowed]
NSData GetStateHash (LACompanionType companionType);
}
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), NoWatch]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface LADomainState {
[Export ("biometry")]
LADomainStateBiometry Biometry { get; }
[Export ("companion")]
LADomainStateCompanion Companion { get; }
[Export ("stateHash"), NullAllowed]
NSData StateHash { get; }
}
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface LAEnvironment {
[Export ("addObserver:")]
void AddObserver (ILAEnvironmentObserver observer);
[Export ("removeObserver:")]
void RemoveObserver (ILAEnvironmentObserver observer);
[Static]
[Export ("currentUser")]
LAEnvironment CurrentUser { get; }
[Export ("state")]
LAEnvironmentState State { get; }
}
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
[Protocol (BackwardsCompatibleCodeGeneration = false), Model]
[BaseType (typeof (NSObject))]
interface LAEnvironmentObserver {
[Export ("environment:stateDidChangeFromOldState:")]
void StateDidChangeFromOldState (LAEnvironment environment, LAEnvironmentState oldState);
}
interface ILAEnvironmentObserver { }
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface LAEnvironmentMechanism {
[Export ("isUsable")]
bool IsUsable { get; }
[Export ("localizedName")]
string LocalizedName { get; }
[Export ("iconSystemName")]
string IconSystemName { get; }
}
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
[BaseType (typeof (LAEnvironmentMechanism))]
[DisableDefaultCtor]
interface LAEnvironmentMechanismBiometry {
[Export ("biometryType")]
LABiometryType BiometryType { get; }
[Export ("isEnrolled")]
bool IsEnrolled { get; }
[Export ("isLockedOut")]
bool IsLockedOut { get; }
[Export ("stateHash")]
NSData StateHash { get; }
[Export ("builtInSensorInaccessible")]
bool BuiltInSensorInaccessible { get; }
}
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
[BaseType (typeof (LAEnvironmentMechanism))]
[DisableDefaultCtor]
interface LAEnvironmentMechanismCompanion {
[Export ("type")]
LACompanionType Type { get; }
[Export ("stateHash"), NullAllowed]
NSData StateHash { get; }
}
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
[BaseType (typeof (LAEnvironmentMechanism))]
[DisableDefaultCtor]
interface LAEnvironmentMechanismUserPassword {
[Export ("isSet")]
bool IsSet { get; }
}
[Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), Watch (11, 0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface LAEnvironmentState : NSCopying {
[Export ("biometry"), NullAllowed]
LAEnvironmentMechanismBiometry Biometry { get; }
[Export ("userPassword"), NullAllowed]
LAEnvironmentMechanismUserPassword UserPassword { get; }
[NoWatch]
[Export ("companions")]
LAEnvironmentMechanismCompanion [] Companions { get; }
[Export ("allMechanisms")]
LAEnvironmentMechanism [] AllMechanisms { get; }
}
}