attest method

Future<Object> attest(
  1. dynamic data
)

Performs device attestation with the provided data.

This method creates a platform-specific attestation token that proves the app's authenticity and integrity. The attestation includes the provided data to prevent replay attacks.

Parameters

  • data: Data to include in the attestation (String or Object that will be JSON encoded)

Returns

A Future that resolves to an attestation object containing the platform-specific token

Throws

  • Exception if the platform is not supported
  • Platform-specific exceptions if attestation fails

Platform Details

iOS: Uses Apple's App Attestation service which requires:

  • An attestation key (generated automatically if needed)
  • The app to be signed with a valid provisioning profile
  • The device to support attestation (iOS 14+)

Android: Uses Google Play Integrity API which requires:

  • A valid Google Cloud project number
  • The app to be installed from Google Play or a trusted source
  • Play Integrity API to be enabled in the Google Cloud Console

Implementation

Future<Object> attest(dynamic data) async {
  final attestationData = data is String ? data : jsonEncode(data);

  if (Platform.isIOS) {
    _keyId ??= await CalljmpDevice.instance.appleGenerateAttestationKey();
    return CalljmpDevice.instance.appleAttestKey(_keyId!, attestationData);
  }

  if (Platform.isAndroid) {
    return CalljmpDevice.instance.androidRequestIntegrityToken(
      _cloudProjectNumber,
      attestationData,
    );
  }

  throw Exception("Unsupported platform: ${Platform.operatingSystem}");
}