Fork me on GitHub
#clojurescript
<
2020-01-15
>
lilactown17:01:45

is there a proper way to package and import a .js file in a CLJS lib, so that it can be used by a fighweel-main/deps.edn/clojurescript project?

thheller17:01:37

not sure anymore but maybe via :foreign-lib :libs or so

lilactown17:01:17

atm I’m simply putting it on the classpath and importing it via a relative path: https://github.com/Lokeh/helix/blob/master/src/helix/core.cljs#L5 which works great in shadow-cljs

lilactown17:01:51

the error in figwheel is weird:

[Figwheel:SEVERE] java.lang.IllegalArgumentException: /_SLASH_impl_SLASH_class/js.cljs is not a relative path

thheller17:01:57

yeah that syntax definitely won't work

thheller17:01:19

you can try something with goog.provide("helix.core.impl.class") and use it like any other cljs/closure ns

thheller17:01:36

I think :foreign-libs :libs understands those

lilactown17:01:29

can I use esm export syntax in that case?

thheller17:01:03

you just use helix.core.impl.class.whatWasTheExport = function() { ... }

thheller17:01:23

and then (:require [helix.core.impl.class :as cl]) (cl/whatWasTheExport ...)

lilactown17:01:45

ugh. CLJS munges the name helix.impl.class to helix.impl.class$ 😵

thheller20:01:27

just change the filename to something not reserved? 😛

lilactown17:01:20

:thinking_face: attempting to fix that by appending $ to the ns names in my JS file leads to a $jscomp error in shadow-cljs

lilactown17:01:41

thanks. I’ll try that if I can’t get the closure syntax to work

Pavel Klavík18:01:34

Hi, I am trying to make ring-oauth2 working with FB. I am setting it up like this:

(oauth2/wrap-oauth2 handler
                        {:facebook {:authorize-uri    ""
                                    :access-token-uri ""
                                    :client-id        fb-id
                                    :client-secret    fb-secret
                                    :scopes           ["email"]
                                    :launch-uri       (b/path-for routes/routes :fb/launch)
                                    :redirect-uri     (b/path-for routes/routes :fb/callback)
                                    :landing-uri      (b/path-for routes/routes :fb/resolve)}})))
I am getting redirected to http://localhost:3000/login/fb/callback?code=AQDg8bFWIqHGSUOpwuC0JE__MZlm4jY7morHodW5ZSFL480mrPK1LYm9UQsBzKGaN1_dwMBDEygMrsPsjkKtI4eLlexemYDWMkHs84dHdcX4Ewww_YB3eTAq7enq7A4fwJ4G_bg69ewgGPDhCMs-9Ax_m7F9_dP1ncGN_fnIFsz3yenogqjxZqGnDQcjc7DSUrPzkdT8_mEpY7ryB0rgZjJsSpatWv-ROHN7SxO75qQzhPJ-XFZkGaDPqlRi2ChL5xMpEMTSEi37aj6ef_orxyr_veEr6tkKHJ9_w4eTax0LRWIaT-RnzSLdWqu2eBfm1n7fS-1RODmsTreF7oepp5ZT&amp;state=LMMsbgrnpCkF#_=_ and get the following output there:

Pavel Klavík18:01:34

