Skip to content

Commit

Permalink
Fix some typos and improve formatting in README (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
Calinou authored and omsmith committed Jan 25, 2019
1 parent 6613fad commit 682e944
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This was developed against `draft-ietf-jose-json-web-signature-08` and
implements the entire spec **except** X.509 Certificate Chain
signing/verifying (patches welcome).

There are both syncronous (`jws.sign`, `jws.verify`) and streaming
There are both synchronous (`jws.sign`, `jws.verify`) and streaming
(`jws.createSign`, `jws.createVerify`) APIs.

# Install
Expand All @@ -18,6 +18,7 @@ $ npm install jws
# Usage

## jws.ALGORITHMS

Array of supported algorithms. The following algorithms are currently supported.

alg Parameter Value | Digital Signature or MAC Algorithm
Expand All @@ -36,7 +37,6 @@ ES384 | ECDSA using P-384 curve and SHA-384 hash algorithm
ES512 | ECDSA using P-521 curve and SHA-512 hash algorithm
none | No digital signature or MAC value included


## jws.sign(options)

(Synchronous) Return a JSON Web Signature for a header and a payload.
Expand Down Expand Up @@ -67,7 +67,7 @@ const signature = jws.sign({

## jws.verify(signature, algorithm, secretOrKey)

(Synchronous) Returns`true` or `false` for whether a signature matches a
(Synchronous) Returns `true` or `false` for whether a signature matches a
secret or key.

`signature` is a JWS Signature. `header.alg` must be a value found in `jws.ALGORITHMS`.
Expand All @@ -92,6 +92,7 @@ Returns an object with three properties, e.g.
```

## jws.createSign(options)

Returns a new SignStream object.

Options:
Expand All @@ -106,7 +107,8 @@ value is known ahead of time, or a stream for convenience.
`key`/`privateKey`/`secret` may also be an object when using an encrypted
private key, see the [crypto documentation][encrypted-key-docs].

Example
Example:

```js

// This...
Expand All @@ -118,7 +120,7 @@ jws.createSign({
// ...
});

// is equivilant to this:
// is equivalent to this:
const signer = jws.createSign({
header: { alg: 'RS256' },
});
Expand All @@ -130,6 +132,7 @@ signer.on('done', function(signature) {
```

## jws.createVerify(options)

Returns a new VerifyStream object.

Options:
Expand All @@ -142,7 +145,8 @@ Options:
All options expect a string or a buffer when the value is known ahead of
time, or a stream for convenience.

Example
Example:

```js

// This...
Expand All @@ -163,8 +167,9 @@ verifier.on('done', function(verified, obj) {
```

## Class: SignStream
A `Readable Stream` that emits a single data event, the calculated
signature, when done.

A `Readable Stream` that emits a single data event (the calculated
signature) when done.

### Event: 'done'
`function (signature) { }`
Expand All @@ -174,7 +179,7 @@ signature, when done.
A `Writable Stream` that expects the JWS payload. Do *not* use if you
passed a `payload` option to the constructor.

Example
Example:

```js
payloadStream.pipe(signer.payload);
Expand Down Expand Up @@ -203,6 +208,7 @@ of whether or not that signature was valid.
`valid` is a boolean for whether or not the signature is valid.

### verifier.signature

A `Writable Stream` that expects a JWS Signature. Do *not* use if you
passed a `signature` option to the constructor.

Expand All @@ -211,7 +217,6 @@ passed a `signature` option to the constructor.
A `Writable Stream` that expects a public key or secret. Do *not* use if you
passed a `key` or `secret` option to the constructor.


# TODO

* It feels like there should be some convenience options/APIs for
Expand All @@ -220,7 +225,6 @@ passed a `key` or `secret` option to the constructor.

* X.509 support, ugh


# License

MIT
Expand Down

0 comments on commit 682e944

Please sign in to comment.