![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
ts-jose
Advanced tools
Readme
Wrap functions of JOSE in steady interface.
[!Note]
This package's version will FOLLOW the version of JOSE
Additional options
name | Description |
---|---|
kid | Using specific key in JWKS |
jti | Verify payload jti |
// `key` must be JWK or JWKS.
await JWT.verify(token, key, options);
// Use embedded key instead given one.
await JWT.verify(token, undefined, options);
Using JOSE options
name | Referrer |
---|---|
issuer | setIssuer |
audience | setAudience |
subject | setSubject |
exp | setExpirationTime |
jti | setJti |
notBefore | setNotBefore |
iat | setIssuedAt |
typ | Header |
kid | Header |
alg | Header |
Additional options
name | type | default | description |
---|---|---|---|
jwk | boolean | false | Whether embedded key to header |
await JWT.sign(payload, key, options); // key must be JWK or JWKS
Additional options
name | Description |
---|---|
kid | Using specific key in JWKS |
enc | Encrypt algorithm |
alg | Key management algorithm |
await JWT.decrypt(cypher, key, options);
Using JOSE options
name | Referrer |
---|---|
issuer | setIssuer |
audience | setAudience |
subject | setSubject |
exp | setExpirationTime |
jti | setJti |
notBefore | setNotBefore |
iat | setIssuedAt |
typ | Header |
kid | Header |
enc | Header |
alg | Header |
await JWT.encrypt(payload, key, options);
You can sign pure string.
await JWS.verify(data, key, options);
Only using below JWT.sign's options:
typ
kid
alg
jwk
await JWS.sign('some-data', key, options);
You can encrypt pure string.
Additional options
Same as JWT.decrypt
await JWE.decrypt(cypher, key, options);
Only using below JWT.encrypt's options:
kid
alg
enc
await JWE.encrypt('some-data', key, options);
// generate key
const key: JWK = await JWK.generate('ES256', {
kid: 'some-id',
use: 'sig',
// crv: string, some algorithms need to add curve - EdDSA
// modulusLength: number, some algorithms need to add length - RSA
});
// object to JWK
const key: JWK = await JWK.fromObject({
kid: 'some-id',
alg: 'ES256',
kty: 'EC',
crv: 'P-256',
x: '123',
y: '456',
d: '789',
});
// JWK to object
const keyObject: JWKObject = key.toObject(false); // true to output private object, default: false
// private JWK to public JWK
const newKey: JWK = await key.toPublic();
// get key's status
key.isPrivate;
// check key "id", "use", "alg"
try {
// return `this` if all pass
key.getKey({ kid: 'some-id', use: 'sig', alg: 'ES256' });
} catch (err) {
// throw error if this key has different metadata from options
}
// object to JWKS
const keys = await JWKS.fromObject({
keys: [
{
alg: 'ES256',
kty: 'EC',
x: '123',
y: '456',
},
],
});
// get key from store in specific options
try {
const key: JWK = keys.getKey({ kid: 'some-id', use: 'sig', alg: 'ES256' });
} catch (err) {
// throw error if not found
}
const key: JWK = keys.getKeyByKid('some-id');
const key: JWK = keys.getKeyByUse('sig');
const key: JWK = keys.getKeyByAlg('ES256');
const publicKeys = await keys.toPublic();
FAQs
Wrap functions of JOSE in steady interface
The npm package ts-jose receives a total of 586 weekly downloads. As such, ts-jose popularity was classified as not popular.
We found that ts-jose demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.