// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_CREDENTIAL_EXCHANGE_MODEL_CREDENTIAL_EXCHANGE_PASSKEY_H_
#define IOS_CHROME_BROWSER_CREDENTIAL_EXCHANGE_MODEL_CREDENTIAL_EXCHANGE_PASSKEY_H_

#import <Foundation/Foundation.h>

// Intermediate data model for a passkey credential, used to translate between
// password manager's C++ representations of it and the Swift struct used by the
// OS Credential Exchange library.
// (https://fidoalliance.org/specs/cx/cxf-v1.0-ps-20250814.html#dict-passkey)
@interface CredentialExchangePasskey : NSObject

// Probabilistically-unique identifier of a credential.
// (https://www.w3.org/TR/webauthn-2/#credential-id)
@property(nonatomic, copy) NSData* credentialId;

// Relying party identifier.
// (https://www.w3.org/TR/webauthn-2/#rp-id)
@property(nonatomic, copy) NSString* rpId;

// Human-readable account identifier.
// (https://www.w3.org/TR/webauthn-2/#dom-publickeycredentialentity-name)
@property(nonatomic, copy) NSString* userName;

// Human-readable name for the account, used for display.
// (https://www.w3.org/TR/webauthn-2/#dom-publickeycredentialuserentity-displayname)
@property(nonatomic, copy) NSString* userDisplayName;

// User identifier. Also called user handle in context of WebAuthn.
// (https://www.w3.org/TR/webauthn-2/#user-handle)
@property(nonatomic, copy) NSData* userId;

// Private key of a passkey, unencrypted.
@property(nonatomic, copy) NSData* privateKey;

// Creation date of the credential in the exporting password manager.
@property(nonatomic, copy) NSDate* creationDate;

// 32-byte secret used for the WebAuthn PRF / CTAP2.1 hmac-secret extension.
// (https://fidoalliance.org/specs/cx/cxf-v1.0-ps-20250814.html#dict-fido2-hmac-credentials)
@property(nonatomic, copy) NSData* hmacSecret;

// The algorithm used for the hmac-secret extension.
@property(nonatomic, copy) NSString* hmacSecretAlgorithm;

// The contents of the DEFLATE-compressed large blob data.
// (https://www.w3.org/TR/webauthn-3/#largeblob)
@property(nonatomic, copy) NSData* largeBlob;

// The claimed uncompressed size of the DEFLATE-compressed large blob.
@property(nonatomic, copy) NSNumber* largeBlobUncompressedSize;

- (instancetype)initWithCredentialId:(NSData*)credentialId
                                rpId:(NSString*)rpId
                            userName:(NSString*)userName
                     userDisplayName:(NSString*)userDisplayName
                              userId:(NSData*)userId
                          privateKey:(NSData*)privateKey
                        creationDate:(NSDate*)creationDate
                          hmacSecret:(NSData*)hmacSecret
                 hmacSecretAlgorithm:(NSString*)hmacSecretAlgorithm
                           largeBlob:(NSData*)largeBlob
           largeBlobUncompressedSize:(NSNumber*)largeBlobUncompressedSize
    NS_DESIGNATED_INITIALIZER;

- (instancetype)init NS_UNAVAILABLE;

@end

#endif  // IOS_CHROME_BROWSER_CREDENTIAL_EXCHANGE_MODEL_CREDENTIAL_EXCHANGE_PASSKEY_H_
