@pristine-ts/jwt 2.0.3 → 2.0.5
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.
- package/dist/lib/cjs/errors/invalid-jwt.error.js +8 -12
- package/dist/lib/cjs/errors/invalid-jwt.error.js.map +1 -1
- package/dist/lib/cjs/errors/jwt-authorization-header.error.js +4 -8
- package/dist/lib/cjs/errors/jwt-authorization-header.error.js.map +1 -1
- package/dist/lib/cjs/guards/jwt-protected.guard.js +7 -0
- package/dist/lib/cjs/guards/jwt-protected.guard.js.map +1 -1
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/esm/errors/invalid-jwt.error.js +9 -13
- package/dist/lib/esm/errors/invalid-jwt.error.js.map +1 -1
- package/dist/lib/esm/errors/jwt-authorization-header.error.js +5 -9
- package/dist/lib/esm/errors/jwt-authorization-header.error.js.map +1 -1
- package/dist/lib/esm/guards/jwt-protected.guard.js +7 -0
- package/dist/lib/esm/guards/jwt-protected.guard.js.map +1 -1
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/types/errors/invalid-jwt.error.d.ts +2 -2
- package/dist/types/errors/jwt-authorization-header.error.d.ts +2 -2
- package/package.json +5 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PristineError } from "@pristine-ts/common";
|
|
2
2
|
/**
|
|
3
3
|
* This Error is thrown when you try to decode a JWT but the token is invalid.
|
|
4
4
|
*/
|
|
5
|
-
export class InvalidJwtError extends
|
|
5
|
+
export class InvalidJwtError extends PristineError {
|
|
6
6
|
/**
|
|
7
7
|
* This Error is thrown when you try to decode a JWT but the token is invalid.
|
|
8
8
|
* @param message The error message to show.
|
|
@@ -13,17 +13,13 @@ export class InvalidJwtError extends LoggableError {
|
|
|
13
13
|
* @param publicKey The public key used to decode the JWT.
|
|
14
14
|
*/
|
|
15
15
|
constructor(message, previousError, request, token, algorithm, publicKey) {
|
|
16
|
-
super(message, {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// Set the prototype explicitly.
|
|
24
|
-
// As specified in the documentation in TypeScript
|
|
25
|
-
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
26
|
-
Object.setPrototypeOf(this, InvalidJwtError.prototype);
|
|
16
|
+
super(message, { details: {
|
|
17
|
+
request,
|
|
18
|
+
previousError,
|
|
19
|
+
token,
|
|
20
|
+
algorithm,
|
|
21
|
+
publicKey,
|
|
22
|
+
} });
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
25
|
//# sourceMappingURL=invalid-jwt.error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-jwt.error.js","sourceRoot":"","sources":["../../../../src/errors/invalid-jwt.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAU,MAAM,qBAAqB,CAAC;AAE3D;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,aAAa;IAEhD;;;;;;;;OAQG;IACH,YAAmB,OAAe,EAAE,aAAoB,EAAE,OAAgB,EAAE,KAAa,EAAE,SAAiB,EAAE,SAAiB;QAC7H,KAAK,CAAC,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"invalid-jwt.error.js","sourceRoot":"","sources":["../../../../src/errors/invalid-jwt.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAU,MAAM,qBAAqB,CAAC;AAE3D;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,aAAa;IAEhD;;;;;;;;OAQG;IACH,YAAmB,OAAe,EAAE,aAAoB,EAAE,OAAgB,EAAE,KAAa,EAAE,SAAiB,EAAE,SAAiB;QAC7H,KAAK,CAAC,OAAO,EAAE,EAAC,OAAO,EAAE;gBACvB,OAAO;gBACP,aAAa;gBACb,KAAK;gBACL,SAAS;gBACT,SAAS;aACV,EAAC,CAAC,CAAC;IAAE,CAAC;CACV"}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PristineError } from "@pristine-ts/common";
|
|
2
2
|
/**
|
|
3
3
|
* This Error is thrown when there's you try to decode a JWT in a request but the AuthorizationHeader is missing.
|
|
4
4
|
*/
|
|
5
|
-
export class JwtAuthorizationHeaderError extends
|
|
5
|
+
export class JwtAuthorizationHeaderError extends PristineError {
|
|
6
6
|
/**
|
|
7
7
|
* This Error is thrown when there's you try to decode a JWT in a request but the AuthorizationHeader is missing.
|
|
8
8
|
* @param message The error message.
|
|
9
9
|
* @param request The request that is missing the AuthorizationHeader.
|
|
10
10
|
*/
|
|
11
11
|
constructor(message, request) {
|
|
12
|
-
super(message, {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// Set the prototype explicitly.
|
|
16
|
-
// As specified in the documentation in TypeScript
|
|
17
|
-
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
18
|
-
Object.setPrototypeOf(this, JwtAuthorizationHeaderError.prototype);
|
|
12
|
+
super(message, { details: {
|
|
13
|
+
request,
|
|
14
|
+
} });
|
|
19
15
|
}
|
|
20
16
|
}
|
|
21
17
|
//# sourceMappingURL=jwt-authorization-header.error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-authorization-header.error.js","sourceRoot":"","sources":["../../../../src/errors/jwt-authorization-header.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAU,MAAM,qBAAqB,CAAC;AAE3D;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,aAAa;IAC5D;;;;OAIG;IACH,YAAmB,OAAe,EAAE,OAAgB;QAClD,KAAK,CAAC,OAAO,EAAE
|
|
1
|
+
{"version":3,"file":"jwt-authorization-header.error.js","sourceRoot":"","sources":["../../../../src/errors/jwt-authorization-header.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAU,MAAM,qBAAqB,CAAC;AAE3D;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,aAAa;IAC5D;;;;OAIG;IACH,YAAmB,OAAe,EAAE,OAAgB;QAClD,KAAK,CAAC,OAAO,EAAE,EAAC,OAAO,EAAE;gBACvB,OAAO;aACR,EAAC,CAAC,CAAC;IAAE,CAAC;CACV"}
|
|
@@ -11,6 +11,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
13
|
import { inject, injectable } from "tsyringe";
|
|
14
|
+
import { Request, traced } from "@pristine-ts/common";
|
|
14
15
|
/**
|
|
15
16
|
* This guard is used to verify that a route can only be accessed when a request has a valid JWT.
|
|
16
17
|
*/
|
|
@@ -40,6 +41,12 @@ let JwtProtectedGuard = class JwtProtectedGuard {
|
|
|
40
41
|
return Promise.resolve();
|
|
41
42
|
}
|
|
42
43
|
};
|
|
44
|
+
__decorate([
|
|
45
|
+
traced(),
|
|
46
|
+
__metadata("design:type", Function),
|
|
47
|
+
__metadata("design:paramtypes", [Request, Object]),
|
|
48
|
+
__metadata("design:returntype", Promise)
|
|
49
|
+
], JwtProtectedGuard.prototype, "isAuthorized", null);
|
|
43
50
|
JwtProtectedGuard = __decorate([
|
|
44
51
|
injectable(),
|
|
45
52
|
__param(0, inject("JwtManagerInterface")),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-protected.guard.js","sourceRoot":"","sources":["../../../../src/guards/jwt-protected.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"jwt-protected.guard.js","sourceRoot":"","sources":["../../../../src/guards/jwt-protected.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAoB,OAAO,EAAE,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAGvE;;GAEG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAI5B,YAA2C,UAAgD;QAA/B,eAAU,GAAV,UAAU,CAAqB;QAHpF,YAAO,GAAG,eAAe,CAAC;IAIjC,CAAC;IAED;;;;OAIG;IAEH,YAAY,CAAC,OAAgB,EAAE,QAA4B;QACzD,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;YACtC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC;iBACvC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;iBAC5B,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,OAAY;QACrB,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;QAE5B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF,CAAA;AAjBC;IADC,MAAM,EAAE;;qCACa,OAAO;;qDAM5B;AAnBU,iBAAiB;IAD7B,UAAU,EAAE;IAKE,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;;GAJ/B,iBAAiB,CA8B7B"}
|