makeNonceTransform function

HttpAgentRequestTransformFnCall makeNonceTransform([
  1. NonceFunc nonceFn = makeNonce
])

Implementation

HttpAgentRequestTransformFnCall makeNonceTransform([
  NonceFunc nonceFn = makeNonce,
]) {
  return (HttpAgentRequest request) async {
    // Nonce are only useful for async calls, to prevent replay attacks. Other types of
    // calls don't need Nonce so we just skip creating one.
    if (request.endpoint == Endpoint.call) {
      (request as HttpAgentSubmitRequest).body.nonce = nonceFn();
    }
    return request;
  };
}