@flink-app/generic-auth-plugin 0.11.5 → 0.11.6

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 Thu Jan 09 2025 19:44:02 GMT+0100 (Central European Standard Time)
1
+ // Generated Thu Jan 30 2025 11:53:42 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 Thu Jan 09 2025 19:44:02 GMT+0100 (Central European Standard Time)
1
+ // Generated Thu Jan 30 2025 11:53:42 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 Thu Jan 09 2025 19:44:02 GMT+0100 (Central European Standard Time)
1
+ // Generated Thu Jan 30 2025 11:53:42 GMT+0100 (Central European Standard Time)
2
2
  import { autoRegisteredRepos } from "@flink-app/flink";
3
3
  export const repos = [];
4
4
  autoRegisteredRepos.push(...repos);
@@ -337,6 +337,14 @@
337
337
  },
338
338
  "token": {
339
339
  "type": "string"
340
+ },
341
+ "platform": {
342
+ "type": "string",
343
+ "enum": [
344
+ "ios",
345
+ "android",
346
+ "web"
347
+ ]
340
348
  }
341
349
  },
342
350
  "required": [
@@ -373,6 +381,14 @@
373
381
  },
374
382
  "token": {
375
383
  "type": "string"
384
+ },
385
+ "platform": {
386
+ "type": "string",
387
+ "enum": [
388
+ "ios",
389
+ "android",
390
+ "web"
391
+ ]
376
392
  }
377
393
  },
378
394
  "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 Thu Jan 09 2025 19:44:03 GMT+0100 (Central European Standard Time)
32
+ // Generated Thu Jan 30 2025 11:53:43 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 Thu Jan 09 2025 19:44:02 GMT+0100 (Central European Standard Time)
1
+ // Generated Thu Jan 30 2025 11:53:42 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 Thu Jan 09 2025 19:44:02 GMT+0100 (Central European Standard Time)
4
+ // Generated Thu Jan 30 2025 11:53:42 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 Thu Jan 09 2025 19:44:02 GMT+0100 (Central European Standard Time)
4
+ // Generated Thu Jan 30 2025 11:53:42 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 Thu Jan 09 2025 19:44:02 GMT+0100 (Central European Standard Time)
4
+ // Generated Thu Jan 30 2025 11:53:42 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);
@@ -337,6 +337,14 @@
337
337
  },
338
338
  "token": {
339
339
  "type": "string"
340
+ },
341
+ "platform": {
342
+ "type": "string",
343
+ "enum": [
344
+ "ios",
345
+ "android",
346
+ "web"
347
+ ]
340
348
  }
341
349
  },
342
350
  "required": [
@@ -373,6 +381,14 @@
373
381
  },
374
382
  "token": {
375
383
  "type": "string"
384
+ },
385
+ "platform": {
386
+ "type": "string",
387
+ "enum": [
388
+ "ios",
389
+ "android",
390
+ "web"
391
+ ]
376
392
  }
377
393
  },
378
394
  "required": [
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // Generated Thu Jan 09 2025 19:44:02 GMT+0100 (Central European Standard Time)
3
+ // Generated Thu Jan 30 2025 11:53:42 GMT+0100 (Central European Standard Time)
4
4
  require("./generatedHandlers");
5
5
  require("./generatedRepos");
6
6
  require("./generatedJobs");
@@ -72,4 +72,4 @@ var postUserPushRegisterTokenHandler = function (_a) {
72
72
  };
73
73
  exports.default = postUserPushRegisterTokenHandler;
74
74
  exports.__assumedHttpMethod = "", exports.__file = "UserPushRegisterToken.ts", exports.__query = [], exports.__params = [];
75
- exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "deviceId": { "type": "string" }, "token": { "type": "string" } }, "required": ["deviceId", "token"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "status": { "type": "string", "enum": ["success", "failed"] } }, "required": ["status"], "definitions": {} } };
75
+ exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "deviceId": { "type": "string" }, "token": { "type": "string" }, "platform": { "type": "string", "enum": ["ios", "android", "web"] } }, "required": ["deviceId", "token"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "status": { "type": "string", "enum": ["success", "failed"] } }, "required": ["status"], "definitions": {} } };
@@ -66,4 +66,4 @@ var postUserRemoveTokenHandler = function (_a) {
66
66
  };
