@capacitor-community/device-check
TypeScript icon, indicating that this package has built-in type declarations

6.0.0 • Public • Published


DEVICE CHECK

@capacitor-community/device-check


The DeviceCheck API is used to reduce fraudulent use of your services by managing device state and asserting app integrity.

This plugin calls the DeviceCheck API generateToken method which returns a token that your App's server must verify with Apple Servers.

The call generateToken will return a token on success which you must send to your backend for verification. See Apple's Docs on this.

token is a base64 encoded string containing the token returned by []DCDevice.current.generateToken](https://developer.apple.com/documentation/devicecheck/dcdevice/generatetoken(completionhandler:)).

Install

npm install @capacitor-community/device-check
npx cap sync

Usage

import { DeviceCheck } from '@capacitor-community/device-check';
...
try {
      const result = await DeviceCheck.generateToken();
      console.log(`DeviceCheck token`, result.token);
    } catch (err) {
        // Recommendation: Report to backend and exit the application
    }

Versions

  • If you are using Capacitor 5 use version 5.x
  • If you are using Capacitor 6 use version 6.x

API

generateToken()

generateToken() => Promise<{ token: string; }>

Returns: Promise<{ token: string; }>


Errors

The following errors can occur and should be handled.

On Web and Android the result of generateToken will be an empty token "".

On iOS these errors can be caught in a catch:

  • DeviceCheck is not supported on this device - iOS reports that the device doesnt support the Device Check API (eg iOS less than v11)
  • DeviceCheck token encoding failed - iOS failed to encode the token.
  • DeviceCheck error: [some-error] - iOS reported some other error with the localized error description of [some-error]

Package Sidebar

Install

npm i @capacitor-community/device-check

Weekly Downloads

4

Version

6.0.0

License

MIT

Unpacked Size

17.4 kB

Total Files

26

Last publish

Collaborators

  • vmfo
  • multishiv19
  • ionicjs
  • danielprrazevedo
  • nkalupahana
  • dtarnawsky
  • ryaa
  • dallasjames
  • tafelnl
  • thegnuu
  • pbowyer
  • capcombot
  • jcesarmobile
  • maxlynch
  • mhartington
  • it_mike_s
  • byrds
  • rdlabo
  • priyankpatel
  • dwieeb
  • stewan
  • arielhernandezmusa
  • jeepq
  • start9keagan
  • boosten
  • nklayman
  • ihadeed
  • ckgaparajita
  • jpender
  • nhyatt
  • pwespi
  • epicshaggy
  • thomasvidas
  • robingenz
  • diachedelic
  • johnborges
  • tobyas
  • elylucas
  • giodimiliaionic
  • brownoxford
  • mrbatista
  • bazuka5801
  • hemang