An open API service indexing awesome lists of open source software.

https://github.com/tswayne/js-libtrust

Javascript implementation of libtrust
https://github.com/tswayne/js-libtrust

Last synced: 4 months ago
JSON representation

Javascript implementation of libtrust

Awesome Lists containing this project

README

        

# js-libtrust
Javascript implementation of docker's [libtrust](https://github.com/docker/libtrust) fingerprint, used for the key id header in the jwt used for dockr authentication. The implementation follows the spec outlined in
docker's [token authentication implementation](https://docs.docker.com/registry/spec/auth/jwt/):
```markdown
The “kid” field has to be in a libtrust fingerprint compatible format. Such a format can be generated by following steps:
1. Take the DER encoded public key which the JWT token was signed against.
2. Create a SHA256 hash out of it and truncate to 240bits.
3. Split the result into 12 base32 encoded groups with : as delimiter.
```

## Usage
```javascript
const fs = require('fs')
const libtrust = require('libtrust')
const publicKey = fs.readFileSync('certificate.crt', 'utf-8')

const keyId = libtrust.fingerprint(publicKey)
```

### Shout out
Big shout out to @kyleburnett who cracked a few pieces to enable this javascript implementation.