@tmlmobilidade/interfaces 20250829.936.9 → 20250829.1023.6

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.
@@ -37,8 +37,8 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
37
37
  updated_at: import("@tmlmobilidade/types").UnixTimestamp;
38
38
  phone?: string | null | undefined | undefined;
39
39
  email: string;
40
- email_verified?: (null | import("@tmlmobilidade/types").UnixTimestamp) | undefined;
41
40
  permissions: import("@tmlmobilidade/types").Permission<unknown>[];
41
+ email_verified?: (null | import("@tmlmobilidade/types").UnixTimestamp) | undefined;
42
42
  first_name: string;
43
43
  last_name: string;
44
44
  organization_ids: string[];
@@ -62,8 +62,8 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
62
62
  updated_at: import("@tmlmobilidade/types").UnixTimestamp;
63
63
  phone?: string | null | undefined | undefined;
64
64
  email: string;
65
- email_verified?: (null | import("@tmlmobilidade/types").UnixTimestamp) | undefined;
66
65
  permissions: import("@tmlmobilidade/types").Permission<unknown>[];
66
+ email_verified?: (null | import("@tmlmobilidade/types").UnixTimestamp) | undefined;
67
67
  first_name: string;
68
68
  last_name: string;
69
69
  organization_ids: string[];
@@ -1,7 +1,6 @@
1
1
  export * from './agencies/agencies.interface.js';
2
2
  export * from './alerts/alerts-realtime.interface.js';
3
3
  export * from './alerts/alerts.interface.js';
4
- export * from './auth/authorization.middleware.js';
5
4
  export * from './auth/roles.interface.js';
6
5
  export * from './auth/sessions.interface.js';
7
6
  export * from './auth/users.interface.js';
@@ -2,7 +2,6 @@
2
2
  export * from './agencies/agencies.interface.js';
3
3
  export * from './alerts/alerts-realtime.interface.js';
4
4
  export * from './alerts/alerts.interface.js';
5
- export * from './auth/authorization.middleware.js';
6
5
  export * from './auth/roles.interface.js';
7
6
  export * from './auth/sessions.interface.js';
8
7
  export * from './auth/users.interface.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/interfaces",
3
- "version": "20250829.936.9",
3
+ "version": "20250829.1023.6",
4
4
  "author": "João de Vasconcelos & Jusi Monteiro",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "homepage": "https://github.com/tmlmobilidade/services#readme",
@@ -1,9 +0,0 @@
1
- import { type FastifyRequest } from '@tmlmobilidade/connectors';
2
- import { type Permission, type User } from '@tmlmobilidade/types';
3
- declare module 'fastify' {
4
- interface FastifyRequest {
5
- me: User;
6
- permissions: Permission<unknown>[];
7
- }
8
- }
9
- export declare function authorizationMiddleware<T = unknown>(scope: string, action: string): (request: FastifyRequest) => Promise<void>;
@@ -1,18 +0,0 @@
1
- /* * */
2
- import { authProvider } from '../../providers/auth/auth.js';
3
- import { HttpException, HttpStatus } from '@tmlmobilidade/lib';
4
- import { hasPermission } from '@tmlmobilidade/utils';
5
- export function authorizationMiddleware(scope, action) {
6
- return async (request) => {
7
- const token = request.cookies.session_token;
8
- if (!token) {
9
- throw new HttpException(HttpStatus.UNAUTHORIZED, 'Invalid authorization token');
10
- }
11
- const permissions = await authProvider.getPermissions(token);
12
- if (!hasPermission(permissions, scope, action)) {
13
- throw new HttpException(HttpStatus.FORBIDDEN, 'User does not have permissions');
14
- }
15
- const user = await authProvider.getUser(token);
16
- request.me = user;
17
- };
18
- }