@guarani/jose
Version:
Implementation of the RFCs of the JOSE Working Group.
94 lines (93 loc) • 3.52 kB
TypeScript
/// <reference types="node" />
import { Dict, OneOrMany, Optional } from '@guarani/types';
import { JsonWebTokenClaimOptions } from './jsonwebtoken-claim.options';
import { JsonWebTokenClaimsParams } from './jsonwebtoken-claims.params';
/**
* Implementation of {@link https://www.rfc-editor.org/rfc/rfc7519.html#section-4 RFC 7519 Section 4}.
*/
export declare class JsonWebTokenClaims implements JsonWebTokenClaimsParams {
/**
* Identifier of the Issuer of the Token.
*/
readonly iss?: Optional<string>;
/**
* Subject represented by the Token.
*/
readonly sub?: Optional<string>;
/**
* Identifier of the Audience the Token is intended to.
*/
readonly aud?: Optional<OneOrMany<string>>;
/**
* UTC time denoting the Expiration Time of the Token.
*/
readonly exp?: Optional<number>;
/**
* UTC time denoting the moment when the Token will become valid.
*/
readonly nbf?: Optional<number>;
/**
* UTC time denoting the moment when the Token was created.
*/
readonly iat?: Optional<number>;
/**
* Identifier of the Token.
*/
readonly jti?: Optional<string>;
/**
* Instantiates a new JSON Web Token Claims for usage with JSON Web Tokens.
*
* @param claims Defines the claims of the JSON Web Token.
* @param options Validation options for the claims.
*/
constructor(claims: JsonWebTokenClaimsParams, options?: Optional<Dict<JsonWebTokenClaimOptions>>);
/**
* Parses the provided Base64Url Encoded String into a JSON Web Token Claims object.
*
* @param data Base64Url Encoded String encoded JSON Web Token Claims.
* @param options Validation options for the claims.
* @returns Parsed JSON Web Token Claims.
*/
static parse(data: string, options?: Optional<Dict<JsonWebTokenClaimOptions>>): JsonWebTokenClaims;
/**
* Parses the provided Buffer into a JSON Web Token Claims object.
*
* @param data Buffer encoded JSON Web Token Claims.
* @param options Validation options for the claims.
* @returns Parsed JSON Web Token Claims.
*/
static parse(data: Buffer, options?: Optional<Dict<JsonWebTokenClaimOptions>>): JsonWebTokenClaims;
/**
* Validates the Default JSON Web Token Claims based on the rules of
* {@link https://www.rfc-editor.org/rfc/rfc7519.html#section-4 RFC 7519 Section 4}.
*
* @param claims JSON Web Token Claims.
*/
protected validateDefaultClaims(claims: JsonWebTokenClaimsParams): void;
/**
* Method used when extending **JsonWebTokenClaims** via inheritance.
*
* This method **SHOULD** be implemented by the child class in order to provide validation for custom
* JSON Web Token Claims supported by it.
*
* *Implementation of this method is optional.*
*
* @param claims JSON Web Token Claims.
*/
protected validateCustomClaims?(claims: JsonWebTokenClaimsParams): void;
/**
* Validates the provided JSON Web Token Claims based on the provided Options.
*
* @param claims JSON Web Token Claims.
* @param options Dictionary used to validate the provided JSON Web Token Claims.
*/
private validateClaimsOptions;
/**
* Returns the JSON Encoded String of the JSON Web Token Claims.
*/
toString(): string;
/**
* Returns the Buffer representation of the JSON Encoded String of the JSON Web Token Claims.
*/
toBuffer(): Buffer;
}