# @rubensworks/solid-client-authn-browser

> **This is a fork of [inrupt/solid-client-authn-js](https://github.com/inrupt/solid-client-authn-js) that includes support for [Web workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers).** **If you don't need Web work

Latest version **1.13.0** (published 2022-07-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rubensworks/solid-client-authn-browser
pnpm add @rubensworks/solid-client-authn-browser
yarn add @rubensworks/solid-client-authn-browser
bun add @rubensworks/solid-client-authn-browser
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.13.0 |
| Published | 2022-07-15 |
| First published | 2022-01-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 2.2 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 77 |
| Maintainers | rubensworks |

## Links

- npm: https://www.npmjs.com/package/@rubensworks/solid-client-authn-browser
- Repository: https://github.com/inrupt/solid-client-authn
- Homepage: https://github.com/inrupt/solid-client-authn#readme
- Issues: https://github.com/inrupt/solid-client-authn/issues
- npm.io page: https://npm.io/package/@rubensworks/solid-client-authn-browser

## Dependencies (9)

- [jose](https://npm.io/package/jose.md) ^4.3.7
- [uuid](https://npm.io/package/uuid.md) ^8.3.1
- [events](https://npm.io/package/events.md) ^3.3.0
- [@types/node](https://npm.io/package/@types/node.md) ^17.0.2
- [@types/uuid](https://npm.io/package/@types/uuid.md) ^8.3.0
- [lodash.clonedeep](https://npm.io/package/lodash.clonedeep.md) ^4.5.0
- [@types/lodash.clonedeep](https://npm.io/package/@types/lodash.clonedeep.md) ^4.5.6
- [@rubensworks/oidc-client-ext](https://npm.io/package/@rubensworks/oidc-client-ext.md) ^1.13.0
- [@rubensworks/solid-client-authn-core](https://npm.io/package/@rubensworks/solid-client-authn-core.md) ^1.13.0

## Recent versions

- 1.13.0 (latest) — 2022-07-15
- 1.12.0 — 2022-01-11

## README

# Solid JavaScript authentication for the browser - solid-client-authn-browser

**This is a fork of [inrupt/solid-client-authn-js](https://github.com/inrupt/solid-client-authn-js) that includes support for [Web workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers).**
**If you don't need Web worker support, it is recommended to use Inrupt's original [inrupt/solid-client-authn-js](https://github.com/inrupt/solid-client-authn-js) packages.**
_The motivation for this fork can be found here: https://github.com/rubensworks/solid-client-authn-js/pull/1802_

`solid-client-authn-browser` is a library designed to authenticate web apps (in the browser) with Solid identity servers.
The main documentation is at the [root of the repository](https://github.com/rubensworks/solid-client-authn-js).

## Usage within Web workers

This package enables support for [Web workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers)
by setting up a communication channel that exposes a fetch-like method to the worker, and follows the following flow:

- Worker wants to do an authenticated request.
- Worker sends request information to the main Window.
- Window constructs authenticated headers for the request information.
- Window sends back authenticated headers to the Worker.
- Worker performs request using the authenticated headers.

Example usage (Window):

```javascript
   const session = getDefaultSession();
   const worker = new Worker(...);
   const windowToWorkerHandler = new WindowToWorkerHandler(this, worker, session);
   worker.onmessage = async (message) => {
      if (windowToWorkerHandler.onmessage(message)) {
        // This means that the message was taken care of by the handler
      } else {
        // Optionally, take care of any other custom messages that your worker may send.
      }
    };
```

Example usage (Worker):

```javascript
   const workerToWindowHandler = new WorkerToWindowHandler(self);
   self.onmessage = (message => {
    if (workerToWindowHandler.onmessage(message)) {
      // This means that the message was taken care of by the handler
    } else {
      // Optionally, take care of any other custom messages that your worker may receive.
    }
   // Use the authenticated fetch function
  const authFetch = workerToWindowHandler.buildAuthenticatedFetch();
  await authFetch('https://example.org/');
```

A full working example can be found in:
https://github.com/rubensworks/solid-client-authn-js/tree/feature/web-workers/packages/browser/examples/single/bundle

## Required polyfills

Our JavaScript Client Libraries use relatively modern JavaScript features that
will work in all commonly used browsers, except Internet Explorer. Additionally,
`@rubensworks/solid-client-authn-browser` currently expects the Node.js `events`
module. Webpack versions before version 5 used to add a polyfill for that by
default; if you do not use Webpack, or use version 5 or later, please install
the `events` npm package as well.

## Underlying libraries

`solid-client-authn-browser` is based on [`oidc-client-js`](https://github.com/IdentityModel/oidc-client-js), forked in
[`@inrupt/oidc-client`](https://github.com/inrupt/oidc-client-js) after the original library stopped being supported.
However, the latter lacks some features that are necessary to provide the developer experience we specifically want for the Solid ecosystem, so we developed [`oidc-client-ext`](https://www.npmjs.com/package/@rubensworks/oidc-client-ext) to add these features.

# Other Inrupt Solid JavaScript Libraries

[`@rubensworks/solid-client-authn-browser`](https://www.npmjs.com/package/@rubensworks/solid-client-authn-browser)is part of a family open source JavaScript libraries designed to support developers building Solid applications.

## Inrupt Solid JavaScript Client Libraries

### Data access and permissions management - solid-client

[@inrupt/solid-client](https://docs.inrupt.com/client-libraries/solid-client-js/) allows developers to access data and manage permissions on data stored in Solid Pods.

### Authentication - solid-client-authn

[@inrupt/solid-client-authn](https://github.com/inrupt/solid-client-authn) allows developers to authenticate against a Solid server. This is necessary when the resources on your Pod are not public.

### Vocabularies and interoperability - solid-common-vocab-rdf

[@inrupt/solid-common-vocab-rdf](https://github.com/inrupt/solid-common-vocab-rdf) allows developers to build interoperable apps by reusing well-known vocabularies. These libraries provide vocabulary terms as constants that you just have to import.

# Issues & Help

## Solid Community Forum

If you have questions about working with Solid or just want to share what you’re working on, visit the [Solid forum](https://forum.solidproject.org/). The Solid forum is a good place to meet the rest of the community.

## Bugs and Feature Requests

- For public feedback, bug reports, and feature requests please file an issue via [GitHub](https://github.com/inrupt/solid-client-authn/issues/).
- For non-public feedback or support inquiries please use the [Inrupt Service Desk](https://inrupt.atlassian.net/servicedesk).

## Prerequisite

The `solid-client-authn` libraries are compatible with [NSS](https://github.com/solid/node-solid-server/releases/tag/v5.3.0) 5.3.X and higher.

## Documentation

- [Using this library from within the browser](https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/authenticate/)
- [Inrupt documentation Homepage](https://docs.inrupt.com/)

---
_Source: https://npm.io/package/@rubensworks/solid-client-authn-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
