objc2_crypto_token_kit/generated/
TKToken.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-security")]
8use objc2_security::*;
9
10use crate::*;
11
12/// TKTokenObjectID Unique and persistent identification of objects on the token.
13///
14/// Uniquely and persistently identifies objects (keys and certificates) present on the token.  Type of this identifier must be compatible with plist and its format is defined by the implementation of token extension.
15///
16/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenobjectid?language=objc)
17pub type TKTokenObjectID = AnyObject;
18
19/// TKTokenInstanceID Unique, persistent identifier of this token in the form of string.
20///
21/// InstanceID is Typically implemented by some kind of serial number of the target hardware, for example SmartCard serial number.
22///
23/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokeninstanceid?language=objc)
24pub type TKTokenInstanceID = NSString;
25
26/// TKTokenDriverClassID ClassID of the token driver.
27///
28/// Identical with
29/// `com.apple.ctk.class-id`token extension attribute. Typically in the RDN form (com.company.id).
30///
31/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokendriverclassid?language=objc)
32pub type TKTokenDriverClassID = NSString;
33
34/// [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenoperation?language=objc)
35// NS_ENUM
36#[repr(transparent)]
37#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
38pub struct TKTokenOperation(pub NSInteger);
39impl TKTokenOperation {
40    #[doc(alias = "TKTokenOperationNone")]
41    pub const None: Self = Self(0);
42    /// Reading of raw data of certificate.
43    #[doc(alias = "TKTokenOperationReadData")]
44    pub const ReadData: Self = Self(1);
45    /// Cryptographic signature using private key.
46    #[doc(alias = "TKTokenOperationSignData")]
47    pub const SignData: Self = Self(2);
48    /// Decrypting data using private key.
49    #[doc(alias = "TKTokenOperationDecryptData")]
50    pub const DecryptData: Self = Self(3);
51    /// Performing Diffie-Hellman style of cryptographic key exchange using private key.
52    #[doc(alias = "TKTokenOperationPerformKeyExchange")]
53    pub const PerformKeyExchange: Self = Self(4);
54}
55
56unsafe impl Encode for TKTokenOperation {
57    const ENCODING: Encoding = NSInteger::ENCODING;
58}
59
60unsafe impl RefEncode for TKTokenOperation {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64/// TKTokenOperationConstraint represents authentication constraint of token object for specific token operation.
65///
66/// Persistently identifies constraint for performing specific operation on specific object.  Value of constraint can be either:
67/// -
68/// `true`: the operation is always allowed without any authentication needed
69/// -
70/// `false`: the operation is never allowed, typically not implemented
71/// - any other plist-compatible value: defined by the token extension implementation.  Such constraint is opaque to the system and is required to stay constant for the given object during the whole token's lifetime.  For example, SmartCard token extension might decide to use string 'PIN' to indicate that the operation is protected by presenting valid PIN to the card first.
72///
73/// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenoperationconstraint?language=objc)
74pub type TKTokenOperationConstraint = AnyObject;
75
76extern_class!(
77    /// TKTokenKeyAlgorithm Encapsulates cryptographic algorithm, possibly with additional associated required algorithms.
78    ///
79    /// An algorithm supported by a key can be usually described by one value of
80    /// `SecKeyAlgorithm`enumeration.  However, some tokens (notably smartcards) require that input data for the operation are in generic format, but that generic format must be formatted according to some more specific algorithm.  An example for this would be token accepting raw data for cryptographic signature but requiring that raw data are formatted according to PKCS1 padding rules.  To express such requirement, TKTokenKeyAlgorithm defines target algorithm (
81    /// `kSecKeyAlgorithmRSASignatureRaw`in our example) and a set of other algorithms which were used (continuing example above,
82    /// `kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA1`will be reported as supported).
83    ///
84    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenkeyalgorithm?language=objc)
85    #[unsafe(super(NSObject))]
86    #[derive(Debug, PartialEq, Eq, Hash)]
87    pub struct TKTokenKeyAlgorithm;
88);
89
90extern_conformance!(
91    unsafe impl NSObjectProtocol for TKTokenKeyAlgorithm {}
92);
93
94impl TKTokenKeyAlgorithm {
95    extern_methods!(
96        #[unsafe(method(init))]
97        #[unsafe(method_family = init)]
98        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
99
100        #[cfg(feature = "objc2-security")]
101        /// Checks if specified algorithm is base operation algorithm.
102        #[unsafe(method(isAlgorithm:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn isAlgorithm(&self, algorithm: &SecKeyAlgorithm) -> bool;
105
106        #[cfg(feature = "objc2-security")]
107        /// Checks whether specified algorithm is either target algorithm or one of the algorithms through which the operation passed.
108        #[unsafe(method(supportsAlgorithm:))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn supportsAlgorithm(&self, algorithm: &SecKeyAlgorithm) -> bool;
111    );
112}
113
114/// Methods declared on superclass `NSObject`.
115impl TKTokenKeyAlgorithm {
116    extern_methods!(
117        #[unsafe(method(new))]
118        #[unsafe(method_family = new)]
119        pub unsafe fn new() -> Retained<Self>;
120    );
121}
122
123extern_class!(
124    /// TKTokenKeyExchangeParameters Encapsulates parameters needed for performing specific Key Exchange operation types.
125    ///
126    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenkeyexchangeparameters?language=objc)
127    #[unsafe(super(NSObject))]
128    #[derive(Debug, PartialEq, Eq, Hash)]
129    pub struct TKTokenKeyExchangeParameters;
130);
131
132extern_conformance!(
133    unsafe impl NSObjectProtocol for TKTokenKeyExchangeParameters {}
134);
135
136impl TKTokenKeyExchangeParameters {
137    extern_methods!(
138        /// Requested output size of key exchange result.  Should be ignored if output size is not configurable for specified key exchange algorithm.
139        #[unsafe(method(requestedSize))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn requestedSize(&self) -> NSInteger;
142
143        /// Additional shared information input, typically used for key derivation (KDF) step of key exchange algorithm.  Should be ignored if shared info is not used for specified key exchange algorithm.
144        #[unsafe(method(sharedInfo))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn sharedInfo(&self) -> Option<Retained<NSData>>;
147    );
148}
149
150/// Methods declared on superclass `NSObject`.
151impl TKTokenKeyExchangeParameters {
152    extern_methods!(
153        #[unsafe(method(init))]
154        #[unsafe(method_family = init)]
155        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
156
157        #[unsafe(method(new))]
158        #[unsafe(method_family = new)]
159        pub unsafe fn new() -> Retained<Self>;
160    );
161}
162
163extern_class!(
164    /// TKTokenSession represents token session which shares authentication status.
165    ///
166    /// Token implementation must inherit its own session implementation from TKTokenSession (or its subclass TKSmartCardTokenSession in case of SmartCard tokens).
167    ///
168    /// TKTokenSession should keep an authentication state of the token.  Authentication status (e.g. entered PIN to unlock SmartCard) should not be shared across borders of single TKTokenSession instance.
169    ///
170    /// TKTokenSession is always instantiated by TKToken when framework detects access to the token from new authentication session.
171    ///
172    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokensession?language=objc)
173    #[unsafe(super(NSObject))]
174    #[derive(Debug, PartialEq, Eq, Hash)]
175    pub struct TKTokenSession;
176);
177
178extern_conformance!(
179    unsafe impl NSObjectProtocol for TKTokenSession {}
180);
181
182impl TKTokenSession {
183    extern_methods!(
184        /// Parameter `token`: Token instance to which is this session instance bound.
185        #[unsafe(method(initWithToken:))]
186        #[unsafe(method_family = init)]
187        pub unsafe fn initWithToken(this: Allocated<Self>, token: &TKToken) -> Retained<Self>;
188
189        #[unsafe(method(token))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn token(&self) -> Retained<TKToken>;
192
193        #[unsafe(method(delegate))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn delegate(
196            &self,
197        ) -> Option<Retained<ProtocolObject<dyn TKTokenSessionDelegate>>>;
198
199        /// Setter for [`delegate`][Self::delegate].
200        ///
201        /// This is a [weak property][objc2::topics::weak_property].
202        #[unsafe(method(setDelegate:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn setDelegate(
205            &self,
206            delegate: Option<&ProtocolObject<dyn TKTokenSessionDelegate>>,
207        );
208
209        #[unsafe(method(init))]
210        #[unsafe(method_family = init)]
211        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
212    );
213}
214
215/// Methods declared on superclass `NSObject`.
216impl TKTokenSession {
217    extern_methods!(
218        #[unsafe(method(new))]
219        #[unsafe(method_family = new)]
220        pub unsafe fn new() -> Retained<Self>;
221    );
222}
223
224extern_protocol!(
225    /// TKTokenSessionDelegate contains operations with token objects provided by token implementors which should be performed in the context of authentication session.
226    ///
227    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokensessiondelegate?language=objc)
228    pub unsafe trait TKTokenSessionDelegate: NSObjectProtocol {
229        /// Establishes a context for the requested authentication operation.
230        ///
231        /// Parameter `session`: Related TKTokenSession instance.
232        ///
233        /// Parameter `operation`: Identifier of the operation.
234        ///
235        /// Parameter `constraint`: Constraint to be satisfied by this authentication operation.
236        ///
237        /// Parameter `error`: Error details (see TKError.h).
238        ///
239        /// Returns: authOperation Resulting context of the operation, which will be eventually finalized by receiving 'finishWithError:'.  The resulting 'authOperation' can be of any type based on TKTokenAuthOperation. For known types (e.g. TKTokenPasswordAuthOperation) the system will first fill in the context-specific properties (e.g. 'password') before triggering 'finishWithError:'. When no authentication is actually needed (typically because the session is already authenticated for requested constraint), return instance of TKTokenAuthOperation class instead of any specific subclass.
240        ///
241        /// # Safety
242        ///
243        /// `constraint` should be of the correct type.
244        #[optional]
245        #[unsafe(method(tokenSession:beginAuthForOperation:constraint:error:_))]
246        #[unsafe(method_family = none)]
247        unsafe fn tokenSession_beginAuthForOperation_constraint_error(
248            &self,
249            session: &TKTokenSession,
250            operation: TKTokenOperation,
251            constraint: &TKTokenOperationConstraint,
252        ) -> Result<Retained<TKTokenAuthOperation>, Retained<NSError>>;
253
254        /// Checks whether specified operation and algorithm is supported on specified key.
255        ///
256        /// Parameter `session`: Related TKTokenSession instance.
257        ///
258        /// Parameter `operation`: Type of cryptographic operation for which the list of supported algorithms should be retrieved.
259        ///
260        /// Parameter `keyObjectID`: Identifier of the private key object.
261        ///
262        /// Parameter `algorithm`: Algorithm with which the oepration should be performed.
263        ///
264        /// Returns: YES if the operation is supported, NO otherwise.
265        ///
266        /// # Safety
267        ///
268        /// `key_object_id` should be of the correct type.
269        #[optional]
270        #[unsafe(method(tokenSession:supportsOperation:usingKey:algorithm:))]
271        #[unsafe(method_family = none)]
272        unsafe fn tokenSession_supportsOperation_usingKey_algorithm(
273            &self,
274            session: &TKTokenSession,
275            operation: TKTokenOperation,
276            key_object_id: &TKTokenObjectID,
277            algorithm: &TKTokenKeyAlgorithm,
278        ) -> bool;
279
280        /// Performs cryptographic signature operation.
281        ///
282        /// Parameter `session`: Related TKTokenSession instance.
283        ///
284        /// Parameter `dataToSign`: Input data for the signature operation.
285        ///
286        /// Parameter `keyObjectID`: Identifier of the private key object.
287        ///
288        /// Parameter `algorithm`: Requested signature algorithm to be used.
289        ///
290        /// Parameter `error`: Error details (see TKError.h).  If authentication is required (by invoking beginAuthForOperation:),
291        /// `TKErrorCodeAuthenticationNeeded`should be used.
292        ///
293        /// Returns: Resulting signature, or nil if an error happened.
294        ///
295        /// # Safety
296        ///
297        /// `key_object_id` should be of the correct type.
298        #[optional]
299        #[unsafe(method(tokenSession:signData:usingKey:algorithm:error:_))]
300        #[unsafe(method_family = none)]
301        unsafe fn tokenSession_signData_usingKey_algorithm_error(
302            &self,
303            session: &TKTokenSession,
304            data_to_sign: &NSData,
305            key_object_id: &TKTokenObjectID,
306            algorithm: &TKTokenKeyAlgorithm,
307        ) -> Result<Retained<NSData>, Retained<NSError>>;
308
309        /// Decrypts ciphertext using private key.
310        ///
311        /// Parameter `session`: Related TKTokenSession instance.
312        ///
313        /// Parameter `ciphertext`: Encrypted data to decrypt.
314        ///
315        /// Parameter `keyObjectID`: Identifier of the private key object.
316        ///
317        /// Parameter `algorithm`: Requested encryption/decryption algorithm to be used.
318        ///
319        /// Parameter `error`: Error details (see TKError.h).  If authentication is required (by invoking beginAuthForOperation:),
320        /// `TKErrorCodeAuthenticationNeeded`should be used.
321        ///
322        /// Returns: Resulting decrypted plaintext, or nil if an error happened.
323        ///
324        /// # Safety
325        ///
326        /// `key_object_id` should be of the correct type.
327        #[optional]
328        #[unsafe(method(tokenSession:decryptData:usingKey:algorithm:error:_))]
329        #[unsafe(method_family = none)]
330        unsafe fn tokenSession_decryptData_usingKey_algorithm_error(
331            &self,
332            session: &TKTokenSession,
333            ciphertext: &NSData,
334            key_object_id: &TKTokenObjectID,
335            algorithm: &TKTokenKeyAlgorithm,
336        ) -> Result<Retained<NSData>, Retained<NSError>>;
337
338        /// Performs Diffie-Hellman style key exchange operation.
339        ///
340        /// Parameter `session`: Related TKTokenSession instance.
341        ///
342        /// Parameter `otherPartyPublicKeyData`: Raw public data of other party public key.
343        ///
344        /// Parameter `objectID`: Identifier of the private key object.
345        ///
346        /// Parameter `algorithm`: Requested key exchange algorithm to be used.
347        ///
348        /// Parameter `parameters`: Additional parameters for key exchange operation.  Chosen algorithm dictates meaning of parameters.
349        ///
350        /// Parameter `error`: Error details (see TKError.h).  If authentication is required (by invoking beginAuthForOperation:),
351        /// `TKErrorCodeAuthenticationNeeded`should be used.
352        ///
353        /// Returns: Result of key exchange operation, or nil if the operation failed.
354        ///
355        /// # Safety
356        ///
357        /// `object_id` should be of the correct type.
358        #[optional]
359        #[unsafe(method(tokenSession:performKeyExchangeWithPublicKey:usingKey:algorithm:parameters:error:_))]
360        #[unsafe(method_family = none)]
361        unsafe fn tokenSession_performKeyExchangeWithPublicKey_usingKey_algorithm_parameters_error(
362            &self,
363            session: &TKTokenSession,
364            other_party_public_key_data: &NSData,
365            object_id: &TKTokenObjectID,
366            algorithm: &TKTokenKeyAlgorithm,
367            parameters: &TKTokenKeyExchangeParameters,
368        ) -> Result<Retained<NSData>, Retained<NSError>>;
369    }
370);
371
372extern_class!(
373    /// Class representing single token.  When implementing SmartCard based token, it is recommended to inherit the implementation from TKSmartCardToken.  Token object serves as synchronization point, all operations invoked upon token and all its sessions are serialized.
374    ///
375    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktoken?language=objc)
376    #[unsafe(super(NSObject))]
377    #[derive(Debug, PartialEq, Eq, Hash)]
378    pub struct TKToken;
379);
380
381extern_conformance!(
382    unsafe impl NSObjectProtocol for TKToken {}
383);
384
385impl TKToken {
386    extern_methods!(
387        /// Initializes token instance
388        ///
389        /// Parameter `tokenDriver`: Creating token driver.
390        ///
391        /// Parameter `instanceID`: Unique, persistent identifier of this token.
392        #[unsafe(method(initWithTokenDriver:instanceID:))]
393        #[unsafe(method_family = init)]
394        pub unsafe fn initWithTokenDriver_instanceID(
395            this: Allocated<Self>,
396            token_driver: &TKTokenDriver,
397            instance_id: &TKTokenInstanceID,
398        ) -> Retained<Self>;
399
400        #[unsafe(method(tokenDriver))]
401        #[unsafe(method_family = none)]
402        pub unsafe fn tokenDriver(&self) -> Retained<TKTokenDriver>;
403
404        #[unsafe(method(delegate))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn TKTokenDelegate>>>;
407
408        /// Setter for [`delegate`][Self::delegate].
409        ///
410        /// This is a [weak property][objc2::topics::weak_property].
411        #[unsafe(method(setDelegate:))]
412        #[unsafe(method_family = none)]
413        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn TKTokenDelegate>>);
414
415        #[cfg(feature = "TKTokenConfiguration")]
416        /// Token configuration associated with this token instance.
417        #[unsafe(method(configuration))]
418        #[unsafe(method_family = none)]
419        pub unsafe fn configuration(&self) -> Retained<TKTokenConfiguration>;
420
421        #[cfg(feature = "TKTokenKeychainItem")]
422        /// Keychain contents (certificate and key items) representing this token.
423        #[unsafe(method(keychainContents))]
424        #[unsafe(method_family = none)]
425        pub unsafe fn keychainContents(&self) -> Option<Retained<TKTokenKeychainContents>>;
426
427        #[unsafe(method(init))]
428        #[unsafe(method_family = init)]
429        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
430    );
431}
432
433/// Methods declared on superclass `NSObject`.
434impl TKToken {
435    extern_methods!(
436        #[unsafe(method(new))]
437        #[unsafe(method_family = new)]
438        pub unsafe fn new() -> Retained<Self>;
439    );
440}
441
442extern_protocol!(
443    /// TKTokenDelegate contains operations implementing functionality of token class.
444    ///
445    /// TKTokenDelegate represents protocol which must be implemented by token implementors' class representing token.  Apart from being able to identify itself with its unique identifier, and must be able to establish new TKTokenSession when requested.
446    ///
447    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokendelegate?language=objc)
448    pub unsafe trait TKTokenDelegate: NSObjectProtocol {
449        /// Create new session instance
450        ///
451        /// All operations with objects on the token are performed inside TKTokenSession which represent authentication context.  This method is called whenever new authentication context is needed (typically when client application wants to perform token operation using keychain object which has associated LocalAuthentication LAContext which was not yet seen by this token instance).
452        ///
453        /// Parameter `token`: Related token instance.
454        #[unsafe(method(token:createSessionWithError:_))]
455        #[unsafe(method_family = none)]
456        unsafe fn token_createSessionWithError(
457            &self,
458            token: &TKToken,
459        ) -> Result<Retained<TKTokenSession>, Retained<NSError>>;
460
461        /// Terminates previously created session, implementation should free all associated resources.
462        ///
463        /// Parameter `token`: Related token instance.
464        #[optional]
465        #[unsafe(method(token:terminateSession:))]
466        #[unsafe(method_family = none)]
467        unsafe fn token_terminateSession(&self, token: &TKToken, session: &TKTokenSession);
468    }
469);
470
471extern_class!(
472    /// Base class for token drivers.  SmartCard token drivers should use TKSmartCardTokenDriver subclass.
473    ///
474    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokendriver?language=objc)
475    #[unsafe(super(NSObject))]
476    #[derive(Debug, PartialEq, Eq, Hash)]
477    pub struct TKTokenDriver;
478);
479
480extern_conformance!(
481    unsafe impl NSObjectProtocol for TKTokenDriver {}
482);
483
484impl TKTokenDriver {
485    extern_methods!(
486        #[unsafe(method(delegate))]
487        #[unsafe(method_family = none)]
488        pub unsafe fn delegate(
489            &self,
490        ) -> Option<Retained<ProtocolObject<dyn TKTokenDriverDelegate>>>;
491
492        /// Setter for [`delegate`][Self::delegate].
493        ///
494        /// This is a [weak property][objc2::topics::weak_property].
495        #[unsafe(method(setDelegate:))]
496        #[unsafe(method_family = none)]
497        pub unsafe fn setDelegate(
498            &self,
499            delegate: Option<&ProtocolObject<dyn TKTokenDriverDelegate>>,
500        );
501    );
502}
503
504/// Methods declared on superclass `NSObject`.
505impl TKTokenDriver {
506    extern_methods!(
507        #[unsafe(method(init))]
508        #[unsafe(method_family = init)]
509        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
510
511        #[unsafe(method(new))]
512        #[unsafe(method_family = new)]
513        pub unsafe fn new() -> Retained<Self>;
514    );
515}
516
517extern_protocol!(
518    /// Delegate for customizing token driver operations.  SmartCard tokens should implement TKSmartCardTokenDriverDelegate instead of this base protocol.
519    ///
520    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokendriverdelegate?language=objc)
521    pub unsafe trait TKTokenDriverDelegate: NSObjectProtocol {
522        #[cfg(feature = "TKTokenConfiguration")]
523        /// Creates new token for specified configuration. SmartCard token drivers should not implement this method.
524        #[optional]
525        #[unsafe(method(tokenDriver:tokenForConfiguration:error:_))]
526        #[unsafe(method_family = none)]
527        unsafe fn tokenDriver_tokenForConfiguration_error(
528            &self,
529            driver: &TKTokenDriver,
530            configuration: &TKTokenConfiguration,
531        ) -> Result<Retained<TKToken>, Retained<NSError>>;
532
533        /// Terminates previously created token, should release all resources associated with it.
534        #[optional]
535        #[unsafe(method(tokenDriver:terminateToken:))]
536        #[unsafe(method_family = none)]
537        unsafe fn tokenDriver_terminateToken(&self, driver: &TKTokenDriver, token: &TKToken);
538    }
539);
540
541extern_class!(
542    /// Context of a pending authentication operation.
543    ///
544    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenauthoperation?language=objc)
545    #[unsafe(super(NSObject))]
546    #[derive(Debug, PartialEq, Eq, Hash)]
547    pub struct TKTokenAuthOperation;
548);
549
550extern_conformance!(
551    unsafe impl NSCoding for TKTokenAuthOperation {}
552);
553
554extern_conformance!(
555    unsafe impl NSObjectProtocol for TKTokenAuthOperation {}
556);
557
558extern_conformance!(
559    unsafe impl NSSecureCoding for TKTokenAuthOperation {}
560);
561
562impl TKTokenAuthOperation {
563    extern_methods!(
564        /// Handler triggered by the system in order to let the token finalize the authentication operation.
565        ///
566        /// Parameter `error`: Error details (see TKError.h).
567        ///
568        /// Returns: Finalization status.
569        #[unsafe(method(finishWithError:_))]
570        #[unsafe(method_family = none)]
571        pub unsafe fn finishWithError(&self) -> Result<(), Retained<NSError>>;
572    );
573}
574
575/// Methods declared on superclass `NSObject`.
576impl TKTokenAuthOperation {
577    extern_methods!(
578        #[unsafe(method(init))]
579        #[unsafe(method_family = init)]
580        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
581
582        #[unsafe(method(new))]
583        #[unsafe(method_family = new)]
584        pub unsafe fn new() -> Retained<Self>;
585    );
586}
587
588extern_class!(
589    /// Context of a password authentication operation.
590    ///
591    /// See also [Apple's documentation](https://developer.apple.com/documentation/cryptotokenkit/tktokenpasswordauthoperation?language=objc)
592    #[unsafe(super(TKTokenAuthOperation, NSObject))]
593    #[derive(Debug, PartialEq, Eq, Hash)]
594    pub struct TKTokenPasswordAuthOperation;
595);
596
597extern_conformance!(
598    unsafe impl NSCoding for TKTokenPasswordAuthOperation {}
599);
600
601extern_conformance!(
602    unsafe impl NSObjectProtocol for TKTokenPasswordAuthOperation {}
603);
604
605extern_conformance!(
606    unsafe impl NSSecureCoding for TKTokenPasswordAuthOperation {}
607);
608
609impl TKTokenPasswordAuthOperation {
610    extern_methods!(
611        /// Password, which will be filled in by the system when 'finishWithError:' is called.
612        #[unsafe(method(password))]
613        #[unsafe(method_family = none)]
614        pub unsafe fn password(&self) -> Option<Retained<NSString>>;
615
616        /// Setter for [`password`][Self::password].
617        ///
618        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
619        #[unsafe(method(setPassword:))]
620        #[unsafe(method_family = none)]
621        pub unsafe fn setPassword(&self, password: Option<&NSString>);
622    );
623}
624
625/// Methods declared on superclass `NSObject`.
626impl TKTokenPasswordAuthOperation {
627    extern_methods!(
628        #[unsafe(method(init))]
629        #[unsafe(method_family = init)]
630        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
631
632        #[unsafe(method(new))]
633        #[unsafe(method_family = new)]
634        pub unsafe fn new() -> Retained<Self>;
635    );
636}