@flink-app/generic-auth-plugin 0.12.1-alpha.28 → 0.12.1-alpha.29

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 Mon Sep 22 2025 13:39:12 GMT+0200 (Central European Summer Time)
1
+ // Generated Mon Sep 22 2025 13:48:37 GMT+0200 (Central European Summer 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 Mon Sep 22 2025 13:39:12 GMT+0200 (Central European Summer Time)
1
+ // Generated Mon Sep 22 2025 13:48:37 GMT+0200 (Central European Summer 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 Mon Sep 22 2025 13:39:12 GMT+0200 (Central European Summer Time)
1
+ // Generated Mon Sep 22 2025 13:48:37 GMT+0200 (Central European Summer 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 Mon Sep 22 2025 13:39:12 GMT+0200 (Central European Summer Time)
32
+ // Generated Mon Sep 22 2025 13:48:38 GMT+0200 (Central European Summer 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 Mon Sep 22 2025 13:39:12 GMT+0200 (Central European Summer Time)
1
+ // Generated Mon Sep 22 2025 13:48:37 GMT+0200 (Central European Summer 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 Mon Sep 22 2025 13:39:12 GMT+0200 (Central European Summer Time)
4
+ // Generated Mon Sep 22 2025 13:48:37 GMT+0200 (Central European Summer 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 Mon Sep 22 2025 13:39:12 GMT+0200 (Central European Summer Time)
4
+ // Generated Mon Sep 22 2025 13:48:37 GMT+0200 (Central European Summer 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 Mon Sep 22 2025 13:39:12 GMT+0200 (Central European Summer Time)
4
+ // Generated Mon Sep 22 2025 13:48:37 GMT+0200 (Central European Summer 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 Mon Sep 22 2025 13:39:12 GMT+0200 (Central European Summer Time)
3
+ // Generated Mon Sep 22 2025 13:48:37 GMT+0200 (Central European Summer Time)
4
4
  require("./generatedHandlers");
5
5
  require("./generatedRepos");
6
6
  require("./generatedJobs");
@@ -1,4 +1,4 @@
1
- import { FlinkRepo } from "@flink-app/flink";
1
+ import { FlinkRepo, FlinkRequest } from "@flink-app/flink";
2
2
  import { JwtAuthPlugin } from "@flink-app/jwt-auth-plugin";
3
3
  import { User } from "./schemas/User";
4
4
  import { UserCreateRes } from "./schemas/UserCreateRes";
