@flink-app/generic-auth-plugin 0.12.1-alpha.2 → 0.12.1-alpha.21

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 Wed Mar 19 2025 23:07:08 GMT+0100 (Central European Standard Time)
1
+ // Generated Fri Aug 08 2025 18:12:36 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 Wed Mar 19 2025 23:07:08 GMT+0100 (Central European Standard Time)
1
+ // Generated Fri Aug 08 2025 18:12:36 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 Wed Mar 19 2025 23:07:08 GMT+0100 (Central European Standard Time)
1
+ // Generated Fri Aug 08 2025 18:12:36 GMT+0200 (Central European Summer Time)
2
2
  import { autoRegisteredRepos } from "@flink-app/flink";
3
3
  export const repos = [];
4
4
  autoRegisteredRepos.push(...repos);
@@ -264,6 +264,88 @@
264
264
  "invalidCode",
265
265
  "passwordError"
266
266
  ]
267
+ },
268
+ "user": {
269
+ "type": "object",
270
+ "properties": {
271
+ "_id": {
272
+ "type": "string"
273
+ },
274
+ "username": {
275
+ "type": "string"
276
+ },
277
+ "password": {
278
+ "type": "string"
279
+ },
280
+ "salt": {
281
+ "type": "string"
282
+ },
283
+ "pwdResetStartedAt": {
284
+ "type": [
285
+ "string",
286
+ "null"
287
+ ]
288
+ },
289
+ "roles": {
290
+ "type": "array",
291
+ "items": {
292
+ "type": "string"
293
+ }
294
+ },
295
+ "authentificationMethod": {
296
+ "type": "string",
297
+ "enum": [
298
+ "password",
299
+ "sms"
300
+ ]
301
+ },
302
+ "profile": {
303
+ "type": "object"
304
+ },
305
+ "pushNotificationTokens": {
306
+ "type": "array",
307
+ "items": {
308
+ "type": "object",
309
+ "properties": {
310
+ "deviceId": {
311
+ "type": "string"
312
+ },
313
+ "token": {
314
+ "type": "string"
315
+ },
316
+ "platform": {
317
+ "type": "string",
318
+ "enum": [
319
+ "ios",
320
+ "android",
321
+ "web"
322
+ ]
323
+ },
324
+ "type": {
325
+ "type": "string",
326
+ "enum": [
327
+ "firebase",
328
+ "apn-voip"
329
+ ]
330
+ }
331
+ },
332
+ "required": [
333
+ "deviceId",
334
+ "token"
335
+ ],
336
+ "additionalProperties": false
337
+ }
338
+ }
339
+ },
340
+ "required": [
341
+ "_id",
342
+ "username",
343
+ "roles",
344
+ "authentificationMethod",
345
+ "profile",
346
+ "pushNotificationTokens"
347
+ ],
348
+ "additionalProperties": false
267
349
  }
268
350
  },
269
351
  "required": [
@@ -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 Wed Mar 19 2025 23:07:08 GMT+0100 (Central European Standard Time)
32
+ // Generated Fri Aug 08 2025 18:12:36 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,5 +1,6 @@
1
- // Generated Wed Mar 19 2025 23:07:08 GMT+0100 (Central European Standard Time)
1
+ // Generated Fri Aug 08 2025 18:12:36 GMT+0200 (Central European Summer Time)
2
2
  import "./generatedHandlers";
3
3
  import "./generatedRepos";
4
4
  import "./generatedJobs";
5
5
  import "../src/index";
6
+ export default {}; // Export an empty object to make it a module
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handlers = void 0;
4
- // Generated Wed Mar 19 2025 23:07:08 GMT+0100 (Central European Standard Time)
4
+ // Generated Fri Aug 08 2025 18:12:36 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 Wed Mar 19 2025 23:07:08 GMT+0100 (Central European Standard Time)
4
+ // Generated Fri Aug 08 2025 18:12:36 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 Wed Mar 19 2025 23:07:08 GMT+0100 (Central European Standard Time)
4
+ // Generated Fri Aug 08 2025 18:12:36 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);
@@ -264,6 +264,88 @@
264
264
  "invalidCode",
265
265
  "passwordError"
266
266
  ]
