Hmm, I think I'll go to start port buddy to nodejs.
there are no real and good library for crypto and jws/jwe/jwt for js š
yo
forget about my response earlier, i misunderstood the question
for customizing the creation of xhr objects, you can provide your own XhrIo
implementation
see https://github.com/funcool/httpurr/blob/master/src/httpurr/client/xhr.cljs#L12
alternatively, you can call methods on the default XhrIO
object, for instance .setWithCredentials()
https://google.github.io/closure-library/api/goog.net.XhrIo.html
the second seems more appropriate. So would that beā¦
(.setWithCredentials āhttpurr.client.xhr/*xhr-impl*)
does that mean that itās not constructing a new XhrIo object each time itās used?
@dialelo ok I misunderstood that. It looks like the reify constructs a new XhrIo object but Iām not sure at what point I can call the method on it. Because the return value of the send! function is a promise at that point and the request is already in flight. Youāll have to forgive me Iām not terribly familiar with the interop/reify stuff
don't worry @kingoftheknoll, you're right in that you can't call methods on the xhr
of the reified object since the request is i flight
about the second idea, it'd be something like:
(.setWithCredentials httpurr.client.xhr/*xhr-impl* true)
this will make all Xhr objects created by XhrIo have the credentials flag set to true
i believe is what you want
yep, note that *xhr-impl*
expects an instance of XhrIo
, so you should bind it to the result of calling MyXhrIo
also be aware that .setWithCredentials
doesn't return the XhrIo
instance
@dialelo just getting back to this, looks like with-bindings doesnāt exist in clojurescript. Not entirely sure what to use to do the binding. BTW ^ changed the constructor to...
(defn MyXhrIo []
(doto (goog.net.XhrIo.)
(.setWithCredentials true)))
which will return the object.haven't used with-bindings
before, you can do (binding [httpurr.client.xhr.*xhr-impl* (MyXhrIo) ...)
@dialelo the binding works but now Iām getting the error httpurr.client.xhr._STAR_xhr_impl_STAR_.send is not a function
. So right here https://github.com/funcool/httpurr/blob/master/src/httpurr/client/xhr.cljs#L72 itās trying to actually call send (which looks like a static method) on on the object I already instantiated. This feels like Russian nesting dolls here because to set withCredentials you need to instantiate but to send it must be static. So looking at the line I linked above I donāt see how itās possible to do it.
@dialelo hereās the XhrIo code that shows withCredentials is an argument. https://github.com/google/closure-library/blob/master/closure/goog/net/xhrio.js#L330