Could British India have realistically allied with both Afghanistan and the Punjab?

Could British India have realistically allied with both Afghanistan and the Punjab?

In his book The Return of a King, historian William Dalrymple is strongly critical of British policy toward Afghanistan prior to the disastrous invasion of 1839. He implies, quoting the British envoy William Burnes, that the British could have successfully bought the rulers of both Afghanistan and the Punjab on-side.

While I see no reason to doubt the suggestion that the ruler of Afghanistan, Dost Mohammed, was pro-British, his price for a formal alliance was British help in reclaiming Peshawar from the invading Punjabi forces. Given this friction between the two states, the idea that diplomatic solution was not just feasible but relatively easy, seems a bold one.

"Relatively easy" is difficult to qualify without extensive quotes from the book, as it's implied in tone rather than stated directly, but here's an example:

This, he [Burnes] realised, was actually good news for his mission, as it could only make Ranjit Singh [the Punjabi ruler] more willing to come to terms with Dost Mohammed about the future of the city, and with luck allow Burnes to reconcile the two rivals, bringing both into alliance with the British.

Reading around the subject - see James Perry in Arrogant Armies for example - it seems there is a view that this friction was indeed insoluble and Britain would have found it impossible to placate both states.

Which view is correct?

The apparent boldness of the diplomatic solution was in fact the only chance at getting the first foothold in the Great game( with the Russian empire). At the time of Maharaja Ranjit Singh's zenith the British as well as the Sikhs did not go into conflict (the Sikhs had a well oiled army and a stable administration governing), so the question of placating the Sikhs doesn't arise. However the Sikh tacit support was needed as the British primarily wanted to have a say in the political sphere in Afghanistan in order to prevent Russian advances whereas Ranjit Singh wanted to maintain his empire without ceding space to Dost Mohammad or the tribes.

The reason behind William Burnes failure to strike a deal is due to his inability to convince Lord Auckland. This compounded by the tripartite treaty led to the disaster that followed. Therefore this diplomatic solution was to develop a stronger bond with the Afghans rather than placating both the Sikhs and the Afghans and in hindsight would possibly have been successful but for the unknown reasons as to why Lord Auckland didn't approve of it.