@flink-app/generic-auth-plugin 0.12.1-alpha.35 → 0.12.1-alpha.39

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.
@@ -1,4 +1,4 @@
1
- // Generated Sat Oct 25 2025 11:09:04 GMT+0200 (Central European Summer Time)
1
+ // Generated Wed Oct 29 2025 12:28:09 GMT+0100 (Central European Standard Time)
2
2
  import { autoRegisteredHandlers, HttpMethod } from "@flink-app/flink";
3
3
  import * as UserCreate_0 from "../src/handlers/UserCreate";
4
4
  import * as UserLogin_0 from "../src/handlers/UserLogin";
@@ -1,4 +1,4 @@
1
- // Generated Sat Oct 25 2025 11:09:04 GMT+0200 (Central European Summer Time)
1
+ // Generated Wed Oct 29 2025 12:28:09 GMT+0100 (Central European Standard Time)
2
2
  import { autoRegisteredJobs } from "@flink-app/flink";
3
3
  export const jobs = [];
4
4
  autoRegisteredJobs.push(...jobs);
@@ -1,4 +1,4 @@
1
- // Generated Sat Oct 25 2025 11:09:04 GMT+0200 (Central European Summer Time)
1
+ // Generated Wed Oct 29 2025 12:28:09 GMT+0100 (Central European Standard Time)
2
2
  import { autoRegisteredRepos } from "@flink-app/flink";
3
3
  export const repos = [];
4
4
  autoRegisteredRepos.push(...repos);
@@ -29,7 +29,7 @@ import { PutManagementUserRolesByUseridRes } from "../../src/schemas/Management/
29
29
  import { PutManagementUserUsernameByUseridReq } from "../../src/schemas/Management/PutUserUsernameByUseridReq";
30
30
  import { PutManagementUserUsernameByUseridRes } from "../../src/schemas/Management/PutUserUsernameByUseridRes";
31
31
 
32
- // Generated Sat Oct 25 2025 11:09:04 GMT+0200 (Central European Summer Time)
32
+ // Generated Wed Oct 29 2025 12:28:09 GMT+0100 (Central European Standard Time)
33
33
  export interface UserCreate_7_ReqSchema extends UserCreateReq {}
34
34
 
35
35
  export interface UserCreate_7_ResSchema extends UserCreateRes {}
package/.flink/start.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Generated Sat Oct 25 2025 11:09:04 GMT+0200 (Central European Summer Time)
1
+ // Generated Wed Oct 29 2025 12:28:09 GMT+0100 (Central European Standard Time)
2
2
  import "./generatedHandlers";
3
3
  import "./generatedRepos";
4
4
  import "./generatedJobs";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handlers = void 0;
4
- // Generated Sat Oct 25 2025 11:09:04 GMT+0200 (Central European Summer Time)
4
+ // Generated Wed Oct 29 2025 12:28:09 GMT+0100 (Central European Standard Time)
5
5
  var flink_1 = require("@flink-app/flink");
6
6
  exports.handlers = [];
7
7
  flink_1.autoRegisteredHandlers.push.apply(flink_1.autoRegisteredHandlers, exports.handlers);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.jobs = void 0;
4
- // Generated Sat Oct 25 2025 11:09:04 GMT+0200 (Central European Summer Time)
4
+ // Generated Wed Oct 29 2025 12:28:09 GMT+0100 (Central European Standard Time)
5
5
  var flink_1 = require("@flink-app/flink");
6
6
  exports.jobs = [];
7
7
  flink_1.autoRegisteredJobs.push.apply(flink_1.autoRegisteredJobs, exports.jobs);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.repos = void 0;
4
- // Generated Sat Oct 25 2025 11:09:04 GMT+0200 (Central European Summer Time)
4
+ // Generated Wed Oct 29 2025 12:28:09 GMT+0100 (Central European Standard Time)
5
5
  var flink_1 = require("@flink-app/flink");
6
6
  exports.repos = [];
7
7
  flink_1.autoRegisteredRepos.push.apply(flink_1.autoRegisteredRepos, exports.repos);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // Generated Sat Oct 25 2025 11:09:04 GMT+0200 (Central European Summer Time)
3
+ // Generated Wed Oct 29 2025 12:28:09 GMT+0100 (Central European Standard Time)
4
4
  require("./generatedHandlers");
5
5
  require("./generatedRepos");
6
6
  require("./generatedJobs");
@@ -53,5 +53,8 @@ export interface genericAuthContext {
53
53
  onUserCreated?: {
54
54
  (user: User): Promise<void>;
55
55
  };
56
+ onUserUpdated?: {
57
+ (user: User, updatedData: UserProfile): Promise<void>;
58
+ };
56
59
  };
57
60
  }
@@ -1,6 +1,7 @@
1
1
  import { FlinkRequest } from "@flink-app/flink";
2
2
  import { User } from "./schemas/User";
3
3
  import { UserPasswordResetSettings } from "./schemas/UserPasswordResetSettings";
4
+ import { UserProfile } from "./schemas/UserProfile";
4
5
  import { client as smsClient } from "@flink-app/sms-plugin";
