Fork me on GitHub
#clojurescript
<
2017-01-29
>
Pablo Fernandez00:01:07

When my cljsjs packages requires cljsjs.classnames, its javascript file instead of running “window.classNames = classNames” it runs “module.exports = classNames” and then, well, classNames is not defined. What am I missing here?

sbauer03:01:39

This is probably simpler than I am making it but is there a way to get the javascript arguments object of a function? The equivalent to this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments I think that cljs.core has an a js-arguments macro but there is a comment saying it is for internal use only... is there something publicly facing?

sova-soars-the-sora03:01:38

Can someone explain to me in simple terms how to handle authentication for my cljs app? Is it a viable strategy to use sockets for the authentication ?

emccue05:01:47

That is the same question as how to authentication in any js app, and there are a lot of different answers if you are building that from scratch

emccue05:01:24

As far as JavaScript libraries that handle auth, there are TOOONS

emccue05:01:56

A quick starter is auth0, which is already bundled on cljsjs

emccue05:01:44

It's a service, but it has a pretty good free plan, so that is a definite plus

sova-soars-the-sora07:01:35

I have a security concern that might not be one... So a user submits username + password across the wire unencrypted, and i pass back a key, and then they use that key to authenticate successive requests.

sova-soars-the-sora07:01:00

i'm wondering: doesn't it make more sense to hash the password clientside, before i send it to the server box

sova-soars-the-sora07:01:47

anyway, maybe that's a frivolous concern.. but i'm gonna do it that way. any recommendations on crypto libraries for cljs? thanks by the way

thedavidmeister07:01:17

@sova why are you sending password on the wire unencrypted?

thedavidmeister07:01:15

also, what were you thinking, something like bcrypt?

thedavidmeister07:01:08

@sova tl;dr "If a user can login by sending the hash to the server, then the hash is effectively the password."

thedavidmeister07:01:14

anyone have experience getting i18n from google closure to work in cljs?

thedavidmeister07:01:34

i'm really struggling to get number formatting working 😞

thedavidmeister07:01:46

specifically with the advanced compilation on

thedavidmeister08:01:11

(ns i18n.number
 (:require goog.i18n.NumberFormat
           goog.i18n.NumberFormat.Format
           goog.i18n.NumberFormatSymbols))

(defn number-formatter
 [locale]
 (set! goog.i18n.NumberFormatSymbols (aget goog.i18n (str "NumberFormatSymbols_" (clojure.string/replace locale "-" "_"))))
 (goog.i18n.NumberFormat. goog.i18n.NumberFormat.Format.DECIMAL))

(-> (number-formatter "en-IN") (.format 1000000) prn)
(-> (number-formatter "en-IN") (.parse "1,000,000.00") prn)

(-> (number-formatter "en") (.format 1000000) prn)
(-> (number-formatter "en") (.parse "1,000,000.00") prn)

(-> (number-formatter "fr") (.format 1000000) prn)
(-> (number-formatter "fr") (.parse "1,000,000.00") prn)

thedavidmeister08:01:34

works fine with compilation in :none

thedavidmeister08:01:50

two issues (so far) with :advanced compilation

thedavidmeister08:01:15

WARNING - incomplete alias created for namespace goog.i18n
goog.i18n.NumberFormatSymbols = (goog.i18n[[cljs.core.str("NumberFormatSymbols_"),cljs.core.str(clojure.string.replace(locale,"-","_"))].join('')]);

thedavidmeister08:01:43

Uncaught TypeError: Cannot read property '$DEF_CURRENCY_CODE$' of undefined

thedavidmeister08:01:28

normally i see issues like this when i haven't set up externs, but i had assumed externs would not be needed for google closure?

thedavidmeister08:01:27

nm, sorted it out

deas09:01:22

Anybody got :preprocess playing nicely with lein-cljsbuild ? Feeling​ tempted to hack the latter,

pbaille10:01:53

Hi, i'm following this tutorial https://clojurescript.org/guides/javascript-modules and have the following error when trying this at the repl: (require '[js.hello :as hello] :reload) => SyntaxError: Identifier 'sayHello$$module$src$js$hello' has already been declared

pbaille11:01:50

does anyone had this too?

anmonteiro18:01:13

so cool. I must say I was a little bit skeptical wrt externs inference. But now it seems that if your libraries don't do anything fancy (i.e. ugly dynamic JS stuff) your resulting bundle may actually decrease in size - by just not using externs 🙂

etherfuse20:01:19

Any reason to prefer cljs-http over happy, or is there a preferred http library for clojurescript?

alun21:01:45

hello everybody, I’m interested in how people are measuring test coverage for their clojurescript projects. Quick googling didn’t find a lot of info so I went and worked out a solution based on doo test runner via Istanbul and karma-coverage. It required to do some changes to the doo (still in review) and karma-reporter projects. This is a sample project https://github.com/katlex/reagent-covered/ which demostrates the setup. And a sample coverage report for a file - https://katlex.github.io/reagent-covered/coverage/app/sources/list.js.html I know so far it’s kinda ugly, but it’s enough to understand which parts aren’t covered and to maintain automatic checking of minimum coverage requirements for a project. Eager to hear any thoughts on it. Thanks.

rarous18:01:47

alun: For aws-lambda code we are using Istanbul with sourcemaps. For browser code, there is https://github.com/honzabrecka/karma-cljs-test and you can use anything that supports karma

alun20:01:56

@U050487DQ thanks for the info https://github.com/honzabrecka/karma-cljs-test can be used by doo and I’m using it with my example as well, for Instanbul with source maps did you manage to show you the coverage on original CLJS code?

alun21:01:04

@U0GJRGV6G thank you for the note, I guess https://github.com/SitePen/remap-istanbul is the thing that I was looking for. I think we need to make it a standart part of doo runner , that must be simpler solution that porting cloverage to clojurescript

rarous03:01:41

@U17754ZAL my script for lambda coverage:

lein cljsbuild once test
LOCAL_DYNAMO_URL= istanbul cover target/test/test.js --type json --print none
remap-istanbul -i coverage/coverage.json -o coverage/html-report --type html
remap-istanbul -i coverage/coverage.json -o coverage/summary.txt --type text-summary
cat coverage/summary.txt

rarous03:01:13

Mapped result aint perfect, but better then nothing. 🙂