clojure.lang.ExceptionInfo: clj-http: status 400 {:cached nil, :request-time 213, :repeatable? false, :protocol-version {:name "HTTP", :major 1, :minor 1}, :streaming? true, :http-client #object[org.apache.http.impl.client.InternalHttpClient 0xe150485 "org.apache.http.impl.client.InternalHttpClient@e150485"], :chunked? false, :type :clj-http.client/unexceptional-status, :reason-phrase "Bad Request", :headers {"Content-Type" "application/json", "Access-Control-Allow-Origin" "*", "Content-Length" "131", "Alt-Svc" "h3-24=\":443\"; ma=3600", "X-FB-Debug" "feSevDFTF8dSnJw5OHrOs4Ni+HWomFy/mVE4iXEFT5Q6n21oTbKYzVXonVKna0vMr20t4fnkC9rCjW4fwBkImA==", "facebook-api-version" "v2.11", "Strict-Transport-Security" "max-age=15552000; preload", "WWW-Authenticate" "OAuth \"Facebook Platform\" \"invalid_code\" \"Invalid verification code format.\"", "Connection" "close", "Pragma" "no-cache", "Expires" "Sat, 01 Jan 2000 00:00:00 GMT", "x-fb-rev" "1001607678", "x-fb-trace-id" "E3wvIO4CVyS", "Date" "Wed, 15 Jan 2020 18:47:10 GMT", "x-fb-request-id" "A-mrcz2bch-YlNYKTkVhP--", "Cache-Control" "no-store"}, :orig-content-encoding nil, :status 400, :length 131, :body "{\"error\":{\"message\":\"Invalid verification code format.\",\"type\":\"OAuthException\",\"code\":100,\"fbtrace_id\":\"A-mrcz2bch-YlNYKTkVhP--\"}}", :trace-redirects []}
	at slingshot.support$stack_trace.invoke(support.clj:201)
	at clj_http.client$exceptions_response.invokeStatic(client.clj:245)
	at clj_http.client$exceptions_response.invoke(client.clj:236)
	at clj_http.client$wrap_exceptions$fn__41203.invoke(client.clj:254)
	at clj_http.client$wrap_accept$fn__41449.invoke(client.clj:737)
	at clj_http.client$wrap_accept_encoding$fn__41456.invoke(client.clj:759)
	at clj_http.client$wrap_content_type$fn__41443.invoke(client.clj:720)
	at clj_http.client$wrap_form_params$fn__41552.invoke(client.clj:961)
	at clj_http.client$wrap_nested_params$fn__41573.invoke(client.clj:995)
	at clj_http.client$wrap_flatten_nested_params$fn__41582.invoke(client.clj:1019)
	at clj_http.client$wrap_method$fn__41510.invoke(client.clj:895)
	at clj_http.cookies$wrap_cookies$fn__40490.invoke(cookies.clj:131)
	at clj_http.links$wrap_links$fn__40978.invoke(links.clj:63)
	at clj_http.client$wrap_unknown_host$fn__41590.invoke(client.clj:1048)
	at clj_http.client$request_STAR_.invokeStatic(client.clj:1176)
	at clj_http.client$request_STAR_.invoke(client.clj:1169)
	at clj_http.client$post.invokeStatic(client.clj:1194)
	at clj_http.client$post.doInvoke(client.clj:1190)
	at clojure.lang.RestFn.invoke(RestFn.java:423)
	at ring.middleware.oauth2$get_access_token.invokeStatic(oauth2.clj:65)
	at ring.middleware.oauth2$get_access_token.invoke(oauth2.clj:61)
	at ring.middleware.oauth2$make_redirect_handler$fn__41733.invoke(oauth2.clj:78)
	at ring.middleware.oauth2$wrap_oauth2$fn__41762.invoke(oauth2.clj:101)
	at orgpad.server.handler.core$wrap_html_js_css_no_cache$fn__42062.invoke(core.clj:31)
	at co.deps.ring_etag_middleware$wrap_file_etag$fn__42002.invoke(ring_etag_middleware.clj:95)
	at ring.middleware.not_modified$wrap_not_modified$fn__39952.invoke(not_modified.clj:53)
	at ring.middleware.gzip$wrap_gzip$fn__42053.invoke(gzip.clj:100)
	at bidi.ring$eval41815$fn__41816.invoke(ring.cljc:25)
	at bidi.ring$eval41794$fn__41795$G__41785__41804.invoke(ring.cljc:16)
	at bidi.ring$make_handler$fn__41824.invoke(ring.cljc:43)
	at clojure.lang.Var.invoke(Var.java:384)
	at aleph.http.server$handle_request$fn__16142$f__2135__auto____16143.invoke(server.clj:158)
	at clojure.lang.AFn.run(AFn.java:22)
	at io.aleph.dirigiste.Executor$Worker$1.run(Executor.java:62)
	at manifold.executor$thread_factory$reify__2017$f__2018.invoke(executor.clj:44)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.lang.Thread.run(Unknown Source)

Pavel Klavík18:01:05

What am I doing wrong? I am getting "OAuth \"Facebook Platform\" \"invalid_code\" \"Invalid verification code format.\""