5
6
  export interface GenericAuthPluginOptions {
6
7
  repoName: string;
@@ -32,6 +33,9 @@ export interface GenericAuthPluginOptions {
32
33
  onUserCreated?: {
33
34
  (user: User): Promise<void>;
34
35
  };
36
+ onUserUpdated?: {
37
+ (user: User, updatedData: UserProfile): Promise<void>;
38
+ };
35
39
  /**
36
40
  * If true, when a new device is registered, all other devices identified by `deviceId`
37
41
  * will be deregistered to avoid duplicate notifications.
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
40
40
  var flink_1 = require("@flink-app/flink");
41
41
  var PutManagementUserProfileByUserid = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
42
- var pluginName, repo, user;
42
+ var pluginName, repo, user, updatedUser;
43
43
  var ctx = _b.ctx, req = _b.req, origin = _b.origin;
44
44
  return __generator(this, function (_c) {
45
45
  switch (_c.label) {
@@ -55,10 +55,18 @@ var PutManagementUserProfileByUserid = function (_a) { return __awaiter(void 0,
55
55
  return [4 /*yield*/, repo.updateOne(user._id, { profile: req.body })];
56
56
  case 2:
57
57
  _c.sent();
58
- return [2 /*return*/, {
59
- data: {},
60
- status: 200,
61
- }];
58
+ return [4 /*yield*/, repo.getById(req.params.userid)];
59
+ case 3:
60
+ updatedUser = _c.sent();
61
+ if (!ctx.plugins[pluginName].onUserUpdated) return [3 /*break*/, 5];
62
+ return [4 /*yield*/, ctx.plugins[pluginName].onUserUpdated(updatedUser, req.body)];
63
+ case 4:
64
+ _c.sent();
65
+ _c.label = 5;
66
+ case 5: return [2 /*return*/, {
67
+ data: {},
68
+ status: 200,
69
+ }];
62
70
  }
63
71
  });
64
72
  }); };
@@ -71,9 +71,14 @@ var putUserProfileHandler = function (_a) { return __awaiter(void 0, [_a], void
71
71
  return [4 /*yield*/, repo.getById(userId)];
72
72
  case 3:
73
73
  user = _c.sent();
74
- return [2 /*return*/, {
75
- data: user.profile,
76
- }];
74
+ if (!ctx.plugins[pluginName].onUserUpdated) return [3 /*break*/, 5];
75
+ return [4 /*yield*/, ctx.plugins[pluginName].onUserUpdated(user, req.body)];
76
+ case 4:
77
+ _c.sent();
78
+ _c.label = 5;
79
+ case 5: return [2 /*return*/, {
80
+ data: user.profile,
81
+ }];
77
82
  }
78
83
  });
79
84
  }); };
package/dist/src/index.js CHANGED
@@ -47,11 +47,11 @@ __exportStar(require("./management"), exports);
47
47
  var genericAuthPlugin = function (options) {
48
48
  if (options.pluginId == null)
49
49
  options.pluginId = "genericAuthPlugin";
50
- var sms = options.sms, usernameFormat = options.usernameFormat, restOptions = __rest(options, ["sms", "usernameFormat"]);
50
+ var sms = options.sms, usernameFormat = options.usernameFormat, onUserUpdated = options.onUserUpdated, restOptions = __rest(options, ["sms", "usernameFormat", "onUserUpdated"]);
51
51
  return {
52
52
  id: options.pluginId,
53
53
  init: function (app) { return (0, init_1.init)(app, options); },
54
- ctx: __assign(__assign({}, restOptions), { loginUser: coreFunctions_1.loginUser, loginByToken: coreFunctions_1.loginByToken, createUser: coreFunctions_1.createUser, changePassword: coreFunctions_1.changePassword, passwordResetStart: coreFunctions_1.passwordResetStart, passwordResetComplete: coreFunctions_1.passwordResetComplete, usernameFormat: usernameFormat || /.{1,}$/, smsOptions: sms }),
54
+ ctx: __assign(__assign({}, restOptions), { loginUser: coreFunctions_1.loginUser, loginByToken: coreFunctions_1.loginByToken, createUser: coreFunctions_1.createUser, changePassword: coreFunctions_1.changePassword, passwordResetStart: coreFunctions_1.passwordResetStart, passwordResetComplete: coreFunctions_1.passwordResetComplete, usernameFormat: usernameFormat || /.{1,}$/, smsOptions: sms, onUserUpdated: onUserUpdated }),
55
55
  };
56
56
  };
57
57
  exports.genericAuthPlugin = genericAuthPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flink-app/generic-auth-plugin",
3
- "version": "0.12.1-alpha.35",
3
+ "version": "0.12.1-alpha.39",
4
4
  "description": "Flink plugin that provides a generic user authentification solution.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\"",
@@ -30,5 +30,5 @@
30
30
  "ts-node": "^9.1.1",
31
31
  "typescript": "5.4.5"
32
32
  },
33
- "gitHead": "f8e8c6565a9ca1dd3e5fdb4c2a791c99ae3ba51a"
33
+ "gitHead": "5be6cf2e80d665d08d380bc5e495bf9e20ff7b6e"
34
34
  }
