exchangeIdentityTicket method

Exchanges a short-lived, single-use Identity Ticket.

The result intentionally excludes access and refresh tokens. Session credentials remain private to the implementation that owns the session.

Implementation

@override
Future<InappifySdkResult<InappifyAuthenticationResult>>
exchangeIdentityTicket(InappifyIdentityTicketRequest request) async {
  final cancelled = _preCancelled<InappifyAuthenticationResult>(
    'exchangeIdentityTicket',
    request.cancellation,
  );
  if (cancelled != null) return cancelled;
  return _run<InappifyAuthenticationResult>(
    'exchangeIdentityTicket',
    action: () async {
      final previousCustomer = _customerInfo;
      final previousOfferings = _offerings;
      final raw = await _callSessionMutation(
        method: 'exchangeIdentityTicket',
        positionalArguments: <Object?>[
          request.identityTicket,
          if (request.cancellation != null) const <String, Object?>{},
        ],
        cancellation: request.cancellation,
        injectAbortSignal: request.cancellation != null,
        previousCustomer: previousCustomer,
        previousOfferings: previousOfferings,
      );
      _clearUnchangedSessionMirrors(previousCustomer, previousOfferings);
      final result = InappifyWebPayloadCodec.authentication(raw);
      _bridge.clearPendingCheckout();
      await _refreshCachedStateBestEffort(includeOfferings: true);
      return result;
    },
    cancellation: request.cancellation,
    mutationMayHaveCommitted: true,
  );
}