Upgrading to solid-client-authn-js in browser

Returned to have a look at the current status of solid podding. Am trying to follow Authenticate (Browser) — Inrupt JavaScript Client Libraries to upgrade an old attempt

import { handleIncomingRedirect, login, fetch, getDefaultSession } from '@inrupt/solid-client-authn-browser'

produces issues with “does not provide an export named” fetch or getDefaultSession. Anyone using @inrupt/solid-client-authn-browser in module style in an html page?

Looks fine to me if you’re using a bundler, e.g. webpack. If not, you’d probably want to use the script tag and a premade bundle?

You could have a look to solid hello world examples https://hello.0data.app/solid/

Hi @josephguillaume ,

I first did as that document says

npm install @inrupt/solid-client-authn-browser

and copied to server location. But there is no bundle or other js in @inrupt/solid-client-authn-browser but there is a dist. Attempt running npm run build there but it is lacking sibling projects.

So I cloned GitHub - inrupt/solid-client-authn-js: A client library for authenticating with Solid and built it there:

cd solid-client-authn-js

npm install

npm run build

and this does build and the bundle shows up ./solid-client-authn-js/packages/browser/dist/solid-client-authn.bundle.js. Copied everything in /solid-client-authn-js/packages/browser/dist to server location under ./js/solid-client-authn-browser/

and in the html did the

import { handleIncomingRedirect, login, fetch, getDefaultSession } from './js/solid-client-authn-browser/solid-client-authn.bundle.js'

Can see the solid-client-authn.bundle.js is served but no import. Tried rebuilding everything with "compiler option "module": "ES6" to the packages’ tsconfig.json" but no difference

Tried both Electron 94 and Firefox 95

Also tested importing a hyperapp example and it works in both Electron 94 & Firefox 95 in the same project

Hi @bourgeoa
I followed the location where your examples get the bundle and tried

import { handleIncomingRedirect, login, fetch, getDefaultSession } from 'https://cdn.jsdelivr.net/npm/@inrupt/solid-client-authn-browser@1.11.3/dist/solid-client-authn.bundle.js'

with the same “does not provide an export named” fetch result

fetch is a property of session … import Session and use it’s fetch method.

Hi @jeffz if I take fetch out of the lineup it complains about getDefaultSession and so on. Somehow there is no module solid-client-authn-browser importable into these versions of browser. Can test on Chrome tonight.

Did try
packages/browser/examples/single/bundle/
as the main readme says under GitHub - inrupt/solid-client-authn-js: A client library for authenticating with Solid and it built, came to cmpiled with warnings and waits so tried the http://localhost:3001/. Nothing

When you import the library with a script tag you get an obect called solidClientAuthentication. You can then use, for example solidClientAuthentication.getDefaultSession() or same for solidClientAuthentication.login() and solidClientAuthentication.handleIncoomingRedirect. You can see a working example of these methods at https://solid.github.io/solid-rest/browser/examples/authn.html

Ah you think the docs are forecasting some future state of solid? I’ll go back to script tags and test other aspects. Thank you

I don’t know whether importing solid-client-authn-browser directly without the script tag is supported, I can’t get it to work using the CDN version of the library. Perhaps @nicolasmondada would know if it is supported.

Hi @rimmartin, and sorry for being late to the battle. If it is still of any help, https://github.com/inrupt/solid-client-authn-js/tree/main/packages/browser/examples/single/script is an example using solid-client-authn-browser in a script tag, which should be a supported use case. As it is not our main use case though, it may not be 100% up to date, so let us know if you try it and run into any sort of issue.