react-native-ios-appattest
This library for React Native wraps Native iOS App Attest API's. AppAttest
API's can be used by an app to prove its integrity to backends. Apple's
documentation can be found here.
Related repos:
Consuming the library
$ npm install react-native-ios-appattest --save
// Link native components
$ cd ios && pod install && cd ..
In case you have build time issues with Flipper, disable Flipper while linking
native components.
NO_FLIPPER=1 pod install
Note Attestation is only supported on real devices, not on simulators.
Generating an Attestation to provide device integrity
import * as AppAttest from 'react-native-ios-appattest';
const supported = await AppAttest.attestationSupported();
if (!supported) { }
const keyId = await AppAttest.generateKeys();
const challengeHashBase64 =
const attestationBase64 = await AppAttest.attestKeys(
keyId,
challengeHashBase64,
);
Send attestationBase64
to your server. The server needs to check
the attestation object (and you can use appattest-checker-node).
If the checks pass, save the public key for the client (which is embedded in
the attestation) in the server, indexed by some id for this device.
If the server confirms that attestationBase64 could be validated, client
should persist keyId
string for use with request attestation.
Attesting Requests
When the client needs to issue requests to the backend, it can generate
assertions for them, such that the backend can trust their integrity (e.g.
they came from the same device and haven't been tampered with)
const serverChallenge = <...>
const requestBody = { , challenge: serverChallenge };
const clientDataHashBase64 =
const clientAttestationBase64 = await AppAttest.attestRequestData(
clientDataHashBase64,
this.keyId,
);
Send the request to the backend as normal and include clientAttestationBase64
(e.g. as an HTTP header). The server should needs to validate the attestation
before executing the request. It should use the previously saved public key for
the client. The request should be executed only if it the attestation passes
validation. appattest-checker-node provides an API to do this.