Fork me on GitHub
#hyperfiddle
<
2023-11-06
>
Vincent16:11:03

@dustingetz a little off topic but what do you use for screen recording? I am thinking to make some "walk through" videos of my electric code and currently i'm doing (2x quicktime)

Adrian Smith17:11:40

I used Wondershare demo creator to create a RCF video in 2021 seemed ok to use at the time, I'm not a power video editor though

Vincent17:11:01

thanks Adrian 😄 will check it out now

grounded_sage21:11:05

Vimeo has a pretty good free recorder these days as well

henrik17:11:52

I need a better way to send an access-token along when establishing the Electric websocket connection. What’s the suggested way to do this?

Vincent17:11:40

currently represented as session id in my knowledge

Vincent17:11:44

in the examples^

Vincent17:11:19

ideally the access token is stored... clientside in browser storage, in header of every request? both?

Vincent17:11:09

tangentially related: i'm using tuple <timestamp, username> to derive a <userhash> and pass all three when the user does stuff. Probably a better way exists.

henrik17:11:00

I was pretty sure that you can’t use headers with a websocket connection, and have to rely on a query-string or some other mechanism. How do you supply these headers?

henrik17:11:41

I believe the session ID used in the examples is just the standard session ID attached to all websocket connections.

Geoffrey Gaillard17:11:08

As far as I know, it is not possible to set headers on the WS UPGRADE request. Is it ok to pass your token as a query param? If no, then you need a two-step mechanism: 1. Issue a request to /set-token, a. pass your token as a header b. generate a unique id (e.g. uuid), c. store the pair (uid, token) into some hash-map i. ensures the pair is short-lived - clean it up after a few seconds (e.g. with a missionary task or make your map a TTL cache) d. return the uid 2. pass the UID as a query param in the WS connection url a. get the corresponding token from the map

henrik17:11:02

In this case, a third party (Auth0) handles all the storage etc., so I literally only have to find a non-insane way to have the access-token travel along with the WS connection request.

henrik17:11:43

But 2 assumes that I can manipulate *ws-server-url* in Electric. Is this supported?

Geoffrey Gaillard18:11:02

Not in Electric, but you can rebind *ws-server-url* before calling hyperfiddle.electric/boot , so before the program starts.

👍 2
Vincent18:11:04

oh that looks like a very elegant solution (!)

Vincent18:11:16

maybe you can write a blog post about how you achieve it

J18:11:21

What about the cookie?

henrik19:11:42

Not the kind of thing you want to leave hanging around in a cookie. It’ll go stale if your cookie lives longer than the access token it holds.

Adrian Smith18:11:21

OpenAI are letting people create custom gpts, I remember Dustin once said it would be good to have a bot that could help with support check it on their devday video

Jordan Calderwood00:11:30

Yeah a dialed in Electric GPT would be amazing for helping with the minutia

👍 1
wei22:11:03

anybody have a working electric+rama clojure api example of subscribing to changes on a pstate? having some trouble converting the callback of foreign-proxy to something electric can use (missionary observable?)

J08:11:15

I’m doing this:

(defn make-reactive-query [path pstate]
  (->> (m/observe
        (fn [!]
          ;; Init
          (! nil)
          (let [cp (r/foreign-proxy-async path pstate {:callback-fn (proxy-callback !)})]
            #(.close @cp))))
       (m/relieve {})))
There is also a thread about this: https://clojurians.slack.com/archives/CL85MBPEF/p1698062851851949

🔥 1
wei18:11:12

thank you. and what is proxy-callback in your :callback-fn?

wei18:11:21

(my guess is, it's not needed if i'm observing the whole collection and not looking at diffs?)