@payello-module/jwt 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
package/dist/JWT.js CHANGED
@@ -59,7 +59,7 @@ export class JWT {
59
59
  }
60
60
  // Validates the present of required properties in the payload.
61
61
  const requiredProps = opts.requiredProps || ["jti", "iss", "iat"];
62
- for (const prop in requiredProps) {
62
+ for (const prop of requiredProps) {
63
63
  if (!payload[prop]) {
64
64
  throw new JwtError(`Payload missing ${prop} value`);
65
65
  }
@@ -67,7 +67,9 @@ export class JWT {
67
67
  // Returns an object containing the extracted components of the JWT.
68
68
  return {
69
69
  header: header,
70
+ headerRaw: bits[0],
70
71
  payload: payload,
72
+ payloadRaw: bits[1],
71
73
  signature: bits[2]
72
74
  };
73
75
  }
@@ -86,7 +88,7 @@ export class JWT {
86
88
  }
87
89
  let verify = false;
88
90
  // Preparation of the data to verify the signature.
89
- const data = `${btoa(JSON.stringify(extracted.header))}.${btoa(JSON.stringify(extracted.payload))}`;
91
+ const data = `${extracted.headerRaw}.${extracted.payloadRaw}`;
90
92
  // Verification of the signature based on the algorithm specified in the header.
91
93
  switch (extracted.header.alg) {
92
94
  case 'HS256':
@@ -1,6 +1,8 @@
1
1
  import { JwtHeader } from "./JwtHeader";
2
2
  export interface JwtExtract {
3
3
  header: JwtHeader;
4
+ headerRaw: string;
4
5
  payload: any;
6
+ payloadRaw: string;
5
7
  signature: string;
6
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payello-module/jwt",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "author": "Payello <devsupport@payello.com> (https://payello.com/)",
5
5
  "displayName": "@payello-module/jwt",
6
6
  "description": "JSON Web Token Module",