Skip to content
This repository has been archived by the owner on Oct 24, 2019. It is now read-only.

Commit

Permalink
Update README.md with usage instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-f committed Apr 3, 2017
1 parent 70db6e6 commit 2c6b5d4
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions README.md
Expand Up @@ -7,3 +7,48 @@
JS client authentication library for [Solid](https://github.com/solid/solid)
browser-based clients. Used inside
[`solid-client`](https://github.com/solid/solid-client).

## Usage

The `solid-auth-tls` client can be used from Node as well as browser processes.

### Within Node

```js
const auth = require('solid-auth-tls')

auth.login({ key: 'path/to/tls-key.pem', cert: 'path/to/tls-cert.pem' })
.then(webId => /* ... */)
.catch(err => /* ... */)
```

### Within the Browser

A UMD bundle is provided so that you can do the following (after including the
bundle via an HTML `<script>` tag):

```js
SolidAuthTLS.login() // the browser automatically provides the client key/cert for you
.then(webId => /* ... */)
.catch(err => /* ... */)
```

You can also use a module bundler such as webpack and require the module like in
the node example. When using webpack you need to include the following
plugin(s) in order to keep webpack from trying to resolve node modules such as
`fs` and `https`. Add this to your `webpack.config.js`:

```js
const webpack = require('webpack')

module.exports = {
// ...
plugins: [
new webpack.DefinePlugin({ 'global.IS_BROWSER': true })
new webpack.optimize.UglifyJsPlugin(/* ... */)
]
}
```

This makes sure that code paths that require node modules (for use within node)
become dead code and get removed by the `UglifyJsPlugin`'s dead code eliminator.

0 comments on commit 2c6b5d4

Please sign in to comment.