Return JSON from /_publicKey

This commit is contained in:
MICHAEL JACKSON 2017-11-13 21:33:04 -08:00
parent ba6fb43aa4
commit a38eebfe7e
2 changed files with 11 additions and 2 deletions

View File

@ -56,7 +56,7 @@ Example:
### GET /\_publicKey
The [public key](https://en.wikipedia.org/wiki/Public-key_cryptography) unpkg uses to encrypt authentication tokens, in plain text. You can also find the key [on GitHub](https://github.com/unpkg/unpkg/blob/master/public.key).
The [public key](https://en.wikipedia.org/wiki/Public-key_cryptography) unpkg uses to encrypt authentication tokens, as JSON. You can also find the key as plain text [on GitHub](https://github.com/unpkg/unpkg/blob/master/public.key).
This can be useful to verify a token was issued by unpkg.
@ -64,6 +64,15 @@ Required scope: none
Query parameters: none
Example:
```log
> curl "https://unpkg.com/_publicKey"
{
"publicKey": "..."
}
```
# Blacklist
To protect unpkg users and prevent abuse, unpkg manages a blacklist of npm packages that are known to contain harmful code.

View File

@ -1,7 +1,7 @@
const AuthAPI = require('../AuthAPI')
function showPublicKey(req, res) {
res.type('text').send(AuthAPI.getPublicKey())
res.send({ publicKey: AuthAPI.getPublicKey() })
}
module.exports = showPublicKey