@loopstack/auth 0.10.2 → 0.10.3
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/CHANGELOG.md +9 -0
- package/package.json +3 -3
- package/dist/guards/onditional-auth.guard.d.ts +0 -11
- package/dist/guards/onditional-auth.guard.js +0 -41
- package/dist/guards/onditional-auth.guard.js.map +0 -1
- package/dist/guards/worker-auth.guard.d.ts +0 -7
- package/dist/guards/worker-auth.guard.js +0 -31
- package/dist/guards/worker-auth.guard.js.map +0 -1
- package/dist/seeds/local-dev-user.seed.d.ts +0 -11
- package/dist/seeds/local-dev-user.seed.js +0 -48
- package/dist/seeds/local-dev-user.seed.js.map +0 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@loopstack/auth",
|
|
3
3
|
"displayName": "Loopstack Auth Module",
|
|
4
4
|
"description": "The auth module of the loopstack automation framework",
|
|
5
|
-
"version": "0.10.
|
|
5
|
+
"version": "0.10.3",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Jakob Klippel",
|
|
8
8
|
"url": "https://www.linkedin.com/in/jakob-klippel/"
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@loopstack/core": "^0.10.
|
|
15
|
-
"@loopstack/shared": "^0.10.
|
|
14
|
+
"@loopstack/core": "^0.10.3",
|
|
15
|
+
"@loopstack/shared": "^0.10.2",
|
|
16
16
|
"@nestjs/common": "^11.0.1",
|
|
17
17
|
"@nestjs/config": "^4.0.0",
|
|
18
18
|
"@nestjs/core": "^11.0.1",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
-
import { ConfigService } from '@nestjs/config';
|
|
3
|
-
import { JwtAuthGuard } from './jwt-auth.guard';
|
|
4
|
-
import { LocalDevModeGuard } from './local-dev-mode.guard';
|
|
5
|
-
export declare class ConditionalAuthGuard implements CanActivate {
|
|
6
|
-
private readonly configService;
|
|
7
|
-
private readonly jwtAuthGuard;
|
|
8
|
-
private readonly localDevModeGuard;
|
|
9
|
-
constructor(configService: ConfigService, jwtAuthGuard: JwtAuthGuard, localDevModeGuard: LocalDevModeGuard);
|
|
10
|
-
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
11
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ConditionalAuthGuard = void 0;
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const config_1 = require("@nestjs/config");
|
|
15
|
-
const jwt_auth_guard_1 = require("./jwt-auth.guard");
|
|
16
|
-
const local_dev_mode_guard_1 = require("./local-dev-mode.guard");
|
|
17
|
-
let ConditionalAuthGuard = class ConditionalAuthGuard {
|
|
18
|
-
configService;
|
|
19
|
-
jwtAuthGuard;
|
|
20
|
-
localDevModeGuard;
|
|
21
|
-
constructor(configService, jwtAuthGuard, localDevModeGuard) {
|
|
22
|
-
this.configService = configService;
|
|
23
|
-
this.jwtAuthGuard = jwtAuthGuard;
|
|
24
|
-
this.localDevModeGuard = localDevModeGuard;
|
|
25
|
-
}
|
|
26
|
-
async canActivate(context) {
|
|
27
|
-
const isLocalDevMode = this.configService.get('app.isLocalMode');
|
|
28
|
-
if (isLocalDevMode) {
|
|
29
|
-
return this.localDevModeGuard.canActivate(context);
|
|
30
|
-
}
|
|
31
|
-
return this.jwtAuthGuard.canActivate(context);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
exports.ConditionalAuthGuard = ConditionalAuthGuard;
|
|
35
|
-
exports.ConditionalAuthGuard = ConditionalAuthGuard = __decorate([
|
|
36
|
-
(0, common_1.Injectable)(),
|
|
37
|
-
__metadata("design:paramtypes", [config_1.ConfigService,
|
|
38
|
-
jwt_auth_guard_1.JwtAuthGuard,
|
|
39
|
-
local_dev_mode_guard_1.LocalDevModeGuard])
|
|
40
|
-
], ConditionalAuthGuard);
|
|
41
|
-
//# sourceMappingURL=onditional-auth.guard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onditional-auth.guard.js","sourceRoot":"","sources":["../../src/guards/onditional-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2E;AAC3E,2CAA+C;AAC/C,qDAAgD;AAChD,iEAA2D;AAGpD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAEZ;IACA;IACA;IAHnB,YACmB,aAA4B,EAC5B,YAA0B,EAC1B,iBAAoC;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAC5B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACpD,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAU,iBAAiB,CAAC,CAAC;QAE1E,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAqB,CAAC;IACpE,CAAC;CACF,CAAA;AAhBY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAGuB,sBAAa;QACd,6BAAY;QACP,wCAAiB;GAJ5C,oBAAoB,CAgBhC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
-
import { ConfigService } from '@nestjs/config';
|
|
3
|
-
export declare class WorkerAuthGuard implements CanActivate {
|
|
4
|
-
private readonly configService;
|
|
5
|
-
constructor(configService: ConfigService);
|
|
6
|
-
canActivate(context: ExecutionContext): boolean;
|
|
7
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.WorkerAuthGuard = void 0;
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const config_1 = require("@nestjs/config");
|
|
15
|
-
let WorkerAuthGuard = class WorkerAuthGuard {
|
|
16
|
-
configService;
|
|
17
|
-
constructor(configService) {
|
|
18
|
-
this.configService = configService;
|
|
19
|
-
}
|
|
20
|
-
canActivate(context) {
|
|
21
|
-
const { user } = context.switchToHttp().getRequest();
|
|
22
|
-
const clientId = this.configService.get('auth.clientId');
|
|
23
|
-
return clientId === user.workerId;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
exports.WorkerAuthGuard = WorkerAuthGuard;
|
|
27
|
-
exports.WorkerAuthGuard = WorkerAuthGuard = __decorate([
|
|
28
|
-
(0, common_1.Injectable)(),
|
|
29
|
-
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
30
|
-
], WorkerAuthGuard);
|
|
31
|
-
//# sourceMappingURL=worker-auth.guard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker-auth.guard.js","sourceRoot":"","sources":["../../src/guards/worker-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2E;AAC3E,2CAA+C;AAaxC,IAAM,eAAe,GAArB,MAAM,eAAe;IACG;IAA7B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAE7D,WAAW,CAAC,OAAyB;QACnC,MAAM,EAAE,IAAI,EAAE,GAAmC,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACrF,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,eAAe,CAAC,CAAC;QACjE,OAAO,QAAQ,KAAK,IAAI,CAAC,QAAQ,CAAC;IACpC,CAAC;CACF,CAAA;AARY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;qCAEiC,sBAAa;GAD9C,eAAe,CAQ3B"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
-
import { ConfigService } from '@nestjs/config';
|
|
3
|
-
import { UserRepository } from '../repositories';
|
|
4
|
-
export declare class LocalDevUserSeeder implements OnModuleInit {
|
|
5
|
-
private readonly configService;
|
|
6
|
-
private readonly userRepository;
|
|
7
|
-
private readonly LOCAL_DEV_USER_ID;
|
|
8
|
-
constructor(configService: ConfigService, userRepository: UserRepository);
|
|
9
|
-
onModuleInit(): Promise<void>;
|
|
10
|
-
getLocalDevUserId(): string;
|
|
11
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LocalDevUserSeeder = void 0;
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const config_1 = require("@nestjs/config");
|
|
15
|
-
const repositories_1 = require("../repositories");
|
|
16
|
-
let LocalDevUserSeeder = class LocalDevUserSeeder {
|
|
17
|
-
configService;
|
|
18
|
-
userRepository;
|
|
19
|
-
LOCAL_DEV_USER_ID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890';
|
|
20
|
-
constructor(configService, userRepository) {
|
|
21
|
-
this.configService = configService;
|
|
22
|
-
this.userRepository = userRepository;
|
|
23
|
-
}
|
|
24
|
-
async onModuleInit() {
|
|
25
|
-
const isLocalMode = this.configService.get('app.isLocalMode');
|
|
26
|
-
if (!isLocalMode)
|
|
27
|
-
return;
|
|
28
|
-
const existingUser = await this.userRepository.findById(this.LOCAL_DEV_USER_ID);
|
|
29
|
-
if (!existingUser) {
|
|
30
|
-
await this.userRepository.create({
|
|
31
|
-
id: this.LOCAL_DEV_USER_ID,
|
|
32
|
-
isActive: true,
|
|
33
|
-
roles: [],
|
|
34
|
-
});
|
|
35
|
-
console.log('✓ Local dev user created');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
getLocalDevUserId() {
|
|
39
|
-
return this.LOCAL_DEV_USER_ID;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
exports.LocalDevUserSeeder = LocalDevUserSeeder;
|
|
43
|
-
exports.LocalDevUserSeeder = LocalDevUserSeeder = __decorate([
|
|
44
|
-
(0, common_1.Injectable)(),
|
|
45
|
-
__metadata("design:paramtypes", [config_1.ConfigService,
|
|
46
|
-
repositories_1.UserRepository])
|
|
47
|
-
], LocalDevUserSeeder);
|
|
48
|
-
//# sourceMappingURL=local-dev-user.seed.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local-dev-user.seed.js","sourceRoot":"","sources":["../../src/seeds/local-dev-user.seed.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,2CAA0D;AAC1D,2CAA+C;AAG/C,kDAAiD;AAI1C,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAIV;IACA;IAJF,iBAAiB,GAAG,sCAAsC,CAAC;IAE5E,YACmB,aAA4B,EAC5B,cAA8B;QAD9B,kBAAa,GAAb,aAAa,CAAe;QAC5B,mBAAc,GAAd,cAAc,CAAgB;IAC9C,CAAC;IAEJ,KAAK,CAAC,YAAY;QAChB,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAU,iBAAiB,CAAC,CAAC;QACvE,IAAI,CAAC,WAAW;YAAE,OAAO;QAGzB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEhF,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;gBAC/B,EAAE,EAAE,IAAI,CAAC,iBAAiB;gBAC1B,QAAQ,EAAE,IAAI;gBACd,KAAK,EAAE,EAAE;aACc,CAAC,CAAC;YAE3B,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;CACF,CAAA;AA7BY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;qCAKuB,sBAAa;QACZ,6BAAc;GALtC,kBAAkB,CA6B9B"}
|