Socket
Socket
Sign inDemoInstall

authorized-rules

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

authorized-rules - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

3

package.json
{
"name": "authorized-rules",
"version": "0.1.0",
"version": "0.1.1",
"description": "",

@@ -38,3 +38,2 @@ "main": "dist/index.js",

"@types/jwt-decode": "^3.1.0",
"assert": "^2.0.0",
"http-errors": "^1.8.0",

@@ -41,0 +40,0 @@ "jwt-decode": "^3.1.2"

import jwtDecoder from 'jwt-decode';
import createError from 'http-errors';
import {AssertionError} from 'assert';

@@ -25,7 +24,6 @@ export type JwtToken = {

export const authorize = async <T1 = void, T2 = void, T3 = void, T4 = void>(
{headers: {authorization}}: Request,
jwtToken: string,
executionRule: Rule<T1 | T2 | T3 | T4>
): Promise<(T1 | T2 | T3 | T4)[]> => {
assertBearerToken(authorization);
const token = getToken(authorization);
const token = getToken(jwtToken);

@@ -66,10 +64,2 @@ if (!token.iss) {

function assertBearerToken(val: any): asserts val is string {
if (val && val.includes('Bearer')) {
return;
}
throw new AssertionError({message: 'not a valid bearer token'});
}
const getToken = (authorizationHeader: string): JwtToken & {iss: string} =>
jwtDecoder(authorizationHeader.replace('Bearer ', ''));
const getToken = (token: string): JwtToken & {iss: string} => jwtDecoder(token);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc