PageSourceSearch

https://www.americaneagle.ae/scripts/third-party/jwt.js

js americaneagle.ae collected 2026-10-02 13:25:36 UTC 2,722 bytes, 76 lines download raw bytes

1/*  The MIT License (MIT)
2
3    Copyright (c) 2015 Auth0, Inc. <[email protected]> (http://auth0.com)
4
5    Permission is hereby granted, free of charge, to any person obtaining a copy
6    of this software and associated documentation files (the "Software"), to deal
7    in the Software without restriction, including without limitation the rights
8    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9    copies of the Software, and to permit persons to whom the Software is
10    furnished to do so, subject to the following conditions:
11
12    The above copyright notice and this permission notice shall be included in all
13    copies or substantial portions of the Software.
14
15    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21    SOFTWARE. */
22
23export class InvalidTokenError extends Error {
24}
25InvalidTokenError.prototype.name = 'InvalidTokenError';
26function b64DecodeUnicode(str) {
27  return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {
vendor: 1,329 bytes, lines 28-76
28    let code = p.charCodeAt(0).toString(16).toUpperCase();
29    if (code.length < 2) {
30      code = `0${code}`;
31    }
32    return `%${code}`;
33  }));
34}
35function base64UrlDecode(str) {
36  let output = str.replace(/-/g, '+').replace(/_/g, '/');
37  switch (output.length % 4) {
38    case 0:
39      break;
40    case 2:
41      output += '==';
42      break;
43    case 3:
44      output += '=';
45      break;
46    default:
47      throw new Error('base64 string is not of the correct length');
48  }
49  try {
50    return b64DecodeUnicode(output);
51  } catch (err) {
52    return atob(output);
53  }
54}
55export function jwtDecode(token, options) {
56  if (typeof token !== 'string') {
57    throw new InvalidTokenError('Invalid token specified: must be a string');
58  }
59  const opts = options || {};
60  const pos = opts.header === true ? 0 : 1;
61  const part = token.split('.')[pos];
62  if (typeof part !== 'string') {
63    throw new InvalidTokenError(`Invalid token specified: missing part #${pos + 1}`);
64  }
65  let decoded;
66  try {
67    decoded = base64UrlDecode(part);
68  } catch (e) {
69    throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${pos + 1} (${e.message})`);
70  }
71  try {
72    return JSON.parse(decoded);
73  } catch (e) {
74    throw new InvalidTokenError(`Invalid token specified: invalid json for part #${pos + 1} (${e.message})`);
75  }
76}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.