diff --git a/packages/celest_auth/android/build.gradle b/packages/celest_auth/android/build.gradle index 27f50d18..ff5e995a 100644 --- a/packages/celest_auth/android/build.gradle +++ b/packages/celest_auth/android/build.gradle @@ -58,15 +58,10 @@ android { } dependencies { - implementation "androidx.browser:browser:1.7.0" - implementation "androidx.credentials:credentials:1.3.0-alpha01" implementation "androidx.credentials:credentials-play-services-auth:1.3.0-alpha01" implementation "com.google.android.libraries.identity.googleid:googleid:1.1.0" implementation "androidx.biometric:biometric:1.2.0-alpha05" implementation "com.google.android.gms:play-services-auth:21.0.0" implementation "com.google.android.gms:play-services-fido:20.1.0" - - // Secure Storage - implementation 'androidx.security:security-crypto:1.1.0-alpha06' } diff --git a/packages/celest_auth/android/src/main/kotlin/dev/celest/celest_auth/CelestSecureStorage.kt b/packages/celest_auth/android/src/main/kotlin/dev/celest/celest_auth/CelestSecureStorage.kt deleted file mode 100644 index a4777740..00000000 --- a/packages/celest_auth/android/src/main/kotlin/dev/celest/celest_auth/CelestSecureStorage.kt +++ /dev/null @@ -1,61 +0,0 @@ -package dev.celest.celest_auth - -import android.annotation.SuppressLint -import android.app.Activity -import android.content.SharedPreferences -import androidx.annotation.Keep -import androidx.annotation.Nullable -import androidx.security.crypto.EncryptedSharedPreferences -import androidx.security.crypto.MasterKey - -// TODO(dnys1): Exclude from backup: -// - https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferences -// - https://developer.android.com/guide/topics/data/autobackup#IncludingFiles -@Keep -class CelestSecureStorage(private val mainActivity: Activity) { - - private val sharedPreferences: SharedPreferences by lazy { - val masterKey = MasterKey.Builder(mainActivity) - .setKeyScheme(MasterKey.KeyScheme.AES256_GCM) - .build() - val sharedPreferences = EncryptedSharedPreferences.create( - mainActivity, - "auth_secrets", - masterKey, - EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, - EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM, - ) - sharedPreferences - } - - private val editor: SharedPreferences.Editor - get() = sharedPreferences.edit() - - fun write(dataKey: String, value: String?) { - with(editor) { - putString(dataKey, value) - apply() - } - } - - fun read(dataKey: String): String? = sharedPreferences.getString(dataKey, null) - - fun readAll(): Map = sharedPreferences.all.mapValues { it.value as String } - - fun delete(dataKey: String): String? { - val current = read(dataKey) - with(editor) { - remove(dataKey) - apply() - } - return current - } - - fun clear() { - with(editor) { - clear() - apply() - } - } - -} \ No newline at end of file diff --git a/packages/celest_auth/example/android/app/build.gradle b/packages/celest_auth/example/android/app/build.gradle index 615231fb..f01e1bba 100644 --- a/packages/celest_auth/example/android/app/build.gradle +++ b/packages/celest_auth/example/android/app/build.gradle @@ -64,12 +64,10 @@ flutter { dependencies { // These dependencies are only present so that `jnigen` will work. // Applications should not include these. - implementation "androidx.browser:browser:1.7.0" implementation "androidx.credentials:credentials:1.3.0-alpha01" implementation "androidx.credentials:credentials-play-services-auth:1.3.0-alpha01" implementation "com.google.android.libraries.identity.googleid:googleid:1.1.0" implementation "androidx.biometric:biometric:1.2.0-alpha05" implementation "com.google.android.gms:play-services-auth:21.0.0" implementation "com.google.android.gms:play-services-fido:20.1.0" - implementation 'androidx.security:security-crypto:1.1.0-alpha06' } diff --git a/packages/celest_auth/ffigen.core_foundation.yaml b/packages/celest_auth/ffigen.core_foundation.yaml deleted file mode 100644 index 10a3cb3c..00000000 --- a/packages/celest_auth/ffigen.core_foundation.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: CoreFoundation -description: | - Bindings for Core Foundation on iOS/macOS. - - Regenerate bindings with `dart run ffigen --config=ffigen.core_foundation.yaml`. -language: "c" -output: - bindings: "lib/src/native/darwin/core_foundation.ffi.dart" -compiler-opts: - - "-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" -headers: - entry-points: - - "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDictionary.h" - - "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h" - - "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFData.h" -preamble: | - // ignore_for_file: type=lint - // ignore_for_file: return_of_invalid_type - // ignore_for_file: unnecessary_non_null_assertion -comments: - style: any - length: full - -ffi-native: -exclude-all-by-default: true -typedefs: - include: - - "CF.*" -globals: - include: - - "kCF.*" -functions: - include: - - CFDictionaryCreate - - CFDataCreate - - CFStringGetCStringPtr - - CFStringGetCString - - CFStringGetLength - - CFStringGetMaximumSizeForEncoding - - CFStringCreateWithCString - - CFDataGetBytePtr - - CFRelease -structs: - rename: - "__CFString": CFString - "__CFData": CFData - "__CFDictionary": CFDictionary -unnamed-enums: - include: - - "kCF.*" diff --git a/packages/celest_auth/ffigen.security.yaml b/packages/celest_auth/ffigen.security.yaml deleted file mode 100644 index ed33002c..00000000 --- a/packages/celest_auth/ffigen.security.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: SecurityFramework -description: | - Bindings for Security framework on iOS/macOS. - - Regenerate bindings with `dart run ffigen --config=ffigen.security.yaml`. -language: "c" -output: - bindings: "lib/src/native/darwin/security.ffi.dart" -compiler-opts: - - "-F/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" -headers: - entry-points: - - "/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Security.framework/Headers/SecItem.h" -preamble: | - // ignore_for_file: type=lint - // ignore_for_file: return_of_invalid_type - // ignore_for_file: unnecessary_non_null_assertion -comments: - style: any - length: full -library-imports: - cf: "package:celest_auth/src/native/darwin/core_foundation.ffi.dart" - -ffi-native: -exclude-all-by-default: true -functions: - include: - - SecItemAdd - - SecItemUpdate - - SecItemCopyMatching - - SecItemDelete - - SecCopyErrorMessageString -globals: - include: - - "kSec.*" - - "kCF.*" -unnamed-enums: - include: - - errSecSuccess - - errSecItemNotFound - - errSecDuplicateItem - - errSecUserCanceled - - errSecAuthFailed - - errSecInteractionRequired - - errSecMissingEntitlement - - errSecInvalidOwnerEdit -type-map: - typedefs: - CFString: - lib: cf - c-type: CFString - dart-type: CFString - CFType: - lib: cf - c-type: CFType - dart-type: CFType - CFData: - lib: cf - c-type: CFData - dart-type: CFData - CFDictionary: - lib: cf - c-type: CFDictionary - dart-type: CFDictionary - CFStringRef: - lib: cf - c-type: CFStringRef - dart-type: CFStringRef - CFTypeRef: - lib: cf - c-type: CFTypeRef - dart-type: CFTypeRef - CFDictionaryRef: - lib: cf - c-type: CFDictionaryRef - dart-type: CFDictionaryRef diff --git a/packages/celest_auth/jnigen.yaml b/packages/celest_auth/jnigen.yaml index 1ea01fba..93eed7b2 100644 --- a/packages/celest_auth/jnigen.yaml +++ b/packages/celest_auth/jnigen.yaml @@ -17,7 +17,6 @@ output: classes: - dev.celest.celest_auth.CelestAuth - - dev.celest.celest_auth.CelestSecureStorage # Core Android/Java types - android.app.Activity diff --git a/packages/celest_auth/lib/src/auth.dart b/packages/celest_auth/lib/src/auth.dart index 40a8fde6..dbb57428 100644 --- a/packages/celest_auth/lib/src/auth.dart +++ b/packages/celest_auth/lib/src/auth.dart @@ -1,6 +1,5 @@ import 'package:celest_auth/src/flows/auth_flow.dart'; import 'package:celest_auth/src/platform/auth_platform.dart'; -import 'package:celest_auth/src/storage/secure_storage.dart'; import 'package:celest_core/celest_core.dart'; import 'package:http/http.dart' as http; import 'package:meta/meta.dart'; diff --git a/packages/celest_auth/lib/src/native/android/jni_bindings.ffi.dart b/packages/celest_auth/lib/src/native/android/jni_bindings.ffi.dart index 74e4d351..57584b30 100644 --- a/packages/celest_auth/lib/src/native/android/jni_bindings.ffi.dart +++ b/packages/celest_auth/lib/src/native/android/jni_bindings.ffi.dart @@ -110,124 +110,6 @@ final class $CelestAuthType extends jni.JObjType { } } -/// from: dev.celest.celest_auth.CelestSecureStorage -class CelestSecureStorage extends jni.JObject { - @override - late final jni.JObjType $type = type; - - CelestSecureStorage.fromRef( - jni.JObjectPtr ref, - ) : super.fromRef(ref); - - static final _class = - jni.Jni.findJClass(r"dev/celest/celest_auth/CelestSecureStorage"); - - /// The type which includes information such as the signature of this class. - static const type = $CelestSecureStorageType(); - static final _id_new0 = jni.Jni.accessors - .getMethodIDOf(_class.reference, r"", r"(Landroid/app/Activity;)V"); - - /// from: public void (android.app.Activity activity) - /// The returned object must be released after use, by calling the [release] method. - factory CelestSecureStorage( - Activity activity, - ) { - return CelestSecureStorage.fromRef(jni.Jni.accessors.newObjectWithArgs( - _class.reference, _id_new0, [activity.reference]).object); - } - - static final _id_write = jni.Jni.accessors.getMethodIDOf( - _class.reference, r"write", r"(Ljava/lang/String;Ljava/lang/String;)V"); - - /// from: public final void write(java.lang.String string, java.lang.String string1) - void write( - jni.JString string, - jni.JString string1, - ) { - return jni.Jni.accessors.callMethodWithArgs( - reference, - _id_write, - jni.JniCallType.voidType, - [string.reference, string1.reference]).check(); - } - - static final _id_read = jni.Jni.accessors.getMethodIDOf( - _class.reference, r"read", r"(Ljava/lang/String;)Ljava/lang/String;"); - - /// from: public final java.lang.String read(java.lang.String string) - /// The returned object must be released after use, by calling the [release] method. - jni.JString read( - jni.JString string, - ) { - return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( - reference, - _id_read, - jni.JniCallType.objectType, - [string.reference]).object); - } - - static final _id_readAll = jni.Jni.accessors - .getMethodIDOf(_class.reference, r"readAll", r"()Ljava/util/Map;"); - - /// from: public final java.util.Map readAll() - /// The returned object must be released after use, by calling the [release] method. - jni.JMap readAll() { - return const jni.JMapType(jni.JStringType(), jni.JStringType()).fromRef( - jni.Jni.accessors.callMethodWithArgs( - reference, _id_readAll, jni.JniCallType.objectType, []).object); - } - - static final _id_delete = jni.Jni.accessors.getMethodIDOf( - _class.reference, r"delete", r"(Ljava/lang/String;)Ljava/lang/String;"); - - /// from: public final java.lang.String delete(java.lang.String string) - /// The returned object must be released after use, by calling the [release] method. - jni.JString delete( - jni.JString string, - ) { - return const jni.JStringType().fromRef(jni.Jni.accessors.callMethodWithArgs( - reference, - _id_delete, - jni.JniCallType.objectType, - [string.reference]).object); - } - - static final _id_clear = - jni.Jni.accessors.getMethodIDOf(_class.reference, r"clear", r"()V"); - - /// from: public final void clear() - void clear() { - return jni.Jni.accessors.callMethodWithArgs( - reference, _id_clear, jni.JniCallType.voidType, []).check(); - } -} - -final class $CelestSecureStorageType extends jni.JObjType { - const $CelestSecureStorageType(); - - @override - String get signature => r"Ldev/celest/celest_auth/CelestSecureStorage;"; - - @override - CelestSecureStorage fromRef(jni.JObjectPtr ref) => - CelestSecureStorage.fromRef(ref); - - @override - jni.JObjType get superType => const jni.JObjectType(); - - @override - final superCount = 1; - - @override - int get hashCode => ($CelestSecureStorageType).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == ($CelestSecureStorageType) && - other is $CelestSecureStorageType; - } -} - /// from: android.app.Activity$ScreenCaptureCallback class Activity_ScreenCaptureCallback extends jni.JObject { @override diff --git a/packages/celest_auth/lib/src/native/darwin/core_foundation.ffi.dart b/packages/celest_auth/lib/src/native/darwin/core_foundation.ffi.dart deleted file mode 100644 index d196c09d..00000000 --- a/packages/celest_auth/lib/src/native/darwin/core_foundation.ffi.dart +++ /dev/null @@ -1,754 +0,0 @@ -// ignore_for_file: type=lint -// ignore_for_file: return_of_invalid_type -// ignore_for_file: unnecessary_non_null_assertion - -// AUTO GENERATED FILE, DO NOT EDIT. -// -// Generated by `package:ffigen`. -import 'dart:ffi' as ffi; - -@ffi.Native() -external double kCFCoreFoundationVersionNumber; - -/// Constant used by some functions to indicate failed searches. -@ffi.Native() -external final int kCFNotFound; - -/// the singleton null instance -@ffi.Native() -external final CFNullRef kCFNull; - -/// This is a synonym for NULL, if you'd rather use a named constant. -@ffi.Native() -external final CFAllocatorRef kCFAllocatorDefault; - -/// Default system allocator; you rarely need to use this. -@ffi.Native() -external final CFAllocatorRef kCFAllocatorSystemDefault; - -/// This allocator uses malloc(), realloc(), and free(). This should not be -/// generally used; stick to kCFAllocatorDefault whenever possible. This -/// allocator is useful as the "bytesDeallocator" in CFData or -/// "contentsDeallocator" in CFString where the memory was obtained as a -/// result of malloc() type functions. -@ffi.Native() -external final CFAllocatorRef kCFAllocatorMalloc; - -/// This allocator explicitly uses the default malloc zone, returned by -/// malloc_default_zone(). It should only be used when an object is -/// safe to be allocated in non-scanned memory. -@ffi.Native() -external final CFAllocatorRef kCFAllocatorMallocZone; - -/// Null allocator which does nothing and allocates no memory. This allocator -/// is useful as the "bytesDeallocator" in CFData or "contentsDeallocator" -/// in CFString where the memory should not be freed. -@ffi.Native() -external final CFAllocatorRef kCFAllocatorNull; - -/// Special allocator argument to CFAllocatorCreate() which means -/// "use the functions given in the context to allocate the allocator -/// itself as well". -@ffi.Native() -external final CFAllocatorRef kCFAllocatorUseContext; - -@ffi.Native() -external void CFRelease( - CFTypeRef cf, -); - -/// ! -/// @constant kCFTypeDictionaryKeyCallBacks -/// Predefined CFDictionaryKeyCallBacks structure containing a -/// set of callbacks appropriate for use when the keys of a -/// CFDictionary are all CFTypes. -@ffi.Native() -external final CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; - -/// ! -/// @constant kCFCopyStringDictionaryKeyCallBacks -/// Predefined CFDictionaryKeyCallBacks structure containing a -/// set of callbacks appropriate for use when the keys of a -/// CFDictionary are all CFStrings, which may be mutable and -/// need to be copied in order to serve as constant keys for -/// the values in the dictionary. -@ffi.Native() -external final CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks; - -/// ! -/// @constant kCFTypeDictionaryValueCallBacks -/// Predefined CFDictionaryValueCallBacks structure containing a set -/// of callbacks appropriate for use when the values in a CFDictionary -/// are all CFTypes. -@ffi.Native() -external final CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; - -/// ! -/// @function CFDictionaryCreate -/// Creates a new immutable dictionary with the given values. -/// @param allocator The CFAllocator which should be used to allocate -/// memory for the dictionary and its storage for values. This -/// parameter may be NULL in which case the current default -/// CFAllocator is used. If this reference is not a valid -/// CFAllocator, the behavior is undefined. -/// @param keys A C array of the pointer-sized keys to be used for -/// the parallel C array of values to be put into the dictionary. -/// This parameter may be NULL if the numValues parameter is 0. -/// This C array is not changed or freed by this function. If -/// this parameter is not a valid pointer to a C array of at -/// least numValues pointers, the behavior is undefined. -/// @param values A C array of the pointer-sized values to be in the -/// dictionary. This parameter may be NULL if the numValues -/// parameter is 0. This C array is not changed or freed by -/// this function. If this parameter is not a valid pointer to -/// a C array of at least numValues pointers, the behavior is -/// undefined. -/// @param numValues The number of values to copy from the keys and -/// values C arrays into the CFDictionary. This number will be -/// the count of the dictionary. If this parameter is -/// negative, or greater than the number of values actually -/// in the keys or values C arrays, the behavior is undefined. -/// @param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure -/// initialized with the callbacks for the dictionary to use on -/// each key in the dictionary. The retain callback will be used -/// within this function, for example, to retain all of the new -/// keys from the keys C array. A copy of the contents of the -/// callbacks structure is made, so that a pointer to a structure -/// on the stack can be passed in, or can be reused for multiple -/// dictionary creations. If the version field of this -/// callbacks structure is not one of the defined ones for -/// CFDictionary, the behavior is undefined. The retain field may -/// be NULL, in which case the CFDictionary will do nothing to add -/// a retain to the keys of the contained values. The release field -/// may be NULL, in which case the CFDictionary will do nothing -/// to remove the dictionary's retain (if any) on the keys when the -/// dictionary is destroyed or a key-value pair is removed. If the -/// copyDescription field is NULL, the dictionary will create a -/// simple description for a key. If the equal field is NULL, the -/// dictionary will use pointer equality to test for equality of -/// keys. If the hash field is NULL, a key will be converted from -/// a pointer to an integer to compute the hash code. This callbacks -/// parameter itself may be NULL, which is treated as if a valid -/// structure of version 0 with all fields NULL had been passed in. -/// Otherwise, if any of the fields are not valid pointers to -/// functions of the correct type, or this parameter is not a -/// valid pointer to a CFDictionaryKeyCallBacks callbacks structure, -/// the behavior is undefined. If any of the keys put into the -/// dictionary is not one understood by one of the callback functions -/// the behavior when that callback function is used is undefined. -/// @param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure -/// initialized with the callbacks for the dictionary to use on -/// each value in the dictionary. The retain callback will be used -/// within this function, for example, to retain all of the new -/// values from the values C array. A copy of the contents of the -/// callbacks structure is made, so that a pointer to a structure -/// on the stack can be passed in, or can be reused for multiple -/// dictionary creations. If the version field of this callbacks -/// structure is not one of the defined ones for CFDictionary, the -/// behavior is undefined. The retain field may be NULL, in which -/// case the CFDictionary will do nothing to add a retain to values -/// as they are put into the dictionary. The release field may be -/// NULL, in which case the CFDictionary will do nothing to remove -/// the dictionary's retain (if any) on the values when the -/// dictionary is destroyed or a key-value pair is removed. If the -/// copyDescription field is NULL, the dictionary will create a -/// simple description for a value. If the equal field is NULL, the -/// dictionary will use pointer equality to test for equality of -/// values. This callbacks parameter itself may be NULL, which is -/// treated as if a valid structure of version 0 with all fields -/// NULL had been passed in. Otherwise, -/// if any of the fields are not valid pointers to functions -/// of the correct type, or this parameter is not a valid -/// pointer to a CFDictionaryValueCallBacks callbacks structure, -/// the behavior is undefined. If any of the values put into the -/// dictionary is not one understood by one of the callback functions -/// the behavior when that callback function is used is undefined. -/// @result A reference to the new immutable CFDictionary. -@ffi.Native< - CFDictionaryRef Function( - CFAllocatorRef, - ffi.Pointer>, - ffi.Pointer>, - CFIndex, - ffi.Pointer, - ffi.Pointer)>() -external CFDictionaryRef CFDictionaryCreate( - CFAllocatorRef allocator, - ffi.Pointer> keys, - ffi.Pointer> values, - int numValues, - ffi.Pointer keyCallBacks, - ffi.Pointer valueCallBacks, -); - -/// ! -/// @constant kCFTypeArrayCallBacks -/// Predefined CFArrayCallBacks structure containing a set of callbacks -/// appropriate for use when the values in a CFArray are all CFTypes. -@ffi.Native() -external final CFArrayCallBacks kCFTypeArrayCallBacks; - -@ffi.Native< - CFDataRef Function( - CFAllocatorRef, ffi.Pointer, CFIndex)>() -external CFDataRef CFDataCreate( - CFAllocatorRef allocator, - ffi.Pointer bytes, - int length, -); - -@ffi.Native Function(CFDataRef)>() -external ffi.Pointer CFDataGetBytePtr( - CFDataRef theData, -); - -/// Returns the display name for the given value. The key tells what -/// the value is, and is one of the usual locale property keys, though -/// not all locale property keys have values with display name values. -@ffi.Native() -external final CFNotificationName kCFLocaleCurrentLocaleDidChangeNotification; - -/// Locale Keys -@ffi.Native() -external final CFLocaleKey kCFLocaleIdentifier; - -@ffi.Native() -external final CFLocaleKey kCFLocaleLanguageCode; - -@ffi.Native() -external final CFLocaleKey kCFLocaleCountryCode; - -@ffi.Native() -external final CFLocaleKey kCFLocaleScriptCode; - -@ffi.Native() -external final CFLocaleKey kCFLocaleVariantCode; - -@ffi.Native() -external final CFLocaleKey kCFLocaleExemplarCharacterSet; - -@ffi.Native() -external final CFLocaleKey kCFLocaleCalendarIdentifier; - -@ffi.Native() -external final CFLocaleKey kCFLocaleCalendar; - -@ffi.Native() -external final CFLocaleKey kCFLocaleCollationIdentifier; - -@ffi.Native() -external final CFLocaleKey kCFLocaleUsesMetricSystem; - -/// "Metric", "U.S." or "U.K." -@ffi.Native() -external final CFLocaleKey kCFLocaleMeasurementSystem; - -@ffi.Native() -external final CFLocaleKey kCFLocaleDecimalSeparator; - -@ffi.Native() -external final CFLocaleKey kCFLocaleGroupingSeparator; - -@ffi.Native() -external final CFLocaleKey kCFLocaleCurrencySymbol; - -/// ISO 3-letter currency code -@ffi.Native() -external final CFLocaleKey kCFLocaleCurrencyCode; - -@ffi.Native() -external final CFLocaleKey kCFLocaleCollatorIdentifier; - -@ffi.Native() -external final CFLocaleKey kCFLocaleQuotationBeginDelimiterKey; - -@ffi.Native() -external final CFLocaleKey kCFLocaleQuotationEndDelimiterKey; - -@ffi.Native() -external final CFLocaleKey kCFLocaleAlternateQuotationBeginDelimiterKey; - -@ffi.Native() -external final CFLocaleKey kCFLocaleAlternateQuotationEndDelimiterKey; - -@ffi.Native() -external final CFCalendarIdentifier kCFGregorianCalendar; - -@ffi.Native() -external final CFCalendarIdentifier kCFBuddhistCalendar; - -@ffi.Native() -external final CFCalendarIdentifier kCFChineseCalendar; - -@ffi.Native() -external final CFCalendarIdentifier kCFHebrewCalendar; - -@ffi.Native() -external final CFCalendarIdentifier kCFIslamicCalendar; - -@ffi.Native() -external final CFCalendarIdentifier kCFIslamicCivilCalendar; - -@ffi.Native() -external final CFCalendarIdentifier kCFJapaneseCalendar; - -@ffi.Native() -external final CFCalendarIdentifier kCFRepublicOfChinaCalendar; - -@ffi.Native() -external final CFCalendarIdentifier kCFPersianCalendar; - -@ffi.Native() -external final CFCalendarIdentifier kCFIndianCalendar; - -@ffi.Native() -external final CFCalendarIdentifier kCFISO8601Calendar; - -@ffi.Native() -external final CFCalendarIdentifier kCFIslamicTabularCalendar; - -@ffi.Native() -external final CFCalendarIdentifier kCFIslamicUmmAlQuraCalendar; - -/// Predefined domains; value of "code" will correspond to preexisting values in these domains. -@ffi.Native() -external final CFErrorDomain kCFErrorDomainPOSIX; - -@ffi.Native() -external final CFErrorDomain kCFErrorDomainOSStatus; - -@ffi.Native() -external final CFErrorDomain kCFErrorDomainMach; - -@ffi.Native() -external final CFErrorDomain kCFErrorDomainCocoa; - -/// Key to identify the end user-presentable description in userInfo. Should be one or more complete sentence(s) describing both what failed and why. For instance 'You can't save the file "To Do List" because the volume "Macintosh HD" is out of space.' -@ffi.Native() -external final CFStringRef kCFErrorLocalizedDescriptionKey; - -/// Key to identify the end user-presentable failing operation ("what failed") description in userInfo. Should be one or more complete sentence(s), for instance 'The file "To Do List" couldn't be saved.' -@ffi.Native() -external final CFStringRef kCFErrorLocalizedFailureKey; - -/// Key to identify the end user-presentable failure reason ("why it failed") description in userInfo. Should be one or more complete sentence(s), for instance 'The volume "Macintosh HD" is out of space.' -@ffi.Native() -external final CFStringRef kCFErrorLocalizedFailureReasonKey; - -/// Key to identify the end user-presentable recovery suggestion in userInfo. Should be one or more complete sentence(s), for instance 'Remove some files from the volume, and then try again.' -@ffi.Native() -external final CFStringRef kCFErrorLocalizedRecoverySuggestionKey; - -/// Key to identify the description in the userInfo dictionary. Should be a complete sentence if possible. Should not contain domain name or error code. -@ffi.Native() -external final CFStringRef kCFErrorDescriptionKey; - -/// Key to identify the underlying error in userInfo. -@ffi.Native() -external final CFStringRef kCFErrorUnderlyingErrorKey; - -/// Key to identify associated URL in userInfo. Typically one of this or kCFErrorFilePathKey is provided. -@ffi.Native() -external final CFStringRef kCFErrorURLKey; - -/// Key to identify associated file path in userInfo. Typically one of this or kCFErrorURLKey is provided. -@ffi.Native() -external final CFStringRef kCFErrorFilePathKey; - -@ffi.Native< - CFStringRef Function( - CFAllocatorRef, ffi.Pointer, CFStringEncoding)>() -external CFStringRef CFStringCreateWithCString( - CFAllocatorRef alloc, - ffi.Pointer cStr, - int encoding, -); - -/// Number of 16-bit Unicode characters in the string. -@ffi.Native() -external int CFStringGetLength( - CFStringRef theString, -); - -@ffi.Native< - ffi.UnsignedChar Function( - CFStringRef, ffi.Pointer, CFIndex, CFStringEncoding)>() -external int CFStringGetCString( - CFStringRef theString, - ffi.Pointer buffer, - int bufferSize, - int encoding, -); - -@ffi.Native Function(CFStringRef, CFStringEncoding)>() -external ffi.Pointer CFStringGetCStringPtr( - CFStringRef theString, - int encoding, -); - -@ffi.Native() -external int CFStringGetMaximumSizeForEncoding( - int length, - int encoding, -); - -/// Transform identifiers for CFStringTransform() -@ffi.Native() -external final CFStringRef kCFStringTransformStripCombiningMarks; - -@ffi.Native() -external final CFStringRef kCFStringTransformToLatin; - -@ffi.Native() -external final CFStringRef kCFStringTransformFullwidthHalfwidth; - -@ffi.Native() -external final CFStringRef kCFStringTransformLatinKatakana; - -@ffi.Native() -external final CFStringRef kCFStringTransformLatinHiragana; - -@ffi.Native() -external final CFStringRef kCFStringTransformHiraganaKatakana; - -@ffi.Native() -external final CFStringRef kCFStringTransformMandarinLatin; - -@ffi.Native() -external final CFStringRef kCFStringTransformLatinHangul; - -@ffi.Native() -external final CFStringRef kCFStringTransformLatinArabic; - -@ffi.Native() -external final CFStringRef kCFStringTransformLatinHebrew; - -@ffi.Native() -external final CFStringRef kCFStringTransformLatinThai; - -@ffi.Native() -external final CFStringRef kCFStringTransformLatinCyrillic; - -@ffi.Native() -external final CFStringRef kCFStringTransformLatinGreek; - -@ffi.Native() -external final CFStringRef kCFStringTransformToXMLHex; - -@ffi.Native() -external final CFStringRef kCFStringTransformToUnicodeName; - -@ffi.Native() -external final CFStringRef kCFStringTransformStripDiacritics; - -typedef CFIndex = ffi.Long; -typedef DartCFIndex = int; - -/// Null representant -typedef CFNullRef = ffi.Pointer<__CFNull>; - -final class __CFNull extends ffi.Opaque {} - -/// Allocator API -/// -/// Most of the time when specifying an allocator to Create functions, the NULL -/// argument indicates "use the default"; this is the same as using kCFAllocatorDefault -/// or the return value from CFAllocatorGetDefault(). This assures that you will use -/// the allocator in effect at that time. -typedef CFAllocatorRef = ffi.Pointer<__CFAllocator>; - -final class __CFAllocator extends ffi.Opaque {} - -/// Base "type" of all "CF objects", and polymorphic functions on them -typedef CFTypeRef = ffi.Pointer; - -final class CFDictionaryKeyCallBacks extends ffi.Struct { - @CFIndex() - external int version; - - external CFDictionaryRetainCallBack retain; - - external CFDictionaryReleaseCallBack release; - - external CFDictionaryCopyDescriptionCallBack copyDescription; - - external CFDictionaryEqualCallBack equal; - - external CFDictionaryHashCallBack hash; -} - -/// ! -/// @typedef CFDictionaryKeyCallBacks -/// Structure containing the callbacks for keys of a CFDictionary. -/// @field version The version number of the structure type being passed -/// in as a parameter to the CFDictionary creation functions. -/// This structure is version 0. -/// @field retain The callback used to add a retain for the dictionary -/// on keys as they are used to put values into the dictionary. -/// This callback returns the value to use as the key in the -/// dictionary, which is usually the value parameter passed to -/// this callback, but may be a different value if a different -/// value should be used as the key. The dictionary's allocator -/// is passed as the first argument. -/// @field release The callback used to remove a retain previously added -/// for the dictionary from keys as their values are removed from -/// the dictionary. The dictionary's allocator is passed as the -/// first argument. -/// @field copyDescription The callback used to create a descriptive -/// string representation of each key in the dictionary. This -/// is used by the CFCopyDescription() function. -/// @field equal The callback used to compare keys in the dictionary for -/// equality. -/// @field hash The callback used to compute a hash code for keys as they -/// are used to access, add, or remove values in the dictionary. -typedef CFDictionaryRetainCallBack - = ffi.Pointer>; -typedef CFDictionaryRetainCallBackFunction = ffi.Pointer Function( - CFAllocatorRef allocator, ffi.Pointer value); -typedef CFDictionaryReleaseCallBack - = ffi.Pointer>; -typedef CFDictionaryReleaseCallBackFunction = ffi.Void Function( - CFAllocatorRef allocator, ffi.Pointer value); -typedef DartCFDictionaryReleaseCallBackFunction = void Function( - CFAllocatorRef allocator, ffi.Pointer value); -typedef CFDictionaryCopyDescriptionCallBack = ffi - .Pointer>; -typedef CFDictionaryCopyDescriptionCallBackFunction = CFStringRef Function( - ffi.Pointer value); -typedef CFStringRef = ffi.Pointer; - -final class CFString extends ffi.Opaque {} - -typedef CFDictionaryEqualCallBack - = ffi.Pointer>; -typedef CFDictionaryEqualCallBackFunction = ffi.UnsignedChar Function( - ffi.Pointer value1, ffi.Pointer value2); -typedef DartCFDictionaryEqualCallBackFunction = int Function( - ffi.Pointer value1, ffi.Pointer value2); -typedef CFDictionaryHashCallBack - = ffi.Pointer>; -typedef CFDictionaryHashCallBackFunction = CFHashCode Function( - ffi.Pointer value); -typedef DartCFDictionaryHashCallBackFunction = DartCFHashCode Function( - ffi.Pointer value); -typedef CFHashCode = ffi.UnsignedLong; -typedef DartCFHashCode = int; - -/// ! -/// @typedef CFDictionaryValueCallBacks -/// Structure containing the callbacks for values of a CFDictionary. -/// @field version The version number of the structure type being passed -/// in as a parameter to the CFDictionary creation functions. -/// This structure is version 0. -/// @field retain The callback used to add a retain for the dictionary -/// on values as they are put into the dictionary. -/// This callback returns the value to use as the value in the -/// dictionary, which is usually the value parameter passed to -/// this callback, but may be a different value if a different -/// value should be added to the dictionary. The dictionary's -/// allocator is passed as the first argument. -/// @field release The callback used to remove a retain previously added -/// for the dictionary from values as they are removed from -/// the dictionary. The dictionary's allocator is passed as the -/// first argument. -/// @field copyDescription The callback used to create a descriptive -/// string representation of each value in the dictionary. This -/// is used by the CFCopyDescription() function. -/// @field equal The callback used to compare values in the dictionary for -/// equality in some operations. -final class CFDictionaryValueCallBacks extends ffi.Struct { - @CFIndex() - external int version; - - external CFDictionaryRetainCallBack retain; - - external CFDictionaryReleaseCallBack release; - - external CFDictionaryCopyDescriptionCallBack copyDescription; - - external CFDictionaryEqualCallBack equal; -} - -/// ! -/// @typedef CFDictionaryRef -/// This is the type of a reference to immutable CFDictionarys. -typedef CFDictionaryRef = ffi.Pointer; - -final class CFDictionary extends ffi.Opaque {} - -final class CFArrayCallBacks extends ffi.Struct { - @CFIndex() - external int version; - - external CFArrayRetainCallBack retain; - - external CFArrayReleaseCallBack release; - - external CFArrayCopyDescriptionCallBack copyDescription; - - external CFArrayEqualCallBack equal; -} - -/// ! -/// @typedef CFArrayCallBacks -/// Structure containing the callbacks of a CFArray. -/// @field version The version number of the structure type being passed -/// in as a parameter to the CFArray creation functions. This -/// structure is version 0. -/// @field retain The callback used to add a retain for the array on -/// values as they are put into the array. This callback returns -/// the value to store in the array, which is usually the value -/// parameter passed to this callback, but may be a different -/// value if a different value should be stored in the array. -/// The array's allocator is passed as the first argument. -/// @field release The callback used to remove a retain previously added -/// for the array from values as they are removed from the -/// array. The array's allocator is passed as the first -/// argument. -/// @field copyDescription The callback used to create a descriptive -/// string representation of each value in the array. This is -/// used by the CFCopyDescription() function. -/// @field equal The callback used to compare values in the array for -/// equality for some operations. -typedef CFArrayRetainCallBack - = ffi.Pointer>; -typedef CFArrayRetainCallBackFunction = ffi.Pointer Function( - CFAllocatorRef allocator, ffi.Pointer value); -typedef CFArrayReleaseCallBack - = ffi.Pointer>; -typedef CFArrayReleaseCallBackFunction = ffi.Void Function( - CFAllocatorRef allocator, ffi.Pointer value); -typedef DartCFArrayReleaseCallBackFunction = void Function( - CFAllocatorRef allocator, ffi.Pointer value); -typedef CFArrayCopyDescriptionCallBack - = ffi.Pointer>; -typedef CFArrayCopyDescriptionCallBackFunction = CFStringRef Function( - ffi.Pointer value); -typedef CFArrayEqualCallBack - = ffi.Pointer>; -typedef CFArrayEqualCallBackFunction = ffi.UnsignedChar Function( - ffi.Pointer value1, ffi.Pointer value2); -typedef DartCFArrayEqualCallBackFunction = int Function( - ffi.Pointer value1, ffi.Pointer value2); -typedef CFDataRef = ffi.Pointer; - -final class CFData extends ffi.Opaque {} - -typedef CFNotificationName = CFStringRef; -typedef CFLocaleKey = CFStringRef; - -/// Values for kCFLocaleCalendarIdentifier -typedef CFCalendarIdentifier = CFStringRef; -typedef CFErrorDomain = CFStringRef; - -/// Identifier for character encoding; the values are the same as Text Encoding Converter TextEncoding. -typedef CFStringEncoding = ffi.UnsignedInt; -typedef DartCFStringEncoding = int; - -const int kCFCompareLessThan = -1; - -const int kCFCompareEqualTo = 0; - -const int kCFCompareGreaterThan = 1; - -const int kCFDataSearchBackwards = 1; - -const int kCFDataSearchAnchored = 2; - -const int kCFCharacterSetControl = 1; - -const int kCFCharacterSetWhitespace = 2; - -const int kCFCharacterSetWhitespaceAndNewline = 3; - -const int kCFCharacterSetDecimalDigit = 4; - -const int kCFCharacterSetLetter = 5; - -const int kCFCharacterSetLowercaseLetter = 6; - -const int kCFCharacterSetUppercaseLetter = 7; - -const int kCFCharacterSetNonBase = 8; - -const int kCFCharacterSetDecomposable = 9; - -const int kCFCharacterSetAlphaNumeric = 10; - -const int kCFCharacterSetPunctuation = 11; - -const int kCFCharacterSetCapitalizedLetter = 13; - -const int kCFCharacterSetSymbol = 14; - -const int kCFCharacterSetNewline = 15; - -const int kCFCharacterSetIllegal = 12; - -const int kCFNotificationDeliverImmediately = 1; - -const int kCFNotificationPostToAllSessions = 2; - -const int kCFLocaleLanguageDirectionUnknown = 0; - -const int kCFLocaleLanguageDirectionLeftToRight = 1; - -const int kCFLocaleLanguageDirectionRightToLeft = 2; - -const int kCFLocaleLanguageDirectionTopToBottom = 3; - -const int kCFLocaleLanguageDirectionBottomToTop = 4; - -const int kCFStringEncodingMacRoman = 0; - -const int kCFStringEncodingWindowsLatin1 = 1280; - -const int kCFStringEncodingISOLatin1 = 513; - -const int kCFStringEncodingNextStepLatin = 2817; - -const int kCFStringEncodingASCII = 1536; - -const int kCFStringEncodingUnicode = 256; - -const int kCFStringEncodingUTF8 = 134217984; - -const int kCFStringEncodingNonLossyASCII = 3071; - -const int kCFStringEncodingUTF16 = 256; - -const int kCFStringEncodingUTF16BE = 268435712; - -const int kCFStringEncodingUTF16LE = 335544576; - -const int kCFStringEncodingUTF32 = 201326848; - -const int kCFStringEncodingUTF32BE = 402653440; - -const int kCFStringEncodingUTF32LE = 469762304; - -const int kCFCompareCaseInsensitive = 1; - -const int kCFCompareBackwards = 4; - -const int kCFCompareAnchored = 8; - -const int kCFCompareNonliteral = 16; - -const int kCFCompareLocalized = 32; - -const int kCFCompareNumerically = 64; - -const int kCFCompareDiacriticInsensitive = 128; - -const int kCFCompareWidthInsensitive = 256; - -const int kCFCompareForcedOrdering = 512; - -const int kCFStringNormalizationFormD = 0; - -const int kCFStringNormalizationFormKD = 1; - -const int kCFStringNormalizationFormC = 2; - -const int kCFStringNormalizationFormKC = 3; diff --git a/packages/celest_auth/lib/src/native/darwin/darwin_ffi_helpers.dart b/packages/celest_auth/lib/src/native/darwin/darwin_ffi_helpers.dart deleted file mode 100644 index d975f8fc..00000000 --- a/packages/celest_auth/lib/src/native/darwin/darwin_ffi_helpers.dart +++ /dev/null @@ -1,112 +0,0 @@ -import 'dart:ffi'; - -import 'package:ffi/ffi.dart'; - -import 'core_foundation.ffi.dart'; - -extension StringToCFString on String { - /// Converts `this` to a [CFString] within the given [arena]. - Pointer toCFString(Arena arena) { - final str = toNativeUtf8(allocator: arena); - final cfStr = CFStringCreateWithCString( - nullptr, // default allocator - str.cast(), - kCFStringEncodingUTF8, - ); - arena.onReleaseAll(() { - CFRelease(cfStr.cast()); - }); - return cfStr; - } - - /// Converts `this` to a [CFData] within the given [arena]. - Pointer toCFData(Arena arena) { - final data = toNativeUtf8(allocator: arena); - final cfData = CFDataCreate( - nullptr, // default allocator - data.cast(), - data.length, - ); - arena.onReleaseAll(() { - CFRelease(cfData.cast()); - }); - return cfData; - } -} - -extension MapToCFDictionary on Map { - /// Converts `this` to a [CFDictionary] within the given [arena]. - Pointer toCFDictionary(Arena arena) { - final cfKeys = arena(length); - final cfValues = arena(length); - var i = 0; - for (final entry in entries) { - cfKeys[i] = entry.key.cast(); - cfValues[i] = entry.value.cast(); - i++; - } - final cfDict = CFDictionaryCreate( - nullptr, // default allocator - cfKeys, - cfValues, - length, - nullptr, // kCFTypeDictionaryKeyCallBacks - nullptr, // kCFTypeDictionaryValueCallBacks - ); - arena.onReleaseAll(() { - CFRelease(cfDict.cast()); - }); - return cfDict; - } -} - -extension CFDataRefToString on CFDataRef { - /// Converts `this` to a [String]. - String? toDartString() { - if (this == nullptr) { - return null; - } - final ptr = CFDataGetBytePtr(this); - if (ptr == nullptr) { - return null; - } - return ptr.cast().toDartString(); - } -} - -extension CFStringRefToString on CFStringRef { - /// Converts `this` to a [String]. - String? toDartString() { - if (this == nullptr) return null; - final cStringPtr = CFStringGetCStringPtr( - this, - kCFStringEncodingUTF8, - ); - if (cStringPtr != nullptr) { - return cStringPtr.cast().toDartString(); - } - // Call CFStringGetCString as a backup. - // See: https://developer.apple.com/documentation/corefoundation/1542133-cfstringgetcstringptr - final strLen = CFStringGetLength(this); - final maxLen = CFStringGetMaximumSizeForEncoding( - strLen, - kCFStringEncodingUTF8, - ) + - 1 /* terminating NUL byte */; - final buffer = calloc(maxLen); - try { - final ret = CFStringGetCString( - this, - buffer, - maxLen, - kCFStringEncodingUTF8, - ); - if (ret == 0 /* FALSE */) { - return null; - } - return buffer.cast().toDartString(); - } finally { - calloc.free(buffer); - } - } -} diff --git a/packages/celest_auth/lib/src/native/darwin/foundation.yaml b/packages/celest_auth/lib/src/native/darwin/foundation.yaml index fca9aabd..5ed24ce6 100644 --- a/packages/celest_auth/lib/src/native/darwin/foundation.yaml +++ b/packages/celest_auth/lib/src/native/darwin/foundation.yaml @@ -68,13 +68,13 @@ files: name: NSValue c:objc(cs)Protocol: name: Protocol - "objcBlock: cidr2x*? gplou5 e3833g": + "objcBlock: cptx1f*? c7w328 egoeft": name: ObjCBlock_ObjCObject_NSError_NSString - "objcBlock: d6nkhg d6nkhg* 20skwe": - name: ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong - "objcBlock: d6nkhg e3833g bool*": + "objcBlock: ejnfxy 3u6ow8* gyejpi": + name: ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong + "objcBlock: ejnfxy egoeft bool*": name: ObjCBlock_ffiVoid_NSString_bool - "objcBlock: d6nkhg e3833g? g9ysj6 g9ysj6 bool*": + "objcBlock: ejnfxy egoeft? dxgaxi dxgaxi bool*": name: ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool - "objcBlock: d6nkhg g39d4z* 20skwe": - name: ObjCBlock_ffiVoid_ffiUnsignedShort_ffiUnsignedLong + "objcBlock: ejnfxy ejnfxy* gyejpi": + name: ObjCBlock_ffiVoid_ffiVoid_ffiUnsignedLong diff --git a/packages/celest_auth/lib/src/native/darwin/security.ffi.dart b/packages/celest_auth/lib/src/native/darwin/security.ffi.dart deleted file mode 100644 index 8a719218..00000000 --- a/packages/celest_auth/lib/src/native/darwin/security.ffi.dart +++ /dev/null @@ -1,1594 +0,0 @@ -// ignore_for_file: type=lint -// ignore_for_file: return_of_invalid_type -// ignore_for_file: unnecessary_non_null_assertion - -// AUTO GENERATED FILE, DO NOT EDIT. -// -// Generated by `package:ffigen`. -import 'dart:ffi' as ffi; -import 'package:celest_auth/src/native/darwin/core_foundation.ffi.dart' as cf; - -@ffi.Native() -external double kCFCoreFoundationVersionNumber; - -/// Constant used by some functions to indicate failed searches. -@ffi.Native() -external final int kCFNotFound; - -/// the singleton null instance -@ffi.Native>() -external final ffi.Pointer<__CFNull> kCFNull; - -/// This is a synonym for NULL, if you'd rather use a named constant. -@ffi.Native>() -external final ffi.Pointer<__CFAllocator> kCFAllocatorDefault; - -/// Default system allocator; you rarely need to use this. -@ffi.Native>() -external final ffi.Pointer<__CFAllocator> kCFAllocatorSystemDefault; - -/// This allocator uses malloc(), realloc(), and free(). This should not be -/// generally used; stick to kCFAllocatorDefault whenever possible. This -/// allocator is useful as the "bytesDeallocator" in CFData or -/// "contentsDeallocator" in CFString where the memory was obtained as a -/// result of malloc() type functions. -@ffi.Native>() -external final ffi.Pointer<__CFAllocator> kCFAllocatorMalloc; - -/// This allocator explicitly uses the default malloc zone, returned by -/// malloc_default_zone(). It should only be used when an object is -/// safe to be allocated in non-scanned memory. -@ffi.Native>() -external final ffi.Pointer<__CFAllocator> kCFAllocatorMallocZone; - -/// Null allocator which does nothing and allocates no memory. This allocator -/// is useful as the "bytesDeallocator" in CFData or "contentsDeallocator" -/// in CFString where the memory should not be freed. -@ffi.Native>() -external final ffi.Pointer<__CFAllocator> kCFAllocatorNull; - -/// Special allocator argument to CFAllocatorCreate() which means -/// "use the functions given in the context to allocate the allocator -/// itself as well". -@ffi.Native>() -external final ffi.Pointer<__CFAllocator> kCFAllocatorUseContext; - -/// ! -/// @function SecCopyErrorMessageString -/// @abstract Returns a string describing the specified error result code. -/// @param status An error result code of type OSStatus or CSSM_RETURN, as returned by a Security or CSSM function. -/// @reserved Reserved for future use. Your code should pass NULL in this parameter. -/// @result A reference to an error string, or NULL if no error string is available for the specified result code. Your code must release this reference by calling the CFRelease function. -@ffi.Native)>() -external cf.CFStringRef SecCopyErrorMessageString( - int status, - ffi.Pointer reserved, -); - -@ffi.Native>() -external final ffi.Pointer<__CFBoolean> kCFBooleanTrue; - -@ffi.Native>() -external final ffi.Pointer<__CFBoolean> kCFBooleanFalse; - -@ffi.Native>() -external final ffi.Pointer<__CFNumber> kCFNumberPositiveInfinity; - -@ffi.Native>() -external final ffi.Pointer<__CFNumber> kCFNumberNegativeInfinity; - -@ffi.Native>() -external final ffi.Pointer<__CFNumber> kCFNumberNaN; - -/// ! -/// @constant kCFTypeArrayCallBacks -/// Predefined CFArrayCallBacks structure containing a set of callbacks -/// appropriate for use when the values in a CFArray are all CFTypes. -@ffi.Native() -external final CFArrayCallBacks kCFTypeArrayCallBacks; - -/// ! -/// @constant kCFTypeDictionaryKeyCallBacks -/// Predefined CFDictionaryKeyCallBacks structure containing a -/// set of callbacks appropriate for use when the keys of a -/// CFDictionary are all CFTypes. -@ffi.Native() -external final CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; - -/// ! -/// @constant kCFCopyStringDictionaryKeyCallBacks -/// Predefined CFDictionaryKeyCallBacks structure containing a -/// set of callbacks appropriate for use when the keys of a -/// CFDictionary are all CFStrings, which may be mutable and -/// need to be copied in order to serve as constant keys for -/// the values in the dictionary. -@ffi.Native() -external final CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks; - -/// ! -/// @constant kCFTypeDictionaryValueCallBacks -/// Predefined CFDictionaryValueCallBacks structure containing a set -/// of callbacks appropriate for use when the values in a CFDictionary -/// are all CFTypes. -@ffi.Native() -external final CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; - -/// ! -/// @enum Class Key Constant -/// @discussion Predefined key constant used to get or set item class values in -/// a dictionary. Its value is one of the constants defined in the Value -/// Constants for kSecClass. -/// @constant kSecClass Specifies a dictionary key whose value is the item's -/// class code. You use this key to get or set a value of type CFTypeRef -/// that contains the item class code. -@ffi.Native() -external cf.CFStringRef kSecClass; - -/// ! -/// @enum Class Value Constants -/// @discussion Predefined item class constants used to get or set values in -/// a dictionary. The kSecClass constant is the key and its value is one -/// of the constants defined here. Note: on Mac OS X 10.6, only items -/// of class kSecClassInternetPassword are supported. -/// @constant kSecClassInternetPassword Specifies Internet password items. -/// @constant kSecClassGenericPassword Specifies generic password items. -/// @constant kSecClassCertificate Specifies certificate items. -/// @constant kSecClassKey Specifies key items. -/// @constant kSecClassIdentity Specifies identity items. -@ffi.Native() -external cf.CFStringRef kSecClassInternetPassword; - -@ffi.Native() -external cf.CFStringRef kSecClassGenericPassword; - -@ffi.Native() -external cf.CFStringRef kSecClassCertificate; - -@ffi.Native() -external cf.CFStringRef kSecClassKey; - -@ffi.Native() -external cf.CFStringRef kSecClassIdentity; - -/// ! -/// @enum Attribute Key Constants -/// @discussion Predefined item attribute keys used to get or set values in a -/// dictionary. Not all attributes apply to each item class. The table -/// below lists the currently defined attributes for each item class: -/// -/// kSecClassGenericPassword item attributes: -/// kSecAttrAccess (OS X only) -/// kSecAttrAccessControl -/// kSecAttrAccessGroup (iOS; also OS X if kSecAttrSynchronizable and/or kSecUseDataProtectionKeychain set) -/// kSecAttrAccessible (iOS; also OS X if kSecAttrSynchronizable and/or kSecUseDataProtectionKeychain set) -/// kSecAttrCreationDate -/// kSecAttrModificationDate -/// kSecAttrDescription -/// kSecAttrComment -/// kSecAttrCreator -/// kSecAttrType -/// kSecAttrLabel -/// kSecAttrIsInvisible -/// kSecAttrIsNegative -/// kSecAttrAccount -/// kSecAttrService -/// kSecAttrGeneric -/// kSecAttrSynchronizable -/// -/// kSecClassInternetPassword item attributes: -/// kSecAttrAccess (OS X only) -/// kSecAttrAccessControl -/// kSecAttrAccessGroup (iOS; also OS X if kSecAttrSynchronizable and/or kSecUseDataProtectionKeychain set) -/// kSecAttrAccessible (iOS; also OS X if kSecAttrSynchronizable and/or kSecUseDataProtectionKeychain set) -/// kSecAttrCreationDate -/// kSecAttrModificationDate -/// kSecAttrDescription -/// kSecAttrComment -/// kSecAttrCreator -/// kSecAttrType -/// kSecAttrLabel -/// kSecAttrIsInvisible -/// kSecAttrIsNegative -/// kSecAttrAccount -/// kSecAttrSecurityDomain -/// kSecAttrServer -/// kSecAttrProtocol -/// kSecAttrAuthenticationType -/// kSecAttrPort -/// kSecAttrPath -/// kSecAttrSynchronizable -/// -/// kSecClassCertificate item attributes: -/// kSecAttrAccessible (iOS only) -/// kSecAttrAccessControl (iOS only) -/// kSecAttrAccessGroup (iOS only) -/// kSecAttrCertificateType -/// kSecAttrCertificateEncoding -/// kSecAttrLabel -/// kSecAttrSubject -/// kSecAttrIssuer -/// kSecAttrSerialNumber -/// kSecAttrSubjectKeyID -/// kSecAttrPublicKeyHash -/// kSecAttrSynchronizable -/// -/// kSecClassKey item attributes: -/// kSecAttrAccess (OS X only) -/// kSecAttrAccessControl -/// kSecAttrAccessGroup (iOS; also OS X if kSecAttrSynchronizable and/or kSecUseDataProtectionKeychain set) -/// kSecAttrAccessible (iOS; also OS X if kSecAttrSynchronizable and/or kSecUseDataProtectionKeychain set) -/// kSecAttrKeyClass -/// kSecAttrLabel -/// kSecAttrApplicationLabel -/// kSecAttrIsPermanent -/// kSecAttrApplicationTag -/// kSecAttrKeyType -/// kSecAttrPRF (OS X only) -/// kSecAttrSalt (OS X only) -/// kSecAttrRounds (OS X only) -/// kSecAttrKeySizeInBits -/// kSecAttrEffectiveKeySize -/// kSecAttrCanEncrypt -/// kSecAttrCanDecrypt -/// kSecAttrCanDerive -/// kSecAttrCanSign -/// kSecAttrCanVerify -/// kSecAttrCanWrap -/// kSecAttrCanUnwrap -/// kSecAttrSynchronizable -/// -/// Note that the attributes kSecAttrCan* describe attributes of the -/// key itself at relatively high level. Some of these attributes are -/// mathematical -- for example, a DSA key cannot encrypt. Others are -/// key-level policy issues -- for example, it is good cryptographic -/// hygiene to use an RSA key either for encryption or signing but not -/// both. Compare these to the certificate-level policy values in -/// SecPolicy.h. -/// -/// kSecClassIdentity item attributes: -/// Since an identity is the combination of a private key and a -/// certificate, this class shares attributes of both kSecClassKey and -/// kSecClassCertificate. -/// -/// @constant kSecAttrAccessible Specifies a dictionary key whose value -/// indicates when your application needs access to an item's data. You -/// should choose the most restrictive option that meets your application's -/// needs to allow the system to protect that item in the best way possible. -/// See the "kSecAttrAccessible Value Constants" section for a list of -/// values which can be specified. -/// IMPORTANT: This attribute is currently not supported for OS X keychain -/// items, unless the kSecAttrSynchronizable attribute is also present. If -/// both attributes are specified on either OS X or iOS, the value for the -/// kSecAttrAccessible key may only be one whose name does not end with -/// "ThisDeviceOnly", as those cannot sync to another device. -/// -/// @constant kSecAttrAccessControl Specifies a dictionary key whose value -/// is SecAccessControl instance which contains access control conditions -/// for item. -/// IMPORTANT: This attribute is mutually exclusive with kSecAttrAccess -/// attribute. -/// -/// @constant kSecAttrAccess Specifies a dictionary key whose value -/// is a SecAccessRef describing the access control settings for this item. -/// This key is available on OS X only. -/// -/// @constant kSecAttrAccessGroup Specifies a dictionary key whose value is -/// a CFStringRef indicating which access group a item is in. The access -/// groups that a particular application has membership in are determined by -/// two entitlements for that application. The application-identifier -/// entitlement contains the application's single access group, unless -/// there is a keychain-access-groups entitlement present. The latter -/// has as its value a list of access groups; the first item in this list -/// is the default access group. Unless a specific access group is provided -/// as the value of kSecAttrAccessGroup when SecItemAdd is called, new items -/// are created in the application's default access group. Specifying this -/// attribute in SecItemCopyMatching, SecItemUpdate, or SecItemDelete calls -/// limits the search to the specified access group (of which the calling -/// application must be a member to obtain matching results.) To share -/// keychain items between multiple applications, each application must have -/// a common group listed in its keychain-access-groups entitlement, and each -/// must specify this shared access group name as the value for the -/// kSecAttrAccessGroup key in the dictionary passed to SecItem functions. -/// -/// @constant kSecAttrSynchronizable Specifies a dictionary key whose value is -/// a CFBooleanRef indicating whether the item in question can be synchronized. -/// To add a new item which can be synced to other devices, or to obtain -/// synchronizable results from a query, supply this key with a value of -/// kCFBooleanTrue. If the key is not supplied, or has a value of -/// kCFBooleanFalse, then no synchronizable items will be added or returned. -/// A predefined value, kSecAttrSynchronizableAny, may be provided instead of -/// kCFBooleanTrue if both synchronizable and non-synchronizable results are -/// desired. -/// -/// IMPORTANT: Specifying the kSecAttrSynchronizable key has several caveats: -/// -/// - Updating or deleting items using the kSecAttrSynchronizable key will -/// affect all copies of the item, not just the one on your local device. -/// Be sure that it makes sense to use the same password on all devices -/// before deciding to make a password synchronizable. -/// - Starting in iOS 14, macOS 11, and watchOS 7, the keychain -/// synchronizes passwords, certificates, and cryptographic keys. -/// Earlier OS versions synchronize only passwords. -/// - Items stored or obtained using the kSecAttrSynchronizable key cannot -/// specify SecAccessRef-based access control with kSecAttrAccess. If a -/// password is intended to be shared between multiple applications, the -/// kSecAttrAccessGroup key must be specified, and each application -/// using this password must have a 'keychain-access-groups' entitlement -/// with the specified access group value. -/// - Items stored or obtained using the kSecAttrSynchronizable key may -/// not also specify a kSecAttrAccessible value which is incompatible -/// with syncing (namely, those whose names end with "ThisDeviceOnly".) -/// - On macOS, when kSecAttrSynchronizable is set to true, returning -/// references is supported only for Certificate, Key or Identity items. -/// - Persistent references to synchronizable items should be avoided; -/// while they may work locally, they cannot be moved between devices, -/// and may not resolve if the item is modified on some other device. -/// - When specifying a query that uses the kSecAttrSynchronizable key, -/// search keys are limited to the item's class and attributes. -/// The only search constant which may be used is kSecMatchLimit; other -/// constants using the kSecMatch prefix are not supported at this time. -/// -/// @constant kSecAttrSynchronizableAny Specifies that both synchronizable and -/// non-synchronizable results should be returned from this query. This may be -/// used as a value for the kSecAttrSynchronizable dictionary key in a call to -/// SecItemCopyMatching, SecItemUpdate, or SecItemDelete. -/// -/// @constant kSecAttrCreationDate (read-only) Specifies a dictionary key whose -/// value is the item's creation date. You use this key to get a value -/// of type CFDateRef that represents the date the item was created. -/// @constant kSecAttrModificationDate (read-only) Specifies a dictionary key -/// whose value is the item's modification date. You use this key to get -/// a value of type CFDateRef that represents the last time the item was -/// updated. -/// @constant kSecAttrDescription Specifies a dictionary key whose value is -/// the item's description attribute. You use this key to set or get a -/// value of type CFStringRef that represents a user-visible string -/// describing this particular kind of item (e.g., "disk image password"). -/// @constant kSecAttrComment Specifies a dictionary key whose value is the -/// item's comment attribute. You use this key to set or get a value of -/// type CFStringRef containing the user-editable comment for this item. -/// @constant kSecAttrCreator Specifies a dictionary key whose value is the -/// item's creator attribute. You use this key to set or get a value of -/// type CFNumberRef that represents the item's creator. This number is -/// the unsigned integer representation of a four-character code (e.g., -/// 'aCrt'). -/// @constant kSecAttrType Specifies a dictionary key whose value is the item's -/// type attribute. You use this key to set or get a value of type -/// CFNumberRef that represents the item's type. This number is the -/// unsigned integer representation of a four-character code (e.g., -/// 'aTyp'). -/// @constant kSecAttrLabel Specifies a dictionary key whose value is the -/// item's label attribute. You use this key to set or get a value of -/// type CFStringRef containing the user-visible label for this item. -/// @constant kSecAttrIsInvisible Specifies a dictionary key whose value is the -/// item's invisible attribute. You use this key to set or get a value -/// of type CFBooleanRef that indicates whether the item is invisible -/// (i.e., should not be displayed.) -/// @constant kSecAttrIsNegative Specifies a dictionary key whose value is the -/// item's negative attribute. You use this key to set or get a value of -/// type CFBooleanRef that indicates whether there is a valid password -/// associated with this keychain item. This is useful if your application -/// doesn't want a password for some particular service to be stored in -/// the keychain, but prefers that it always be entered by the user. -/// @constant kSecAttrAccount Specifies a dictionary key whose value is the -/// item's account attribute. You use this key to set or get a CFStringRef -/// that contains an account name. (Items of class -/// kSecClassGenericPassword, kSecClassInternetPassword have this -/// attribute.) -/// @constant kSecAttrService Specifies a dictionary key whose value is the -/// item's service attribute. You use this key to set or get a CFStringRef -/// that represents the service associated with this item. (Items of class -/// kSecClassGenericPassword have this attribute.) -/// @constant kSecAttrGeneric Specifies a dictionary key whose value is the -/// item's generic attribute. You use this key to set or get a value of -/// CFDataRef that contains a user-defined attribute. (Items of class -/// kSecClassGenericPassword have this attribute.) -/// @constant kSecAttrSecurityDomain Specifies a dictionary key whose value -/// is the item's security domain attribute. You use this key to set or -/// get a CFStringRef value that represents the Internet security domain. -/// (Items of class kSecClassInternetPassword have this attribute.) -/// @constant kSecAttrServer Specifies a dictionary key whose value is the -/// item's server attribute. You use this key to set or get a value of -/// type CFStringRef that contains the server's domain name or IP address. -/// (Items of class kSecClassInternetPassword have this attribute.) -/// @constant kSecAttrProtocol Specifies a dictionary key whose value is the -/// item's protocol attribute. You use this key to set or get a value of -/// type CFNumberRef that denotes the protocol for this item (see the -/// SecProtocolType enum in SecKeychainItem.h). (Items of class -/// kSecClassInternetPassword have this attribute.) -/// @constant kSecAttrAuthenticationType Specifies a dictionary key whose value -/// is the item's authentication type attribute. You use this key to set -/// or get a value of type CFNumberRef that denotes the authentication -/// scheme for this item (see the kSecAttrAuthenticationType value -/// constants below). -/// @constant kSecAttrPort Specifies a dictionary key whose value is the item's -/// port attribute. You use this key to set or get a CFNumberRef value -/// that represents an Internet port number. (Items of class -/// kSecClassInternetPassword have this attribute.) -/// @constant kSecAttrPath Specifies a dictionary key whose value is the item's -/// path attribute, typically this is the path component of the URL. You use -/// this key to set or get a CFStringRef value that represents a path. (Items -/// of class kSecClassInternetPassword have this attribute.) -/// @constant kSecAttrSubject (read-only) Specifies a dictionary key whose -/// value is the item's subject. You use this key to get a value of type -/// CFDataRef that contains the X.500 subject name of a certificate. -/// (Items of class kSecClassCertificate have this attribute.) -/// @constant kSecAttrIssuer (read-only) Specifies a dictionary key whose value -/// is the item's issuer. You use this key to get a value of type -/// CFDataRef that contains the X.500 issuer name of a certificate. (Items -/// of class kSecClassCertificate have this attribute.) -/// @constant kSecAttrSerialNumber (read-only) Specifies a dictionary key whose -/// value is the item's serial number. You use this key to get a value -/// of type CFDataRef that contains the serial number data of a -/// certificate. (Items of class kSecClassCertificate have this -/// attribute.) -/// @constant kSecAttrSubjectKeyID (read-only) Specifies a dictionary key whose -/// value is the item's subject key ID. You use this key to get a value -/// of type CFDataRef that contains the subject key ID of a certificate. -/// (Items of class kSecClassCertificate have this attribute.) -/// @constant kSecAttrPublicKeyHash (read-only) Specifies a dictionary key -/// whose value is the item's public key hash. You use this key to get a -/// value of type CFDataRef that contains the hash of a certificate's -/// public key. (Items of class kSecClassCertificate have this attribute.) -/// @constant kSecAttrCertificateType (read-only) Specifies a dictionary key -/// whose value is the item's certificate type. You use this key to get -/// a value of type CFNumberRef that denotes the certificate type -/// (On iOS, currently the value of this attribute must be equal to the -/// version of the X509 certificate. So, 1 for v1, 2 for v2, and 3 for v3 -/// certificates). (On OSX, see the CSSM_CERT_TYPE enum in cssmtype.h). -/// Only items of class kSecClassCertificate have this attribute. -/// @constant kSecAttrCertificateEncoding (read-only) Specifies a dictionary -/// key whose value is the item's certificate encoding. You use this key -/// to get a value of type CFNumberRef that denotes the certificate -/// encoding (On iOS, currently only the value 3 meaning -/// kSecAttrCertificateEncodingDER is supported). On OSX, see the -/// CSSM_CERT_ENCODING enum in cssmtype.h. Only items of class -/// kSecClassCertificate have this attribute. -/// @constant kSecAttrKeyClass (read only) Specifies a dictionary key whose -/// value is one of kSecAttrKeyClassPublic, kSecAttrKeyClassPrivate or -/// kSecAttrKeyClassSymmetric. -/// @constant kSecAttrApplicationLabel Specifies a dictionary key whose value -/// is the key's application label attribute. This is different from the -/// kSecAttrLabel (which is intended to be human-readable). This attribute -/// is used to look up a key programmatically; in particular, for keys of -/// class kSecAttrKeyClassPublic and kSecAttrKeyClassPrivate, the value of -/// this attribute is the hash of the public key. This item is a type of CFDataRef. -/// Legacy keys may contain a UUID in this field as a CFStringRef. -/// @constant kSecAttrIsPermanent Specifies a dictionary key whose value is a -/// CFBooleanRef indicating whether the key in question will be stored -/// permanently. -/// @constant kSecAttrIsSensitive Specifies a dictionary key whose value is a -/// CFBooleanRef indicating that the key in question can only be exported -/// in a wrapped (encrypted) format. OS X only. -/// @constant kSecAttrIsExtractable Specifies a dictionary key whose value is a -/// CFBooleanRef indicating whether the key in question can be exported from -/// its keychain container. OS X only. -/// @constant kSecAttrApplicationTag Specifies a dictionary key whose value is a -/// CFDataRef containing private tag data. -/// @constant kSecAttrKeyType Specifies a dictionary key whose value is a -/// CFNumberRef indicating the algorithm associated with this key -/// (On iOS, currently only the value 42 is supported, alternatively you can use -/// kSecAttrKeyTypeRSA). (On OSX, see the CSSM_ALGORITHMS enum in cssmtype.h). -/// -/// @constant kSecAttrPRF Specifies a dictionary key whose value is the PRF -/// (pseudo-random function) for this key (see "kSecAttrPRF Value Constants".) -/// OS X only. -/// @constant kSecAttrSalt Specifies a dictionary key whose value is a -/// CFData containing the salt to use for this key. OS X only. -/// @constant kSecAttrRounds Specifies a dictionary key whose value is the -/// number of rounds for the pseudo-random function specified by kSecAttrPRF. -/// OS X only. -/// @constant kSecAttrKeySizeInBits Specifies a dictionary key whose value -/// is a CFNumberRef indicating the number of bits in this key. -/// @constant kSecAttrEffectiveKeySize Specifies a dictionary key whose value -/// is a CFNumberRef indicating the effective number of bits in this key. -/// For example, a DES key has a kSecAttrKeySizeInBits of 64, but a -/// kSecAttrEffectiveKeySize of 56 bits. -/// @constant kSecAttrCanEncrypt Specifies a dictionary key whole value is a -/// CFBooleanRef indicating whether the key in question can be used to -/// encrypt data. -/// @constant kSecAttrCanDecrypt Specifies a dictionary key whose value is a -/// CFBooleanRef indicating whether the key in question can be used to -/// decrypt data. -/// @constant kSecAttrCanDerive Specifies a dictionary key whole value is a -/// CFBooleanRef indicating whether the key in question can be used to -/// derive another key. -/// @constant kSecAttrCanSign Specifies a dictionary key whole value is a -/// CFBooleanRef indicating whether the key in question can be used to -/// create a digital signature. -/// @constant kSecAttrCanVerify Specifies a dictionary key whole value is a -/// CFBooleanRef indicating whether the key in question can be used to -/// verify a digital signature. -/// @constant kSecAttrCanWrap Specifies a dictionary key whole value is a -/// CFBooleanRef indicating whether the key in question can be used to -/// wrap another key. -/// @constant kSecAttrCanUnwrap Specifies a dictionary key whole value is a -/// CFBooleanRef indicating whether the key in question can be used to -/// unwrap another key. -/// @constant kSecAttrSyncViewHint Specifies a dictionary key whose value is -/// a CFStringRef. This value is part of the primary key of each item, and -/// can be used to help distiguish Sync Views when defining their -/// queries. iOS and sychronizable items only. -/// @constant kSecAttrTokenID Specifies a dictionary key whose presence -/// indicates that item is backed by external token. Value of this attribute -/// is CFStringRef uniquely identifying containing token. When this attribute -/// is not present, item is stored in internal keychain database. -/// Note that once item is created, this attribute cannot be changed - in other -/// words it is not possible to migrate existing items to, from or between tokens. -/// Currently the only available value for this attribute is -/// kSecAttrTokenIDSecureEnclave, which indicates that item (private key) is -/// backed by device's Secure Enclave. -@ffi.Native() -external cf.CFStringRef kSecAttrAccessible; - -@ffi.Native() -external cf.CFStringRef kSecAttrAccess; - -@ffi.Native() -external cf.CFStringRef kSecAttrAccessControl; - -@ffi.Native() -external cf.CFStringRef kSecAttrAccessGroup; - -@ffi.Native() -external cf.CFStringRef kSecAttrSynchronizable; - -@ffi.Native() -external cf.CFStringRef kSecAttrSynchronizableAny; - -@ffi.Native() -external cf.CFStringRef kSecAttrCreationDate; - -@ffi.Native() -external cf.CFStringRef kSecAttrModificationDate; - -@ffi.Native() -external cf.CFStringRef kSecAttrDescription; - -@ffi.Native() -external cf.CFStringRef kSecAttrComment; - -@ffi.Native() -external cf.CFStringRef kSecAttrCreator; - -@ffi.Native() -external cf.CFStringRef kSecAttrType; - -@ffi.Native() -external cf.CFStringRef kSecAttrLabel; - -@ffi.Native() -external cf.CFStringRef kSecAttrIsInvisible; - -@ffi.Native() -external cf.CFStringRef kSecAttrIsNegative; - -@ffi.Native() -external cf.CFStringRef kSecAttrAccount; - -@ffi.Native() -external cf.CFStringRef kSecAttrService; - -@ffi.Native() -external cf.CFStringRef kSecAttrGeneric; - -@ffi.Native() -external cf.CFStringRef kSecAttrSecurityDomain; - -@ffi.Native() -external cf.CFStringRef kSecAttrServer; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocol; - -@ffi.Native() -external cf.CFStringRef kSecAttrAuthenticationType; - -@ffi.Native() -external cf.CFStringRef kSecAttrPort; - -@ffi.Native() -external cf.CFStringRef kSecAttrPath; - -@ffi.Native() -external cf.CFStringRef kSecAttrSubject; - -@ffi.Native() -external cf.CFStringRef kSecAttrIssuer; - -@ffi.Native() -external cf.CFStringRef kSecAttrSerialNumber; - -@ffi.Native() -external cf.CFStringRef kSecAttrSubjectKeyID; - -@ffi.Native() -external cf.CFStringRef kSecAttrPublicKeyHash; - -@ffi.Native() -external cf.CFStringRef kSecAttrCertificateType; - -@ffi.Native() -external cf.CFStringRef kSecAttrCertificateEncoding; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyClass; - -@ffi.Native() -external cf.CFStringRef kSecAttrApplicationLabel; - -@ffi.Native() -external cf.CFStringRef kSecAttrIsPermanent; - -@ffi.Native() -external cf.CFStringRef kSecAttrIsSensitive; - -@ffi.Native() -external cf.CFStringRef kSecAttrIsExtractable; - -@ffi.Native() -external cf.CFStringRef kSecAttrApplicationTag; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyType; - -@ffi.Native() -external cf.CFStringRef kSecAttrPRF; - -@ffi.Native() -external cf.CFStringRef kSecAttrSalt; - -@ffi.Native() -external cf.CFStringRef kSecAttrRounds; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeySizeInBits; - -@ffi.Native() -external cf.CFStringRef kSecAttrEffectiveKeySize; - -@ffi.Native() -external cf.CFStringRef kSecAttrCanEncrypt; - -@ffi.Native() -external cf.CFStringRef kSecAttrCanDecrypt; - -@ffi.Native() -external cf.CFStringRef kSecAttrCanDerive; - -@ffi.Native() -external cf.CFStringRef kSecAttrCanSign; - -@ffi.Native() -external cf.CFStringRef kSecAttrCanVerify; - -@ffi.Native() -external cf.CFStringRef kSecAttrCanWrap; - -@ffi.Native() -external cf.CFStringRef kSecAttrCanUnwrap; - -@ffi.Native() -external cf.CFStringRef kSecAttrSyncViewHint; - -@ffi.Native() -external cf.CFStringRef kSecAttrTokenID; - -@ffi.Native() -external cf.CFStringRef kSecAttrPersistantReference; - -@ffi.Native() -external cf.CFStringRef kSecAttrPersistentReference; - -/// ! -/// @enum kSecAttrAccessible Value Constants -/// @discussion Predefined item attribute constants used to get or set values -/// in a dictionary. The kSecAttrAccessible constant is the key and its -/// value is one of the constants defined here. -/// When asking SecItemCopyMatching to return the item's data, the error -/// errSecInteractionNotAllowed will be returned if the item's data is not -/// available until a device unlock occurs. -/// @constant kSecAttrAccessibleWhenUnlocked Item data can only be accessed -/// while the device is unlocked. This is recommended for items that only -/// need be accesible while the application is in the foreground. Items -/// with this attribute will migrate to a new device when using encrypted -/// backups. -/// @constant kSecAttrAccessibleAfterFirstUnlock Item data can only be -/// accessed once the device has been unlocked after a restart. This is -/// recommended for items that need to be accesible by background -/// applications. Items with this attribute will migrate to a new device -/// when using encrypted backups. -/// @constant kSecAttrAccessibleAlways Item data can always be accessed -/// regardless of the lock state of the device. This is not recommended -/// for anything except system use. Items with this attribute will migrate -/// to a new device when using encrypted backups. -/// @constant kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly Item data can -/// only be accessed while the device is unlocked. This is recommended for -/// items that only need to be accessible while the application is in the -/// foreground and requires a passcode to be set on the device. Items with -/// this attribute will never migrate to a new device, so after a backup -/// is restored to a new device, these items will be missing. This -/// attribute will not be available on devices without a passcode. Disabling -/// the device passcode will cause all previously protected items to -/// be deleted. -/// @constant kSecAttrAccessibleWhenUnlockedThisDeviceOnly Item data can only -/// be accessed while the device is unlocked. This is recommended for items -/// that only need be accesible while the application is in the foreground. -/// Items with this attribute will never migrate to a new device, so after -/// a backup is restored to a new device, these items will be missing. -/// @constant kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly Item data can -/// only be accessed once the device has been unlocked after a restart. -/// This is recommended for items that need to be accessible by background -/// applications. Items with this attribute will never migrate to a new -/// device, so after a backup is restored to a new device these items will -/// be missing. -/// @constant kSecAttrAccessibleAlwaysThisDeviceOnly Item data can always -/// be accessed regardless of the lock state of the device. This option -/// is not recommended for anything except system use. Items with this -/// attribute will never migrate to a new device, so after a backup is -/// restored to a new device, these items will be missing. -@ffi.Native() -external cf.CFStringRef kSecAttrAccessibleWhenUnlocked; - -@ffi.Native() -external cf.CFStringRef kSecAttrAccessibleAfterFirstUnlock; - -@ffi.Native() -external cf.CFStringRef kSecAttrAccessibleAlways; - -@ffi.Native() -external cf.CFStringRef kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly; - -@ffi.Native() -external cf.CFStringRef kSecAttrAccessibleWhenUnlockedThisDeviceOnly; - -@ffi.Native() -external cf.CFStringRef kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly; - -@ffi.Native() -external cf.CFStringRef kSecAttrAccessibleAlwaysThisDeviceOnly; - -/// ! -/// @enum kSecAttrProtocol Value Constants -/// @discussion Predefined item attribute constants used to get or set values -/// in a dictionary. The kSecAttrProtocol constant is the key and its -/// value is one of the constants defined here. -/// @constant kSecAttrProtocolFTP. -/// @constant kSecAttrProtocolFTPAccount. -/// @constant kSecAttrProtocolHTTP. -/// @constant kSecAttrProtocolIRC. -/// @constant kSecAttrProtocolNNTP. -/// @constant kSecAttrProtocolPOP3. -/// @constant kSecAttrProtocolSMTP. -/// @constant kSecAttrProtocolSOCKS. -/// @constant kSecAttrProtocolIMAP. -/// @constant kSecAttrProtocolLDAP. -/// @constant kSecAttrProtocolAppleTalk. -/// @constant kSecAttrProtocolAFP. -/// @constant kSecAttrProtocolTelnet. -/// @constant kSecAttrProtocolSSH. -/// @constant kSecAttrProtocolFTPS. -/// @constant kSecAttrProtocolHTTPS. -/// @constant kSecAttrProtocolHTTPProxy. -/// @constant kSecAttrProtocolHTTPSProxy. -/// @constant kSecAttrProtocolFTPProxy. -/// @constant kSecAttrProtocolSMB. -/// @constant kSecAttrProtocolRTSP. -/// @constant kSecAttrProtocolRTSPProxy. -/// @constant kSecAttrProtocolDAAP. -/// @constant kSecAttrProtocolEPPC. -/// @constant kSecAttrProtocolIPP. -/// @constant kSecAttrProtocolNNTPS. -/// @constant kSecAttrProtocolLDAPS. -/// @constant kSecAttrProtocolTelnetS. -/// @constant kSecAttrProtocolIMAPS. -/// @constant kSecAttrProtocolIRCS. -/// @constant kSecAttrProtocolPOP3S. -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolFTP; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolFTPAccount; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolHTTP; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolIRC; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolNNTP; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolPOP3; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolSMTP; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolSOCKS; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolIMAP; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolLDAP; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolAppleTalk; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolAFP; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolTelnet; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolSSH; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolFTPS; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolHTTPS; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolHTTPProxy; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolHTTPSProxy; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolFTPProxy; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolSMB; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolRTSP; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolRTSPProxy; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolDAAP; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolEPPC; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolIPP; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolNNTPS; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolLDAPS; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolTelnetS; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolIMAPS; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolIRCS; - -@ffi.Native() -external cf.CFStringRef kSecAttrProtocolPOP3S; - -/// ! -/// @enum kSecAttrAuthenticationType Value Constants -/// @discussion Predefined item attribute constants used to get or set values -/// in a dictionary. The kSecAttrAuthenticationType constant is the key -/// and its value is one of the constants defined here. -/// @constant kSecAttrAuthenticationTypeNTLM. -/// @constant kSecAttrAuthenticationTypeMSN. -/// @constant kSecAttrAuthenticationTypeDPA. -/// @constant kSecAttrAuthenticationTypeRPA. -/// @constant kSecAttrAuthenticationTypeHTTPBasic. -/// @constant kSecAttrAuthenticationTypeHTTPDigest. -/// @constant kSecAttrAuthenticationTypeHTMLForm. -/// @constant kSecAttrAuthenticationTypeDefault. -@ffi.Native() -external cf.CFStringRef kSecAttrAuthenticationTypeNTLM; - -@ffi.Native() -external cf.CFStringRef kSecAttrAuthenticationTypeMSN; - -@ffi.Native() -external cf.CFStringRef kSecAttrAuthenticationTypeDPA; - -@ffi.Native() -external cf.CFStringRef kSecAttrAuthenticationTypeRPA; - -@ffi.Native() -external cf.CFStringRef kSecAttrAuthenticationTypeHTTPBasic; - -@ffi.Native() -external cf.CFStringRef kSecAttrAuthenticationTypeHTTPDigest; - -@ffi.Native() -external cf.CFStringRef kSecAttrAuthenticationTypeHTMLForm; - -@ffi.Native() -external cf.CFStringRef kSecAttrAuthenticationTypeDefault; - -/// ! -/// @enum kSecAttrKeyClass Value Constants -/// @discussion Predefined item attribute constants used to get or set values -/// in a dictionary. The kSecAttrKeyClass constant is the key -/// and its value is one of the constants defined here. -/// @constant kSecAttrKeyClassPublic. -/// @constant kSecAttrKeyClassPrivate. -/// @constant kSecAttrKeyClassSymmetric. -@ffi.Native() -external cf.CFStringRef kSecAttrKeyClassPublic; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyClassPrivate; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyClassSymmetric; - -/// ! -/// @enum kSecAttrKeyType Value Constants -/// @discussion Predefined item attribute constants used to get or set values -/// in a dictionary. The kSecAttrKeyType constant is the key -/// and its value is one of the constants defined here. -/// @constant kSecAttrKeyTypeECSECPrimeRandom. The used curve is P-192, P-256, P-384 or P-521. -/// The size is specified by kSecAttrKeySizeInBits attribute. Curves are defined in FIPS PUB 186-4 standard. -/// @constant kSecAttrKeyTypeEC This is the legacy name for kSecAttrKeyTypeECSECPrimeRandom, new applications should not use it. -/// @constant kSecAttrKeyTypeDSA (OSX only) -/// @constant kSecAttrKeyTypeAES (OSX only) -/// @constant kSecAttrKeyType3DES (OSX only) -/// @constant kSecAttrKeyTypeRC4 (OSX only) -/// @constant kSecAttrKeyTypeRC2 (OSX only) -/// @constant kSecAttrKeyTypeCAST (OSX only) -/// @constant kSecAttrKeyTypeECDSA (deprecated; use kSecAttrKeyTypeECSECPrimeRandom instead.) (OSX only) -@ffi.Native() -external cf.CFStringRef kSecAttrKeyTypeRSA; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyTypeDSA; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyTypeAES; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyTypeDES; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyType3DES; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyTypeRC4; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyTypeRC2; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyTypeCAST; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyTypeECDSA; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyTypeEC; - -@ffi.Native() -external cf.CFStringRef kSecAttrKeyTypeECSECPrimeRandom; - -/// @enum kSecAttrPRF Value Constants -/// @discussion Predefined item attribute constants used to specify the PRF -/// to use with SecKeyDeriveFromPassword. OS X only. -/// @constant kSecAttrPRFHmacAlgSHA1 -/// @constant kSecAttrPRFHmacAlgSHA224 -/// @constant kSecAttrPRFHmacAlgSHA256 -/// @constant kSecAttrPRFHmacAlgSHA384 -/// @constant kSecAttrPRFHmacAlgSHA512 -@ffi.Native() -external cf.CFStringRef kSecAttrPRFHmacAlgSHA1; - -@ffi.Native() -external cf.CFStringRef kSecAttrPRFHmacAlgSHA224; - -@ffi.Native() -external cf.CFStringRef kSecAttrPRFHmacAlgSHA256; - -@ffi.Native() -external cf.CFStringRef kSecAttrPRFHmacAlgSHA384; - -@ffi.Native() -external cf.CFStringRef kSecAttrPRFHmacAlgSHA512; - -/// ! -/// @enum Search Constants -/// @discussion Predefined search constants used to set values in a query -/// dictionary. You can specify a combination of search attributes and -/// item attributes when looking for matching items with the -/// SecItemCopyMatching function. -/// @constant kSecMatchPolicy Specifies a dictionary key whose value is a -/// SecPolicyRef. If provided, returned certificates or identities must -/// verify with this policy. -/// @constant kSecMatchItemList OS X only. Specifies a dictionary key whose value is a -/// CFArray of SecKeychainItemRef items. If provided, returned items will be -/// limited to the subset which are contained in this list. -/// @constant kSecMatchSearchList Specifies a dictionary key whose value is a -/// CFArray of SecKeychainRef items. If provided, the search will be limited -/// to the keychains contained in this list. -/// @constant kSecMatchIssuers Specifies a dictionary key whose value is a -/// CFArray of X.500 names (of type CFDataRef). If provided, returned -/// certificates or identities will be limited to those whose -/// certificate chain contains one of the issuers provided in this list. -/// @constant kSecMatchEmailAddressIfPresent Specifies a dictionary key whose -/// value is a CFStringRef containing an RFC822 email address. If -/// provided, returned certificates or identities will be limited to those -/// that contain the address in their subject or subject alternative name. -/// @constant kSecMatchSubjectContains Specifies a dictionary key whose value -/// is a CFStringRef. If provided, returned certificates or identities -/// will be limited to those containing this string in the subject. -/// @constant kSecMatchSubjectStartsWith OS X only. Specifies a dictionary key whose value -/// is a CFStringRef. If provided, returned certificates or identities -/// will be limited to those with subject names that start with this string. -/// @constant kSecMatchSubjectEndsWith OS X only. Specifies a dictionary key whose value -/// is a CFStringRef. If provided, returned certificates or identities -/// will be limited to those with subject names that end with this string. -/// @constant kSecMatchSubjectWholeString OS X only. Specifies a dictionary key whose -/// value is a CFStringRef. If provided, returned certificates or identities -/// will be limited to those matching this string exactly in the subject. -/// @constant kSecMatchCaseInsensitive Specifies a dictionary key whose value -/// is a CFBooleanRef. If this value is kCFBooleanFalse, or is not -/// provided, then case-sensitive string matching is performed. -/// @constant kSecMatchDiacriticInsensitive OS X only. Specifies a dictionary key whose -/// value is a CFBooleanRef. If this value is kCFBooleanFalse, or is not -/// provided, then diacritic-sensitive string matching is performed. -/// @constant kSecMatchWidthInsensitive OS X only. Specifies a dictionary key whose -/// value is a CFBooleanRef. If this value is kCFBooleanFalse, or is not -/// provided, then string matching is width-sensitive (e.g. 'a' != 0xFF41). -/// @constant kSecMatchTrustedOnly Specifies a dictionary key whose value is -/// a CFBooleanRef. If provided with a value of kCFBooleanTrue, only -/// certificates which can be verified back to a trusted anchor will be -/// returned. If this value is kCFBooleanFalse, or is not provided, then -/// both trusted and untrusted certificates may be returned. -/// @constant kSecMatchValidOnDate Specifies a dictionary key whose value is -/// of type CFDateRef. If provided, returned keys, certificates or -/// identities will be limited to those which are valid for the given date. -/// Pass a value of kCFNull to indicate the current date. -/// @constant kSecMatchLimit Specifies a dictionary key whose value is a -/// CFNumberRef. If provided, this value specifies the maximum number of -/// results to return. If not provided, results are limited to the first -/// item found. Predefined values are provided for a single item -/// (kSecMatchLimitOne) and all matching items (kSecMatchLimitAll). -/// @constant kSecMatchLimitOne Specifies that results are limited to the first -/// item found; used as a value for the kSecMatchLimit dictionary key. -/// @constant kSecMatchLimitAll Specifies that an unlimited number of results -/// may be returned; used as a value for the kSecMatchLimit dictionary -/// key. -@ffi.Native() -external cf.CFStringRef kSecMatchPolicy; - -@ffi.Native() -external cf.CFStringRef kSecMatchItemList; - -@ffi.Native() -external cf.CFStringRef kSecMatchSearchList; - -@ffi.Native() -external cf.CFStringRef kSecMatchIssuers; - -@ffi.Native() -external cf.CFStringRef kSecMatchEmailAddressIfPresent; - -@ffi.Native() -external cf.CFStringRef kSecMatchSubjectContains; - -@ffi.Native() -external cf.CFStringRef kSecMatchSubjectStartsWith; - -@ffi.Native() -external cf.CFStringRef kSecMatchSubjectEndsWith; - -@ffi.Native() -external cf.CFStringRef kSecMatchSubjectWholeString; - -@ffi.Native() -external cf.CFStringRef kSecMatchCaseInsensitive; - -@ffi.Native() -external cf.CFStringRef kSecMatchDiacriticInsensitive; - -@ffi.Native() -external cf.CFStringRef kSecMatchWidthInsensitive; - -@ffi.Native() -external cf.CFStringRef kSecMatchTrustedOnly; - -@ffi.Native() -external cf.CFStringRef kSecMatchValidOnDate; - -@ffi.Native() -external cf.CFStringRef kSecMatchLimit; - -@ffi.Native() -external cf.CFStringRef kSecMatchLimitOne; - -@ffi.Native() -external cf.CFStringRef kSecMatchLimitAll; - -/// ! -/// @enum Return Type Key Constants -/// @discussion Predefined return type keys used to set values in a dictionary. -/// You use these keys to specify the type of results which should be -/// returned by the SecItemCopyMatching or SecItemAdd function. You can -/// specify zero or more of these return types. If more than one of these -/// result types is specified, the result is returned as a CFDictionaryRef -/// whose keys are the result types and values are the requested data. -/// @constant kSecReturnData Specifies a dictionary key whose value is of type -/// CFBooleanRef. A value of kCFBooleanTrue indicates that the data of -/// an item (CFDataRef) should be returned. For keys and password -/// items, data is secret (encrypted) and may require the user to enter -/// a password for access. -/// @constant kSecReturnAttributes Specifies a dictionary key whose value is -/// of type CFBooleanRef. A value of kCFBooleanTrue indicates that the -/// (non-encrypted) attributes of an item (CFDictionaryRef) should be -/// returned. -/// @constant kSecReturnRef Specifies a dictionary key whose value is a -/// CFBooleanRef. A value of kCFBooleanTrue indicates that a reference -/// should be returned. Depending on the item class requested, the -/// returned reference(s) may be of type SecKeychainItemRef, SecKeyRef, -/// SecCertificateRef, or SecIdentityRef. Note that returning references is -/// supported only for Certificate, Key or Identity items on iOS, watchOS and -/// tvOS. Similarly, returning references is supported only for Certificate, Key -/// or Identity items on macOS when either kSecUseDataProtectionKeychain -/// is set to true or kSecAttrSynchronizable is set to true. -/// @constant kSecReturnPersistentRef Specifies a dictionary key whose value -/// is of type CFBooleanRef. A value of kCFBooleanTrue indicates that a -/// persistent reference to an item (CFDataRef) should be returned. -@ffi.Native() -external cf.CFStringRef kSecReturnData; - -@ffi.Native() -external cf.CFStringRef kSecReturnAttributes; - -@ffi.Native() -external cf.CFStringRef kSecReturnRef; - -@ffi.Native() -external cf.CFStringRef kSecReturnPersistentRef; - -/// ! -/// @enum Value Type Key Constants -/// @discussion Predefined value type keys used to pass values in a dictionary. -/// You can specify zero or more of these types depending on the function -/// you are calling. For SecItemCopyMatching or SecItemAdd these are -/// used as keys in the results dictionary. -/// @constant kSecValueData Specifies a dictionary key whose value is of type -/// CFDataRef. For keys and password items, data is secret (encrypted) -/// and may require the user to enter a password for access. -/// @constant kSecValueRef Specifies a dictionary key whose value, depending -/// on the item class requested, is of type SecKeychainItemRef, SecKeyRef, -/// SecCertificateRef, or SecIdentityRef. -/// @constant kSecValuePersistentRef Specifies a dictionary key whose value -/// is of type CFDataRef. The bytes in this CFDataRef can be stored by -/// the caller and used on a subsequent invocation of the application (or -/// even a different application) to retrieve the item referenced by it. -@ffi.Native() -external cf.CFStringRef kSecValueData; - -@ffi.Native() -external cf.CFStringRef kSecValueRef; - -@ffi.Native() -external cf.CFStringRef kSecValuePersistentRef; - -/// ! -/// @enum Other Constants -/// @discussion Predefined constants used to set values in a dictionary. -/// @constant kSecUseItemList Specifies a dictionary key whose value is a -/// CFArray of items. If provided, this array is treated as the set of -/// all possible items to search, or add if the API being called is -/// SecItemAdd. The items in this array may be of type SecKeyRef, -/// SecCertificateRef, SecIdentityRef, or CFDataRef (for a persistent -/// item reference.) The items in the array must all be of the same -/// type. When this attribute is provided, no keychains are searched. -/// @constant kSecUseKeychain OS X only. Specifies a dictionary key whose value is a -/// keychain reference. You use this key to specify a value of type -/// SecKeychainRef to which SecItemAdd will add the provided item(s). -/// @constant kSecUseOperationPrompt Specifies a dictionary key whose value -/// is a CFStringRef that represents a user-visible string describing -/// the operation for which the application is attempting to authenticate. -/// The application is responsible for the text localization. -/// @constant kSecUseNoAuthenticationUI OS X only. Specifies a dictionary key whose value -/// is a CFBooleanRef. If provided with a value of kCFBooleanTrue, the error -/// errSecInteractionNotAllowed will be returned if the item is attempting -/// to authenticate with UI. -/// @constant kSecUseAuthenticationUI Specifies a dictionary key whose value -/// is one of kSecUseAuthenticationUIAllow, kSecUseAuthenticationUIFail, kSecUseAuthenticationUISkip. -/// @constant kSecUseAuthenticationContext Specifies a dictionary key whose value -/// is LAContext to be used for keychain item authentication. -/// If the item requires authentication and this key is omitted, a new context -/// will be created just for the purpose of the single call. -/// If the specified context has been previously authenticated, the operation -/// will succeed without asking user for authentication. -/// If the specified context has not been previously authenticated, the new -/// authentication will be started on this context, allowing caller to -/// eventually reuse the successfully authenticated context in subsequent -/// keychain operations. -/// @constant kSecUseDataProtectionKeychain Specifies a dictionary key whose value -/// is a CFBooleanRef. Set to kCFBooleanTrue to use kSecAttrAccessGroup and/or -/// kSecAttrAccessible on macOS without requiring the item to be marked synchronizable. -/// Note that when kSecUseDataProtectionKeychain is set to true, returning references is -/// supported only for Certificate, Key or Identity items. -/// @constant kSecUseUserIndependentKeychain Specifies a dctionary key whose value is a CFBooleanRef -/// indicating whether the item is shared with other personas on the system. -@ffi.Native() -external cf.CFStringRef kSecUseItemList; - -@ffi.Native() -external cf.CFStringRef kSecUseKeychain; - -@ffi.Native() -external cf.CFStringRef kSecUseOperationPrompt; - -@ffi.Native() -external cf.CFStringRef kSecUseNoAuthenticationUI; - -@ffi.Native() -external cf.CFStringRef kSecUseAuthenticationUI; - -@ffi.Native() -external cf.CFStringRef kSecUseAuthenticationContext; - -@ffi.Native() -external cf.CFStringRef kSecUseDataProtectionKeychain; - -@ffi.Native() -external cf.CFStringRef kSecUseUserIndependentKeychain; - -/// ! -/// @enum kSecUseAuthenticationUI Value Constants -/// @discussion Predefined item attribute constants used to get or set values -/// in a dictionary. The kSecUseAuthenticationUI constant is the key and its -/// value is one of the constants defined here. -/// If the key kSecUseAuthenticationUI not provided then kSecUseAuthenticationUIAllow -/// is used as default. -/// @constant kSecUseAuthenticationUIAllow Specifies that authenticate UI can appear. -/// @constant kSecUseAuthenticationUIFail Specifies that the error -/// errSecInteractionNotAllowed will be returned if an item needs -/// to authenticate with UI -/// @constant kSecUseAuthenticationUISkip Specifies that all items which need -/// to authenticate with UI will be silently skipped. This value can be used -/// only with SecItemCopyMatching. -@ffi.Native() -external cf.CFStringRef kSecUseAuthenticationUIAllow; - -@ffi.Native() -external cf.CFStringRef kSecUseAuthenticationUIFail; - -@ffi.Native() -external cf.CFStringRef kSecUseAuthenticationUISkip; - -/// ! -/// @enum kSecAttrTokenID Value Constants -/// @discussion Predefined item attribute constant used to get or set values -/// in a dictionary. The kSecAttrTokenID constant is the key and its value -/// can be kSecAttrTokenIDSecureEnclave. -/// @constant kSecAttrTokenIDSecureEnclave Specifies well-known identifier of the -/// token implemented using device's Secure Enclave. The only keychain items -/// supported by the Secure Enclave token are 256-bit elliptic curve keys -/// (kSecAttrKeyTypeECSecPrimeRandom). Keys must be generated on the secure enclave using -/// SecKeyGenerateKeyPair call with kSecAttrTokenID set to -/// kSecAttrTokenIDSecureEnclave in the parameters dictionary, it is not -/// possible to import pregenerated keys to kSecAttrTokenIDSecureEnclave token. -@ffi.Native() -external cf.CFStringRef kSecAttrTokenIDSecureEnclave; - -/// ! -/// @enum kSecAttrAccessGroup Value Constants -/// @constant kSecAttrAccessGroupToken Represents well-known access group -/// which contains items provided by external token (typically smart card). -/// This may be used as a value for kSecAttrAccessGroup attribute. Every -/// application has access to this access group so it is not needed to -/// explicitly list it in keychain-access-groups entitlement, but application -/// must explicitly state this access group in keychain queries in order to -/// be able to access items from external tokens. -@ffi.Native() -external cf.CFStringRef kSecAttrAccessGroupToken; - -/// ! -/// @function SecItemCopyMatching -/// @abstract Returns one or more items which match a search query. -/// @param query A dictionary containing an item class specification and -/// optional attributes for controlling the search. See the "Keychain -/// Search Attributes" section for a description of currently defined -/// search attributes. -/// @param result On return, a CFTypeRef reference to the found item(s). The -/// exact type of the result is based on the search attributes supplied -/// in the query, as discussed below. -/// @result A result code. See "Security Error Codes" (SecBase.h). -/// @discussion Attributes defining a search are specified by adding key/value -/// pairs to the query dictionary. -/// -/// A typical query consists of: -/// -/// a kSecClass key, whose value is a constant from the Class -/// Constants section that specifies the class of item(s) to be searched -/// one or more keys from the "Attribute Key Constants" section, whose value -/// is the attribute data to be matched -/// one or more keys from the "Search Constants" section, whose value is -/// used to further refine the search -/// a key from the "Return Type Key Constants" section, specifying the type of -/// results desired -/// -/// Result types are specified as follows: -/// -/// To obtain the data of a matching item (CFDataRef), specify -/// kSecReturnData with a value of kCFBooleanTrue. -/// To obtain the attributes of a matching item (CFDictionaryRef), specify -/// kSecReturnAttributes with a value of kCFBooleanTrue. -/// To obtain a reference to a matching item (SecKeychainItemRef, -/// SecKeyRef, SecCertificateRef, or SecIdentityRef), specify kSecReturnRef -/// with a value of kCFBooleanTrue. Note that returning references is -/// supported only for Certificate, Key or Identity items on iOS, watchOS and -/// tvOS. Similarly, returning references is supported only for Certificate, Key -/// or Identity items on macOS when either kSecUseDataProtectionKeychain -/// is set to true or kSecAttrSynchronizable is set to true. -/// To obtain a persistent reference to a matching item (CFDataRef), -/// specify kSecReturnPersistentRef with a value of kCFBooleanTrue. Note -/// that unlike normal references, a persistent reference may be stored -/// on disk or passed between processes. -/// If more than one of these result types is specified, the result is -/// returned as a CFDictionaryRef containing all the requested data. -/// If a result type is not specified, no results are returned. -/// -/// By default, this function returns only the first match found. To obtain -/// more than one matching item at a time, specify kSecMatchLimit with a value -/// greater than 1. The result will be a CFArrayRef containing up to that -/// number of matching items; the items' types are described above. -/// -/// To filter a provided list of items down to those matching the query, -/// specify a kSecMatchItemList whose value is a CFArray of SecKeychainItemRef, -/// SecKeyRef, SecCertificateRef, or SecIdentityRef items. The objects in the -/// provided array must be of the same type. -/// -/// On iOS, to convert from a persistent item reference to a normal item reference, -/// specify a kSecValuePersistentRef whose value a CFDataRef (the persistent -/// reference), and a kSecReturnRef whose value is kCFBooleanTrue. -/// -/// On OSX, to convert from persistent item references to normal item references, -/// specify a kSecMatchItemList whose value is a CFArray containing one or -/// more CFDataRef elements (the persistent reference), and a kSecReturnRef -/// whose value is kCFBooleanTrue. The objects in the provided array must be -/// of the same type. -@ffi.Native)>() -external int SecItemCopyMatching( - cf.CFDictionaryRef query, - ffi.Pointer result, -); - -/// ! -/// @function SecItemAdd -/// @abstract Add one or more items to a keychain. -/// @param attributes A dictionary containing an item class specification and -/// optional entries specifying the item's attribute values. See the -/// "Attribute Key Constants" section for a description of currently defined -/// attributes. -/// @param result On return, a CFTypeRef reference to the newly added item(s). -/// The exact type of the result is based on the values supplied -/// in attributes, as discussed below. Pass NULL if this result is not -/// required. -/// @result A result code. See "Security Error Codes" (SecBase.h). -/// @discussion Attributes defining an item are specified by adding key/value -/// pairs to the attributes dictionary. To add multiple items to a keychain -/// at once use the kSecUseItemList key with an array of items as its value. -/// This is currently only supported for non password items. -/// -/// On OSX, To add an item to a particular keychain, supply kSecUseKeychain -/// with a SecKeychainRef as its value. -/// -/// On iOS, watchOS & tvOS, Certificate, Key, and Identity items may be -/// added by reference, but neither Internet Passwords nor Generic Passwords -/// may be. Similarly, on macOS with either kSecUseDataProtectionKeychain -/// set to true or kSecAttrSynchronizable set to true, Certificate, Key, and Identity -/// items may be added by reference, but neither Internet Passwords nor Generic -/// Passwords may be. -/// -/// Result types are specified as follows: -/// -/// To obtain the data of the added item (CFDataRef), specify -/// kSecReturnData with a value of kCFBooleanTrue. -/// To obtain all the attributes of the added item (CFDictionaryRef), -/// specify kSecReturnAttributes with a value of kCFBooleanTrue. -/// To obtain a reference to the added item (SecKeychainItemRef, SecKeyRef, -/// SecCertificateRef, or SecIdentityRef), specify kSecReturnRef with a -/// value of kCFBooleanTrue. See also note about kSecReturnRef and -/// macOS. -/// To obtain a persistent reference to the added item (CFDataRef), specify -/// kSecReturnPersistentRef with a value of kCFBooleanTrue. Note that -/// unlike normal references, a persistent reference may be stored on disk -/// or passed between processes. -/// If more than one of these result types is specified, the result is -/// returned as a CFDictionaryRef containing all the requested data. -/// On iOS, if a result type is not specified, no results are returned. -/// On OSX, the added item is returned. -@ffi.Native)>() -external int SecItemAdd( - cf.CFDictionaryRef attributes, - ffi.Pointer result, -); - -/// ! -/// @function SecItemUpdate -/// @abstract Modify zero or more items which match a search query. -/// @param query A dictionary containing an item class specification and -/// optional attributes for controlling the search. See the "Attribute -/// Constants" and "Search Constants" sections for a description of -/// currently defined search attributes. -/// @param attributesToUpdate A dictionary containing one or more attributes -/// whose values should be set to the ones specified. Only real keychain -/// attributes are permitted in this dictionary (no "meta" attributes are -/// allowed.) See the "Attribute Key Constants" section for a description of -/// currently defined value attributes. -/// @result A result code. See "Security Error Codes" (SecBase.h). -/// @discussion Attributes defining a search are specified by adding key/value -/// pairs to the query dictionary. -@ffi.Native() -external int SecItemUpdate( - cf.CFDictionaryRef query, - cf.CFDictionaryRef attributesToUpdate, -); - -/// ! -/// @function SecItemDelete -/// @abstract Delete zero or more items which match a search query. -/// @param query A dictionary containing an item class specification and -/// optional attributes for controlling the search. See the "Attribute -/// Constants" and "Search Constants" sections for a description of -/// currently defined search attributes. -/// @result A result code. See "Security Error Codes" (SecBase.h). -/// @discussion Attributes defining a search are specified by adding key/value -/// pairs to the query dictionary. -/// -/// By default, this function deletes all items matching the specified query. -/// You can change this behavior by specifying one of the follow keys: -/// -/// To delete an item identified by a transient reference, on iOS, specify -/// kSecValueRef with a item reference. On OS X, give a kSecMatchItemList -/// containing an item reference. -/// To delete an item identified by a persistent reference, on iOS, specify -/// kSecValuePersistentRef with a persistent reference returned by -/// using the kSecReturnPersistentRef key to SecItemCopyMatching or -/// SecItemAdd. on OSX, use kSecMatchItemList with a persistent reference -/// returned by using the kSecReturnPersistentRef key with -/// SecItemCopyMatching or SecItemAdd. -/// To delete multiple items specify kSecMatchItemList with an array -/// of references. -/// If more than one of these result keys is specified, the behavior is -/// undefined. -@ffi.Native() -external int SecItemDelete( - cf.CFDictionaryRef query, -); - -final class __CFNull extends ffi.Opaque {} - -final class __CFAllocator extends ffi.Opaque {} - -final class __CFBoolean extends ffi.Opaque {} - -final class __CFNumber extends ffi.Opaque {} - -final class CFArrayCallBacks extends ffi.Struct { - @ffi.Long() - external int version; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer<__CFAllocator>, ffi.Pointer)>> retain; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer<__CFAllocator>, ffi.Pointer)>> release; - - external ffi.Pointer< - ffi.NativeFunction)>> - copyDescription; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.UnsignedChar Function( - ffi.Pointer, ffi.Pointer)>> equal; -} - -final class CFDictionaryKeyCallBacks extends ffi.Struct { - @ffi.Long() - external int version; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer<__CFAllocator>, ffi.Pointer)>> retain; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer<__CFAllocator>, ffi.Pointer)>> release; - - external ffi.Pointer< - ffi.NativeFunction)>> - copyDescription; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.UnsignedChar Function( - ffi.Pointer, ffi.Pointer)>> equal; - - external ffi.Pointer< - ffi.NativeFunction)>> - hash; -} - -/// ! -/// @typedef CFDictionaryValueCallBacks -/// Structure containing the callbacks for values of a CFDictionary. -/// @field version The version number of the structure type being passed -/// in as a parameter to the CFDictionary creation functions. -/// This structure is version 0. -/// @field retain The callback used to add a retain for the dictionary -/// on values as they are put into the dictionary. -/// This callback returns the value to use as the value in the -/// dictionary, which is usually the value parameter passed to -/// this callback, but may be a different value if a different -/// value should be added to the dictionary. The dictionary's -/// allocator is passed as the first argument. -/// @field release The callback used to remove a retain previously added -/// for the dictionary from values as they are removed from -/// the dictionary. The dictionary's allocator is passed as the -/// first argument. -/// @field copyDescription The callback used to create a descriptive -/// string representation of each value in the dictionary. This -/// is used by the CFCopyDescription() function. -/// @field equal The callback used to compare values in the dictionary for -/// equality in some operations. -final class CFDictionaryValueCallBacks extends ffi.Struct { - @ffi.Long() - external int version; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer<__CFAllocator>, ffi.Pointer)>> retain; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer<__CFAllocator>, ffi.Pointer)>> release; - - external ffi.Pointer< - ffi.NativeFunction)>> - copyDescription; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.UnsignedChar Function( - ffi.Pointer, ffi.Pointer)>> equal; -} - -const int errSecSuccess = 0; - -const int errSecUserCanceled = -128; - -const int errSecMissingEntitlement = -34018; - -const int errSecAuthFailed = -25293; - -const int errSecDuplicateItem = -25299; - -const int errSecItemNotFound = -25300; - -const int errSecInteractionRequired = -25315; - -const int errSecInvalidOwnerEdit = -25244; diff --git a/packages/celest_auth/lib/src/storage/secure_storage.android.dart b/packages/celest_auth/lib/src/storage/secure_storage.android.dart deleted file mode 100644 index 61e88856..00000000 --- a/packages/celest_auth/lib/src/storage/secure_storage.android.dart +++ /dev/null @@ -1,41 +0,0 @@ -import 'package:celest_auth/src/native/android/jni_bindings.ffi.dart'; -import 'package:celest_auth/src/storage/secure_storage.dart'; -import 'package:jni/jni.dart'; - -final class SecureStoragePlatformAndroid extends SecureStoragePlatform { - SecureStoragePlatformAndroid() : super.base() { - Jni.initDLApi(); - } - - late final Activity _mainActivity = - Activity.fromRef(Jni.getCurrentActivity()); - late final CelestSecureStorage _secureStorage = - CelestSecureStorage(_mainActivity); - - @override - void clear() => _secureStorage.clear(); - - @override - String? delete(String key) { - final value = _secureStorage.delete(key.toJString()); - if (value.isNull) { - return null; - } - return value.toDartString(); - } - - @override - String? read(String key) => - _secureStorage.read(key.toJString()).toDartString(); - - @override - Map readAll() => _secureStorage.readAll().map( - (key, value) => MapEntry(key.toDartString(), value.toDartString()), - ); - - @override - String write(String key, String value) { - _secureStorage.write(key.toJString(), value.toJString()); - return value; - } -} diff --git a/packages/celest_auth/lib/src/storage/secure_storage.dart b/packages/celest_auth/lib/src/storage/secure_storage.dart deleted file mode 100644 index 89dc26fa..00000000 --- a/packages/celest_auth/lib/src/storage/secure_storage.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'package:celest_auth/src/storage/secure_storage.android.dart'; -import 'package:celest_auth/src/storage/secure_storage.darwin.dart'; -import 'package:celest_auth/src/storage/secure_storage.stub.dart'; -// ignore: implementation_imports -import 'package:celest_core/src/util/globals.dart'; -import 'package:meta/meta.dart'; -import 'package:os_detect/os_detect.dart' as os; - -abstract interface class SecureStorage { - factory SecureStorage() = SecureStoragePlatform; - const SecureStorage._(); - - void init() {} - String? read(String key); - Map readAll(); - String write(String key, String value); - String? delete(String key); - void clear(); -} - -abstract base class SecureStoragePlatform extends SecureStorage { - factory SecureStoragePlatform() { - if (kIsWeb) { - return SecureStoragePlatformStub(); - } - if (os.isIOS || os.isMacOS) { - return SecureStoragePlatformDarwin(); - } - if (os.isAndroid) { - return SecureStoragePlatformAndroid(); - } - throw UnimplementedError(); - } - - @protected - const SecureStoragePlatform.base() : super._(); -} diff --git a/packages/celest_auth/lib/src/storage/secure_storage.darwin.dart b/packages/celest_auth/lib/src/storage/secure_storage.darwin.dart deleted file mode 100644 index 63832098..00000000 --- a/packages/celest_auth/lib/src/storage/secure_storage.darwin.dart +++ /dev/null @@ -1,179 +0,0 @@ -import 'dart:ffi'; - -import 'package:celest_auth/src/native/darwin/core_foundation.ffi.dart'; -import 'package:celest_auth/src/native/darwin/darwin_ffi_helpers.dart'; -import 'package:celest_auth/src/native/darwin/security.ffi.dart'; -import 'package:celest_auth/src/storage/secure_storage.dart'; -import 'package:celest_auth/src/storage/secure_storage_exception_impl.dart'; -// ignore: implementation_imports -import 'package:celest_core/src/util/globals.dart'; -import 'package:ffi/ffi.dart'; -import 'package:os_detect/os_detect.dart' as os; - -final class SecureStoragePlatformDarwin extends SecureStoragePlatform { - SecureStoragePlatformDarwin() : super.base(); - - static const _serviceName = 'dev.celest.celest_auth'; - static final _useDataProtection = os.isMacOS && kReleaseMode; - - Map _baseAttributes(Arena arena) { - final service = _serviceName.toCFString(arena); - return { - kSecClass: kSecClassGenericPassword, - kSecAttrService: service, - if (_useDataProtection) kSecUseDataProtectionKeychain: kCFBooleanTrue, - }; - } - - @override - void clear() => using((arena) => _clear(arena: arena)); - - @override - String? delete(String key) => using((arena) { - final current = _read(key, arena: arena); - _delete(key, arena: arena); - return current; - }); - - @override - String? read(String key) => using((arena) => _read(key, arena: arena)); - - @override - Map readAll() { - // TODO: implement readAll - throw UnimplementedError(); - } - - @override - String write(String key, String value) => using((arena) { - _write(key, value, arena: arena); - return value; - }); - - String? _read(String key, {required Arena arena}) { - final attributes = _baseAttributes(arena); - final query = { - ...attributes, - kSecAttrAccount: key.toCFString(arena), - kSecReturnData: kCFBooleanTrue, - kSecMatchLimit: kSecMatchLimitOne, - kSecReturnData: kCFBooleanTrue, - }; - try { - final result = arena(); - _check( - () => SecItemCopyMatching(query.toCFDictionary(arena), result), - key: key, - ); - final data = result.value.cast(); - arena.onReleaseAll(() => CFRelease(data.cast())); - return data.toDartString(); - } on SecureStorageItemNotFoundException { - return null; - } on Exception { - // May happen if the data is not UTF-8 encoded or corrupted. - throw const SecureStorageUnknownException(); - } - } - - void _write(String key, String value, {required Arena arena}) { - final query = { - ..._baseAttributes(arena), - kSecAttrAccount: key.toCFString(arena), - }; - final gets = SecItemCopyMatching(query.toCFDictionary(arena), nullptr); - if (gets != errSecSuccess && gets != errSecItemNotFound) { - throw SecurityFrameworkException.fromStatus(gets, key: key); - } - final itemExists = gets == errSecSuccess; - if (itemExists) { - // Update the item. - final attributes = { - kSecValueData: value.toCFData(arena), - }; - return _check( - () => SecItemUpdate( - query.toCFDictionary(arena), - attributes.toCFDictionary(arena), - ), - key: key, - ); - } - // Else, add the item. - final attributes = { - ...query, - kSecValueData: value.toCFData(arena), - }; - return _check( - () => SecItemAdd(attributes.toCFDictionary(arena), nullptr), - key: key, - ); - } - - void _delete(String key, {required Arena arena}) { - final query = { - ..._baseAttributes(arena), - kSecAttrAccount: key.toCFString(arena), - }; - _check( - () => SecItemDelete(query.toCFDictionary(arena)), - key: key, - ); - } - - void _clear({required Arena arena}) { - final query = { - ..._baseAttributes(arena), - // Required when `useDataProtection` is disabled, however can only be - // passed on macOS. Passing it on iOS will result in a crash. - if (os.isMacOS && !_useDataProtection) kSecMatchLimit: kSecMatchLimitAll, - }; - _check(() => SecItemDelete(query.toCFDictionary(arena))); - } -} - -extension type SecurityFrameworkException(SecureStorageExceptionImpl exception) - implements SecureStorageExceptionImpl { - factory SecurityFrameworkException.fromStatus(int status, {String? key}) { - if (kReleaseMode) { - key = null; - } - final cfMessage = SecCopyErrorMessageString(status, nullptr); - try { - final message = cfMessage.toDartString(); - final exception = switch (status) { - errSecItemNotFound => - SecureStorageItemNotFoundException(message: message), - errSecDuplicateItem => - SecureStorageDuplicateItemException(message: message), - errSecUserCanceled || - errSecAuthFailed || - errSecInteractionRequired => - SecureStorageAccessDeniedException(message: message), - errSecMissingEntitlement => const SecureStorageAccessDeniedException( - message: 'The app is missing the required entitlements', - ), - _ => SecureStorageUnknownException(message), - }; - return SecurityFrameworkException(exception); - } on Exception { - return SecurityFrameworkException( - SecureStorageUnknownException( - 'Unknown error occurred in Security.framework. Status: $status', - ), - ); - } finally { - CFRelease(cfMessage.cast()); - } - } -} - -void _check( - int Function() action, { - String? key, -}) { - final status = action(); - if (status != errSecSuccess) { - throw SecurityFrameworkException.fromStatus(status, key: key); - } -} diff --git a/packages/celest_auth/lib/src/storage/secure_storage.stub.dart b/packages/celest_auth/lib/src/storage/secure_storage.stub.dart deleted file mode 100644 index cd3a467f..00000000 --- a/packages/celest_auth/lib/src/storage/secure_storage.stub.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'dart:collection'; - -import 'package:celest_auth/src/storage/secure_storage.dart'; - -/// An in-memory implementation of [SecureStoragePlatform] for platforms which -/// do not support secure storage. -final class SecureStoragePlatformStub extends SecureStoragePlatform { - SecureStoragePlatformStub() : super.base(); - - final _storage = {}; - - @override - void clear() => _storage.clear(); - - @override - String? delete(String key) => _storage.remove(key); - - @override - String? read(String key) => _storage[key]; - - @override - Map readAll() => UnmodifiableMapView(_storage); - - @override - String write(String key, String value) => _storage[key] = value; -} diff --git a/packages/celest_auth/lib/src/storage/secure_storage_exception_impl.dart b/packages/celest_auth/lib/src/storage/secure_storage_exception_impl.dart deleted file mode 100644 index 3833ca86..00000000 --- a/packages/celest_auth/lib/src/storage/secure_storage_exception_impl.dart +++ /dev/null @@ -1,71 +0,0 @@ -import 'package:celest_core/celest_core.dart'; - -sealed class SecureStorageExceptionImpl implements SecureStorageException { - const SecureStorageExceptionImpl(); -} - -final class SecureStorageItemNotFoundException - extends SecureStorageExceptionImpl { - const SecureStorageItemNotFoundException({ - String? message, - this.key, - }) : message = message ?? 'The item was not found in secure storage'; - - @override - final String message; - final String? key; - - @override - String toString() { - final sb = StringBuffer('ItemNotFoundException: $message'); - if (key != null) { - sb.write(' (key: $key)'); - } - return sb.toString(); - } -} - -final class SecureStorageDuplicateItemException - extends SecureStorageExceptionImpl { - const SecureStorageDuplicateItemException({ - String? message, - this.key, - }) : message = message ?? 'The item already exists in secure storage'; - - @override - final String message; - final String? key; - - @override - String toString() { - final sb = StringBuffer('DuplicateItemException: $message'); - if (key != null) { - sb.write(' (key: $key)'); - } - return sb.toString(); - } -} - -final class SecureStorageAccessDeniedException - extends SecureStorageExceptionImpl { - const SecureStorageAccessDeniedException({ - String? message, - }) : message = message ?? 'Access to secure storage was denied'; - - @override - final String message; - - @override - String toString() => 'AccessDeniedException: $message'; -} - -final class SecureStorageUnknownException extends SecureStorageExceptionImpl { - const SecureStorageUnknownException([String? message]) - : message = message ?? 'An unknown error occurred in secure storage'; - - @override - final String message; - - @override - String toString() => 'UnknownException: $message'; -} diff --git a/packages/celest_auth/generate.sh b/packages/celest_auth/tool/ffigen.sh similarity index 86% rename from packages/celest_auth/generate.sh rename to packages/celest_auth/tool/ffigen.sh index a9b36ba1..b738896c 100755 --- a/packages/celest_auth/generate.sh +++ b/packages/celest_auth/tool/ffigen.sh @@ -13,11 +13,9 @@ flutter build macos popd echo "Generating FFI bindings..." -dart run ffigen --config=ffigen.core_foundation.yaml dart run ffigen --config=ffigen.foundation.yaml echo "Removing 'instancetype' from FFI bindings..." yq -i "del(.files.\"${FOUNDATION_URI}\".symbols.\"c:@T@instancetype\")" ${FOUNDATION_SYMBOLS} -dart run ffigen --config=ffigen.security.yaml dart run ffigen --config=ffigen.darwin.yaml echo "Generating JNI bindings..." diff --git a/packages/celest_core/lib/celest_core.dart b/packages/celest_core/lib/celest_core.dart index bb49a901..446633a5 100644 --- a/packages/celest_core/lib/celest_core.dart +++ b/packages/celest_core/lib/celest_core.dart @@ -15,9 +15,10 @@ export 'src/exception/celest_exception.dart'; export 'src/exception/cloud_exception.dart'; export 'src/exception/serialization_exception.dart'; +/// Secure Storage +export 'src/secure_storage/secure_storage.dart'; +export 'src/secure_storage/secure_storage_exception.dart'; + /// Serialization export 'src/serialization/json_value.dart'; export 'src/serialization/serializer.dart'; - -/// Secure Storage -export 'src/storage/secure_storage_exception.dart'; diff --git a/packages/celest_core/lib/src/storage/secure_storage_exception.dart b/packages/celest_core/lib/src/storage/secure_storage_exception.dart deleted file mode 100644 index 3cf17f90..00000000 --- a/packages/celest_core/lib/src/storage/secure_storage_exception.dart +++ /dev/null @@ -1,3 +0,0 @@ -import 'package:celest_core/celest_core.dart'; - -abstract interface class SecureStorageException implements CelestException {}