67
67
  exports.default = postUserRemoveTokenHandler;
68
68
  exports.__assumedHttpMethod = "", exports.__file = "UserPushRemoveToken.ts", exports.__query = [], exports.__params = [];
69
- exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "deviceId": { "type": "string" }, "token": { "type": "string" } }, "required": ["deviceId", "token"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "status": { "type": "string", "enum": ["success", "failed"] } }, "required": ["status"], "definitions": {} } };
69
+ exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "deviceId": { "type": "string" }, "token": { "type": "string" }, "platform": { "type": "string", "enum": ["ios", "android", "web"] } }, "required": ["deviceId", "token"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "status": { "type": "string", "enum": ["success", "failed"] } }, "required": ["status"], "definitions": {} } };
@@ -1,4 +1,5 @@
1
1
  export interface PushNotificationToken {
2
2
  deviceId: string;
3
3
  token: string;
4
+ platform?: "ios" | "android" | "web";
4
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flink-app/generic-auth-plugin",
3
- "version": "0.11.5",
3
+ "version": "0.11.6",
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": "^4.2.4"
32
32
  },
33
- "gitHead": "3e4488748859fc5f1de798dea4ea2611f9694221"
33
+ "gitHead": "dba26157e6a41c9186a3ff87b821a1e9ea5dfa22"
34
34
  }
@@ -4,34 +4,33 @@ import { PushNotificationToken } from "../schemas/PushNotificationToken";
4
4
  import { PushNotificatioNTokenRes } from "../schemas/PushNotificationTokenRes";
5
5
  import { User } from "../schemas/User";
6
6
 
7
- const postUserPushRegisterTokenHandler: Handler<
8
- FlinkContext<genericAuthContext>,
9
- PushNotificationToken,
10
- PushNotificatioNTokenRes
11
- > = async ({ ctx, req, origin }) => {
12
- let pluginName = origin || "genericAuthPlugin";
13
- let repo = ctx.repos[(<any>ctx.plugins)[pluginName].repoName];
14
-
15
- const user = <User>await repo.getById(req.user._id);
16
-
17
- if (user == null) {
18
- return notFound("User not found");
19
- }
20
-
21
- var exToken = user.pushNotificationTokens.find(
22
- (t) => t.deviceId == req.body.deviceId
23
- );
24
- if (exToken != null) {
25
- exToken.token = req.body.token;
26
- } else {
27
- user.pushNotificationTokens.push(req.body);
28
- }
29
-
30
- await repo.updateOne(user._id, {
31
- pushNotificationTokens: user.pushNotificationTokens,
32
- });
33
-
34
- return { data: { status: "success" } };
7
+ const postUserPushRegisterTokenHandler: Handler<FlinkContext<genericAuthContext>, PushNotificationToken, PushNotificatioNTokenRes> = async ({
8
+ ctx,
9
+ req,
10
+ origin,
11
+ }) => {
12
+ let pluginName = origin || "genericAuthPlugin";
13
+ let repo = ctx.repos[(<any>ctx.plugins)[pluginName].repoName];
14
+
15
+ const user = <User>await repo.getById(req.user._id);
16
+
17
+ if (user == null) {
18
+ return notFound("User not found");
19
+ }
20
+
21
+ let exToken = user.pushNotificationTokens.find((t) => t.deviceId == req.body.deviceId);
22
+
23
+ if (exToken != null) {
24
+ exToken.token = req.body.token;
25
+ } else {
26
+ user.pushNotificationTokens.push(req.body);
27
+ }
28
+
29
+ await repo.updateOne(user._id, {
30
+ pushNotificationTokens: user.pushNotificationTokens,
31
+ });
32
+
33
+ return { data: { status: "success" } };
35
34
  };
36
35
 
37
36
  export default postUserPushRegisterTokenHandler;
@@ -1,4 +1,5 @@
1
- export interface PushNotificationToken{
2
- deviceId : string;
3
- token : string;
4
- }
1
+ export interface PushNotificationToken {
2
+ deviceId: string;
3
+ token: string;
4
+ platform?: "ios" | "android" | "web";
5
+ }
@@ -1,3 +1,3 @@
1
- export interface UserTokenRes{
2
- token : string
3
- }
1
+ export interface UserTokenRes {
2
+ token: string;
3
+ }