Skip to content

Documents for @litert/jwt / Algorithms/Rsa / RsaJwaSigner

Class: RsaJwaSigner ​

Defined in: src/lib/Algorithms/Rsa.ts:193

The RSA JWT signer implementation, for both RSASSA-PKCS1-v1_5 (RS256, ...) and RSASSA-PSS (PS256, ...).

Example ​

Signing with RSASSA-PKCS1-v1_5:

ts
import * as LibJWT from '@litert/jwt';
const signer = new LibJWT.RsaJwaSigner({
    // NOTE: Don't use a RSA key with PSS padding parameters here.
    'privateKey': '-----BEGIN PRIVATE KEY-----\n...',
    'digestType': LibJWT.EDigestType.SHA256,
});
// ...

Signing with RSASSA-PSS:

ts
import * as LibJWT from '@litert/jwt';
const signer = new LibJWT.RsaJwaSigner({
    'privateKey': '-----BEGIN PRIVATE KEY-----\n...',
    'digestType': LibJWT.EDigestType.SHA256,
    // NOTE: if your key is generated as RSA-PSS key, the usePssPadding
    // option can be omitted or set to null.
    'usePssPadding': true,
});
// ...

Implements ​

Constructors ​

Constructor ​

new RsaJwaSigner(opts): RsaJwaSigner

Defined in: src/lib/Algorithms/Rsa.ts:205

Parameters ​

opts ​

IRsaSignerOptions

Returns ​

RsaJwaSigner

Properties ​

digestType ​

readonly digestType: EDigestType

Defined in: src/lib/Algorithms/Rsa.ts:201

The digest type to use for signing.

Implementation of ​

IJwaSigner.digestType


family ​

readonly family: ESigningAlgoFamily = cL.ESigningAlgoFamily.RSA

Defined in: src/lib/Algorithms/Rsa.ts:195

The signing algorithm family.

Implementation of ​

IJwaSigner.family


jwa ​

readonly jwa: ESigningJwa

Defined in: src/lib/Algorithms/Rsa.ts:197

The signing algorithm to use, for the alg claim in the JWT header.

Implementation of ​

IJwaSigner.jwa


keyId? ​

readonly optional keyId?: string | null

Defined in: src/lib/Algorithms/Rsa.ts:199

The key ID to use in the JWT header.

Implementation of ​

IJwaSigner.keyId

Methods ​

sign() ​

sign(content): Buffer

Defined in: src/lib/Algorithms/Rsa.ts:218

Sign the provided data and return the signature.

Parameters ​

content ​

string | Buffer<ArrayBufferLike>

Returns ​

Buffer

The signature.

Implementation of ​

IJwaSigner.sign