DeviceCheck (device_check v0.3.0)

Copy Markdown View Source

Elixir client for the Apple DeviceCheck API.

DeviceCheck lets your server:

  • Validate a device token generated by DCDevice
  • Query the two per-device fraud bits stored by Apple
  • Update those two bits to reflect device-level state

The public surface is intentionally small:

DeviceCheck.validate_token(device_token)
DeviceCheck.query_bits(device_token)
DeviceCheck.update_bits(device_token, bit0: true, bit1: false)
DeviceCheck.token()

Configuration

config :device_check,
  team_id: System.get_env("APPLE_TEAM_ID"),
  key_id: System.get_env("DEVICE_CHECK_KEY_ID"),
  private_key: System.get_env("DEVICE_CHECK_PRIVATE_KEY"),
  development: true

Every function also accepts per-call opts that override the application config.

Summary

Functions

Query the two DeviceCheck bits for a device token.

Query the two DeviceCheck bits for a device token.

Return a cached-per-call DeviceCheck access token after JWT generation.

Update one or both DeviceCheck bits for a device token.

Update one or both DeviceCheck bits for a device token.

Validate a device token with Apple.

Validate a device token with Apple.

Types

opts()

@type opts() :: keyword()

response()

@type response() :: {:ok, term()} | {:error, term()}

Functions

query_bits(device_token, opts \\ [])

@spec query_bits(String.t(), opts()) ::
  {:ok, map() | :bit_state_not_found} | {:error, term()}

Query the two DeviceCheck bits for a device token.

query_two_bits(device_token, opts \\ [])

@spec query_two_bits(String.t(), opts()) ::
  {:ok, map() | :bit_state_not_found} | {:error, term()}

Query the two DeviceCheck bits for a device token.

token(opts \\ [])

@spec token(opts()) :: {:ok, String.t()} | {:error, term()}

Return a cached-per-call DeviceCheck access token after JWT generation.

update_bits(device_token, opts \\ [])

@spec update_bits(String.t(), opts()) :: response()

Update one or both DeviceCheck bits for a device token.

update_two_bits(device_token, opts \\ [])

@spec update_two_bits(String.t(), opts()) :: response()

Update one or both DeviceCheck bits for a device token.

validate_device_token(device_token, opts \\ [])

@spec validate_device_token(String.t(), opts()) :: response()

Validate a device token with Apple.

validate_token(device_token, opts \\ [])

@spec validate_token(String.t(), opts()) :: response()

Validate a device token with Apple.