@volcanicminds/backend 0.2.39 → 0.2.41

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.
@@ -0,0 +1,37 @@
1
+ export const tokenParamsSchema = {
2
+ $id: 'tokenParamsSchema',
3
+ type: 'object',
4
+ nullable: true,
5
+ properties: {
6
+ id: {
7
+ type: 'string',
8
+ description: 'Token id'
9
+ }
10
+ }
11
+ }
12
+
13
+ export const tokenBodySchema = {
14
+ $id: 'tokenBodySchema',
15
+ type: 'object',
16
+ nullable: true,
17
+ properties: {
18
+ name: { type: 'string' },
19
+ description: { type: 'string' },
20
+ requiredRoles: { type: 'array', items: { type: 'string' } }
21
+ }
22
+ }
23
+
24
+ export const tokenSchema = {
25
+ $id: 'tokenSchema',
26
+ type: 'object',
27
+ nullable: true,
28
+ properties: {
29
+ id: { type: 'string' },
30
+ _id: { type: 'string' },
31
+ externalId: { type: 'string' },
32
+ name: { type: 'string' },
33
+ description: { type: 'string' },
34
+ token: { type: 'string' },
35
+ roles: { type: 'array', items: { type: 'string' } }
36
+ }
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volcanicminds/backend",
3
- "version": "0.2.39",
3
+ "version": "0.2.41",
4
4
  "codename": "turin",
5
5
  "license": "MIT",
6
6
  "description": "The volcanic (minds) backend",
package/types/global.d.ts CHANGED
@@ -7,6 +7,12 @@ export interface AuthenticatedUser {
7
7
  roles: Role[]
8
8
  }
9
9
 
10
+ export interface AuthenticatedToken {
11
+ getId(): any
12
+ name: string
13
+ roles: Role[]
14
+ }
15
+
10
16
  export interface Role {
11
17
  code: string
12
18
  name: string
@@ -69,6 +75,7 @@ export interface ConfiguredRoute {
69
75
  }
70
76
 
71
77
  export interface UserManagement {
78
+ isValidUser(data: any): boolean
72
79
  createUser(data: any): any | null
73
80
  resetExternalId(data: any): any | null
74
81
  updateUserById(id: string, user: any): any | null
@@ -81,16 +88,32 @@ export interface UserManagement {
81
88
  retrieveUserByPassword(email: string, password: string): any | null
82
89
  changePassword(email: string, password: string, oldPassword: string): any | null
83
90
  forgotPassword(email: string): any | null
84
- userConfirmation(user: any)
85
91
  resetPassword(user: any, password: string): any | null
86
- enableUserById(id: string): any | null
87
- disableUserById(id: string): any | null
88
- isValidUser(data: any): boolean
92
+ userConfirmation(user: any)
93
+ blockUserById(id: string, reason: string): any | null
94
+ unblockUserById(id: string): any | null
95
+ countQuery(data: any): any | null
96
+ findQuery(data: any): any | null
97
+ }
98
+
99
+ export interface TokenManagement {
100
+ isValidToken(data: any): boolean
101
+ createToken(data: any): any | null
102
+ resetExternalId(id: string): any | null
103
+ updateTokenById(id: string, token: any): any | null
104
+ retrieveTokenById(id: string): any | null
105
+ retrieveTokenByExternalId(id: string): any | null
106
+ blockTokenById(id: string, reason: string): any | null
107
+ unblockTokenById(id: string): any | null
108
+ countQuery(data: any): any | null
109
+ findQuery(data: any): any | null
110
+ removeTokenById(id: string): any | null
89
111
  }
90
112
 
91
113
  declare module 'fastify' {
92
114
  export interface FastifyRequest {
93
115
  user?: AuthenticatedUser
116
+ token?: AuthenticatedToken
94
117
  startedAt?: Date
95
118
  data(): Data
96
119
  parameters(): Data
@@ -105,6 +128,7 @@ declare module 'fastify' {
105
128
 
106
129
  export interface FastifyRequest extends FastifyRequest {
107
130
  user?: AuthenticatedUser
131
+ token?: AuthenticatedToken
108
132
  startedAt?: Date
109
133
  data(): Data
110
134
  parameters(): Data