@eduzz/miau-client 0.0.9 → 0.0.10

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.
@@ -4,6 +4,7 @@ export type Permission = {
4
4
  organizationId: string;
5
5
  sourceAppId: string;
6
6
  targetAppId: string;
7
+ metadata: Record<string, string>;
7
8
  resources: Resource[];
8
9
  createdAt: Date;
9
10
  updatedAt: Date | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eduzz/miau-client",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Eduzz Miau Client",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -32,9 +32,11 @@ export const miauMiddleware = (miauService: MiauClient) => {
32
32
  const publicKey = await miauService.getPublicKey(decodedToken.header.kid);
33
33
  const appToken = jwt.verify(token, publicKey, { algorithms: ['RS256'] }) as ApplicationToken;
34
34
 
35
- req.application = { id: appToken?.id, name: appToken?.name };
35
+ req.miauApplication = { id: appToken?.id, name: appToken?.name };
36
+
37
+ const permission = await miauService.getPermissions(req.miauApplication.id);
38
+ req.miauMetadata = permission?.metadata || {};
36
39
 
37
- const permission = await miauService.getPermissions(req.application.id);
38
40
  const resources = permission?.resources || [];
39
41
  const isAllowed = resources.some((resource: Resource) => {
40
42
  return (
@@ -1,9 +1,16 @@
1
1
  import { type ApplicationToken } from '@eduzz/miau-types';
2
2
 
3
+ export type MiauApplication = ApplicationToken;
4
+ export type MiauMetadata = Record<string, string>;
5
+
6
+ export interface MiauRequestExtras {
7
+ miauApplication?: MiauApplication;
8
+ miauMetadata?: MiauMetadata;
9
+ }
3
10
  declare global {
4
11
  namespace Express {
5
- interface Request {
6
- application?: ApplicationToken;
12
+ interface Request extends MiauRequestExtras {
13
+ _?: never;
7
14
  }
8
15
  }
9
16
  }