@zola_do/authorization 0.1.17 → 0.1.19
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/README.md +29 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +54 -54
package/README.md
CHANGED
|
@@ -28,6 +28,35 @@ export class AppModule {}
|
|
|
28
28
|
|
|
29
29
|
By default, `JwtGuard` is registered as a global guard. Protect routes automatically; use `@AllowAnonymous()` for public routes.
|
|
30
30
|
|
|
31
|
+
### Override JwtGuard In AppModule
|
|
32
|
+
|
|
33
|
+
If your app uses a different token payload shape or custom validation logic, override `JwtGuard` in `AppModule`.
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { Injectable, ExecutionContext } from '@nestjs/common';
|
|
37
|
+
import { JwtGuard } from '@zola_do/authorization';
|
|
38
|
+
|
|
39
|
+
@Injectable()
|
|
40
|
+
export class AppJwtGuard extends JwtGuard {
|
|
41
|
+
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
42
|
+
// Add app-specific token parsing/validation logic here.
|
|
43
|
+
return super.canActivate(context);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { Module } from '@nestjs/common';
|
|
50
|
+
import { AuthorizationModule, JwtGuard } from '@zola_do/authorization';
|
|
51
|
+
import { AppJwtGuard } from './guards/app-jwt.guard';
|
|
52
|
+
|
|
53
|
+
@Module({
|
|
54
|
+
imports: [AuthorizationModule],
|
|
55
|
+
providers: [{ provide: JwtGuard, useClass: AppJwtGuard }],
|
|
56
|
+
})
|
|
57
|
+
export class AppModule {}
|
|
58
|
+
```
|
|
59
|
+
|
|
31
60
|
### Protected Routes
|
|
32
61
|
|
|
33
62
|
```typescript
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AuthorizationModule } from './authorization.module';
|
|
2
|
+
export { JwtGuard } from './guards/jwt.guard';
|
|
2
3
|
export * from './decorators/allow-anonymous.decorator';
|
|
3
4
|
export * from './decorators/current-user.decorator';
|
|
4
|
-
export * from './guards/jwt.guard';
|
|
5
5
|
export * from './guards/permissions.guard';
|
|
6
6
|
export * from './helper/auth.helper';
|
|
7
7
|
export * from './guards/jwt-refresh.guard';
|
package/dist/index.js
CHANGED
|
@@ -14,12 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.AuthorizationModule = void 0;
|
|
17
|
+
exports.JwtGuard = exports.AuthorizationModule = void 0;
|
|
18
18
|
var authorization_module_1 = require("./authorization.module");
|
|
19
19
|
Object.defineProperty(exports, "AuthorizationModule", { enumerable: true, get: function () { return authorization_module_1.AuthorizationModule; } });
|
|
20
|
+
var jwt_guard_1 = require("./guards/jwt.guard");
|
|
21
|
+
Object.defineProperty(exports, "JwtGuard", { enumerable: true, get: function () { return jwt_guard_1.JwtGuard; } });
|
|
20
22
|
__exportStar(require("./decorators/allow-anonymous.decorator"), exports);
|
|
21
23
|
__exportStar(require("./decorators/current-user.decorator"), exports);
|
|
22
|
-
__exportStar(require("./guards/jwt.guard"), exports);
|
|
23
24
|
__exportStar(require("./guards/permissions.guard"), exports);
|
|
24
25
|
__exportStar(require("./helper/auth.helper"), exports);
|
|
25
26
|
__exportStar(require("./guards/jwt-refresh.guard"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+DAA6D;AAApD,2HAAA,mBAAmB,OAAA;AAC5B,yEAAuD;AACvD,sEAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+DAA6D;AAApD,2HAAA,mBAAmB,OAAA;AAC5B,gDAA8C;AAArC,qGAAA,QAAQ,OAAA;AACjB,yEAAuD;AACvD,sEAAoD;AACpD,6DAA2C;AAC3C,uDAAqC;AACrC,6DAA2C;AAC3C,wEAAsD;AACtD,yDAAuC;AACvC,wDAAsC;AACtC,8DAA4C;AAC5C,wEAAsD;AACtD,0DAAwC;AACxC,sDAAoC;AACpC,oDAAkC"}
|
package/package.json
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@zola_do/authorization",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "JWT auth, guards, strategies for NestJS",
|
|
5
|
-
"author": "zolaDO",
|
|
6
|
-
"license": "ISC",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"main": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"exports": {
|
|
13
|
-
".": {
|
|
14
|
-
"types": "./dist/index.d.ts",
|
|
15
|
-
"default": "./dist/index.js"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist",
|
|
20
|
-
"README.md"
|
|
21
|
-
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "rimraf dist && tsc",
|
|
24
|
-
"prepublishOnly": "npm run build"
|
|
25
|
-
},
|
|
26
|
-
"peerDependencies": {
|
|
27
|
-
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
28
|
-
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
29
|
-
"@nestjs/jwt": "^10.0.0 || ^11.0.0",
|
|
30
|
-
"@nestjs/passport": "^10.0.0 || ^11.0.0",
|
|
31
|
-
"@nestjs/platform-express": "^10.0.0 || ^11.0.0",
|
|
32
|
-
"@nestjs/throttler": "^5.0.0 || ^6.0.0",
|
|
33
|
-
"passport": "^0.7.0",
|
|
34
|
-
"passport-jwt": "^4.0.1",
|
|
35
|
-
"reflect-metadata": "^0.1.0 || ^0.2.0",
|
|
36
|
-
"rxjs": "^7.0.0 || ^8.0.0"
|
|
37
|
-
},
|
|
38
|
-
"peerDependenciesMeta": {
|
|
39
|
-
"@nestjs/throttler": {
|
|
40
|
-
"optional": true
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"@zola_do/core": "^0.1.9",
|
|
45
|
-
"bcrypt": "^6.0.0",
|
|
46
|
-
"jsonwebtoken": "^9.0.
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@types/bcrypt": "^6.0.0",
|
|
50
|
-
"@types/passport-jwt": "^4.0.1",
|
|
51
|
-
"rimraf": "^6.1.
|
|
52
|
-
"typescript": "^5.9.3"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@zola_do/authorization",
|
|
3
|
+
"version": "0.1.19",
|
|
4
|
+
"description": "JWT auth, guards, strategies for NestJS",
|
|
5
|
+
"author": "zolaDO",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "rimraf dist && tsc",
|
|
24
|
+
"prepublishOnly": "npm run build"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
28
|
+
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
29
|
+
"@nestjs/jwt": "^10.0.0 || ^11.0.0",
|
|
30
|
+
"@nestjs/passport": "^10.0.0 || ^11.0.0",
|
|
31
|
+
"@nestjs/platform-express": "^10.0.0 || ^11.0.0",
|
|
32
|
+
"@nestjs/throttler": "^5.0.0 || ^6.0.0",
|
|
33
|
+
"passport": "^0.7.0",
|
|
34
|
+
"passport-jwt": "^4.0.1",
|
|
35
|
+
"reflect-metadata": "^0.1.0 || ^0.2.0",
|
|
36
|
+
"rxjs": "^7.0.0 || ^8.0.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependenciesMeta": {
|
|
39
|
+
"@nestjs/throttler": {
|
|
40
|
+
"optional": true
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@zola_do/core": "^0.1.9",
|
|
45
|
+
"bcrypt": "^6.0.0",
|
|
46
|
+
"jsonwebtoken": "^9.0.3"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/bcrypt": "^6.0.0",
|
|
50
|
+
"@types/passport-jwt": "^4.0.1",
|
|
51
|
+
"rimraf": "^6.1.3",
|
|
52
|
+
"typescript": "^5.9.3"
|
|
53
|
+
}
|
|
54
|
+
}
|