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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationcontrollerdelegate?language=objc)
pub unsafe trait ASAuthorizationControllerDelegate:
NSObjectProtocol + MainThreadOnly
{
#[cfg(feature = "ASAuthorization")]
#[optional]
#[unsafe(method(authorizationController:didCompleteWithAuthorization:))]
#[unsafe(method_family = none)]
unsafe fn authorizationController_didCompleteWithAuthorization(
&self,
controller: &ASAuthorizationController,
authorization: &ASAuthorization,
);
#[optional]
#[unsafe(method(authorizationController:didCompleteWithError:))]
#[unsafe(method_family = none)]
unsafe fn authorizationController_didCompleteWithError(
&self,
controller: &ASAuthorizationController,
error: &NSError,
);
#[cfg(feature = "ASAuthorizationCustomMethod")]
#[optional]
#[unsafe(method(authorizationController:didCompleteWithCustomMethod:))]
#[unsafe(method_family = none)]
unsafe fn authorizationController_didCompleteWithCustomMethod(
&self,
controller: &ASAuthorizationController,
method: &ASAuthorizationCustomMethod,
);
}
);
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationcontrollerpresentationcontextproviding?language=objc)
pub unsafe trait ASAuthorizationControllerPresentationContextProviding:
NSObjectProtocol + MainThreadOnly
{
#[cfg(feature = "ASFoundation")]
#[cfg(target_os = "macos")]
/// Return a view anchor that is most appropriate for athorization UI to be presented over. This view will be used as a hint if a credential provider requires user interaction.
#[unsafe(method(presentationAnchorForAuthorizationController:))]
#[unsafe(method_family = none)]
unsafe fn presentationAnchorForAuthorizationController(
&self,
controller: &ASAuthorizationController,
) -> Retained<ASPresentationAnchor>;
}
);
/// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationcontrollerrequestoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ASAuthorizationControllerRequestOptions(pub NSUInteger);
bitflags::bitflags! {
impl ASAuthorizationControllerRequestOptions: NSUInteger {
/// When used for sign-in requests, tell the authorization controller that it should only be presented if there are credentials immediately available on the local device.
/// When used for registration requests, tell the authorization controller that it should only be presented if the local device is currently set up to fulfill at least one of the request types.
#[doc(alias = "ASAuthorizationControllerRequestOptionPreferImmediatelyAvailableCredentials")]
const PreferImmediatelyAvailableCredentials = 1<<0;
}
}
unsafe impl Encode for ASAuthorizationControllerRequestOptions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for ASAuthorizationControllerRequestOptions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationcontroller?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct ASAuthorizationController;
);
extern_conformance!(
unsafe impl NSObjectProtocol for ASAuthorizationController {}
);
impl ASAuthorizationController {
extern_methods!(
#[cfg(feature = "ASAuthorizationRequest")]
/// Authorization requests that are being serviced by this controller
#[unsafe(method(authorizationRequests))]
#[unsafe(method_family = none)]
pub unsafe fn authorizationRequests(&self) -> Retained<NSArray<ASAuthorizationRequest>>;
/// This delegate will be invoked upon completion of the authorization indicating success or failure.
/// Delegate is required to receive the results of authorization.
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(
&self,
mtm: MainThreadMarker,
) -> Option<Retained<ProtocolObject<dyn ASAuthorizationControllerDelegate>>>;
/// Setter for [`delegate`][Self::delegate].
///
/// This is a [weak property][objc2::topics::weak_property].
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn ASAuthorizationControllerDelegate>>,
);
/// This delegate will be invoked upon needing a presentation context to display authorization UI.
#[unsafe(method(presentationContextProvider))]
#[unsafe(method_family = none)]
pub unsafe fn presentationContextProvider(
&self,
mtm: MainThreadMarker,
) -> Option<
Retained<ProtocolObject<dyn ASAuthorizationControllerPresentationContextProviding>>,
>;
/// Setter for [`presentationContextProvider`][Self::presentationContextProvider].
///
/// This is a [weak property][objc2::topics::weak_property].
#[unsafe(method(setPresentationContextProvider:))]
#[unsafe(method_family = none)]
pub unsafe fn setPresentationContextProvider(
&self,
presentation_context_provider: Option<
&ProtocolObject<dyn ASAuthorizationControllerPresentationContextProviding>,
>,
);
#[cfg(feature = "ASAuthorizationCustomMethod")]
/// A list of custom authorization methods that may be displayed in the authorization UI.
///
/// If the user selects one of these methods, instead of attempting to secure an authorization for the requests, the
/// controller will call authorizationController:didCompleteWithCustomMethod: with the selected method, allowing
/// the client to perform the requested authorization.
#[unsafe(method(customAuthorizationMethods))]
#[unsafe(method_family = none)]
pub unsafe fn customAuthorizationMethods(
&self,
) -> Retained<NSArray<ASAuthorizationCustomMethod>>;
#[cfg(feature = "ASAuthorizationCustomMethod")]
/// Setter for [`customAuthorizationMethods`][Self::customAuthorizationMethods].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
#[unsafe(method(setCustomAuthorizationMethods:))]
#[unsafe(method_family = none)]
pub unsafe fn setCustomAuthorizationMethods(
&self,
custom_authorization_methods: &NSArray<ASAuthorizationCustomMethod>,
);
#[cfg(feature = "ASAuthorizationRequest")]
/// Initialize the controller with authorization requests.
///
///
/// Parameter `authorizationRequests`: At least one request should be provided. Requests of same type maybe honored in first in first out order
#[unsafe(method(initWithAuthorizationRequests:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithAuthorizationRequests(
this: Allocated<Self>,
authorization_requests: &NSArray<ASAuthorizationRequest>,
) -> Retained<Self>;
/// Initiate the authorization flows. Upon completion, the delegate will be called with either success or failure.
/// Certain authorization flows may require a presentation context. The
/// `presentationContextProvider`will be called
/// to provide it.
///
/// The instance will remain retained until the flow is either completed or canceled, and the delegate callback is made.
#[unsafe(method(performRequests))]
#[unsafe(method_family = none)]
pub unsafe fn performRequests(&self);
/// Initiate the authorization flows for requests that support AutoFill presentation. UI will be shown when
/// focusing a text field with the appropriate text content type. Upon completion, the delegate will be called with either success
/// or failure.
///
/// The instance will remain retained until the flow is either completed or canceled, and the delegate callback is made.
#[unsafe(method(performAutoFillAssistedRequests))]
#[unsafe(method_family = none)]
pub unsafe fn performAutoFillAssistedRequests(&self);
/// Initiate the authorization flows. Upon completion, the delegate will be called with either success or failure.
/// Certain authorization flows may require a presentation context. The
/// `presentationContextProvider`will be called
/// to provide it.
///
/// Calling this method with no options is the same as calling
/// `performRequests.`The instance will remain retained until
/// the flow is either completed or canceled, and the delegate callback is made.
#[unsafe(method(performRequestsWithOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn performRequestsWithOptions(
&self,
options: ASAuthorizationControllerRequestOptions,
);
/// Cancel the running authorization flows, if there are any. If a flow is canceled, the delegate callback will
/// be made indicating the cancel.
#[unsafe(method(cancel))]
#[unsafe(method_family = none)]
pub unsafe fn cancel(&self);
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
);
}