authorized-rules
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"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); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
17683
324
- Removedassert@^2.0.0
- Removedassert@2.1.0(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedis-arguments@1.1.1(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-generator-function@1.0.10(transitive)
- Removedis-nan@1.3.2(transitive)
- Removedis-typed-array@1.1.13(transitive)
- Removedobject-is@1.1.6(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@4.1.5(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedutil@0.12.5(transitive)
- Removedwhich-typed-array@1.1.15(transitive)