267
+ },
268
+ "user": {
269
+ "type": "object",
270
+ "properties": {
271
+ "_id": {
272
+ "type": "string"
273
+ },
274
+ "username": {
275
+ "type": "string"
276
+ },
277
+ "password": {
278
+ "type": "string"
279
+ },
280
+ "salt": {
281
+ "type": "string"
282
+ },
283
+ "pwdResetStartedAt": {
284
+ "type": [
285
+ "string",
286
+ "null"
287
+ ]
288
+ },
289
+ "roles": {
290
+ "type": "array",
291
+ "items": {
292
+ "type": "string"
293
+ }
294
+ },
295
+ "authentificationMethod": {
296
+ "type": "string",
297
+ "enum": [
298
+ "password",
299
+ "sms"
300
+ ]
301
+ },
302
+ "profile": {
303
+ "type": "object"
304
+ },
305
+ "pushNotificationTokens": {
306
+ "type": "array",
307
+ "items": {
308
+ "type": "object",
309
+ "properties": {
310
+ "deviceId": {
311
+ "type": "string"
312
+ },
313
+ "token": {
314
+ "type": "string"
315
+ },
316
+ "platform": {
317
+ "type": "string",
318
+ "enum": [
319
+ "ios",
320
+ "android",
321
+ "web"
322
+ ]
323
+ },
324
+ "type": {
325
+ "type": "string",
326
+ "enum": [
327
+ "firebase",
328
+ "apn-voip"
329
+ ]
330
+ }
331
+ },
332
+ "required": [
333
+ "deviceId",
334
+ "token"
335
+ ],
336
+ "additionalProperties": false
337
+ }
338
+ }
339
+ },
340
+ "required": [
341
+ "_id",
342
+ "username",
343
+ "roles",
344
+ "authentificationMethod",
345
+ "profile",
346
+ "pushNotificationTokens"
347
+ ],
348
+ "additionalProperties": false
267
349
  }
268
350
  },
269
351
  "required": [
@@ -2,3 +2,5 @@ import "./generatedHandlers";
2
2
  import "./generatedRepos";
3
3
  import "./generatedJobs";
4
4
  import "../src/index";
5
+ declare const _default: {};
6
+ export default _default;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // Generated Wed Mar 19 2025 23:07:08 GMT+0100 (Central European Standard Time)
3
+ // Generated Fri Aug 08 2025 18:12:36 GMT+0200 (Central European Summer Time)
4
4
  require("./generatedHandlers");
5
5
  require("./generatedRepos");
6
6
  require("./generatedJobs");
7
7
  require("../src/index");
8
+ exports.default = {}; // Export an empty object to make it a module
@@ -414,7 +414,7 @@ function passwordResetComplete(repo_1, auth_1, jwtSecret_1, passwordResetToken_1
414
414
  })];
415
415
  case 6:
416
416
  _a.sent();
417
- return [2 /*return*/, { status: "success" }];
417
+ return [2 /*return*/, { status: "success", user: user }];
418
418
  }
419
419
  });
420
420
  });
@@ -67,4 +67,4 @@ var postPasswordResetCompleteHandler = function (_a) { return __awaiter(void 0,
67
67
  }); };
68
68
  exports.default = postPasswordResetCompleteHandler;
69
69
  exports.__assumedHttpMethod = "", exports.__file = "UserPasswordResetComplete.ts", exports.__query = [], exports.__params = [];
70
- exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "passwordResetToken": { "type": "string" }, "code": { "type": "string" }, "password": { "type": "string" } }, "required": ["code", "password", "passwordResetToken"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "status": { "type": "string", "enum": ["success", "userNotFound", "invalidCode", "passwordError"] } }, "required": ["status"], "definitions": {} } };
70
+ exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "passwordResetToken": { "type": "string" }, "code": { "type": "string" }, "password": { "type": "string" } }, "required": ["code", "password", "passwordResetToken"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "status": { "type": "string", "enum": ["success", "userNotFound", "invalidCode", "passwordError"] }, "user": { "type": "object", "properties": { "_id": { "type": "string" }, "username": { "type": "string" }, "password": { "type": "string" }, "salt": { "type": "string" }, "pwdResetStartedAt": { "type": ["string", "null"] }, "roles": { "type": "array", "items": { "type": "string" } }, "authentificationMethod": { "type": "string", "enum": ["password", "sms"] }, "profile": { "type": "object" }, "pushNotificationTokens": { "type": "array", "items": { "type": "object", "properties": { "deviceId": { "type": "string" }, "token": { "type": "string" }, "platform": { "type": "string", "enum": ["ios", "android", "web"] }, "type": { "type": "string", "enum": ["firebase", "apn-voip"] } }, "required": ["deviceId", "token"], "additionalProperties": false } } }, "required": ["_id", "username", "roles", "authentificationMethod", "profile", "pushNotificationTokens"], "additionalProperties": false } }, "required": ["status"], "definitions": {} } };
@@ -87,7 +87,7 @@ var postUserPushRegisterTokenHandler = function (_a) { return __awaiter(void 0,
87
87
  if (!deregisterOtherDevices) return [3 /*break*/, 9];
88
88
  return [4 /*yield*/, repo.findAll({
89
89
  $or: [{ "pushNotificationTokens.deviceId": req.body.deviceId }, { "pushNotificationTokens.token": req.body.token }],
90
- _id: { $ne: user._id },
90
+ _id: { $ne: repo.buildId(user._id) },
91
91
  })];
92
92
  case 3:
93
93
  otherRegistrations = _d.sent();
@@ -1,3 +1,8 @@
1
+ import { User } from "./User";
1
2
  export interface UserPasswordResetCompleteRes {
2
3
  status: "success" | "userNotFound" | "invalidCode" | "passwordError";
4
+ /**
5
+ * The user object is returned only if the status is "success".
6
+ */
7
+ user?: User;
3
8
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@flink-app/generic-auth-plugin",
3
- "version": "0.12.1-alpha.2",
3
+ "version": "0.12.1-alpha.21",
4
4
  "description": "Flink plugin that provides a generic user authentification solution.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\"",
7
7
  "build": "flink build",
8
- "prepublish": "npm run build",
8
+ "prepare": "npm run build",
9
9
  "watch": "nodemon --exec \"flink build\""
10
10
  },
11
11
  "author": "johan@frost.se",
@@ -16,19 +16,19 @@
16
16
  "types": "dist/src/index.d.ts",
17
17
  "main": "dist/src/index.js",
18
18
  "dependencies": {
19
- "@flink-app/email-plugin": "^0.12.1-alpha.2",
20
- "@flink-app/jwt-auth-plugin": "^0.12.1-alpha.2",
21
- "@flink-app/management-api-plugin": "^0.12.1-alpha.2",
22
- "@flink-app/sms-plugin": "^0.12.1-alpha.2",
19
+ "@flink-app/email-plugin": "^0.12.1-alpha.20",
20
+ "@flink-app/jwt-auth-plugin": "^0.12.1-alpha.20",
21
+ "@flink-app/management-api-plugin": "^0.12.1-alpha.20",
22
+ "@flink-app/sms-plugin": "^0.12.1-alpha.20",
23
23
  "handlebars": "^4.7.7",
24
24
  "jsonwebtoken": "^8.5.1"
25
25
  },
26
26
  "devDependencies": {
27
- "@flink-app/flink": "^0.12.1-alpha.2",
27
+ "@flink-app/flink": "^0.12.1-alpha.20",
28
28
  "@types/jsonwebtoken": "^8.5.2",
29
29
  "@types/node": "22.13.10",
30
30
  "ts-node": "^9.1.1",
31
31
  "typescript": "5.4.5"
32
32
  },
33
- "gitHead": "b5be77c75e10067c81e0ecab8716b30f99833b83"
33
+ "gitHead": "baad28172eb929a54e5fd139d04ebaed74f20ac4"
34
34
  }
@@ -382,7 +382,7 @@ export async function passwordResetComplete(
382
382
  pwdResetStartedAt: null,
383
383
  });
