跳到主要内容
版本:Next

JwtService

Index

Constructors

constructor

Methods

publicdecode

  • decode(token: string, options: DecodeOptions & { complete: true }): Jwt
  • decode(token: string, options: DecodeOptions & { json: true }): JwtPayload
  • decode(token: string, options?: DecodeOptions): JwtPayload
  • Returns the decoded payload without verifying if the signature is valid. token - JWT string to decode [options] - Options for decoding returns - The decoded Token

publicdecodeSync

  • decodeSync(token: string, options: DecodeOptions & { complete: true }): Jwt
  • decodeSync(token: string, options: DecodeOptions & { json: true }): JwtPayload
  • decodeSync(token: string, options?: DecodeOptions): JwtPayload
  • alias decode method

getDecodeOptions

  • getDecodeOptions(options?: DecodeOptions): DecodeOptions

getSignOptions

  • getSignOptions(options?: SignOptions): SignOptions | JwtConfig

getVerifyOptions

  • getVerifyOptions(options?: VerifyOptions): VerifyOptions

isSecret

  • isSecret(secret: any): secret is Secret

publicsign

  • sign(payload: JwtPayload, options?: SignOptions): Promise<string>
  • sign(payload: JwtPayload, secretOrPrivateKey: Secret, options?: SignOptions): Promise<string>
  • Asynchronous sign the given payload into a JSON Web Token string payload - Payload to sign, could be an literal, buffer or string secretOrPrivateKey - Either the secret for HMAC algorithms, or the PEM encoded private key for RSA and ECDSA. [options] - Options for the signature returns - The JSON Web Token string

publicsignSync

  • signSync(payload: JwtPayload, options?: SignOptions): string
  • signSync(payload: JwtPayload, secretOrPrivateKey: Secret, options?: SignOptions): string
  • Synchronously sign the given payload into a JSON Web Token string payload - Payload to sign, could be an literal, buffer or string secretOrPrivateKey - Either the secret for HMAC algorithms, or the PEM encoded private key for RSA and ECDSA. [options] - Options for the signature returns - The JSON Web Token string

publicverify

  • verify(token: string, options?: VerifyOptions & { complete: true }): Promise<string | Jwt>
  • verify(token: string, options?: VerifyOptions): Promise<JwtPayload>
  • verify(token: string, secretOrPublicKey: Secret | GetPublicKeyOrSecret, options?: VerifyOptions & { complete: true }): Promise<string | Jwt>
  • verify(token: string, secretOrPublicKey: Secret | GetPublicKeyOrSecret, options?: VerifyOptions): Promise<JwtPayload>
  • Asynchronous verify given token using a secret or a public key to get a decoded token token - JWT string to verify secretOrPublicKey - Either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA. [options] - Options for the verification returns - The decoded token.

publicverifySync

  • verifySync(token: string, options: VerifyOptions & { complete: true }): string | Jwt
  • verifySync(token: string, options: VerifyOptions): JwtPayload
  • verifySync(token: string, secretOrPublicKey: Secret, options?: VerifyOptions & { complete: true }): string | Jwt
  • verifySync(token: string, secretOrPublicKey: Secret, options?: VerifyOptions): JwtPayload
  • Synchronously verify given token using a secret or a public key to get a decoded token token - JWT string to verify secretOrPublicKey - Either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA. [options] - Options for the verification returns - The decoded token.