@flink-app/generic-auth-plugin 0.11.9 → 0.11.11
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.
- package/.flink/generatedHandlers.ts +1 -1
- package/.flink/generatedJobs.ts +1 -1
- package/.flink/generatedRepos.ts +1 -1
- package/.flink/schemas/schemas.json +16 -0
- package/.flink/schemas/schemas.ts +1 -1
- package/.flink/start.ts +1 -1
- package/dist/.flink/generatedHandlers.js +1 -1
- package/dist/.flink/generatedJobs.js +1 -1
- package/dist/.flink/generatedRepos.js +1 -1
- package/dist/.flink/schemas/schemas.json +16 -0
- package/dist/.flink/start.js +1 -1
- package/dist/src/handlers/UserPushRegisterToken.js +17 -3
- package/dist/src/handlers/UserPushRemoveToken.js +1 -1
- package/dist/src/index.js +25 -11
- package/dist/src/schemas/PushNotificationToken.d.ts +5 -0
- package/package.json +2 -2
- package/src/handlers/UserPushRegisterToken.ts +13 -2
- package/src/index.ts +21 -31
- package/src/schemas/PushNotificationToken.ts +6 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated
|
|
1
|
+
// Generated Thu Feb 13 2025 14:49:55 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";
|
package/.flink/generatedJobs.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated
|
|
1
|
+
// Generated Thu Feb 13 2025 14:49:56 GMT+0100 (Central European Standard Time)
|
|
2
2
|
import { autoRegisteredJobs } from "@flink-app/flink";
|
|
3
3
|
export const jobs = [];
|
|
4
4
|
autoRegisteredJobs.push(...jobs);
|
package/.flink/generatedRepos.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated
|
|
1
|
+
// Generated Thu Feb 13 2025 14:49:55 GMT+0100 (Central European Standard Time)
|
|
2
2
|
import { autoRegisteredRepos } from "@flink-app/flink";
|
|
3
3
|
export const repos = [];
|
|
4
4
|
autoRegisteredRepos.push(...repos);
|
|
@@ -345,6 +345,14 @@
|
|
|
345
345
|
"android",
|
|
346
346
|
"web"
|
|
347
347
|
]
|
|
348
|
+
},
|
|
349
|
+
"type": {
|
|
350
|
+
"type": "string",
|
|
351
|
+
"enum": [
|
|
352
|
+
"firebase",
|
|
353
|
+
"apn-voip"
|
|
354
|
+
],
|
|
355
|
+
"description": "The type of the token. This is used to determine which push notification service to use. Default is \"firebase\""
|
|
348
356
|
}
|
|
349
357
|
},
|
|
350
358
|
"required": [
|
|
@@ -389,6 +397,14 @@
|
|
|
389
397
|
"android",
|
|
390
398
|
"web"
|
|
391
399
|
]
|
|
400
|
+
},
|
|
401
|
+
"type": {
|
|
402
|
+
"type": "string",
|
|
403
|
+
"enum": [
|
|
404
|
+
"firebase",
|
|
405
|
+
"apn-voip"
|
|
406
|
+
],
|
|
407
|
+
"description": "The type of the token. This is used to determine which push notification service to use. Default is \"firebase\""
|
|
392
408
|
}
|
|
393
409
|
},
|
|
394
410
|
"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
|
|
32
|
+
// Generated Thu Feb 13 2025 14:49:56 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,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handlers = void 0;
|
|
4
|
-
// Generated
|
|
4
|
+
// Generated Thu Feb 13 2025 14:49:55 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
|
|
4
|
+
// Generated Thu Feb 13 2025 14:49:56 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
|
|
4
|
+
// Generated Thu Feb 13 2025 14:49:55 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);
|
|
@@ -345,6 +345,14 @@
|
|
|
345
345
|
"android",
|
|
346
346
|
"web"
|
|
347
347
|
]
|
|
348
|
+
},
|
|
349
|
+
"type": {
|
|
350
|
+
"type": "string",
|
|
351
|
+
"enum": [
|
|
352
|
+
"firebase",
|
|
353
|
+
"apn-voip"
|
|
354
|
+
],
|
|
355
|
+
"description": "The type of the token. This is used to determine which push notification service to use. Default is \"firebase\""
|
|
348
356
|
}
|
|
349
357
|
},
|
|
350
358
|
"required": [
|
|
@@ -389,6 +397,14 @@
|
|
|
389
397
|
"android",
|
|
390
398
|
"web"
|
|
391
399
|
]
|
|
400
|
+
},
|
|
401
|
+
"type": {
|
|
402
|
+
"type": "string",
|
|
403
|
+
"enum": [
|
|
404
|
+
"firebase",
|
|
405
|
+
"apn-voip"
|
|
406
|
+
],
|
|
407
|
+
"description": "The type of the token. This is used to determine which push notification service to use. Default is \"firebase\""
|
|
392
408
|
}
|
|
393
409
|
},
|
|
394
410
|
"required": [
|
package/dist/.flink/start.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// Generated
|
|
3
|
+
// Generated Thu Feb 13 2025 14:49:56 GMT+0100 (Central European Standard Time)
|
|
4
4
|
require("./generatedHandlers");
|
|
5
5
|
require("./generatedRepos");
|
|
6
6
|
require("./generatedJobs");
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -41,7 +52,7 @@ var flink_1 = require("@flink-app/flink");
|
|
|
41
52
|
var postUserPushRegisterTokenHandler = function (_a) {
|
|
42
53
|
var ctx = _a.ctx, req = _a.req, origin = _a.origin;
|
|
43
54
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
-
var pluginName, pluginOptions, repo, deregisterOtherDevices, allowMultipleDevices, user, exToken, otherRegistrations, _i, otherRegistrations_1, other, e_1;
|
|
55
|
+
var pluginName, pluginOptions, repo, deregisterOtherDevices, allowMultipleDevices, user, exToken, otherRegistrations, _i, otherRegistrations_1, other, lengthBefore, e_1;
|
|
45
56
|
var _b;
|
|
46
57
|
return __generator(this, function (_c) {
|
|
47
58
|
switch (_c.label) {
|
|
@@ -62,7 +73,7 @@ var postUserPushRegisterTokenHandler = function (_a) {
|
|
|
62
73
|
exToken.token = req.body.token;
|
|
63
74
|
}
|
|
64
75
|
else {
|
|
65
|
-
user.pushNotificationTokens.push(req.body);
|
|
76
|
+
user.pushNotificationTokens.push(__assign(__assign({}, req.body), { type: req.body.type || "firebase" }));
|
|
66
77
|
}
|
|
67
78
|
if (!allowMultipleDevices) {
|
|
68
79
|
// Filter out all other devices except the newly registered one
|
|
@@ -80,6 +91,7 @@ var postUserPushRegisterTokenHandler = function (_a) {
|
|
|
80
91
|
})];
|
|
81
92
|
case 3:
|
|
82
93
|
otherRegistrations = _c.sent();
|
|
94
|
+
flink_1.log.debug("Found " + otherRegistrations.length + " other registrations for device " + req.body.deviceId + " or token " + req.body.token);
|
|
83
95
|
_i = 0, otherRegistrations_1 = otherRegistrations;
|
|
84
96
|
_c.label = 4;
|
|
85
97
|
case 4:
|
|
@@ -88,7 +100,9 @@ var postUserPushRegisterTokenHandler = function (_a) {
|
|
|
88
100
|
_c.label = 5;
|
|
89
101
|
case 5:
|
|
90
102
|
_c.trys.push([5, 7, , 8]);
|
|
103
|
+
lengthBefore = other.pushNotificationTokens.length;
|
|
91
104
|
other.pushNotificationTokens = other.pushNotificationTokens.filter(function (t) { return t.deviceId !== req.body.deviceId && t.token !== req.body.token; });
|
|
105
|
+
flink_1.log.debug("Deregistering " + (lengthBefore - other.pushNotificationTokens.length) + " devices for user " + other._id + " as other user " + user._id + " claimed this device");
|
|
92
106
|
return [4 /*yield*/, repo.updateOne(other._id, {
|
|
93
107
|
pushNotificationTokens: other.pushNotificationTokens,
|
|
94
108
|
})];
|
|
@@ -109,4 +123,4 @@ var postUserPushRegisterTokenHandler = function (_a) {
|
|
|
109
123
|
};
|
|
110
124
|
exports.default = postUserPushRegisterTokenHandler;
|
|
111
125
|
exports.__assumedHttpMethod = "", exports.__file = "UserPushRegisterToken.ts", exports.__query = [], exports.__params = [];
|
|
112
|
-
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": {} } };
|
|
126
|
+
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"] }, "type": { "type": "string", "enum": ["firebase", "apn-voip"], "description": "The type of the token. This is used to determine which push notification service to use. Default is \"firebase\"" } }, "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" }, "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": {} } };
|
|
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"] }, "type": { "type": "string", "enum": ["firebase", "apn-voip"], "description": "The type of the token. This is used to determine which push notification service to use. Default is \"firebase\"" } }, "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": {} } };
|
package/dist/src/index.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -9,6 +20,17 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
9
20
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
21
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
22
|
};
|
|
23
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
24
|
+
var t = {};
|
|
25
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
26
|
+
t[p] = s[p];
|
|
27
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
28
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
29
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
30
|
+
t[p[i]] = s[p[i]];
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
|
+
};
|
|
12
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
35
|
exports.genericAuthPlugin = void 0;
|
|
14
36
|
var coreFunctions_1 = require("./coreFunctions");
|
|
@@ -21,24 +43,16 @@ __exportStar(require("./management"), exports);
|
|
|
21
43
|
var genericAuthPlugin = function (options) {
|
|
22
44
|
if (options.pluginId == null)
|
|
23
45
|
options.pluginId = "genericAuthPlugin";
|
|
46
|
+
var sms = options.sms, usernameFormat = options.usernameFormat, restOptions = __rest(options, ["sms", "usernameFormat"]);
|
|
24
47
|
return {
|
|
25
48
|
id: options.pluginId,
|
|
26
49
|
init: function (app) { return init_1.init(app, options); },
|
|
27
|
-
ctx: {
|
|
28
|
-
loginUser: coreFunctions_1.loginUser,
|
|
50
|
+
ctx: __assign(__assign({}, restOptions), { loginUser: coreFunctions_1.loginUser,
|
|
29
51
|
loginByToken: coreFunctions_1.loginByToken,
|
|
30
52
|
createUser: coreFunctions_1.createUser,
|
|
31
53
|
changePassword: coreFunctions_1.changePassword,
|
|
32
54
|
passwordResetStart: coreFunctions_1.passwordResetStart,
|
|
33
|
-
passwordResetComplete: coreFunctions_1.passwordResetComplete,
|
|
34
|
-
repoName: options.repoName,
|
|
35
|
-
passwordResetSettings: options.passwordResetSettings,
|
|
36
|
-
createPasswordHashAndSaltMethod: options.createPasswordHashAndSaltMethod,
|
|
37
|
-
validatePasswordMethod: options.validatePasswordMethod,
|
|
38
|
-
usernameFormat: options.usernameFormat || /.{1,}$/,
|
|
39
|
-
onSuccessfulLogin: options.onSuccessfulLogin,
|
|
40
|
-
smsOptions: options.sms
|
|
41
|
-
},
|
|
55
|
+
passwordResetComplete: coreFunctions_1.passwordResetComplete, usernameFormat: usernameFormat || /.{1,}$/, smsOptions: sms }),
|
|
42
56
|
};
|
|
43
57
|
};
|
|
44
58
|
exports.genericAuthPlugin = genericAuthPlugin;
|
|
@@ -2,4 +2,9 @@ export interface PushNotificationToken {
|
|
|
2
2
|
deviceId: string;
|
|
3
3
|
token: string;
|
|
4
4
|
platform?: "ios" | "android" | "web";
|
|
5
|
+
/**
|
|
6
|
+
* The type of the token. This is used to determine which push notification service to use.
|
|
7
|
+
* Default is "firebase"
|
|
8
|
+
*/
|
|
9
|
+
type?: "firebase" | "apn-voip";
|
|
5
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flink-app/generic-auth-plugin",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.11",
|
|
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": "
|
|
33
|
+
"gitHead": "0eb9b8d88342ba6c868ba70eed1dddb818d1f6dc"
|
|
34
34
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FlinkContext, Handler, notFound } from "@flink-app/flink";
|
|
1
|
+
import { FlinkContext, Handler, log, notFound } from "@flink-app/flink";
|
|
2
2
|
import { genericAuthContext } from "../genericAuthContext";
|
|
3
3
|
import { PushNotificationToken } from "../schemas/PushNotificationToken";
|
|
4
4
|
import { PushNotificatioNTokenRes } from "../schemas/PushNotificationTokenRes";
|
|
@@ -27,7 +27,7 @@ const postUserPushRegisterTokenHandler: Handler<FlinkContext<genericAuthContext>
|
|
|
27
27
|
if (exToken != null) {
|
|
28
28
|
exToken.token = req.body.token;
|
|
29
29
|
} else {
|
|
30
|
-
user.pushNotificationTokens.push(req.body);
|
|
30
|
+
user.pushNotificationTokens.push({ ...req.body, type: req.body.type || "firebase" });
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
if (!allowMultipleDevices) {
|
|
@@ -45,9 +45,20 @@ const postUserPushRegisterTokenHandler: Handler<FlinkContext<genericAuthContext>
|
|
|
45
45
|
_id: { $ne: user._id },
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
log.debug(`Found ${otherRegistrations.length} other registrations for device ${req.body.deviceId} or token ${req.body.token}`);
|
|
49
|
+
|
|
48
50
|
for (let other of otherRegistrations) {
|
|
49
51
|
try {
|
|
52
|
+
let lengthBefore = other.pushNotificationTokens.length;
|
|
53
|
+
|
|
50
54
|
other.pushNotificationTokens = other.pushNotificationTokens.filter((t) => t.deviceId !== req.body.deviceId && t.token !== req.body.token);
|
|
55
|
+
|
|
56
|
+
log.debug(
|
|
57
|
+
`Deregistering ${lengthBefore - other.pushNotificationTokens.length} devices for user ${other._id} as other user ${
|
|
58
|
+
user._id
|
|
59
|
+
} claimed this device`
|
|
60
|
+
);
|
|
61
|
+
|
|
51
62
|
await repo.updateOne(other._id, {
|
|
52
63
|
pushNotificationTokens: other.pushNotificationTokens,
|
|
53
64
|
});
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { FlinkPlugin } from "@flink-app/flink";
|
|
2
|
-
import {
|
|
3
|
-
loginUser,
|
|
4
|
-
createUser,
|
|
5
|
-
changePassword,
|
|
6
|
-
passwordResetComplete,
|
|
7
|
-
passwordResetStart,
|
|
8
|
-
loginByToken
|
|
9
|
-
} from "./coreFunctions";
|
|
2
|
+
import { loginUser, createUser, changePassword, passwordResetComplete, passwordResetStart, loginByToken } from "./coreFunctions";
|
|
10
3
|
import { init } from "./init";
|
|
11
4
|
import { GenericAuthPluginOptions } from "./genericAuthPluginOptions";
|
|
12
5
|
|
|
@@ -16,27 +9,24 @@ export * from "./schemas/User";
|
|
|
16
9
|
export * from "./genericAuthPluginOptions";
|
|
17
10
|
export * from "./management";
|
|
18
11
|
|
|
19
|
-
export const genericAuthPlugin = (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
smsOptions : options.sms
|
|
40
|
-
},
|
|
41
|
-
};
|
|
12
|
+
export const genericAuthPlugin = (options: GenericAuthPluginOptions): FlinkPlugin => {
|
|
13
|
+
if (options.pluginId == null) options.pluginId = "genericAuthPlugin";
|
|
14
|
+
|
|
15
|
+
const { sms, usernameFormat, ...restOptions } = options;
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
id: options.pluginId,
|
|
19
|
+
init: (app) => init(app, options),
|
|
20
|
+
ctx: {
|
|
21
|
+
...restOptions,
|
|
22
|
+
loginUser,
|
|
23
|
+
loginByToken,
|
|
24
|
+
createUser,
|
|
25
|
+
changePassword,
|
|
26
|
+
passwordResetStart,
|
|
27
|
+
passwordResetComplete,
|
|
28
|
+
usernameFormat: usernameFormat || /.{1,}$/,
|
|
29
|
+
smsOptions: sms,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
42
32
|
};
|
|
@@ -2,4 +2,10 @@ export interface PushNotificationToken {
|
|
|
2
2
|
deviceId: string;
|
|
3
3
|
token: string;
|
|
4
4
|
platform?: "ios" | "android" | "web";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The type of the token. This is used to determine which push notification service to use.
|
|
8
|
+
* Default is "firebase"
|
|
9
|
+
*/
|
|
10
|
+
type?: "firebase" | "apn-voip";
|
|
5
11
|
}
|