Fork me on GitHub

Hi all! I've been using the firebase auth library (via js interop of course) and it's been fine, up until now. I'm trying to use, but I have no idea how to deal with the Persistence typescript interface here. It doesn't seem to be compiled to javascript, and I can't access it via firebase-auth/Persistence or firebase-auth/Persistence.LOCAL or any other obvious permutation. It doesn't appear either if i print out the entire firebase-auth object onto console. Does anyone have experience with typescript interfaces and how one interacts with them from clojurescript?


It's a TS interface - they don't exist in JS. That interface has a single field type. Just create a plain JS object with that field that has the right value and you should be all set.


So e.g. #js {:type "LOCAL"}.

❤️ 1

Oh wonderful! you're a lifesaver. Thanks! ❤️

👍 1

So it seems to work in that the login actually persists, but I get an exception: @firebase/auth: Auth (9.9.0): INTERNAL ASSERTION FAILED: Expected a class definition Would you know of a way to get around this?


That seems like an unrelated error, no clue.


Hmmm I found a way to sidestep it: Turns out google made an escape hatch for Persistence.LOCAL etc..., and it's browserLocalPersistence, browserSessionPersistence and the like. They are of "type" Persistence. I think maybe the library has some mechanism to reject js objects {type: "LOCAL"} for additional type safety.


The type property is supposed to be readonly. The value of a readonly prop must be declared on instantiation of a class (meaning inside constructor or as parameter to instantiating function new MyClass(someValue). Which means it must be a class property, not just an object property. The minimal step to mimic this is to add your type property to the prototype of an empty object, instead of to the object itself. But who knows what Google is actually using to test for the class def assertion. You might need to actually create an ES5 class and instantiate it. Looks like firebase provides a firebase.auth.Auth.Persistence.LOCAL, which I would expect to be an already instantiated Persistence.type.

Sameer Thajudin17:08:06

I deployed a`clojurescript` application in a container and am getting this error. The developer console shows a websocket request being made to port 9631. I exposed the port in the container but that did not seem to help. What can be done to fix this?


You've deployed a development version. Usually, you should deploy a production version, created with shadow-cljs release.

👍 1

Unless you're developing an app with shadow-cljs running in a container?..

Sameer Thajudin17:08:19

I did a lein uberjar and created the jar file which is run in the container. Is there a better way to do it?


No clue on the details of what exactly lein uberjar does, but ideally you should have a separate output directory for your production build and tell lein to only package that dir and not the other dir that stores UI development build.


it's been a while for me with lein but it sounds like lein uberjar might have packed up a development build that was lying around in resources/public and your host page fed it out. It depends on your build settings but this is exactly what I got help with here: If you make sure that shadow doesn't put its dev builds in /resources then I don't think lein uberjar will pick it up. You will have to add whatever your dev location is to the classpath for dev only, though ... if it's not on the classpath, dev cljs won't load, and if it's on the classpath for prd builds, then you're back where you started with dev code in a prd uber jar.

👍 1

you could also make sure to rm the dev code from /resources/public, then run the shadow release build, then make the uberjar, at least to debug and keep it simple.

👍 1
muje hoxe23:08:24

shadow-cljs or krell in general? then in the react native scope.