# ecdsa-sig-formatter

> Translate ECDSA signatures between ASN.1/DER and JOSE-style concatenation

Latest version **1.0.11** (published 2019-01-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ecdsa-sig-formatter
pnpm add ecdsa-sig-formatter
yarn add ecdsa-sig-formatter
bun add ecdsa-sig-formatter
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2019-01-25 |
| First published | 2015-06-10 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 19 |
| Author | D2L Corporation |
| Maintainers | d2l-travis-deploy |
| Keywords | ecdsa, der, asn.1, jwt, jwa, jsonwebtoken, jose |

## Links

- npm: https://www.npmjs.com/package/ecdsa-sig-formatter
- Repository: https://github.com/Brightspace/node-ecdsa-sig-formatter
- Homepage: https://github.com/Brightspace/node-ecdsa-sig-formatter#readme
- Issues: https://github.com/Brightspace/node-ecdsa-sig-formatter/issues
- npm.io page: https://npm.io/package/ecdsa-sig-formatter

## Dependencies (1)

- [safe-buffer](https://npm.io/package/safe-buffer.md) ^5.0.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.11 (latest) — 2019-01-25
- 1.0.10 — 2018-05-14
- 1.0.9 — 2016-12-05
- 1.0.8 — 2016-11-15
- 1.0.7 — 2016-06-18
- 1.0.6 — 2016-06-17
- 1.0.5 — 2016-01-20
- 1.0.2 — 2015-06-12
- 1.0.1 — 2015-06-10
- 1.0.0 — 2015-06-10

## README

# ecdsa-sig-formatter

[![Build Status](https://travis-ci.org/Brightspace/node-ecdsa-sig-formatter.svg?branch=master)](https://travis-ci.org/Brightspace/node-ecdsa-sig-formatter) [![Coverage Status](https://coveralls.io/repos/Brightspace/node-ecdsa-sig-formatter/badge.svg)](https://coveralls.io/r/Brightspace/node-ecdsa-sig-formatter)

Translate between JOSE and ASN.1/DER encodings for ECDSA signatures

## Install
```sh
npm install ecdsa-sig-formatter --save
```

## Usage
```js
var format = require('ecdsa-sig-formatter');

var derSignature = '..'; // asn.1/DER encoded ecdsa signature

var joseSignature = format.derToJose(derSignature);

```

### API

---

#### `.derToJose(Buffer|String signature, String alg)` -> `String`

Convert the ASN.1/DER encoded signature to a JOSE-style concatenated signature.
Returns a _base64 url_ encoded `String`.

* If _signature_ is a `String`, it should be _base64_ encoded
* _alg_ must be one of _ES256_, _ES384_ or _ES512_

---

#### `.joseToDer(Buffer|String signature, String alg)` -> `Buffer`

Convert the JOSE-style concatenated signature to an ASN.1/DER encoded
signature. Returns a `Buffer`

* If _signature_ is a `String`, it should be _base64 url_ encoded
* _alg_ must be one of _ES256_, _ES384_ or _ES512_

## Contributing

1. **Fork** the repository. Committing directly against this repository is
   highly discouraged.

2. Make your modifications in a branch, updating and writing new unit tests
   as necessary in the `spec` directory.

3. Ensure that all tests pass with `npm test`

4. `rebase` your changes against master. *Do not merge*.

5. Submit a pull request to this repository. Wait for tests to run and someone
   to chime in.

### Code Style

This repository is configured with [EditorConfig][EditorConfig] and
[ESLint][ESLint] rules.

[EditorConfig]: http://editorconfig.org/
[ESLint]: http://eslint.org

---
_Source: https://npm.io/package/ecdsa-sig-formatter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
