JwtHelperService (lib/jwthelper.service.ts)

angular2-jwt · projects/angular-jwt/src/lib/jwthelper.service.ts · typescript · MIT
auth

Angular utility for decoding and validating JWT tokens in applications.

// Source: https://github.com/auth0/angular2-jwt | License: MIT | Copyright 2017 Auth0 Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { HttpRequest } from '@angular/common/http';
/* eslint-disable no-bitwise */

import { Injectable, Inject } from '@angular/core';
import { JWT_OPTIONS } from './jwtoptions.token';

@Injectable()
export class JwtHelperService {
  tokenGetter: () => string | Promise<string>;

  constructor(@Inject(JWT_OPTIONS) config: any = null) {
    this.tokenGetter = (config && config.tokenGetter) || function () {};
  }

  public urlBase64Decode(str: string): string {
    let output = str.replace(/-/g, '+').replace(/_/g, '/');
    switch (output.length % 4) {
      case 0: {
        break;
      }
      case 2: {
        output += '==';
       

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key