@@ -23,8 +23,8 @@ export declare function loginByToken(repo: FlinkRepo<any, User>, auth: JwtAuthPl
23
23
  export declare function loginUser(repo: FlinkRepo<any, User>, auth: JwtAuthPlugin, username: string, password: string | undefined, validatePasswordMethod?: {
24
24
  (password: string, hash: string, salt: string): Promise<boolean>;
25
25
  }, smsOptions?: GenericAuthsmsOptions, onSuccessfulLogin?: {
26
- (user: User): Promise<void>;
27
- }): Promise<UserLoginRes>;
26
+ (user: User, req?: FlinkRequest): Promise<void>;
27
+ }, req?: FlinkRequest): Promise<UserLoginRes>;
28
28
  export declare function changePassword(repo: FlinkRepo<any, User>, auth: JwtAuthPlugin, userId: string, newPassword: string, createPasswordHashAndSaltMethod?: {
29
29
  (password: string): Promise<{
30
30
  hash: string;
@@ -190,7 +190,7 @@ function loginByToken(repo, auth, token, code, jwtSecret) {
190
190
  });
191
191
  }
192
192
  exports.loginByToken = loginByToken;
193
- function loginUser(repo, auth, username, password, validatePasswordMethod, smsOptions, onSuccessfulLogin) {
193
+ function loginUser(repo, auth, username, password, validatePasswordMethod, smsOptions, onSuccessfulLogin, req) {
194
194
  return __awaiter(this, void 0, void 0, function () {
195
195
  var user, valid, ex_1, code, payload, secret, options, token, token;
196
196
  return __generator(this, function (_a) {
@@ -262,7 +262,7 @@ function loginUser(repo, auth, username, password, validatePasswordMethod, smsOp
262
262
  case 10:
263
263
  token = _a.sent();
264
264
  if (!onSuccessfulLogin) return [3 /*break*/, 12];
265
- return [4 /*yield*/, onSuccessfulLogin(user)];
265
+ return [4 /*yield*/, onSuccessfulLogin(user, req)];
266
266
  case 11:
267
267
  _a.sent();
268
268
  _a.label = 12;
@@ -1,4 +1,4 @@
1
- import { FlinkRepo } from "@flink-app/flink";
1
+ import { FlinkRepo, FlinkRequest } from "@flink-app/flink";
2
2
  import { JwtAuthPlugin } from "@flink-app/jwt-auth-plugin";
3
3
  import { User } from "./schemas/User";
4
4
  import { UserCreateRes } from "./schemas/UserCreateRes";
@@ -13,7 +13,7 @@ export interface genericAuthContext {
13
13
  genericAuthPlugin: {
14
14
  loginUser(repo: FlinkRepo<any, User>, auth: JwtAuthPlugin, username: string, password?: string, validatePasswordMethod?: {
15
15
  (password: string, hash: string, salt: string): Promise<boolean>;
16
- }, smsOptions?: GenericAuthsmsOptions, onSuccessfulLogin?: (user: User) => Promise<void>): Promise<UserLoginRes>;
16
+ }, smsOptions?: GenericAuthsmsOptions, onSuccessfulLogin?: (user: User, req?: FlinkRequest) => Promise<void>, req?: FlinkRequest): Promise<UserLoginRes>;
17
17
  loginByToken(repo: FlinkRepo<any, User>, auth: JwtAuthPlugin, token: string, code: string, jwtSecret: string): Promise<UserLoginRes>;
18
18
  createUser(repo: FlinkRepo<any, User>, auth: JwtAuthPlugin, username: string, password: string, authentificationMethod: "password" | "sms" | "bankid", roles: string[], profile: UserProfile, createPasswordHashAndSaltMethod?: {
19
19
  (password: string): Promise<{
@@ -48,7 +48,7 @@ export interface genericAuthContext {
48
48
  usernameFormat: RegExp;
49
49
  smsOptions?: GenericAuthsmsOptions;
50
50
  onSuccessfulLogin?: {
51
- (user: User): Promise<void>;
51
+ (user: User, req?: FlinkRequest): Promise<void>;
52
52
  };
53
53
  onUserCreated?: {
54
54
  (user: User): Promise<void>;
@@ -1,3 +1,4 @@
1
+ import { FlinkRequest } from "@flink-app/flink";
1
2
  import { User } from "./schemas/User";
2
3
  import { UserPasswordResetSettings } from "./schemas/UserPasswordResetSettings";
3
4
  import { client as smsClient } from "@flink-app/sms-plugin";
@@ -26,7 +27,7 @@ export interface GenericAuthPluginOptions {
26
27
  usernameFormat?: RegExp;
27
28
  sms?: GenericAuthsmsOptions;
28
29
  onSuccessfulLogin?: {
29
- (user: User): Promise<void>;
30
+ (user: User, req?: FlinkRequest): Promise<void>;
30
31
  };
31
32
  onUserCreated?: {
32
33
  (user: User): Promise<void>;
@@ -50,7 +50,7 @@ var userLoginHandler = function (_a) { return __awaiter(void 0, [_a], void 0, fu
50
50
  _c.label = 1;
51
51
  case 1:
52
52
  _c.trys.push([1, 3, , 4]);
53
- return [4 /*yield*/, ctx.plugins.genericAuthPlugin.loginUser(repo, ctx.auth, req.body.username, req.body.password, ctx.plugins.genericAuthPlugin.validatePasswordMethod, ctx.plugins[pluginName].smsOptions, ctx.plugins[pluginName].onSuccessfulLogin)];
53
+ return [4 /*yield*/, ctx.plugins.genericAuthPlugin.loginUser(repo, ctx.auth, req.body.username, req.body.password, ctx.plugins.genericAuthPlugin.validatePasswordMethod, ctx.plugins[pluginName].smsOptions, ctx.plugins[pluginName].onSuccessfulLogin, req)];
54
54
  case 2:
55
55
  loginResponse = _c.sent();
56
56
  return [3 /*break*/, 4];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flink-app/generic-auth-plugin",
3
- "version": "0.12.1-alpha.28",
3
+ "version": "0.12.1-alpha.29",
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": "cc427603defb6e3d3ea2e66f1bb23d19f11bd23c"
33
+ "gitHead": "40b53cd1ce0d8fc23f942f76b152a754796be01f"
34
34
  }
@@ -1,4 +1,4 @@
1
- import { FlinkRepo, FlinkAuthUser, log } from "@flink-app/flink";
1
+ import { FlinkRepo, FlinkAuthUser, log, FlinkRequest } from "@flink-app/flink";
2
2
  import { JwtAuthPlugin, jwtAuthPlugin } from "@flink-app/jwt-auth-plugin";
3
3
 
4
4
  import { User } from "./schemas/User";
@@ -164,8 +164,9 @@ export async function loginUser(
164
164
  },
165
165
  smsOptions?: GenericAuthsmsOptions,
166
166
  onSuccessfulLogin?: {
167
- (user: User): Promise<void>;
168
- }
167
+ (user: User, req?: FlinkRequest): Promise<void>;
168
+ },
169
+ req?: FlinkRequest
169
170
  ): Promise<UserLoginRes> {
170
171
  const user = await repo.getOne({ username: username.toLowerCase() });
171
172
  if (user == null) {
@@ -231,7 +232,7 @@ export async function loginUser(
231
232
  const token = await auth.createToken({ username: username.toLowerCase(), _id: user._id }, user.roles);
232
233
 
233
234
  if (onSuccessfulLogin) {
234
- await onSuccessfulLogin(user);
235
+ await onSuccessfulLogin(user, req);
235
236
  }
236
237
 
237
238
  return {
@@ -1,4 +1,4 @@
1
- import { FlinkRepo } from "@flink-app/flink";
1
+ import { FlinkRepo, FlinkRequest } from "@flink-app/flink";
2
2
  import { JwtAuthPlugin } from "@flink-app/jwt-auth-plugin";
3
3
  import { User } from "./schemas/User";
4
4
  import { UserCreateRes } from "./schemas/UserCreateRes";
@@ -19,7 +19,8 @@ export interface genericAuthContext {
19
19
  password?: string,
20
20
  validatePasswordMethod?: { (password: string, hash: string, salt: string): Promise<boolean> },
21
21
  smsOptions?: GenericAuthsmsOptions,
22
- onSuccessfulLogin?: (user: User) => Promise<void>
22
+ onSuccessfulLogin?: (user: User, req?: FlinkRequest) => Promise<void>,
23
+ req?: FlinkRequest
23
24
  ): Promise<UserLoginRes>;
24
25
  loginByToken(repo: FlinkRepo<any, User>, auth: JwtAuthPlugin, token: string, code: string, jwtSecret: string): Promise<UserLoginRes>;
25
26
  createUser(
@@ -68,7 +69,7 @@ export interface genericAuthContext {
68
69
  validatePasswordMethod?: { (password: string, hash: string, salt: string): Promise<boolean> };
69
70
  usernameFormat: RegExp;
70
71
  smsOptions?: GenericAuthsmsOptions;
71
- onSuccessfulLogin?: { (user: User): Promise<void> };
72
+ onSuccessfulLogin?: { (user: User, req?: FlinkRequest): Promise<void> };
72
73
  onUserCreated?: { (user: User): Promise<void> };
73
74
  };
74
75
  }
@@ -1,3 +1,4 @@
1
+ import { FlinkRequest } from "@flink-app/flink";
1
2
  import { User } from "./schemas/User";
2
3
  import { UserPasswordResetSettings } from "./schemas/UserPasswordResetSettings";
3
4
  import { client as smsClient } from "@flink-app/sms-plugin";
@@ -23,7 +24,7 @@ export interface GenericAuthPluginOptions {
23
24
  usernameFormat?: RegExp;
24
25
  sms?: GenericAuthsmsOptions;
25
26
  onSuccessfulLogin?: {
26
- (user: User): Promise<void>;
27
+ (user: User, req?: FlinkRequest): Promise<void>;
27
28
  };
28
29
  onUserCreated?: {
29
30
  (user: User): Promise<void>;
@@ -18,7 +18,8 @@ const userLoginHandler: Handler<FlinkContext<genericAuthContext>, UserLoginReq,
18
18
  req.body.password,
19
19
  ctx.plugins.genericAuthPlugin.validatePasswordMethod,
20
20
  (<any>ctx.plugins)[pluginName].smsOptions,
21
- (<any>ctx.plugins)[pluginName].onSuccessfulLogin
21
+ (<any>ctx.plugins)[pluginName].onSuccessfulLogin,
22
+ req
22
23
  );
23
24
  } catch (error: any) {
24
25
  // Convert any thrown error that conforms to flink error structure to a proper response