Hmm, I think I'll go to start port buddy to nodejs.
1👍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