Icard/angular-clarity-master(work.../node_modules/@auth0/angular-jwt/fesm2015/auth0-angular-jwt.mjs.map

1 line
21 KiB
Plaintext
Raw Permalink Normal View History

2024-07-16 14:55:36 +00:00
{"version":3,"file":"auth0-angular-jwt.mjs","sources":["../../../projects/angular-jwt/src/lib/jwtoptions.token.ts","../../../projects/angular-jwt/src/lib/jwthelper.service.ts","../../../projects/angular-jwt/src/lib/jwt.interceptor.ts","../../../projects/angular-jwt/src/lib/angular-jwt.module.ts","../../../projects/angular-jwt/src/index.ts","../../../projects/angular-jwt/src/auth0-angular-jwt.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const JWT_OPTIONS = new InjectionToken('JWT_OPTIONS');\n","import { HttpRequest } from '@angular/common/http';\n/* eslint-disable no-bitwise */\n\nimport { Injectable, Inject } from '@angular/core';\nimport { JWT_OPTIONS } from './jwtoptions.token';\n\n@Injectable()\nexport class JwtHelperService {\n tokenGetter: () => string | Promise<string>;\n\n constructor(@Inject(JWT_OPTIONS) config: any = null) {\n this.tokenGetter = (config && config.tokenGetter) || function () {};\n }\n\n public urlBase64Decode(str: string): string {\n let output = str.replace(/-/g, '+').replace(/_/g, '/');\n switch (output.length % 4) {\n case 0: {\n break;\n }\n case 2: {\n output += '==';\n break;\n }\n case 3: {\n output += '=';\n break;\n }\n default: {\n throw new Error('Illegal base64url string!');\n }\n }\n return this.b64DecodeUnicode(output);\n }\n\n // credits for decoder goes to https://github.com/atk\n private b64decode(str: string): string {\n const chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n let output = '';\n\n str = String(str).replace(/=+$/, '');\n\n if (str.length % 4 === 1) {\n throw new Error(\n `'atob' failed: The string to be decoded is not correctly encoded.`\n );\n }\n\n for (\n // initialize result and counters\n let bc = 0, bs: any, buffer: any, idx = 0;\n // get next character\n (buffer = str.charAt(idx++));\n // character found in table? initialize bit storage and add its ascii value;\n ~buffer &&\n ((bs = bc % 4 ? bs * 64 + buffer : buffer),\n // and if not first of each 4 characters,\n // convert the first 8 bits to one ascii character\n bc++ % 4)\n ? (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6))))\n : 0\n ) {\n // try to find character in table (0-63, not found => -1)\n buffer = chars.indexOf(buffer);\n }\n return output;\n }\n\n private b64DecodeUnicode(str: any) {\n return decodeURIComponent(\n Array.prototype.map\n .call(this.b64decode(str), (c: any) => {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n })\n .join('')\n );\n }\n\n public decodeToken<T = any>(token: string): T | null;\n public decodeToken<T = any>(token: Promise<string>): Promise<T | null>;\n public decodeToken<T = any>(): null | T | Promise<T | null>;\n public decodeToken<T = any>(token: string | Promise<string> = this.tokenGetter()): null | T | Promise<T | null> {\n if (token instanceof Promise) {\n return token.then(t => this._decodeToken(t));\n }\n\n return this._decodeToken(token);\n }\n\n private _decodeToken<T = any>(token: string): null | T {\n if (!token || token === '') {\n return null;\n }\n\n const parts = token.split('.');\n\n if (parts.length !== 3) {\n throw new Error(\n `The inspected token doesn't appear to be a JWT. Check to make sure it has three parts and see https://jwt.io for more.`\n );\n }\n\n const decoded = this.urlBase64Decode(parts[1]);\n if (!decoded) {\n throw new Error('Cannot decode the token.');\n }\n\n return JSON.parse(decoded);\n }\n\n public getTokenExpirationDate(token: string): Date | null;\n public getTokenExpirationDate(token: Promise<string>): Promise<Date | null>;\n public getTokenExpirationDate(): null | Date | Promise<Date | null>;\n public getTokenExpirationDate(\n token: string | Promise<string> = this.tokenGetter()\