itlab-internal-services 0.0.1 → 0.0.2

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 CHANGED
@@ -57,11 +57,11 @@ async delete(targetId: string): Promise<void>
57
57
  ### Content Service
58
58
 
59
59
  ```typescript
60
- async verify(contents: Content[]): Promise<void>
60
+ async verify(contents: Content): Promise<void>
61
61
  ```
62
62
 
63
63
  ```typescript
64
- async post(targetId: string, contents: Content[]): Promise<void>
64
+ async post(targetId: string, contents: Content): Promise<void>
65
65
  ```
66
66
 
67
67
  ```typescript
@@ -8,4 +8,4 @@ export declare class InternalGuard implements CanActivate {
8
8
  export declare class UnauthorizedApplicationException extends HttpException {
9
9
  constructor();
10
10
  }
11
- export declare const Internal: <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
11
+ export declare const Internal: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -41,4 +41,5 @@ class UnauthorizedApplicationException extends common_1.HttpException {
41
41
  }
42
42
  }
43
43
  exports.UnauthorizedApplicationException = UnauthorizedApplicationException;
44
- exports.Internal = (0, common_1.applyDecorators)((0, swagger_1.ApiBasicAuth)(exports.INTERNAL_HEADER_KEY), (0, common_1.UseGuards)(InternalGuard), (0, swagger_1.ApiUnauthorizedResponse)({ description: 'Application unauthorized' }));
44
+ const Internal = () => (0, common_1.applyDecorators)((0, swagger_1.ApiBasicAuth)(exports.INTERNAL_HEADER_KEY), (0, common_1.UseGuards)(InternalGuard), (0, swagger_1.ApiUnauthorizedResponse)({ description: 'Application unauthorized' }));
45
+ exports.Internal = Internal;
@@ -9,11 +9,11 @@ export declare class JwtStrategy extends JwtStrategy_base {
9
9
  validate(payload: any): LAccount;
10
10
  }
11
11
  export declare const Account: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
12
- export declare const AccountId: ParameterDecorator;
13
- export declare const AccountPerms: ParameterDecorator;
12
+ export declare const AccountId: () => ParameterDecorator;
13
+ export declare const AccountPerms: () => ParameterDecorator;
14
14
  export declare const JwtToken: (...dataOrPipes: any[]) => ParameterDecorator;
15
15
  declare const JwtGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
16
16
  export declare class JwtGuard extends JwtGuard_base {
17
17
  }
18
- export declare const Jwt: <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
18
+ export declare const Jwt: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
19
19
  export {};
@@ -39,8 +39,10 @@ exports.Account = (0, common_1.createParamDecorator)((param, ctx) => {
39
39
  const { user } = ctx.switchToHttp().getRequest();
40
40
  return param ? user === null || user === void 0 ? void 0 : user[param] : user;
41
41
  });
42
- exports.AccountId = (0, exports.Account)('id');
43
- exports.AccountPerms = (0, exports.Account)('perms');
42
+ const AccountId = () => (0, exports.Account)('id');
43
+ exports.AccountId = AccountId;
44
+ const AccountPerms = () => (0, exports.Account)('perms');
45
+ exports.AccountPerms = AccountPerms;
44
46
  exports.JwtToken = (0, common_1.createParamDecorator)((_, ctx) => {
45
47
  const h = ctx.switchToHttp().getRequest().header('Authorization');
46
48
  return h.replace('Bearer ', '');
@@ -48,4 +50,5 @@ exports.JwtToken = (0, common_1.createParamDecorator)((_, ctx) => {
48
50
  class JwtGuard extends (0, passport_1.AuthGuard)('jwt') {
49
51
  }
50
52
  exports.JwtGuard = JwtGuard;
51
- exports.Jwt = (0, common_1.applyDecorators)((0, common_1.UseGuards)(JwtGuard), (0, swagger_1.ApiBearerAuth)(), (0, swagger_1.ApiUnauthorizedResponse)({ description: 'Unauthorized' }));
53
+ const Jwt = () => (0, common_1.applyDecorators)((0, common_1.UseGuards)(JwtGuard), (0, swagger_1.ApiBearerAuth)(), (0, swagger_1.ApiUnauthorizedResponse)({ description: 'Unauthorized' }));
54
+ exports.Jwt = Jwt;
@@ -8,4 +8,4 @@ export declare class PermsGuard implements CanActivate {
8
8
  export declare class InsufficientPermissionsException extends HttpException {
9
9
  constructor();
10
10
  }
11
- export declare function Perms(...perms: string[]): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
11
+ export declare const Perms: (...perms: string[]) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -38,9 +38,7 @@ class InsufficientPermissionsException extends common_1.HttpException {
38
38
  }
39
39
  }
40
40
  exports.InsufficientPermissionsException = InsufficientPermissionsException;
41
- function Perms(...perms) {
42
- return (0, common_1.applyDecorators)((0, common_1.SetMetadata)(meta, perms), (0, common_1.UseGuards)(jwt_guard_1.JwtGuard, PermsGuard), (0, swagger_1.ApiBearerAuth)(), (0, swagger_1.ApiOperation)({ summary: 'Perms: ' + perms.join(', ') }), (0, swagger_1.ApiUnauthorizedResponse)({
43
- description: 'Unauthorized or insufficient permissions',
44
- }));
45
- }
41
+ const Perms = (...perms) => (0, common_1.applyDecorators)((0, common_1.SetMetadata)(meta, perms), (0, common_1.UseGuards)(jwt_guard_1.JwtGuard, PermsGuard), (0, swagger_1.ApiBearerAuth)(), (0, swagger_1.ApiOperation)({ summary: 'Perms: ' + perms.join(', ') }), (0, swagger_1.ApiUnauthorizedResponse)({
42
+ description: 'Unauthorized or insufficient permissions',
43
+ }));
46
44
  exports.Perms = Perms;
@@ -23,6 +23,7 @@ exports.InternalModule = void 0;
23
23
  const common_1 = require("@nestjs/common");
24
24
  const random_string_generator_util_1 = require("@nestjs/common/utils/random-string-generator.util");
25
25
  const axios_1 = __importDefault(require("axios"));
26
+ const guards_1 = require("./guards");
26
27
  const internal_constants_1 = require("./internal.constants");
27
28
  const services_1 = require("./services");
28
29
  const axiosConfig = (config) => ({
@@ -119,6 +120,7 @@ InternalModule = InternalModule_1 = __decorate([
119
120
  services_1.ContentService,
120
121
  services_1.SearchService,
121
122
  { provide: internal_constants_1.AXIOS_INSTANCE_TOKEN, useValue: axios_1.default },
123
+ guards_1.JwtStrategy,
122
124
  ],
123
125
  exports: [services_1.CommentService, services_1.ContentService, services_1.SearchService],
124
126
  })
@@ -6,7 +6,7 @@ export declare class ContentService {
6
6
  protected readonly target: Targets;
7
7
  protected readonly prefix: string;
8
8
  constructor(instance?: AxiosInstance, target?: Targets, prefix?: string);
9
- verify(contents: Content[]): Promise<void>;
10
- post(targetId: string, contents: Content[]): Promise<void>;
9
+ verify(contents: Content): Promise<void>;
10
+ post(targetId: string, contents: Content): Promise<void>;
11
11
  delete(targetId: string): Promise<void>;
12
12
  }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "timo.scheuermann@sv-informatik.de",
6
6
  "url": "https://timos.design"
7
7
  },
8
- "version": "0.0.1",
8
+ "version": "0.0.2",
9
9
  "type": "commonjs",
10
10
  "files": [
11
11
  "dist"