How to use the solid-auth-client.trackSession function in solid-auth-client

To help you get started, we’ve selected a few solid-auth-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github solid / solid-ui / src / authn / authn.ts View on Github external
if (me) {
            box.appendChild(logoutButton(me, options))
          } else {
            box.appendChild(signInOrSignUpBox(dom, setIt, options))
          }
        }
        box.me = me ? me.uri : null
      },
      err => {
        alert(`loginStatusBox: ${err}`)
      }
    )
  }

  if (solidAuthClient.trackSession) {
    solidAuthClient.trackSession(session => {
      if (session && session.webId) {
        me = $rdf.sym(session.webId)
      } else {
        me = null
      }
      box.refresh()
    })
  }

  box.me = '99999' // Force refresh
  box.refresh()
  return box
}
github solid / react-components / src / hooks / useWebId.js View on Github external
*/
export default function useWebId(reducer = getWebId) {
  const [result, updateWebId] = useReducer(reducer, webId, reducer);
  useDebugValue(webId);

  useEffect(() => {
    updateWebId(webId);
    subscribers.add(updateWebId);
    return () => subscribers.delete(updateWebId);
  }, []);

  return result;
}

// Inform subscribers when the WebID changes
auth.trackSession(session => {
  webId = session ? session.webId : null;
  for (const subscriber of subscribers)
    subscriber(webId);
});

solid-auth-client

Opaquely authenticates solid clients

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis

Similar packages