Integrity class

Manages device integrity verification and access token lifecycle.

The Integrity class is responsible for coordinating device attestation with the Calljmp service and managing access tokens for authenticated API requests. It ensures that only verified, legitimate devices can access your backend services.

Key Responsibilities

  • Device attestation through platform-specific mechanisms
  • Access token generation and management
  • Challenge-response authentication flows
  • Secure token storage and retrieval

Security Model

The integrity system works by:

  1. Requesting a challenge from the server
  2. Using device attestation to sign the challenge
  3. Exchanging the signed attestation for an access token
  4. Using the access token for subsequent API requests

Usage

Integrity verification typically happens automatically during authentication:

// Integrity checks happen automatically
final user = await calljmp.users.auth.email.authenticate(
  email: 'user@example.com',
  password: 'password',
  policy: UserAuthenticationPolicy.signInOrCreate,
);

// Manual integrity operations (rarely needed)
final isAuthenticated = await calljmp.integrity.authenticated();
if (!isAuthenticated) {
  await calljmp.integrity.access();
}

Constructors

Integrity(Config _config, Attestation _attestation)
Creates a new Integrity instance.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

access({String? challengeToken}) Future<({String accessToken})>
Performs device attestation and retrieves an access token.
authenticated() Future<bool>
Checks if the current access token is valid.
challenge() Future<({String challengeToken})>
Retrieves a challenge token from the server.
clear() Future<void>
Clears the current access token from secure storage.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited