dbm-graph-api 1.1.46 → 1.1.48
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbm-graph-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.48",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@aws-sdk/client-s3": "^3.741.0",
|
|
15
15
|
"@aws-sdk/s3-request-presigner": "^3.741.0",
|
|
16
|
-
"dbm": "^1.4.
|
|
16
|
+
"dbm": "^1.4.6",
|
|
17
17
|
"mime": "^4.0.6",
|
|
18
18
|
"sharp": "^0.33.5",
|
|
19
19
|
"ws": "^8.18.0"
|
|
@@ -341,6 +341,43 @@ export const setupEndpoints = function(aServer) {
|
|
|
341
341
|
return { success: false, error: "incorrect", message: "Incorrect details"};
|
|
342
342
|
});
|
|
343
343
|
|
|
344
|
+
aServer.post('/api/user/loginWith/*', async function handler (aRequest, aReply) {
|
|
345
|
+
let params = {...aRequest.body};
|
|
346
|
+
|
|
347
|
+
let request = new UrlRequest();
|
|
348
|
+
request.setup(aRequest, aReply);
|
|
349
|
+
|
|
350
|
+
let currentUrl = url.parse(aRequest.url);
|
|
351
|
+
let functionName = currentUrl.pathname.substring("/api/user/loginWith/".length);
|
|
352
|
+
|
|
353
|
+
let loginMethod = Dbm.getInstance().repository.getItemIfExists("loginMethods/" + functionName);
|
|
354
|
+
if(!loginMethod) {
|
|
355
|
+
aReply.code(404);
|
|
356
|
+
return { success: false, error: "notFound", message: "No login method " + functionName};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
let user = await loginMethod.controller.getUser(params);
|
|
360
|
+
console.log(user);
|
|
361
|
+
if(user) {
|
|
362
|
+
let sessionId = await user.createSession();
|
|
363
|
+
|
|
364
|
+
let tempArray = sessionId.split(":");
|
|
365
|
+
let sessionDatabaseId = 1*tempArray[0];
|
|
366
|
+
let expiresTime = 1*tempArray[2];
|
|
367
|
+
let expiresDate = (new Date(expiresTime)).toUTCString();
|
|
368
|
+
|
|
369
|
+
aReply.header("Set-Cookie", "dbm_session=" +sessionId + "; Path=/; Expires=" + expiresDate + "; HttpOnly;");
|
|
370
|
+
|
|
371
|
+
let wsToken = crypto.randomBytes(32).toString('base64');
|
|
372
|
+
let expiryLength = 60;
|
|
373
|
+
let hashedWsToken = await user.generateSignedSessionToken(sessionDatabaseId, (new Date()).valueOf()+expiryLength*1000, wsToken, sessionId)
|
|
374
|
+
|
|
375
|
+
return { success: true, data: {id: user.id, "wsToken": hashedWsToken}};
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return { success: false, error: "incorrect", message: "Incorrect details"};
|
|
379
|
+
});
|
|
380
|
+
|
|
344
381
|
let getPublicSessionIdFomCookie = function(aCookies) {
|
|
345
382
|
if(aCookies) {
|
|
346
383
|
let cookies = aCookies.split(";");
|
|
@@ -656,10 +693,18 @@ export const setupSite = function(aServer) {
|
|
|
656
693
|
let assetsUri = site.assetsUri;
|
|
657
694
|
let language = site.language;
|
|
658
695
|
let siteName = site.name;
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
696
|
+
let loaderName = "loader";
|
|
697
|
+
|
|
698
|
+
if(request.query.forceLoader) {
|
|
699
|
+
loaderName = request.query.forceLoader;
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
if((process.env.NODE_ENV === "production" && request.query.forceLoad !== "unminified") || request.query.forceLoad === "minified") {
|
|
703
|
+
loaderName += ".min";
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
let loader = loaderName + ".js?version=" + site.version;
|
|
663
708
|
|
|
664
709
|
let url = request.url;
|
|
665
710
|
let shouldRedirect = false;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
import SelectBaseObject from "./SelectBaseObject.js";
|
|
4
|
+
|
|
5
|
+
export default class IncludeAnyStatus extends SelectBaseObject {
|
|
6
|
+
_construct() {
|
|
7
|
+
super._construct();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async select(aQuery, aData, aRequest) {
|
|
11
|
+
await aRequest.connection.requireRole("admin");
|
|
12
|
+
|
|
13
|
+
aQuery.includeAnyStatus();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async filter(aIds, aData, aRequest) {
|
|
17
|
+
return aIds;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -5,6 +5,7 @@ export {default as IdSelection} from "./IdSelection.js";
|
|
|
5
5
|
export {default as ByObjectType} from "./ByObjectType.js";
|
|
6
6
|
export {default as IncludePrivate} from "./IncludePrivate.js";
|
|
7
7
|
export {default as IncludeDraft} from "./IncludeDraft.js";
|
|
8
|
+
export {default as IncludeAnyStatus} from "./IncludeAnyStatus.js";
|
|
8
9
|
export {default as ObjectRelationQuery} from "./ObjectRelationQuery.js";
|
|
9
10
|
export {default as GlobalObjectRelationQuery} from "./GlobalObjectRelationQuery.js";
|
|
10
11
|
export {default as WithIdentifier} from "./WithIdentifier.js";
|
|
@@ -24,6 +25,7 @@ export const fullSetup = function() {
|
|
|
24
25
|
|
|
25
26
|
register("includePrivate", new DbmGraphApi.range.select.IncludePrivate());
|
|
26
27
|
register("includeDraft", new DbmGraphApi.range.select.IncludeDraft());
|
|
28
|
+
register("includeAnyStatus", new DbmGraphApi.range.select.IncludeAnyStatus());
|
|
27
29
|
|
|
28
30
|
register("objectRelationQuery", new DbmGraphApi.range.select.ObjectRelationQuery());
|
|
29
31
|
register("globalObjectRelationQuery", new DbmGraphApi.range.select.GlobalObjectRelationQuery());
|