isValidRespondAuthenticate static method

bool isValidRespondAuthenticate({
  1. required int id,
  2. required Map<int, PendingSessionAuthRequest> pendingRequests,
  3. List<Cacao>? auths,
})

Implementation

static bool isValidRespondAuthenticate({
  required int id,
  required Map<int, PendingSessionAuthRequest> pendingRequests,
  List<Cacao>? auths,
}) {
  if (!pendingRequests.containsKey(id)) {
    throw Errors.getInternalError(
      Errors.MISSING_OR_INVALID,
      context:
          'approveSessionAuthenticate() Could not find pending auth request with id $id',
    ).toSignError();
  }

  if (auths == null || auths.isEmpty) {
    throw Errors.getInternalError(
      Errors.MISSING_OR_INVALID,
      context:
          'approveSessionAuthenticate() invalid response. Must contain Cacao signatures.',
    ).toSignError();
  }

  return true;
}