objc2-authentication-services 0.3.2

Bindings to the AuthenticationServices framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asuserdetectionstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ASUserDetectionStatus(pub NSInteger);
impl ASUserDetectionStatus {
    #[doc(alias = "ASUserDetectionStatusUnsupported")]
    pub const Unsupported: Self = Self(0);
    #[doc(alias = "ASUserDetectionStatusUnknown")]
    pub const Unknown: Self = Self(1);
    #[doc(alias = "ASUserDetectionStatusLikelyReal")]
    pub const LikelyReal: Self = Self(2);
}

unsafe impl Encode for ASUserDetectionStatus {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for ASUserDetectionStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asuseragerange?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct ASUserAgeRange(pub NSInteger);
impl ASUserAgeRange {
    #[doc(alias = "ASUserAgeRangeUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "ASUserAgeRangeChild")]
    pub const Child: Self = Self(1);
    #[doc(alias = "ASUserAgeRangeNotChild")]
    pub const NotChild: Self = Self(2);
}

unsafe impl Encode for ASUserAgeRange {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for ASUserAgeRange {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/authenticationservices/asauthorizationappleidcredential?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct ASAuthorizationAppleIDCredential;
);

#[cfg(feature = "ASAuthorizationCredential")]
extern_conformance!(
    unsafe impl ASAuthorizationCredential for ASAuthorizationAppleIDCredential {}
);

extern_conformance!(
    unsafe impl NSCoding for ASAuthorizationAppleIDCredential {}
);

extern_conformance!(
    unsafe impl NSCopying for ASAuthorizationAppleIDCredential {}
);

unsafe impl CopyingHelper for ASAuthorizationAppleIDCredential {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for ASAuthorizationAppleIDCredential {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for ASAuthorizationAppleIDCredential {}
);

impl ASAuthorizationAppleIDCredential {
    extern_methods!(
        /// An opaque user ID associated with the AppleID used for the sign in. This identifier will be stable across the 'developer team', it can later be used as an input to
        ///
        /// See: ASAuthorizationRequest to request user contact information.
        ///
        /// The identifier will remain stable as long as the user is connected with the requesting client.  The value may change upon user disconnecting from the identity provider.
        #[unsafe(method(user))]
        #[unsafe(method_family = none)]
        pub unsafe fn user(&self) -> Retained<NSString>;

        /// A copy of the state value that was passed to ASAuthorizationRequest.
        #[unsafe(method(state))]
        #[unsafe(method_family = none)]
        pub unsafe fn state(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "ASAuthorization")]
        /// This value will contain a list of scopes for which the user provided authorization.  These may contain a subset of the requested scopes on
        ///
        /// See: ASAuthorizationAppleIDRequest.  The application should query this value to identify which scopes were returned as it maybe different from ones requested.
        #[unsafe(method(authorizedScopes))]
        #[unsafe(method_family = none)]
        pub unsafe fn authorizedScopes(&self) -> Retained<NSArray<ASAuthorizationScope>>;

        /// A short-lived, one-time valid token that provides proof of authorization to the server component of the app. The authorization code is bound to the specific transaction using the state attribute passed in the authorization request. The server component of the app can validate the code using Apple’s identity service endpoint provided for this purpose.
        #[unsafe(method(authorizationCode))]
        #[unsafe(method_family = none)]
        pub unsafe fn authorizationCode(&self) -> Option<Retained<NSData>>;

        /// A JSON Web Token (JWT) used to communicate information about the identity of the user in a secure way to the app. The ID token will contain the following information: Issuer Identifier, Subject Identifier, Audience, Expiry Time and Issuance Time signed by Apple's identity service.
        #[unsafe(method(identityToken))]
        #[unsafe(method_family = none)]
        pub unsafe fn identityToken(&self) -> Option<Retained<NSData>>;

        /// An optional email shared by the user.  This field is populated with a value that the user authorized.
        #[unsafe(method(email))]
        #[unsafe(method_family = none)]
        pub unsafe fn email(&self) -> Option<Retained<NSString>>;

        /// An optional full name shared by the user.  This field is populated with a value that the user authorized.
        #[unsafe(method(fullName))]
        #[unsafe(method_family = none)]
        pub unsafe fn fullName(&self) -> Option<Retained<NSPersonNameComponents>>;

        /// Check this property for a hint as to whether the current user is a "real user".
        ///
        /// See: ASUserDetectionStatus for guidelines on handling each status
        #[unsafe(method(realUserStatus))]
        #[unsafe(method_family = none)]
        pub unsafe fn realUserStatus(&self) -> ASUserDetectionStatus;

        /// Check this property to determine whether the current user is a child.
        ///
        /// See: ASUserAgeRange for guidelines on handling each status.
        #[unsafe(method(userAgeRange))]
        #[unsafe(method_family = none)]
        pub unsafe fn userAgeRange(&self) -> ASUserAgeRange;

        #[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>;
    );
}