@flink-app/generic-auth-plugin 0.2.0-beta.8 → 0.3.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.
Files changed (64) hide show
  1. package/.flink/generatedHandlers.ts +3 -1
  2. package/.flink/generatedRepos.ts +1 -1
  3. package/.flink/schemas/schemas.json +54 -14
  4. package/.flink/schemas/schemas.ts +21 -15
  5. package/.flink/start.ts +1 -1
  6. package/dist/.flink/generatedHandlers.js +1 -1
  7. package/dist/.flink/generatedRepos.js +1 -1
  8. package/dist/.flink/schemas/schemas.d.ts +20 -14
  9. package/dist/.flink/schemas/schemas.json +54 -14
  10. package/dist/.flink/start.js +1 -1
  11. package/dist/src/coreFunctions.js +32 -21
  12. package/dist/src/handlers/Management/GetUserByUserid.js +2 -2
  13. package/dist/src/handlers/Management/GetUserViewByUserid.d.ts +7 -0
  14. package/dist/src/handlers/Management/GetUserViewByUserid.js +80 -0
  15. package/dist/src/handlers/Management/PutUserPasswordByUserid.js +1 -1
  16. package/dist/src/handlers/Management/PutUserProfileByUserid.js +2 -2
  17. package/dist/src/handlers/Management/PutUserProfileByUseridAppend.js +2 -2
  18. package/dist/src/handlers/Management/PutUserRolesByUserid.js +2 -2
  19. package/dist/src/handlers/Management/PutUserUsernameByUserid.js +5 -3
  20. package/dist/src/handlers/UserLogin.js +1 -1
  21. package/dist/src/handlers/UserPasswordResetComplete.d.ts +1 -2
  22. package/dist/src/handlers/UserPasswordResetComplete.js +5 -10
  23. package/dist/src/handlers/UserPasswordResetForm.d.ts +6 -0
  24. package/dist/src/handlers/UserPasswordResetForm.js +96 -0
  25. package/dist/src/handlers/UserPasswordResetStart.js +1 -0
  26. package/dist/src/handlers/UserProfileGet.js +1 -1
  27. package/dist/src/handlers/UserProfilePut.js +16 -5
  28. package/dist/src/handlers/UserPushRegisterToken.js +1 -1
  29. package/dist/src/handlers/UserPushRemoveToken.js +1 -1
  30. package/dist/src/handlers/UserToken.js +1 -1
  31. package/dist/src/init.js +11 -0
  32. package/dist/src/management.d.ts +6 -0
  33. package/dist/src/management.js +17 -4
  34. package/dist/src/schemas/Management/GetUserViewByUseridReq.d.ts +2 -0
  35. package/dist/src/schemas/Management/GetUserViewByUseridReq.js +2 -0
  36. package/dist/src/schemas/Management/GetUserViewByUseridRes.d.ts +9 -0
  37. package/dist/src/schemas/Management/GetUserViewByUseridRes.js +2 -0
  38. package/dist/src/schemas/UserPasswordResetSettings.d.ts +2 -0
  39. package/package.json +6 -6
  40. package/readme.md +55 -0
  41. package/src/coreFunctions.ts +190 -175
  42. package/src/handlers/Management/GetUserByUserid.ts +21 -15
  43. package/src/handlers/Management/GetUserViewByUserid.ts +38 -0
  44. package/src/handlers/Management/PutUserPasswordByUserid.ts +1 -1
  45. package/src/handlers/Management/PutUserProfileByUserid.ts +22 -16
  46. package/src/handlers/Management/PutUserProfileByUseridAppend.ts +26 -20
  47. package/src/handlers/Management/PutUserRolesByUserid.ts +22 -17
  48. package/src/handlers/Management/PutUserUsernameByUserid.ts +28 -19
  49. package/src/handlers/UserCreate.ts +43 -55
  50. package/src/handlers/UserPasswordResetComplete.ts +2 -10
  51. package/src/handlers/UserPasswordResetForm.ts +144 -0
  52. package/src/handlers/UserPasswordResetStart.ts +1 -0
  53. package/src/handlers/UserProfileGet.ts +1 -1
  54. package/src/handlers/UserProfilePut.ts +10 -4
  55. package/src/handlers/UserPushRegisterToken.ts +1 -1
  56. package/src/handlers/UserPushRemoveToken.ts +1 -1
  57. package/src/handlers/UserToken.ts +1 -1
  58. package/src/init.ts +12 -0
  59. package/src/management.ts +152 -136
  60. package/src/schemas/Management/GetUserViewByUseridReq.ts +3 -0
  61. package/src/schemas/Management/GetUserViewByUseridRes.ts +4 -0
  62. package/src/schemas/UserPasswordResetCompleteReq.ts +5 -5
  63. package/src/schemas/UserPasswordResetSettings.ts +14 -12
  64. package/src/schemas/UserPasswordResetStartRes.ts +5 -5
