Class: IosAppAttest::Validators::AttestationValidator
- Inherits:
-
BaseValidator
- Object
- BaseValidator
- IosAppAttest::Validators::AttestationValidator
- Defined in:
- lib/ios_app_attest/validators/attestation_validator.rb
Overview
Validates attestation structure and format
This validator is responsible for verifying the structure and format of the attestation object received from the Apple App Attest service. It ensures the attestation contains all required keys and has the correct format.
Instance Attribute Summary
Attributes inherited from BaseValidator
Instance Method Summary collapse
-
#extract_auth_data(attestation) ⇒ String
Extract authentication data from attestation.
-
#extract_receipt(attestation) ⇒ String
Extract receipt from attestation statement.
-
#validate(attestation) ⇒ Object
Validate the attestation object structure.
Methods inherited from BaseValidator
Constructor Details
This class inherits a constructor from IosAppAttest::Validators::BaseValidator
Instance Method Details
#extract_auth_data(attestation) ⇒ String
Extract authentication data from attestation
This method extracts the authentication data from the attestation object. The authentication data contains important information like the relying party ID hash, sign count, AAGUID, and credential ID needed for verification.
52 53 54 |
# File 'lib/ios_app_attest/validators/attestation_validator.rb', line 52 def extract_auth_data(attestation) attestation['authData'] end |
#extract_receipt(attestation) ⇒ String
Extract receipt from attestation statement
This method extracts the App Store receipt from the attestation statement. The receipt is used for additional verification with Apple’s servers.
40 41 42 |
# File 'lib/ios_app_attest/validators/attestation_validator.rb', line 40 def extract_receipt(attestation) attestation['attStmt']['receipt'] end |
#validate(attestation) ⇒ Object
Validate the attestation object structure
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ios_app_attest/validators/attestation_validator.rb', line 18 def validate(attestation) required_keys = %w[fmt attStmt authData] missing_keys = required_keys - attestation.keys.map(&:to_s) if missing_keys.any? raise IosAppAttest::AttestationError, "Missing required attestation keys: #{missing_keys.join(', ')}" end unless attestation['fmt'] == 'apple-appattest' raise IosAppAttest::AttestationError, "Invalid attestation format: expected 'apple-appattest'" end end |