@denodeio/seshat 0.0.29 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,6 +28,7 @@ export * from "./signer";
28
28
  type OptionsInput = {
29
29
  fieldName?: string;
30
30
  barongJwtPublicKey?: string;
31
+ jwtPublicKey?: string;
31
32
  issuer?: string;
32
33
  };
33
34
  export declare const sessionVerifier: (options: OptionsInput) => (req: any, res: any, next: any) => void;
@@ -42,6 +42,7 @@ type JwtPayload<T> = {
42
42
  type OptionsInput = {
43
43
  fieldName?: string;
44
44
  barongJwtPublicKey?: string;
45
+ jwtPublicKey?: string;
45
46
  issuer?: string;
46
47
  };
47
48
  declare const sessionVerifier: (options: OptionsInput) => (req: any, res: any, next: any) => void;
@@ -6509,10 +6509,10 @@ function signData(payload, options) {
6509
6509
 
6510
6510
  const sessionVerifier = function (options) {
6511
6511
  const { fieldName = "session", ...actualOptions } = options;
6512
- if (!options || !options.barongJwtPublicKey) {
6513
- throw new Error("Barong JWT Public key should be set");
6512
+ if (!options || (!options.barongJwtPublicKey && !options.jwtPublicKey)) {
6513
+ throw new Error("JWT Public key should be set");
6514
6514
  }
6515
- const barongJwtPublicKey = options.barongJwtPublicKey;
6515
+ const jwtPublicKey = options.barongJwtPublicKey || options.jwtPublicKey;
6516
6516
  const defaultOptions = {
6517
6517
  algorithms: ["RS256"],
6518
6518
  issuer: "auth"
@@ -6529,7 +6529,7 @@ const sessionVerifier = function (options) {
6529
6529
  return;
6530
6530
  }
6531
6531
  try {
6532
- req[fieldName] = jwt.verify(authHeader, barongJwtPublicKey, verificationOptions);
6532
+ req[fieldName] = jwt.verify(authHeader, jwtPublicKey, verificationOptions);
6533
6533
  }
6534
6534
  catch (error) {
6535
6535
  res.status(403);
@@ -6589,6 +6589,7 @@ const validateJws = (key, input) => {
6589
6589
  return verified;
6590
6590
  }
6591
6591
  catch (error) {
6592
+ console.error(error);
6592
6593
  return undefined;
6593
6594
  }
6594
6595
  }