quidproquo-dev-server 0.0.262 → 0.0.263
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/lib/commonjs/actionProcessor/core/apiKeyValidation/getApiKeyValidationValidateActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/apiKeyValidation/getApiKeyValidationValidateActionProcessor.js +26 -0
- package/lib/commonjs/actionProcessor/core/apiKeyValidation/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/apiKeyValidation/index.js +17 -0
- package/lib/commonjs/actionProcessor/core/event/express/api/getEventAutoRespondActionProcessor.js +2 -16
- package/lib/commonjs/actionProcessor/core/event/express/api/getEventGetStorySessionActionProcessor.js +2 -36
- package/lib/commonjs/actionProcessor/core/eventBus/getEventBusSendMessagesActionProcessor.js +2 -2
- package/lib/commonjs/actionProcessor/core/getCoreActionProcessor.js +4 -1
- package/lib/commonjs/actionProcessor/core/queue/getQueueSendMessageActionProcessor.js +2 -2
- package/lib/commonjs/actionProcessor/core/userDirectory/getUserDirectoryDecodeAccessTokenActionProcessor.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/userDirectory/getUserDirectoryDecodeAccessTokenActionProcessor.js +29 -0
- package/lib/commonjs/actionProcessor/core/userDirectory/index.d.ts +2 -0
- package/lib/commonjs/actionProcessor/core/userDirectory/index.js +17 -0
- package/lib/commonjs/actionProcessor/webserver/serviceFunctionOverride/getServiceFunctionExecuteActionProcessor.js +2 -2
- package/lib/esm/actionProcessor/core/apiKeyValidation/getApiKeyValidationValidateActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/apiKeyValidation/getApiKeyValidationValidateActionProcessor.js +11 -0
- package/lib/esm/actionProcessor/core/apiKeyValidation/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/apiKeyValidation/index.js +4 -0
- package/lib/esm/actionProcessor/core/event/express/api/getEventAutoRespondActionProcessor.js +3 -15
- package/lib/esm/actionProcessor/core/event/express/api/getEventGetStorySessionActionProcessor.js +3 -40
- package/lib/esm/actionProcessor/core/eventBus/getEventBusSendMessagesActionProcessor.js +2 -5
- package/lib/esm/actionProcessor/core/getCoreActionProcessor.js +6 -0
- package/lib/esm/actionProcessor/core/queue/getQueueSendMessageActionProcessor.js +2 -5
- package/lib/esm/actionProcessor/core/userDirectory/getUserDirectoryDecodeAccessTokenActionProcessor.d.ts +2 -0
- package/lib/esm/actionProcessor/core/userDirectory/getUserDirectoryDecodeAccessTokenActionProcessor.js +14 -0
- package/lib/esm/actionProcessor/core/userDirectory/index.d.ts +2 -0
- package/lib/esm/actionProcessor/core/userDirectory/index.js +4 -0
- package/lib/esm/actionProcessor/webserver/serviceFunctionOverride/getServiceFunctionExecuteActionProcessor.js +2 -5
- package/package.json +6 -6
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getApiKeyValidationValidateActionProcessor = void 0;
|
|
13
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
|
+
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
15
|
+
const getProcessApiKeyValidationValidate = (_qpqConfig) => {
|
|
16
|
+
return () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
// Permissive dev mode - always return true
|
|
18
|
+
return (0, quidproquo_core_1.actionResult)(true);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const getApiKeyValidationValidateActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
return ({
|
|
23
|
+
[quidproquo_webserver_1.ApiKeyValidationActionType.Validate]: getProcessApiKeyValidationValidate(qpqConfig),
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
exports.getApiKeyValidationValidateActionProcessor = getApiKeyValidationValidateActionProcessor;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getApiKeyValidationActionProcessor = void 0;
|
|
13
|
+
const getApiKeyValidationValidateActionProcessor_1 = require("./getApiKeyValidationValidateActionProcessor");
|
|
14
|
+
const getApiKeyValidationActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (Object.assign({}, (yield (0, getApiKeyValidationValidateActionProcessor_1.getApiKeyValidationValidateActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
16
|
+
});
|
|
17
|
+
exports.getApiKeyValidationActionProcessor = getApiKeyValidationActionProcessor;
|
package/lib/commonjs/actionProcessor/core/event/express/api/getEventAutoRespondActionProcessor.js
CHANGED
|
@@ -10,22 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getEventAutoRespondActionProcessor = void 0;
|
|
13
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
13
|
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
return (0, quidproquo_core_1.actionResult)({
|
|
18
|
-
status: 200,
|
|
19
|
-
isBase64Encoded: false,
|
|
20
|
-
body: '',
|
|
21
|
-
headers: quidproquo_webserver_1.qpqWebServerUtils.getCorsHeaders(qpqConfig, matchResult.config || {}, qpqEventRecord.headers),
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return (0, quidproquo_core_1.actionResult)(null);
|
|
25
|
-
});
|
|
26
|
-
const getEventAutoRespondActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
return ({
|
|
28
|
-
[quidproquo_core_1.EventActionType.AutoRespond]: getProcessAutoRespond(qpqConfig),
|
|
29
|
-
});
|
|
14
|
+
const getEventAutoRespondActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (Object.assign({}, (yield (0, quidproquo_webserver_1.getHttpApiEventAutoRespondActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
30
16
|
});
|
|
31
17
|
exports.getEventAutoRespondActionProcessor = getEventAutoRespondActionProcessor;
|
|
@@ -10,42 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getEventGetStorySessionActionProcessor = void 0;
|
|
13
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
13
|
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ matchStoryResult, qpqEventRecord }, session) {
|
|
18
|
-
var _b, _c;
|
|
19
|
-
const accessToken = quidproquo_webserver_1.qpqWebServerUtils.getAccessTokenFromHeaders(qpqEventRecord.headers);
|
|
20
|
-
if (!accessToken) {
|
|
21
|
-
return (0, quidproquo_core_1.actionResult)(void 0);
|
|
22
|
-
}
|
|
23
|
-
// if this endpoint has no auth settings, BUT we do have an access token
|
|
24
|
-
// then we want to just attempt to extract info for logs, but we will say that its
|
|
25
|
-
// wasValid = false
|
|
26
|
-
if (!((_c = (_b = matchStoryResult.config) === null || _b === void 0 ? void 0 : _b.routeAuthSettings) === null || _c === void 0 ? void 0 : _c.userDirectoryName)) {
|
|
27
|
-
// If this endpoint is unauthenticated, then we will just decode it, and say it wasnt valid, for logs
|
|
28
|
-
const info = quidproquo_webserver_1.qpqWebServerUtils.decodeJWT(accessToken);
|
|
29
|
-
return (0, quidproquo_core_1.actionResult)(Object.assign(Object.assign({}, session), { decodedAccessToken: {
|
|
30
|
-
exp: (info === null || info === void 0 ? void 0 : info.exp) || 0,
|
|
31
|
-
userDirectory: '',
|
|
32
|
-
userId: (info === null || info === void 0 ? void 0 : info.sub) || (info === null || info === void 0 ? void 0 : info.id) || (info === null || info === void 0 ? void 0 : info.userId) || (info === null || info === void 0 ? void 0 : info.username) || '',
|
|
33
|
-
username: (info === null || info === void 0 ? void 0 : info.username) || (info === null || info === void 0 ? void 0 : info.userId) || (info === null || info === void 0 ? void 0 : info.sub) || (info === null || info === void 0 ? void 0 : info.id) || '',
|
|
34
|
-
wasValid: false,
|
|
35
|
-
} }));
|
|
36
|
-
}
|
|
37
|
-
// Use dev-optimized decoder that doesn't make AWS API calls
|
|
38
|
-
// TODO: THIS NEEDS TO BE CHANGED TO USE THE "AUTH" api in a custom implementation!
|
|
39
|
-
const decodedAccessToken = (0, decodeAccessTokenForDev_1.decodeAccessTokenForDev)(matchStoryResult.config.routeAuthSettings.userDirectoryName, accessToken, true);
|
|
40
|
-
if (!decodedAccessToken) {
|
|
41
|
-
throw new Error('Unable to decode access token');
|
|
42
|
-
}
|
|
43
|
-
return (0, quidproquo_core_1.actionResult)(Object.assign(Object.assign({}, session), { decodedAccessToken }));
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
const getEventGetStorySessionActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
return ({
|
|
48
|
-
[quidproquo_core_1.EventActionType.GetStorySession]: getProcessGetStorySession(qpqConfig),
|
|
49
|
-
});
|
|
14
|
+
const getEventGetStorySessionActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (Object.assign({}, (yield (0, quidproquo_webserver_1.getHttpApiEventGetStorySessionActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
50
16
|
});
|
|
51
17
|
exports.getEventGetStorySessionActionProcessor = getEventGetStorySessionActionProcessor;
|
package/lib/commonjs/actionProcessor/core/eventBus/getEventBusSendMessagesActionProcessor.js
CHANGED
|
@@ -13,7 +13,7 @@ exports.getEventBusSendMessagesActionProcessor = void 0;
|
|
|
13
13
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
14
|
const eventBus_1 = require("../../../logic/eventBus");
|
|
15
15
|
const getProcessEventBusSendMessage = (qpqConfig) => {
|
|
16
|
-
return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ eventBusName, eventBusMessages,
|
|
16
|
+
return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ eventBusName, eventBusMessages, }, session) {
|
|
17
17
|
var _b, _c, _d, _e;
|
|
18
18
|
const eventBusConfig = quidproquo_core_1.qpqCoreUtils.getEventBusConfigByName(eventBusName, qpqConfig);
|
|
19
19
|
if (!eventBusConfig) {
|
|
@@ -23,7 +23,7 @@ const getProcessEventBusSendMessage = (qpqConfig) => {
|
|
|
23
23
|
const eventBusEvent = {
|
|
24
24
|
payload: eventBusMessage.payload,
|
|
25
25
|
type: eventBusMessage.type,
|
|
26
|
-
storySession:
|
|
26
|
+
storySession: session,
|
|
27
27
|
eventBusName: eventBusConfig.name,
|
|
28
28
|
targetApplication: ((_b = eventBusConfig.owner) === null || _b === void 0 ? void 0 : _b.application) || quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig),
|
|
29
29
|
targetEnvironment: ((_c = eventBusConfig.owner) === null || _c === void 0 ? void 0 : _c.environment) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig),
|
|
@@ -11,12 +11,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getCoreActionProcessor = void 0;
|
|
13
13
|
const quidproquo_actionprocessor_node_1 = require("quidproquo-actionprocessor-node");
|
|
14
|
+
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
15
|
+
const apiKeyValidation_1 = require("./apiKeyValidation");
|
|
14
16
|
const eventBus_1 = require("./eventBus");
|
|
15
17
|
const graphDatabaseOverride_1 = require("./graphDatabaseOverride");
|
|
16
18
|
const keyValueStore_1 = require("./keyValueStore");
|
|
17
19
|
const log_1 = require("./log");
|
|
18
20
|
const queue_1 = require("./queue");
|
|
21
|
+
const userDirectory_1 = require("./userDirectory");
|
|
19
22
|
const getCoreActionProcessor = (qpqConfig, dynamicModuleLoader, devServerConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (yield (0, graphDatabaseOverride_1.getGraphDatabaseActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, eventBus_1.getEventBusActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, queue_1.getQueueActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, log_1.getLogActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, quidproquo_actionprocessor_node_1.getFileActionProcessor)(devServerConfig.fileStorageConfig)(qpqConfig, dynamicModuleLoader))), (yield (0, keyValueStore_1.getKeyValueStoreActionProcessor)(devServerConfig)(qpqConfig, dynamicModuleLoader)));
|
|
23
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (yield (0, apiKeyValidation_1.getApiKeyValidationActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, graphDatabaseOverride_1.getGraphDatabaseActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, eventBus_1.getEventBusActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, queue_1.getQueueActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, log_1.getLogActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, quidproquo_actionprocessor_node_1.getFileActionProcessor)(devServerConfig.fileStorageConfig)(qpqConfig, dynamicModuleLoader))), (yield (0, keyValueStore_1.getKeyValueStoreActionProcessor)(devServerConfig)(qpqConfig, dynamicModuleLoader))), (yield (0, quidproquo_webserver_1.getRouteAuthValidationActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, userDirectory_1.getUserDirectoryActionProcessor)(qpqConfig, dynamicModuleLoader)));
|
|
21
24
|
});
|
|
22
25
|
exports.getCoreActionProcessor = getCoreActionProcessor;
|
|
@@ -15,7 +15,7 @@ const quidproquo_core_2 = require("quidproquo-core");
|
|
|
15
15
|
const uuid_1 = require("uuid");
|
|
16
16
|
const eventBus_1 = require("../../../logic/eventBus");
|
|
17
17
|
const getProcessQueueSendMessage = (qpqConfig) => {
|
|
18
|
-
return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ queueName, queueMessages
|
|
18
|
+
return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ queueName, queueMessages }, session) {
|
|
19
19
|
var _b, _c, _d, _e;
|
|
20
20
|
const queueConfig = quidproquo_core_1.qpqCoreUtils.getQueueByName(qpqConfig, queueName);
|
|
21
21
|
if (!queueConfig) {
|
|
@@ -25,7 +25,7 @@ const getProcessQueueSendMessage = (qpqConfig) => {
|
|
|
25
25
|
const queueEvent = {
|
|
26
26
|
payload: queueMessage.payload,
|
|
27
27
|
type: queueMessage.type,
|
|
28
|
-
storySession:
|
|
28
|
+
storySession: session,
|
|
29
29
|
messageId: (0, uuid_1.v4)(),
|
|
30
30
|
queueName: queueName,
|
|
31
31
|
targetApplication: ((_b = queueConfig.owner) === null || _b === void 0 ? void 0 : _b.application) || quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig),
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getUserDirectoryDecodeAccessTokenActionProcessor = void 0;
|
|
13
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
|
+
const decodeAccessTokenForDev_1 = require("../../../logic/auth/decodeAccessTokenForDev");
|
|
15
|
+
const getProcessDecodeAccessToken = (_qpqConfig) => {
|
|
16
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ userDirectoryName, accessToken, ignoreExpiration }) {
|
|
17
|
+
const decodedAccessToken = (0, decodeAccessTokenForDev_1.decodeAccessTokenForDev)(userDirectoryName, accessToken, ignoreExpiration);
|
|
18
|
+
if (!decodedAccessToken) {
|
|
19
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.Unauthorized, 'Invalid access token');
|
|
20
|
+
}
|
|
21
|
+
return (0, quidproquo_core_1.actionResult)(decodedAccessToken);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const getUserDirectoryDecodeAccessTokenActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
return ({
|
|
26
|
+
[quidproquo_core_1.UserDirectoryActionType.DecodeAccessToken]: getProcessDecodeAccessToken(qpqConfig),
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
exports.getUserDirectoryDecodeAccessTokenActionProcessor = getUserDirectoryDecodeAccessTokenActionProcessor;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getUserDirectoryActionProcessor = void 0;
|
|
13
|
+
const getUserDirectoryDecodeAccessTokenActionProcessor_1 = require("./getUserDirectoryDecodeAccessTokenActionProcessor");
|
|
14
|
+
const getUserDirectoryActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (Object.assign({}, (yield (0, getUserDirectoryDecodeAccessTokenActionProcessor_1.getUserDirectoryDecodeAccessTokenActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
16
|
+
});
|
|
17
|
+
exports.getUserDirectoryActionProcessor = getUserDirectoryActionProcessor;
|
|
@@ -14,12 +14,12 @@ const quidproquo_core_1 = require("quidproquo-core");
|
|
|
14
14
|
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
15
15
|
const eventBus_1 = require("../../../logic/eventBus");
|
|
16
16
|
const getProcessExecute = (qpqConfig, dynamicModuleLoader) => {
|
|
17
|
-
return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ functionName, service, payload,
|
|
17
|
+
return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ functionName, service, payload, isAsync }, session) {
|
|
18
18
|
const serviceFunctionEvent = {
|
|
19
19
|
functionName: functionName,
|
|
20
20
|
serviceName: service,
|
|
21
21
|
payload: payload,
|
|
22
|
-
storySession:
|
|
22
|
+
storySession: session,
|
|
23
23
|
};
|
|
24
24
|
const eventPromise = eventBus_1.eventBus.publishAndWaitForResponse(quidproquo_webserver_1.ServiceFunctionActionType.Execute, serviceFunctionEvent);
|
|
25
25
|
if (isAsync) {
|
package/lib/esm/actionProcessor/core/apiKeyValidation/getApiKeyValidationValidateActionProcessor.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { actionResult } from 'quidproquo-core';
|
|
2
|
+
import { ApiKeyValidationActionType } from 'quidproquo-webserver';
|
|
3
|
+
const getProcessApiKeyValidationValidate = (_qpqConfig) => {
|
|
4
|
+
return async () => {
|
|
5
|
+
// Permissive dev mode - always return true
|
|
6
|
+
return actionResult(true);
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export const getApiKeyValidationValidateActionProcessor = async (qpqConfig) => ({
|
|
10
|
+
[ApiKeyValidationActionType.Validate]: getProcessApiKeyValidationValidate(qpqConfig),
|
|
11
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { getApiKeyValidationValidateActionProcessor } from './getApiKeyValidationValidateActionProcessor';
|
|
2
|
+
export const getApiKeyValidationActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
3
|
+
...(await getApiKeyValidationValidateActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
4
|
+
});
|
package/lib/esm/actionProcessor/core/event/express/api/getEventAutoRespondActionProcessor.js
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (qpqEventRecord.method === 'OPTIONS') {
|
|
5
|
-
return actionResult({
|
|
6
|
-
status: 200,
|
|
7
|
-
isBase64Encoded: false,
|
|
8
|
-
body: '',
|
|
9
|
-
headers: qpqWebServerUtils.getCorsHeaders(qpqConfig, matchResult.config || {}, qpqEventRecord.headers),
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
return actionResult(null);
|
|
13
|
-
};
|
|
14
|
-
export const getEventAutoRespondActionProcessor = async (qpqConfig) => ({
|
|
15
|
-
[EventActionType.AutoRespond]: getProcessAutoRespond(qpqConfig),
|
|
1
|
+
import { getHttpApiEventAutoRespondActionProcessor } from 'quidproquo-webserver';
|
|
2
|
+
export const getEventAutoRespondActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
3
|
+
...(await getHttpApiEventAutoRespondActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
16
4
|
});
|
package/lib/esm/actionProcessor/core/event/express/api/getEventGetStorySessionActionProcessor.js
CHANGED
|
@@ -1,41 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const getProcessGetStorySession = (qpqConfig) => {
|
|
5
|
-
return async ({ matchStoryResult, qpqEventRecord }, session) => {
|
|
6
|
-
const accessToken = qpqWebServerUtils.getAccessTokenFromHeaders(qpqEventRecord.headers);
|
|
7
|
-
if (!accessToken) {
|
|
8
|
-
return actionResult(void 0);
|
|
9
|
-
}
|
|
10
|
-
// if this endpoint has no auth settings, BUT we do have an access token
|
|
11
|
-
// then we want to just attempt to extract info for logs, but we will say that its
|
|
12
|
-
// wasValid = false
|
|
13
|
-
if (!matchStoryResult.config?.routeAuthSettings?.userDirectoryName) {
|
|
14
|
-
// If this endpoint is unauthenticated, then we will just decode it, and say it wasnt valid, for logs
|
|
15
|
-
const info = qpqWebServerUtils.decodeJWT(accessToken);
|
|
16
|
-
return actionResult({
|
|
17
|
-
...session,
|
|
18
|
-
decodedAccessToken: {
|
|
19
|
-
exp: info?.exp || 0,
|
|
20
|
-
userDirectory: '',
|
|
21
|
-
userId: info?.sub || info?.id || info?.userId || info?.username || '',
|
|
22
|
-
username: info?.username || info?.userId || info?.sub || info?.id || '',
|
|
23
|
-
wasValid: false,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
// Use dev-optimized decoder that doesn't make AWS API calls
|
|
28
|
-
// TODO: THIS NEEDS TO BE CHANGED TO USE THE "AUTH" api in a custom implementation!
|
|
29
|
-
const decodedAccessToken = decodeAccessTokenForDev(matchStoryResult.config.routeAuthSettings.userDirectoryName, accessToken, true);
|
|
30
|
-
if (!decodedAccessToken) {
|
|
31
|
-
throw new Error('Unable to decode access token');
|
|
32
|
-
}
|
|
33
|
-
return actionResult({
|
|
34
|
-
...session,
|
|
35
|
-
decodedAccessToken,
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
export const getEventGetStorySessionActionProcessor = async (qpqConfig) => ({
|
|
40
|
-
[EventActionType.GetStorySession]: getProcessGetStorySession(qpqConfig),
|
|
1
|
+
import { getHttpApiEventGetStorySessionActionProcessor } from 'quidproquo-webserver';
|
|
2
|
+
export const getEventGetStorySessionActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
3
|
+
...(await getHttpApiEventGetStorySessionActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
41
4
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { actionResult, actionResultError, ErrorTypeEnum, EventBusActionType, qpqCoreUtils, } from 'quidproquo-core';
|
|
2
2
|
import { eventBus } from '../../../logic/eventBus';
|
|
3
3
|
const getProcessEventBusSendMessage = (qpqConfig) => {
|
|
4
|
-
return async ({ eventBusName, eventBusMessages,
|
|
4
|
+
return async ({ eventBusName, eventBusMessages, }, session) => {
|
|
5
5
|
const eventBusConfig = qpqCoreUtils.getEventBusConfigByName(eventBusName, qpqConfig);
|
|
6
6
|
if (!eventBusConfig) {
|
|
7
7
|
return actionResultError(ErrorTypeEnum.NotFound, `Event bus ${eventBusName} not found for service [${qpqCoreUtils.getApplicationModuleName(qpqConfig)}]`);
|
|
@@ -10,10 +10,7 @@ const getProcessEventBusSendMessage = (qpqConfig) => {
|
|
|
10
10
|
const eventBusEvent = {
|
|
11
11
|
payload: eventBusMessage.payload,
|
|
12
12
|
type: eventBusMessage.type,
|
|
13
|
-
storySession:
|
|
14
|
-
...session,
|
|
15
|
-
context,
|
|
16
|
-
},
|
|
13
|
+
storySession: session,
|
|
17
14
|
eventBusName: eventBusConfig.name,
|
|
18
15
|
targetApplication: eventBusConfig.owner?.application || qpqCoreUtils.getApplicationName(qpqConfig),
|
|
19
16
|
targetEnvironment: eventBusConfig.owner?.environment || qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig),
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { getFileActionProcessor } from 'quidproquo-actionprocessor-node';
|
|
2
|
+
import { getRouteAuthValidationActionProcessor } from 'quidproquo-webserver';
|
|
3
|
+
import { getApiKeyValidationActionProcessor } from './apiKeyValidation';
|
|
2
4
|
import { getEventBusActionProcessor } from './eventBus';
|
|
3
5
|
import { getGraphDatabaseActionProcessor } from './graphDatabaseOverride';
|
|
4
6
|
import { getKeyValueStoreActionProcessor } from './keyValueStore';
|
|
5
7
|
import { getLogActionProcessor } from './log';
|
|
6
8
|
import { getQueueActionProcessor } from './queue';
|
|
9
|
+
import { getUserDirectoryActionProcessor } from './userDirectory';
|
|
7
10
|
export const getCoreActionProcessor = async (qpqConfig, dynamicModuleLoader, devServerConfig) => {
|
|
8
11
|
return {
|
|
12
|
+
...(await getApiKeyValidationActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
9
13
|
...(await getGraphDatabaseActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
10
14
|
...(await getEventBusActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
11
15
|
...(await getQueueActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
12
16
|
...(await getLogActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
13
17
|
...(await getFileActionProcessor(devServerConfig.fileStorageConfig)(qpqConfig, dynamicModuleLoader)),
|
|
14
18
|
...(await getKeyValueStoreActionProcessor(devServerConfig)(qpqConfig, dynamicModuleLoader)),
|
|
19
|
+
...(await getRouteAuthValidationActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
20
|
+
...(await getUserDirectoryActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
15
21
|
};
|
|
16
22
|
};
|
|
@@ -3,7 +3,7 @@ import { actionResult, QueueActionType } from 'quidproquo-core';
|
|
|
3
3
|
import { v4 as uuidV4 } from 'uuid';
|
|
4
4
|
import { eventBus } from '../../../logic/eventBus';
|
|
5
5
|
const getProcessQueueSendMessage = (qpqConfig) => {
|
|
6
|
-
return async ({ queueName, queueMessages
|
|
6
|
+
return async ({ queueName, queueMessages }, session) => {
|
|
7
7
|
const queueConfig = qpqCoreUtils.getQueueByName(qpqConfig, queueName);
|
|
8
8
|
if (!queueConfig) {
|
|
9
9
|
return actionResultError(ErrorTypeEnum.NotFound, `Queue ${queueName} not found`);
|
|
@@ -12,10 +12,7 @@ const getProcessQueueSendMessage = (qpqConfig) => {
|
|
|
12
12
|
const queueEvent = {
|
|
13
13
|
payload: queueMessage.payload,
|
|
14
14
|
type: queueMessage.type,
|
|
15
|
-
storySession:
|
|
16
|
-
...session,
|
|
17
|
-
context,
|
|
18
|
-
},
|
|
15
|
+
storySession: session,
|
|
19
16
|
messageId: uuidV4(),
|
|
20
17
|
queueName: queueName,
|
|
21
18
|
targetApplication: queueConfig.owner?.application || qpqCoreUtils.getApplicationName(qpqConfig),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { actionResult, actionResultError, ErrorTypeEnum, UserDirectoryActionType, } from 'quidproquo-core';
|
|
2
|
+
import { decodeAccessTokenForDev } from '../../../logic/auth/decodeAccessTokenForDev';
|
|
3
|
+
const getProcessDecodeAccessToken = (_qpqConfig) => {
|
|
4
|
+
return async ({ userDirectoryName, accessToken, ignoreExpiration }) => {
|
|
5
|
+
const decodedAccessToken = decodeAccessTokenForDev(userDirectoryName, accessToken, ignoreExpiration);
|
|
6
|
+
if (!decodedAccessToken) {
|
|
7
|
+
return actionResultError(ErrorTypeEnum.Unauthorized, 'Invalid access token');
|
|
8
|
+
}
|
|
9
|
+
return actionResult(decodedAccessToken);
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export const getUserDirectoryDecodeAccessTokenActionProcessor = async (qpqConfig) => ({
|
|
13
|
+
[UserDirectoryActionType.DecodeAccessToken]: getProcessDecodeAccessToken(qpqConfig),
|
|
14
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { getUserDirectoryDecodeAccessTokenActionProcessor } from './getUserDirectoryDecodeAccessTokenActionProcessor';
|
|
2
|
+
export const getUserDirectoryActionProcessor = async (qpqConfig, dynamicModuleLoader) => ({
|
|
3
|
+
...(await getUserDirectoryDecodeAccessTokenActionProcessor(qpqConfig, dynamicModuleLoader)),
|
|
4
|
+
});
|
|
@@ -2,15 +2,12 @@ import { actionResult, actionResultError, } from 'quidproquo-core';
|
|
|
2
2
|
import { ServiceFunctionActionType } from 'quidproquo-webserver';
|
|
3
3
|
import { eventBus } from '../../../logic/eventBus';
|
|
4
4
|
const getProcessExecute = (qpqConfig, dynamicModuleLoader) => {
|
|
5
|
-
return async ({ functionName, service, payload,
|
|
5
|
+
return async ({ functionName, service, payload, isAsync }, session) => {
|
|
6
6
|
const serviceFunctionEvent = {
|
|
7
7
|
functionName: functionName,
|
|
8
8
|
serviceName: service,
|
|
9
9
|
payload: payload,
|
|
10
|
-
storySession:
|
|
11
|
-
...session,
|
|
12
|
-
context,
|
|
13
|
-
},
|
|
10
|
+
storySession: session,
|
|
14
11
|
};
|
|
15
12
|
const eventPromise = eventBus.publishAndWaitForResponse(ServiceFunctionActionType.Execute, serviceFunctionEvent);
|
|
16
13
|
if (isAsync) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-dev-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.263",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"chalk": "^4.1.2",
|
|
36
36
|
"chokidar": "^4.0.3",
|
|
37
37
|
"multer": "^1.4.5-lts.1",
|
|
38
|
-
"quidproquo-actionprocessor-awslambda": "0.0.
|
|
39
|
-
"quidproquo-actionprocessor-node": "0.0.
|
|
40
|
-
"quidproquo-core": "0.0.
|
|
41
|
-
"quidproquo-webserver": "0.0.
|
|
38
|
+
"quidproquo-actionprocessor-awslambda": "0.0.263",
|
|
39
|
+
"quidproquo-actionprocessor-node": "0.0.263",
|
|
40
|
+
"quidproquo-core": "0.0.263",
|
|
41
|
+
"quidproquo-webserver": "0.0.263",
|
|
42
42
|
"sqlite": "^5.1.1",
|
|
43
43
|
"sqlite3": "^5.1.7",
|
|
44
44
|
"ws": "^8.18.0"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/multer": "^1.4.12",
|
|
48
48
|
"@types/sqlite3": "^3.1.11",
|
|
49
|
-
"quidproquo-tsconfig": "0.0.
|
|
49
|
+
"quidproquo-tsconfig": "0.0.263",
|
|
50
50
|
"typescript": "^5.8.2"
|
|
51
51
|
}
|
|
52
52
|
}
|