384
384
 
385
- return { status: "success" };
385
+ return { status: "success", user };
386
386
  }
387
387
 
388
388
  function generate(n: number): string {
@@ -43,7 +43,7 @@ const postUserPushRegisterTokenHandler: Handler<FlinkContext<genericAuthContext>
43
43
  if (deregisterOtherDevices) {
44
44
  const otherRegistrations = <User[]>await repo.findAll({
45
45
  $or: [{ "pushNotificationTokens.deviceId": req.body.deviceId }, { "pushNotificationTokens.token": req.body.token }],
46
- _id: { $ne: user._id },
46
+ _id: { $ne: repo.buildId(user._id) },
47
47
  });
48
48
 
49
49
  log.debug(`Found ${otherRegistrations.length} other registrations for device ${req.body.deviceId} or token ${req.body.token}`);
@@ -1,3 +1,10 @@
1
- export interface UserPasswordResetCompleteRes{
2
- status : "success" | "userNotFound" | "invalidCode" | "passwordError";
3
- }
1
+ import { User } from "./User";
2
+
3
+ export interface UserPasswordResetCompleteRes {
4
+ status: "success" | "userNotFound" | "invalidCode" | "passwordError";
5
+
6
+ /**
7
+ * The user object is returned only if the status is "success".
8
+ */
9
+ user?: User;
10
+ }
package/CLAUDE.md DELETED
@@ -1,32 +0,0 @@
1
- # CLAUDE.md - Guidelines for Generic Auth Plugin
2
-
3
- ## Build Commands
4
- - Build: `npm run build` (runs `flink build`)
5
- - Watch mode: `npm run watch` (uses nodemon to watch files and trigger builds)
6
- - Publish: `npm run prepublish` (runs build before publishing)
7
-
8
- ## Code Style
9
-
10
- ### TypeScript
11
- - Target: ES5, CommonJS modules, strict typing enabled
12
- - Keep type definitions in separate schema files in the `/schemas` directory
13
- - Use explicit return types on all functions (eg: `Promise<UserLoginRes>`)
14
- - Always handle optionality with `?` and `undefined`/`null` checks
15
-
16
- ### Naming Conventions
17
- - camelCase for variables, functions, and methods
18
- - PascalCase for interfaces and types
19
- - Request types use `Req` suffix (UserLoginReq)
20
- - Response types use `Res` suffix (UserLoginRes)
21
- - Handler files match their function name (UserLogin.ts)
22
-
23
- ### Error Handling
24
- - Use structured error responses with status fields and messages
25
- - Return typed response objects rather than throwing exceptions
26
- - Use try/catch blocks for operations that might fail (JWT verification)
27
-
28
- ### Code Structure
29
- - Group imports: framework first, then local, then third-party
30
- - Separate authentication methods and utility functions
31
- - Use standard 4-space indentation with semicolons
32
- - Maintain consistent function parameter ordering