js-3id icon indicating copy to clipboard operation
js-3id copied to clipboard

iframe throws `Failed to construct 'URL': Invalid URL` in electron app

Open FrozenKiwi opened this issue 2 years ago • 2 comments

Description

My electron app runs fine in dev mode (electron-forge start) but throws when running the exe on the following line: image

The problem is that e is empty (''), and so the new URL throws with

TypeError: Failed to construct 'URL': Invalid URL

Technical Information

I'm 99% sure the offending line calling this function is this one: https://github.com/ceramicstudio/js-3id/blob/238b6eed5bcd6e413f206447d0d8207a84f902cb/apps/management/src/modal/components/HeaderContainer.tsx#L72.

The debug console confirms that document.referrer is "".

This could be fixed by changing https://github.com/ceramicstudio/js-3id/blob/238b6eed5bcd6e413f206447d0d8207a84f902cb/apps/management/src/utils.ts#L38 to check referrer before constructing the URL, and perhaps returning a default if none exists.

I would be happy to put up a PR if necessary, cause this is bit of a blocker for me and seems to be quite simple to fix.

FrozenKiwi avatar Aug 11 '22 21:08 FrozenKiwi

electron isn't officially supported, 3id-connect with the iframe is intended to only work in a browser env, I would expect that more than this single change is needed for it to work in electron.

would suggest using did-session (maybe mentioned in discord already) - https://github.com/ceramicnetwork/js-did/tree/main/packages/did-session did-session will be the primary auth library for ceramic soon

zachferland avatar Aug 25 '22 19:08 zachferland

hey @FrozenKiwi - Stephen, am a fan of what you're building with co2 offsets onchain. wanted to check if you had a chance to try out did-session, the primary auth library for ceramic zach mentioned above https://composedb.js.org/docs/0.4.x/guides/composedb-client/user-sessions

avious00 avatar Mar 15 '23 12:03 avious00