package/src/management.ts CHANGED
@@ -1,7 +1,4 @@
1
- import {
2
- ManagementApiModule,
3
- ManagementApiType,
4
- } from "@flink-app/management-api-plugin";
1
+ import { ManagementApiModule, ManagementApiType } from "@flink-app/management-api-plugin";
5
2
  import { HttpMethod } from "@flink-app/flink";
6
3
  import * as userCreateHandler from "./handlers/UserCreate";
7
4
  import * as GetManagementUser from "./handlers/Management/GetUser";
@@ -11,145 +8,164 @@ import * as PutManagementUserProfileByUserid from "./handlers/Management/PutUser
11
8
  import * as PutManagementUserUsernameByUserid from "./handlers/Management/PutUserUsernameByUserid";
12
9
  import * as PutManagementUserRolesByUserid from "./handlers/Management/PutUserRolesByUserid";
13
10
  import * as DeleteManagementUserByUserid from "./handlers/Management/DeleteUserByUserid";
11
+ import * as GetUserViewByUserid from "./handlers/Management/GetUserViewByUserid";
14
12
 
15
13
  import * as PutUserProfileByUseridAppend from "./handlers/Management/PutUserProfileByUseridAppend";
16
14
  import * as GetSchema from "./handlers/Management/GetSchema";
15
+ import { User } from ".";
16
+ import { GetManagementUserViewByUseridRes } from "./schemas/Management/GetUserViewByUseridRes";
17
17
 
18
18
  export interface GetManagementModuleConfig {
19
- pluginId?: string;
20
- profileSchema?: any;
21
- ui: boolean;
22
- uiSettings?: {
23
- title: string;
24
- enableUserDelete?: boolean;
25
- enableUserCreate?: boolean;
26
- enableUserEdit?: boolean;
27
- };
19
+ pluginId?: string;
20
+ profileSchema?: any;
21
+ ui: boolean;
22
+ userView?: {
23
+ getData(user: User): GetManagementUserViewByUseridRes;
24
+ };
25
+ uiSettings?: {
26
+ title: string;
27
+ enableUserDelete?: boolean;
28
+ enableUserCreate?: boolean;
29
+ enableUserEdit?: boolean;
30
+ enableUserView?: boolean;
31
+ };
28
32
  }
29
33
 
