Add extractEnvelope option to client

Rebase of PR #400