@@ -71,5 +71,6 @@ export interface genericAuthContext {
71
71
  smsOptions?: GenericAuthsmsOptions;
72
72
  onSuccessfulLogin?: { (user: User, req?: FlinkRequest): Promise<void> };
73
73
  onUserCreated?: { (user: User): Promise<void> };
74
+ onUserUpdated?: { (user: User, updatedData: UserProfile): Promise<void> };
74
75
  };
75
76
  }
@@ -1,6 +1,7 @@
1
1
  import { FlinkRequest } from "@flink-app/flink";
2
2
  import { User } from "./schemas/User";
3
3
  import { UserPasswordResetSettings } from "./schemas/UserPasswordResetSettings";
4
+ import { UserProfile } from "./schemas/UserProfile";
4
5
  import { client as smsClient } from "@flink-app/sms-plugin";
5
6
  export interface GenericAuthPluginOptions {
6
7
  repoName: string;
@@ -29,6 +30,9 @@ export interface GenericAuthPluginOptions {
29
30
  onUserCreated?: {
30
31
  (user: User): Promise<void>;
31
32
  };
33
+ onUserUpdated?: {
34
+ (user: User, updatedData: UserProfile): Promise<void>;
35
+ };
32
36
  /**
33
37
  * If true, when a new device is registered, all other devices identified by `deviceId`
34
38
  * will be deregistered to avoid duplicate notifications.
@@ -23,6 +23,12 @@ const PutManagementUserProfileByUserid: Handler<
23
23
 
24
24
  await repo.updateOne(user._id, { profile: req.body });
25
25
 
26
+ const updatedUser = await repo.getById(req.params.userid);
27
+
28
+ if ((<any>ctx.plugins)[pluginName].onUserUpdated) {
29
+ await (<any>ctx.plugins)[pluginName].onUserUpdated(updatedUser, req.body);
30
+ }
31
+
26
32
  return {
27
33
  data: {},
28
34
  status: 200,
@@ -2,34 +2,32 @@ import { FlinkContext, Handler, notFound } from "@flink-app/flink";
2
2
  import { genericAuthContext } from "../genericAuthContext";
3
3
  import { UserProfile } from "../schemas/UserProfile";
4
4
 
5
- const putUserProfileHandler: Handler<
6
- FlinkContext<genericAuthContext>,
7
- UserProfile,
8
- UserProfile
9
- > = async ({ ctx, req, origin }) => {
10
- let pluginName = origin || "genericAuthPlugin";
11
- let repo = ctx.repos[(<any>ctx.plugins)[pluginName].repoName];
5
+ const putUserProfileHandler: Handler<FlinkContext<genericAuthContext>, UserProfile, UserProfile> = async ({ ctx, req, origin }) => {
6
+ let pluginName = origin || "genericAuthPlugin";
7
+ let repo = ctx.repos[(<any>ctx.plugins)[pluginName].repoName];
12
8
 
13
- let userId = req.user._id;
14
- let user = await repo.getById(userId);
15
- if (user == null) {
16
- return notFound();
17
- }
9
+ let userId = req.user._id;
10
+ let user = await repo.getById(userId);
11
+ if (user == null) {
12
+ return notFound();
13
+ }
18
14
 
15
+ const updatedProfile = {
16
+ ...user.profile,
17
+ ...req.body,
18
+ };
19
19
 
20
- const updatedProfile = {
21
- ...user.profile,
22
- ...req.body,
23
- }
20
+ await repo.updateOne(userId, { profile: updatedProfile });
24
21
 
22
+ user = await repo.getById(userId);
25
23
 
26
- await repo.updateOne(userId, { profile: updatedProfile });
24
+ if ((<any>ctx.plugins)[pluginName].onUserUpdated) {
25
+ await (<any>ctx.plugins)[pluginName].onUserUpdated(user, req.body);
26
+ }
27
27
 
28
- user = await repo.getById(userId);
29
-
30
- return {
31
- data: user.profile,
32
- };
28
+ return {
29
+ data: user.profile,
30
+ };
33
31
  };
34
32
 
35
33
  export default putUserProfileHandler;
package/src/index.ts CHANGED
@@ -12,7 +12,7 @@ export * from "./management";
12
12
  export const genericAuthPlugin = (options: GenericAuthPluginOptions): FlinkPlugin => {
13
13
  if (options.pluginId == null) options.pluginId = "genericAuthPlugin";
14
14
 
15
- const { sms, usernameFormat, ...restOptions } = options;
15
+ const { sms, usernameFormat, onUserUpdated, ...restOptions } = options;
16
16
 
17
17
  return {
18
18
  id: options.pluginId,
@@ -27,6 +27,7 @@ export const genericAuthPlugin = (options: GenericAuthPluginOptions): FlinkPlugi
27
27
  passwordResetComplete,
28
28
  usernameFormat: usernameFormat || /.{1,}$/,
29
29
  smsOptions: sms,
30
+ onUserUpdated,
30
31
  },
31
32
  };
32
33
  };