30
- export const GetManagementModule = (
31
- config: GetManagementModuleConfig
32
- ): ManagementApiModule => {
33
- if (config.pluginId == null) config.pluginId = "genericAuthPlugin";
34
-
35
- let endpoints: ManagementApiModule["endpoints"] = [];
36
- endpoints.push({
37
- routeProps: {
38
- path: "",
39
- method: HttpMethod.post,
40
- origin: config.pluginId,
41
- },
42
- handler: userCreateHandler,
43
- });
44
-
45
- endpoints.push({
46
- routeProps: {
47
- path: "",
48
- method: HttpMethod.get,
49
- origin: config.pluginId,
50
- },
51
- handler: GetManagementUser,
52
- });
53
-
54
- endpoints.push({
55
- routeProps: {
56
- path: "/profile/schema",
57
- method: HttpMethod.get,
58
- origin: config.pluginId || "genericAuthPlugin",
59
- },
60
- handler: GetSchema,
61
- });
62
-
63
- endpoints.push({
64
- routeProps: {
65
- path: "/:userid",
66
- method: HttpMethod.get,
67
- origin: config.pluginId,
68
- },
69
-
70
- handler: GetManagementUserByUserid,
71
- });
72
-
73
- endpoints.push({
74
- routeProps: {
75
- path: "/:userid",
76
- method: HttpMethod.delete,
77
- origin: config.pluginId,
78
- },
79
- handler: DeleteManagementUserByUserid,
80
- });
81
-
82
- endpoints.push({
83
- routeProps: {
84
- path: "/password/:userid",
85
- method: HttpMethod.put,
86
- origin: config.pluginId,
87
- },
88
- handler: PutManagementUserPasswordByUserid,
89
- });
90
-
91
- endpoints.push({
92
- routeProps: {
93
- path: "/username/:userid",
94
- method: HttpMethod.put,
95
- origin: config.pluginId,
96
- },
97
- handler: PutManagementUserUsernameByUserid,
98
- });
99
-
100
- endpoints.push({
101
- routeProps: {
102
- path: "/profile/:userid",
103
- method: HttpMethod.put,
104
- origin: config.pluginId,
105
- },
106
- handler: PutManagementUserProfileByUserid,
107
- });
108
-
109
- endpoints.push({
110
- routeProps: {
111
- path: "/profile/:userid/append",
112
- method: HttpMethod.put,
113
- origin: config.pluginId,
114
- },
115
- handler: PutUserProfileByUseridAppend,
116
- });
117
-
118
- endpoints.push({
119
- routeProps: {
120
- path: "/roles/:userid",
121
- method: HttpMethod.put,
122
- origin: config.pluginId,
123
- },
124
- handler: PutManagementUserRolesByUserid,
125
- });
126
-
127
- let features: string[] = [];
128
-
129
- if (config.uiSettings?.enableUserDelete == true) {
130
- features.push("delete");
131
- }
132
- if (config.uiSettings?.enableUserCreate == true) {
133
- features.push("create");
134
- }
135
- if (config.uiSettings?.enableUserEdit == true) {
136
- features.push("edit");
137
- }
138
-
139
- let module: ManagementApiModule = {
140
- id: config.pluginId || "user",
141
- uiSettings: {
142
- title: config.uiSettings?.title || "Users",
143
- icon: "",
144
- features,
145
- },
146
- ui: config.ui,
147
- type: ManagementApiType.user,
148
- endpoints: endpoints,
149
- data : {
150
- profileSchema : config.profileSchema
34
+ export const GetManagementModule = (config: GetManagementModuleConfig): ManagementApiModule => {
35
+ if (config.pluginId == null) config.pluginId = "genericAuthPlugin";
36
+
37
+ let endpoints: ManagementApiModule["endpoints"] = [];
38
+ endpoints.push({
39
+ routeProps: {
40
+ path: "",
41
+ method: HttpMethod.post,
42
+ origin: config.pluginId,
43
+ },
44
+ handler: userCreateHandler,
45
+ });
46
+
47
+ endpoints.push({
48
+ routeProps: {
49
+ path: "",
50
+ method: HttpMethod.get,
51
+ origin: config.pluginId,
52
+ },
53
+ handler: GetManagementUser,
54
+ });
55
+
56
+ endpoints.push({
57
+ routeProps: {
58
+ path: "/profile/schema",
59
+ method: HttpMethod.get,
60
+ origin: config.pluginId || "genericAuthPlugin",
61
+ },
62
+ handler: GetSchema,
63
+ });
64
+
65
+ endpoints.push({
66
+ routeProps: {
67
+ path: "/:userid",
68
+ method: HttpMethod.get,
69
+ origin: config.pluginId,
70
+ },
71
+
72
+ handler: GetManagementUserByUserid,
73
+ });
74
+
75
+ endpoints.push({
76
+ routeProps: {
77
+ path: "/:userid/view",
78
+ method: HttpMethod.get,
79
+ origin: config.pluginId,
80
+ },
81
+
82
+ handler: GetUserViewByUserid,
83
+ });
84
+
85
+ endpoints.push({
86
+ routeProps: {
87
+ path: "/:userid",
88
+ method: HttpMethod.delete,
89
+ origin: config.pluginId,
90
+ },
91
+ handler: DeleteManagementUserByUserid,
92
+ });
93
+
94
+ endpoints.push({
95
+ routeProps: {
96
+ path: "/password/:userid",
97
+ method: HttpMethod.put,
98
+ origin: config.pluginId,
99
+ },
100
+ handler: PutManagementUserPasswordByUserid,
101
+ });
102
+
103
+ endpoints.push({
104
+ routeProps: {
105
+ path: "/username/:userid",
106
+ method: HttpMethod.put,
107
+ origin: config.pluginId,
108
+ },
109
+ handler: PutManagementUserUsernameByUserid,
110
+ });
111
+
112
+ endpoints.push({
113
+ routeProps: {
114
+ path: "/profile/:userid",
115
+ method: HttpMethod.put,
116
+ origin: config.pluginId,
117
+ },
118
+ handler: PutManagementUserProfileByUserid,
119
+ });
120
+
121
+ endpoints.push({
122
+ routeProps: {
123
+ path: "/profile/:userid/append",
124
+ method: HttpMethod.put,
125
+ origin: config.pluginId,
126
+ },
127
+ handler: PutUserProfileByUseridAppend,
128
+ });
129
+
130
+ endpoints.push({
131
+ routeProps: {
132
+ path: "/roles/:userid",
133
+ method: HttpMethod.put,
134
+ origin: config.pluginId,
135
+ },
136
+ handler: PutManagementUserRolesByUserid,
137
+ });
138
+
139
+ let features: string[] = [];
140
+
141
+ if (config.uiSettings?.enableUserDelete == true) {
142
+ features.push("delete");
143
+ }
144
+ if (config.uiSettings?.enableUserCreate == true) {
145
+ features.push("create");
146
+ }
147
+ if (config.uiSettings?.enableUserEdit == true) {
148
+ features.push("edit");
149
+ }
150
+ if (config.uiSettings?.enableUserView == true) {
151
+ features.push("view");
151
152
  }
152
- };
153
153
 
154
- return module;
154
+ let module: ManagementApiModule = {
155
+ id: config.pluginId || "user",
156
+ uiSettings: {
157
+ title: config.uiSettings?.title || "Users",
158
+ icon: "",
159
+ features,
160
+ },
161
+ ui: config.ui,
162
+ type: ManagementApiType.user,
163
+ endpoints: endpoints,
164
+ data: {
165
+ profileSchema: config.profileSchema,
166
+ userViewGetData: config.userView?.getData,
167
+ },
168
+ };
169
+
170
+ return module;
155
171
  };
@@ -0,0 +1,3 @@
1
+ export interface GetManagementUserViewByUseridReq{
2
+
3
+ }
@@ -0,0 +1,4 @@
1
+ export interface GetManagementUserViewByUseridRes {
2
+ buttons: { text: string; url: string }[];
3
+ data: { [key: string]: string };
4
+ }
@@ -1,5 +1,5 @@
1
- export interface UserPasswordResetCompleteReq{
2
- passwordResetToken : string;
3
- code : string,
4
- password : string
5
- }
1
+ export interface UserPasswordResetCompleteReq {
2
+ passwordResetToken: string;
3
+ code: string;
4
+ password: string;
5
+ }
@@ -1,12 +1,14 @@
1
- export interface UserPasswordResetSettings{
2
- email : {
3
- from_address : string,
4
- subject : string,
5
- html : string,
6
- },
7
- code : {
8
- numberOfDigits : number,
9
- lifeTime : string,
10
- jwtSecret : string
11
- }
12
- }
1
+ export interface UserPasswordResetSettings {
2
+ email: {
3
+ from_address: string;
4
+ subject: string;
5
+ html: string;
6
+ };
7
+ code: {
8
+ numberOfDigits: number;
9
+ lifeTime: string;
10
+ jwtSecret: string;
11
+ };
12
+ enablePasswordResetForm?: boolean;
13
+ passwordResetForm?: string;
14
+ }
@@ -1,8 +1,8 @@
1
1
  import { UserProfile } from "./UserProfile";
2
2
 
3
3
  export interface UserPasswordResetStartRes {
4
- status : "success" | "userNotFound",
5
- passwordResetToken? : string,
6
- code? : string,
7
- profile? : UserProfile
8
- }
4
+ status: "success" | "userNotFound";
5
+ passwordResetToken?: string;
6
+ code?: string;
7
+ profile?: UserProfile;
8
+ }