#import <Foundation/Foundation.h>
#import <ZSM/ZSMError.h>
#import <ZSM/ZSMConfig.h>

NS_ASSUME_NONNULL_BEGIN

@class ZSMClient;

/**
 * This block is called when a success/failure result is ready.
 * @param success A boolean indicating whether the operation was successful.
 * @param error The error that occurred during the operation, if any.
 */
typedef void (^ZSMBooleanCompletion)(BOOL success, NSDictionary<NSString *, NSString *> * _Nullable metadata, ZSMError * _Nullable error);

/**
 * This block is called when a data operation is complete.
 * @param data The data resulting from the operation, if successful.
 * @param error The error that occurred during the operation, if any.
 */
typedef void (^ZSMJSONCompletion)(NSDictionary<NSString *, id> * _Nullable data, NSDictionary<NSString *, NSString *> * _Nullable metadata, ZSMError * _Nullable error);

/**
 * This block is called when a data operation is complete.
 * @param signature Signature result from signing
 * @param publicKey public key from signing operation
 * @param error The error that occurred during the operation, if any.
 */
typedef void (^ZSMSignCompletion)(NSData * _Nullable signature, NSData * _Nullable publicKey, NSDictionary<NSString *, NSString *> * _Nullable metadata, ZSMError * _Nullable error);

/**
 * `ZSM` manages security tasks such as activation, checking status, managing keys, and handling signatures.
 */
@interface ZSMClient : NSObject

#pragma mark - Static logging properties

/**
 * Static log level for all clients (FIDO2Client, UMFAClient, CryptoClient).
 * This allows setting the log level without instantiating a client.
 */
@property (class, nonatomic) LogLevel logLevel;

/**
 * Static logging callback function for all clients.
 * This allows setting a custom logging function without instantiating a client.
 */
@property (class, nonatomic, copy, nullable) ZSMLoggingCallback logFunction;

/**
 * Static method to log messages with a specific log level.
 * @param level The level at which to log the message
 * @param message The message to log
 */
+ (void)logWithLevel:(LogLevel)level message:(NSString *)message;


#pragma mark - Registration and initialization

- (instancetype)init NS_UNAVAILABLE;

- (instancetype)initWithConfig:(nonnull ZSMConfig *)config NS_SWIFT_NAME(init(_:));

- (instancetype)initWithConfig:(nonnull ZSMConfig *)config error:(NSError * _Nullable * _Nullable)error NS_SWIFT_NAME(init(_:error:));
/**
 * Configure the client
 * @param config Configuration of this instance
 */
- (void)configure:(nonnull ZSMConfig *)config
NS_SWIFT_NAME(configure(config:));

/**
 Version information about api
 */
@property (class, nonatomic, readonly) NSString *versionString;

/**
 * SDK version string suitable for the X-SDK-Version HTTP header.
 * Returns a JSON dictionary string that labels the iOS SDK version, for example
 * {"iOS":"2.8.0"}.
 */
@property (class, nonatomic, readonly) NSString *sdkVersion;
    
/**
 Configuration of this instance
 */
@property (readonly, nonatomic) ZSMConfig *config;

/**
 * Indicates whether a cryptographic key has been generated.
 */
@property (readonly, nonatomic) BOOL hasCryptographicKey;



/**
 * Unenrolls the UMFA client current user, clearing stored credentials and identity mappings.
 */
- (void)unbindWithCompletion:(nonnull ZSMBooleanCompletion)completion
NS_SWIFT_NAME(unbind(_:));

/**
 * Unenrolls the UMFA client specified user, clearing stored credentials and identity mappings.
 */
- (void)unbindForUser:(nonnull NSString *)user withCompletion:(nonnull ZSMBooleanCompletion)completion
NS_SWIFT_NAME(unbind(user:_:));

/**
 * Get WebAuthn-specific storage identifier for a given consumer ID.
 * This is user-specific and does NOT include installationId, allowing multi-user credential isolation.
 */
- (nonnull NSUUID *)webauthnStorageIdentifierForConsumerId:(nullable NSString *)consumerId;

@end

NS_ASSUME_NONNULL_END
