quidproquo-actionprocessor-awslambda 0.0.100 → 0.0.102

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.
Files changed (50) hide show
  1. package/lib/getActionProcessor/core/event/utils/isAuthValid.js +1 -3
  2. package/lib/getActionProcessor/core/keyValueStore/getKeyValueStoreQueryActionProcessor.d.ts +6 -0
  3. package/lib/getActionProcessor/core/keyValueStore/getKeyValueStoreQueryActionProcessor.js +31 -0
  4. package/lib/getActionProcessor/core/keyValueStore/getKeyValueStoreScanActionProcessor.d.ts +6 -0
  5. package/lib/getActionProcessor/core/keyValueStore/{getKeyValueStoreSetActionProcessor.js → getKeyValueStoreScanActionProcessor.js} +10 -8
  6. package/lib/getActionProcessor/core/keyValueStore/getKeyValueStoreUpsertActionProcessor.d.ts +5 -0
  7. package/lib/getActionProcessor/core/keyValueStore/getKeyValueStoreUpsertActionProcessor.js +38 -0
  8. package/lib/getActionProcessor/core/keyValueStore/index.d.ts +3 -1
  9. package/lib/getActionProcessor/core/keyValueStore/index.js +4 -2
  10. package/lib/getActionProcessor/core/userDirectory/getUserDirectoryGetUserAttributesActionProcessor.d.ts +5 -0
  11. package/lib/getActionProcessor/core/userDirectory/getUserDirectoryGetUserAttributesActionProcessor.js +28 -0
  12. package/lib/getActionProcessor/core/userDirectory/getUserDirectoryReadAccessTokenActionProcessor.js +2 -3
  13. package/lib/getActionProcessor/core/userDirectory/getUserDirectoryRefreshTokenActionProcessor.js +1 -1
  14. package/lib/getActionProcessor/core/userDirectory/getUserDirectorySetUserAttributesActionProcessor.d.ts +5 -0
  15. package/lib/getActionProcessor/core/userDirectory/getUserDirectorySetUserAttributesActionProcessor.js +28 -0
  16. package/lib/getActionProcessor/core/userDirectory/index.d.ts +2 -0
  17. package/lib/getActionProcessor/core/userDirectory/index.js +3 -1
  18. package/lib/logic/cognito/cognitoAttributeMap.d.ts +10 -0
  19. package/lib/logic/cognito/cognitoAttributeMap.js +50 -0
  20. package/lib/logic/cognito/createUser.d.ts +0 -4
  21. package/lib/logic/cognito/createUser.js +3 -31
  22. package/lib/logic/cognito/decodeValidJwt.d.ts +1 -1
  23. package/lib/logic/cognito/decodeValidJwt.js +21 -11
  24. package/lib/logic/cognito/getUser.js +0 -2
  25. package/lib/logic/cognito/getUserAttributes.d.ts +2 -0
  26. package/lib/logic/cognito/getUserAttributes.js +26 -0
  27. package/lib/logic/cognito/requestEmailVerificationCode.js +0 -1
  28. package/lib/logic/cognito/respondToAuthChallengeChallenge.js +0 -1
  29. package/lib/logic/cognito/setUserAttributes.d.ts +2 -0
  30. package/lib/logic/cognito/setUserAttributes.js +36 -0
  31. package/lib/logic/cognito/verifyJwt.d.ts +1 -1
  32. package/lib/logic/cognito/verifyJwt.js +2 -2
  33. package/lib/logic/dynamo/convertObjectToDynamoMap.d.ts +2 -0
  34. package/lib/logic/dynamo/convertObjectToDynamoMap.js +69 -0
  35. package/lib/logic/dynamo/index.d.ts +1 -0
  36. package/lib/logic/dynamo/index.js +1 -0
  37. package/lib/logic/dynamo/putItem.d.ts +9 -1
  38. package/lib/logic/dynamo/putItem.js +35 -3
  39. package/lib/logic/dynamo/qpqDynamoOrm/buildDynamoQuery.d.ts +7 -0
  40. package/lib/logic/dynamo/qpqDynamoOrm/buildDynamoQuery.js +187 -0
  41. package/lib/logic/dynamo/qpqDynamoOrm/index.d.ts +1 -0
  42. package/lib/logic/dynamo/qpqDynamoOrm/index.js +17 -0
  43. package/lib/logic/dynamo/qpqDynamoOrm/thing.d.ts +2 -0
  44. package/lib/logic/dynamo/qpqDynamoOrm/thing.js +26 -0
  45. package/lib/logic/dynamo/query.d.ts +2 -0
  46. package/lib/logic/dynamo/query.js +38 -0
  47. package/lib/logic/dynamo/scan.d.ts +2 -0
  48. package/lib/logic/dynamo/scan.js +35 -0
  49. package/package.json +6 -1
  50. package/lib/getActionProcessor/core/keyValueStore/getKeyValueStoreSetActionProcessor.d.ts +0 -6
@@ -34,10 +34,8 @@ const isAuthValidForCognito = (qpqConfig, authSettings, authHeader) => __awaiter
34
34
  const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
35
35
  // Resolve the user pool id
36
36
  const userPoolId = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameUserPoolIdFromConfig)(userDirectoryName, qpqConfig, authSettings.serviceName, authSettings.applicationName), region);
37
- // Resolve the user pool client id
38
- const userPoolClientId = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameUserPoolClientIdFromConfig)(userDirectoryName, qpqConfig, authSettings.serviceName, authSettings.applicationName), region);
39
37
  // Verify the token
40
- return yield (0, verifyJwt_1.verifyJwt)(accessToken, userPoolId, userPoolClientId, 'access');
38
+ return yield (0, verifyJwt_1.verifyJwt)(accessToken, userPoolId, region, false);
41
39
  });
42
40
  const isAuthValidForApiKeys = (qpqConfig, authSettings, apiKeyHeader) => __awaiter(void 0, void 0, void 0, function* () {
43
41
  const apiKeys = authSettings.apiKeys || [];
@@ -0,0 +1,6 @@
1
+ import { QPQConfig } from 'quidproquo-core';
2
+ import { KeyValueStoreQueryActionProcessor } from 'quidproquo-core';
3
+ declare const _default: (qpqConfig: QPQConfig) => {
4
+ "@quidproquo-core/KeyValueStore/Query": KeyValueStoreQueryActionProcessor<any>;
5
+ };
6
+ export default _default;
@@ -0,0 +1,31 @@
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
+ const quidproquo_core_1 = require("quidproquo-core");
13
+ const awsNamingUtils_1 = require("../../../awsNamingUtils");
14
+ const quidproquo_core_2 = require("quidproquo-core");
15
+ const dynamo_1 = require("../../../logic/dynamo");
16
+ const thing_1 = require("../../../logic/dynamo/qpqDynamoOrm/thing");
17
+ const getProcessKeyValueStoreQuery = (qpqConfig) => {
18
+ return ({ keyValueStoreName, keyCondition, filterCondition }) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const dynamoTableName = (0, awsNamingUtils_1.getQpqRuntimeResourceNameFromConfig)(keyValueStoreName, qpqConfig, 'kvs');
20
+ const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
21
+ const storeConfig = quidproquo_core_1.qpqCoreUtils.getKeyValueStoreByName(qpqConfig, keyValueStoreName);
22
+ if (!storeConfig) {
23
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Could not find key value store with name "${keyValueStoreName}"`);
24
+ }
25
+ const items = yield (0, dynamo_1.query)(dynamoTableName, region, keyCondition, filterCondition, (0, thing_1.getDynamoTableIndexByConfigAndQuery)(storeConfig, keyCondition));
26
+ return (0, quidproquo_core_2.actionResult)(items);
27
+ });
28
+ };
29
+ exports.default = (qpqConfig) => ({
30
+ [quidproquo_core_2.KeyValueStoreActionType.Query]: getProcessKeyValueStoreQuery(qpqConfig),
31
+ });
@@ -0,0 +1,6 @@
1
+ import { QPQConfig } from 'quidproquo-core';
2
+ import { KeyValueStoreScanActionProcessor } from 'quidproquo-core';
3
+ declare const _default: (qpqConfig: QPQConfig) => {
4
+ "@quidproquo-core/KeyValueStore/Scan": KeyValueStoreScanActionProcessor<any>;
5
+ };
6
+ export default _default;
@@ -12,17 +12,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const quidproquo_core_1 = require("quidproquo-core");
13
13
  const awsNamingUtils_1 = require("../../../awsNamingUtils");
14
14
  const quidproquo_core_2 = require("quidproquo-core");
15
- const dynamo_1 = require("../../../logic/dynamo");
16
- const getProcessKeyValueStoreSet = (qpqConfig) => {
17
- return ({ keyValueStoreName, key, value, options }) => __awaiter(void 0, void 0, void 0, function* () {
15
+ const scan_1 = require("../../../logic/dynamo/scan");
16
+ const getProcessKeyValueStoreScan = (qpqConfig) => {
17
+ return ({ keyValueStoreName, filterCondition }) => __awaiter(void 0, void 0, void 0, function* () {
18
18
  const dynamoTableName = (0, awsNamingUtils_1.getQpqRuntimeResourceNameFromConfig)(keyValueStoreName, qpqConfig, 'kvs');
19
19
  const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
20
- yield (0, dynamo_1.putItem)(dynamoTableName, key, value, {
21
- expires: options === null || options === void 0 ? void 0 : options.ttl,
22
- }, region);
23
- return (0, quidproquo_core_2.actionResult)(void 0);
20
+ const storeConfig = quidproquo_core_1.qpqCoreUtils.getKeyValueStoreByName(qpqConfig, keyValueStoreName);
21
+ if (!storeConfig) {
22
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Could not find key value store with name "${keyValueStoreName}"`);
23
+ }
24
+ const items = yield (0, scan_1.scan)(dynamoTableName, region, filterCondition);
25
+ return (0, quidproquo_core_2.actionResult)(items);
24
26
  });
25
27
  };
26
28
  exports.default = (qpqConfig) => ({
27
- [quidproquo_core_2.KeyValueStoreActionType.Set]: getProcessKeyValueStoreSet(qpqConfig),
29
+ [quidproquo_core_2.KeyValueStoreActionType.Scan]: getProcessKeyValueStoreScan(qpqConfig),
28
30
  });
@@ -0,0 +1,5 @@
1
+ import { QPQConfig, KeyValueStoreUpsertActionProcessor } from 'quidproquo-core';
2
+ declare const _default: (qpqConfig: QPQConfig) => {
3
+ "@quidproquo-core/KeyValueStore/Upsert": KeyValueStoreUpsertActionProcessor<any>;
4
+ };
5
+ export default _default;
@@ -0,0 +1,38 @@
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
+ const quidproquo_core_1 = require("quidproquo-core");
13
+ const awsNamingUtils_1 = require("../../../awsNamingUtils");
14
+ const dynamo_1 = require("../../../logic/dynamo");
15
+ const getProcessKeyValueStoreUpsert = (qpqConfig) => {
16
+ return ({ keyValueStoreName, item, options }) => __awaiter(void 0, void 0, void 0, function* () {
17
+ console.log('HERE!');
18
+ const dynamoTableName = (0, awsNamingUtils_1.getQpqRuntimeResourceNameFromConfig)(keyValueStoreName, qpqConfig, 'kvs');
19
+ const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
20
+ const storeConfig = quidproquo_core_1.qpqCoreUtils.getKeyValueStoreByName(qpqConfig, keyValueStoreName);
21
+ if (!storeConfig) {
22
+ return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Could not find key value store with name "${keyValueStoreName}"`);
23
+ }
24
+ const keys = [
25
+ storeConfig.partitionKey,
26
+ ...storeConfig.sortKeys,
27
+ ...storeConfig.indexes.map((i) => i.partitionKey),
28
+ ...storeConfig.indexes.filter((i) => !!i.sortKey).map((i) => i.sortKey),
29
+ ];
30
+ yield (0, dynamo_1.putItem)(dynamoTableName, item, keys, {
31
+ expires: options === null || options === void 0 ? void 0 : options.ttlInSeconds,
32
+ }, region);
33
+ return (0, quidproquo_core_1.actionResult)(void 0);
34
+ });
35
+ };
36
+ exports.default = (qpqConfig) => ({
37
+ [quidproquo_core_1.KeyValueStoreActionType.Upsert]: getProcessKeyValueStoreUpsert(qpqConfig),
38
+ });
@@ -1,7 +1,9 @@
1
1
  import { QPQConfig } from 'quidproquo-core';
2
2
  declare const _default: (qpqConfig: QPQConfig) => {
3
+ "@quidproquo-core/KeyValueStore/Scan": import("quidproquo-core").KeyValueStoreScanActionProcessor<any>;
4
+ "@quidproquo-core/KeyValueStore/Upsert": import("quidproquo-core").KeyValueStoreUpsertActionProcessor<any>;
3
5
  "@quidproquo-core/KeyValueStore/Update": import("quidproquo-core").KeyValueStoreUpdateActionProcessor<any>;
4
- "@quidproquo-core/KeyValueStore/Set": import("quidproquo-core").KeyValueStoreSetActionProcessor<any>;
6
+ "@quidproquo-core/KeyValueStore/Query": import("quidproquo-core").KeyValueStoreQueryActionProcessor<any>;
5
7
  "@quidproquo-core/KeyValueStore/Get": import("quidproquo-core").KeyValueStoreGetActionProcessor<any>;
6
8
  "@quidproquo-core/KeyValueStore/Delete": import("quidproquo-core").KeyValueStoreDeleteActionProcessor;
7
9
  };
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const getKeyValueStoreDeleteActionProcessor_1 = __importDefault(require("./getKeyValueStoreDeleteActionProcessor"));
7
7
  const getKeyValueStoreGetActionProcessor_1 = __importDefault(require("./getKeyValueStoreGetActionProcessor"));
8
- const getKeyValueStoreSetActionProcessor_1 = __importDefault(require("./getKeyValueStoreSetActionProcessor"));
8
+ const getKeyValueStoreUpsertActionProcessor_1 = __importDefault(require("./getKeyValueStoreUpsertActionProcessor"));
9
9
  const getKeyValueStoreUpdateActionProcessor_1 = __importDefault(require("./getKeyValueStoreUpdateActionProcessor"));
10
- exports.default = (qpqConfig) => (Object.assign(Object.assign(Object.assign(Object.assign({}, (0, getKeyValueStoreDeleteActionProcessor_1.default)(qpqConfig)), (0, getKeyValueStoreGetActionProcessor_1.default)(qpqConfig)), (0, getKeyValueStoreSetActionProcessor_1.default)(qpqConfig)), (0, getKeyValueStoreUpdateActionProcessor_1.default)(qpqConfig)));
10
+ const getKeyValueStoreQueryActionProcessor_1 = __importDefault(require("./getKeyValueStoreQueryActionProcessor"));
11
+ const getKeyValueStoreScanActionProcessor_1 = __importDefault(require("./getKeyValueStoreScanActionProcessor"));
12
+ exports.default = (qpqConfig) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, getKeyValueStoreDeleteActionProcessor_1.default)(qpqConfig)), (0, getKeyValueStoreGetActionProcessor_1.default)(qpqConfig)), (0, getKeyValueStoreQueryActionProcessor_1.default)(qpqConfig)), (0, getKeyValueStoreUpdateActionProcessor_1.default)(qpqConfig)), (0, getKeyValueStoreUpsertActionProcessor_1.default)(qpqConfig)), (0, getKeyValueStoreScanActionProcessor_1.default)(qpqConfig)));
@@ -0,0 +1,5 @@
1
+ import { UserDirectoryGetUserAttributesActionProcessor, QPQConfig } from 'quidproquo-core';
2
+ declare const _default: (qpqConfig: QPQConfig) => {
3
+ "@quidproquo-core/UserDirectory/GetUserAttributes": UserDirectoryGetUserAttributesActionProcessor;
4
+ };
5
+ export default _default;
@@ -0,0 +1,28 @@
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
+ const quidproquo_core_1 = require("quidproquo-core");
13
+ const awsNamingUtils_1 = require("../../../awsNamingUtils");
14
+ const getExportedValue_1 = require("../../../logic/cloudformation/getExportedValue");
15
+ const getUserAttributes_1 = require("../../../logic/cognito/getUserAttributes");
16
+ const getUserDirectoryGetUserAttributesActionProcessor = (qpqConfig) => {
17
+ return ({ userDirectoryName, serviceOverride, username }, session) => __awaiter(void 0, void 0, void 0, function* () {
18
+ const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
19
+ const userPoolId = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameUserPoolIdFromConfig)(userDirectoryName, qpqConfig, serviceOverride), region);
20
+ const userAttributes = yield (0, getUserAttributes_1.getUserAttributes)(userPoolId, region, username);
21
+ return (0, quidproquo_core_1.actionResult)(userAttributes);
22
+ });
23
+ };
24
+ exports.default = (qpqConfig) => {
25
+ return {
26
+ [quidproquo_core_1.UserDirectoryActionType.GetUserAttributes]: getUserDirectoryGetUserAttributesActionProcessor(qpqConfig),
27
+ };
28
+ };
@@ -14,11 +14,10 @@ const awsNamingUtils_1 = require("../../../awsNamingUtils");
14
14
  const getExportedValue_1 = require("../../../logic/cloudformation/getExportedValue");
15
15
  const decodeValidJwt_1 = require("../../../logic/cognito/decodeValidJwt");
16
16
  const getUserDirectoryReadAccessTokenActionProcessor = (qpqConfig) => {
17
- return ({ userDirectoryName, serviceOverride }, session) => __awaiter(void 0, void 0, void 0, function* () {
17
+ return ({ userDirectoryName, serviceOverride, ignoreExpiration }, session) => __awaiter(void 0, void 0, void 0, function* () {
18
18
  const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
19
19
  const userPoolId = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameUserPoolIdFromConfig)(userDirectoryName, qpqConfig, serviceOverride), region);
20
- const userPoolClientId = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameUserPoolClientIdFromConfig)(userDirectoryName, qpqConfig, serviceOverride), region);
21
- const authInfo = yield (0, decodeValidJwt_1.decodeValidJwt)(userPoolId, userPoolClientId, 'access', session.accessToken);
20
+ const authInfo = yield (0, decodeValidJwt_1.decodeValidJwt)(userPoolId, region, ignoreExpiration, session.accessToken);
22
21
  if (!authInfo || !(authInfo === null || authInfo === void 0 ? void 0 : authInfo.username)) {
23
22
  return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.Unauthorized, 'Invalid accessToken');
24
23
  }
@@ -19,7 +19,7 @@ const getUserDirectoryRefreshTokenActionProcessor = (qpqConfig) => {
19
19
  const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
20
20
  const userPoolId = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameUserPoolIdFromConfig)(userDirectoryName, qpqConfig), region);
21
21
  const userPoolClientId = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameUserPoolClientIdFromConfig)(userDirectoryName, qpqConfig), region);
22
- const authInfo = yield (0, decodeValidJwt_1.decodeValidJwt)(userPoolId, userPoolClientId, 'access', session.accessToken);
22
+ const authInfo = yield (0, decodeValidJwt_1.decodeValidJwt)(userPoolId, region, true, session.accessToken);
23
23
  if (!authInfo || !(authInfo === null || authInfo === void 0 ? void 0 : authInfo.username)) {
24
24
  return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.Unauthorized, 'Invalid accessToken');
25
25
  }
@@ -0,0 +1,5 @@
1
+ import { UserDirectorySetUserAttributesActionProcessor, QPQConfig } from 'quidproquo-core';
2
+ declare const _default: (qpqConfig: QPQConfig) => {
3
+ "@quidproquo-core/UserDirectory/SetUserAttributes": UserDirectorySetUserAttributesActionProcessor;
4
+ };
5
+ export default _default;
@@ -0,0 +1,28 @@
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
+ const quidproquo_core_1 = require("quidproquo-core");
13
+ const awsNamingUtils_1 = require("../../../awsNamingUtils");
14
+ const getExportedValue_1 = require("../../../logic/cloudformation/getExportedValue");
15
+ const setUserAttributes_1 = require("../../../logic/cognito/setUserAttributes");
16
+ const getUserDirectorySetUserAttributesActionProcessor = (qpqConfig) => {
17
+ return ({ userDirectoryName, serviceOverride, username, userAttributes }, session) => __awaiter(void 0, void 0, void 0, function* () {
18
+ const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
19
+ const userPoolId = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameUserPoolIdFromConfig)(userDirectoryName, qpqConfig, serviceOverride), region);
20
+ yield (0, setUserAttributes_1.setUserAttributes)(userPoolId, region, username, userAttributes);
21
+ return (0, quidproquo_core_1.actionResult)(void 0);
22
+ });
23
+ };
24
+ exports.default = (qpqConfig) => {
25
+ return {
26
+ [quidproquo_core_1.UserDirectoryActionType.SetUserAttributes]: getUserDirectorySetUserAttributesActionProcessor(qpqConfig),
27
+ };
28
+ };
@@ -1,9 +1,11 @@
1
1
  import { QPQConfig } from 'quidproquo-core';
2
2
  declare const _default: (qpqConfig: QPQConfig) => {
3
+ "@quidproquo-core/UserDirectory/SetUserAttributes": import("quidproquo-core").UserDirectorySetUserAttributesActionProcessor;
3
4
  "@quidproquo-core/UserDirectory/RespondToAuthChallenge": import("quidproquo-core").UserDirectoryRespondToAuthChallengeActionProcessor;
4
5
  "@quidproquo-core/UserDirectory/RequestEmailVerification": import("quidproquo-core").UserDirectoryRequestEmailVerificationActionProcessor;
5
6
  "@quidproquo-core/UserDirectory/RefreshToken": import("quidproquo-core").UserDirectoryRefreshTokenActionProcessor;
6
7
  "@quidproquo-core/UserDirectory/ReadAccessToken": import("quidproquo-core").UserDirectoryReadAccessTokenActionProcessor;
8
+ "@quidproquo-core/UserDirectory/GetUserAttributes": import("quidproquo-core").UserDirectoryGetUserAttributesActionProcessor;
7
9
  "@quidproquo-core/UserDirectory/ForgotPassword": import("quidproquo-core").UserDirectoryForgotPasswordActionProcessor;
8
10
  "@quidproquo-core/UserDirectory/CreateUser": import("quidproquo-core").UserDirectoryCreateUserActionProcessor;
9
11
  "@quidproquo-core/UserDirectory/ConfirmForgotPassword": import("quidproquo-core").UserDirectoryConfirmForgotPasswordActionProcessor;
@@ -8,8 +8,10 @@ const getUserDirectoryConfirmEmailVerificationActionProcessor_1 = __importDefaul
8
8
  const getUserDirectoryConfirmForgetPasswordActionProcessor_1 = __importDefault(require("./getUserDirectoryConfirmForgetPasswordActionProcessor"));
9
9
  const getUserDirectoryCreateUserActionProcessor_1 = __importDefault(require("./getUserDirectoryCreateUserActionProcessor"));
10
10
  const getUserDirectoryForgetPasswordActionProcessor_1 = __importDefault(require("./getUserDirectoryForgetPasswordActionProcessor"));
11
+ const getUserDirectoryGetUserAttributesActionProcessor_1 = __importDefault(require("./getUserDirectoryGetUserAttributesActionProcessor"));
11
12
  const getUserDirectoryReadAccessTokenActionProcessor_1 = __importDefault(require("./getUserDirectoryReadAccessTokenActionProcessor"));
12
13
  const getUserDirectoryRefreshTokenActionProcessor_1 = __importDefault(require("./getUserDirectoryRefreshTokenActionProcessor"));
13
14
  const getUserDirectoryRequestEmailVerificationActionProcessor_1 = __importDefault(require("./getUserDirectoryRequestEmailVerificationActionProcessor"));
14
15
  const getUserDirectoryRespondToAuthChallengeActionProcessor_1 = __importDefault(require("./getUserDirectoryRespondToAuthChallengeActionProcessor"));
15
- exports.default = (qpqConfig) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, getUserDirectoryAuthenticateUserActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryConfirmEmailVerificationActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryConfirmForgetPasswordActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryCreateUserActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryForgetPasswordActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryReadAccessTokenActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryRefreshTokenActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryRequestEmailVerificationActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryRespondToAuthChallengeActionProcessor_1.default)(qpqConfig)));
16
+ const getUserDirectorySetUserAttributesActionProcessor_1 = __importDefault(require("./getUserDirectorySetUserAttributesActionProcessor"));
17
+ exports.default = (qpqConfig) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, getUserDirectoryAuthenticateUserActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryConfirmEmailVerificationActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryConfirmForgetPasswordActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryCreateUserActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryForgetPasswordActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryGetUserAttributesActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryReadAccessTokenActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryRefreshTokenActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryRequestEmailVerificationActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryRespondToAuthChallengeActionProcessor_1.default)(qpqConfig)), (0, getUserDirectorySetUserAttributesActionProcessor_1.default)(qpqConfig)));
@@ -0,0 +1,10 @@
1
+ import { UserAttributes } from 'quidproquo-core';
2
+ export declare const cognitoAttributeMap: Record<keyof UserAttributes, string>;
3
+ export declare const getCognitoUserAttributesFromQpqUserAttributes: (userAttributes: UserAttributes) => {
4
+ Name: string;
5
+ Value: string;
6
+ }[];
7
+ export declare const getQpqAttributesFromCognitoUserAttributes: (cognitoUserAttributes: {
8
+ Name: string;
9
+ Value: string;
10
+ }[]) => UserAttributes;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getQpqAttributesFromCognitoUserAttributes = exports.getCognitoUserAttributesFromQpqUserAttributes = exports.cognitoAttributeMap = void 0;
4
+ exports.cognitoAttributeMap = {
5
+ email: 'email',
6
+ emailVerified: 'email_verified',
7
+ userId: 'sub',
8
+ address: 'address',
9
+ birthDate: 'birthdate',
10
+ familyName: 'family_name',
11
+ gender: 'gender',
12
+ givenName: 'given_name',
13
+ locale: 'locale',
14
+ middleName: 'middle_name',
15
+ name: 'name',
16
+ nickname: 'nickname',
17
+ phoneNumber: 'phone_number',
18
+ picture: 'picture',
19
+ preferredUsername: 'preferred_username',
20
+ profile: 'profile',
21
+ website: 'website',
22
+ zoneInfo: 'zoneinfo',
23
+ };
24
+ // Flip the cognitoAttributeMap for reverse mapping
25
+ const reversedCognitoAttributeMap = Object.entries(exports.cognitoAttributeMap).reduce((acc, [key, value]) => (Object.assign(Object.assign({}, acc), { [value]: key })), {});
26
+ const getCognitoUserAttributesFromQpqUserAttributes = (userAttributes) => {
27
+ return Object.keys(userAttributes)
28
+ .map((key) => ({
29
+ Name: exports.cognitoAttributeMap[key],
30
+ Value: `${userAttributes[key]}`,
31
+ }))
32
+ .filter((attribute) => !!attribute.Name && !!attribute.Value);
33
+ };
34
+ exports.getCognitoUserAttributesFromQpqUserAttributes = getCognitoUserAttributesFromQpqUserAttributes;
35
+ const getQpqAttributesFromCognitoUserAttributes = (cognitoUserAttributes) => {
36
+ // Map cognitoUserAttributes to your UserAttributes format
37
+ const userAttributes = cognitoUserAttributes.reduce((acc, { Name, Value }) => {
38
+ const userAttributeKey = reversedCognitoAttributeMap[Name];
39
+ if (!userAttributeKey) {
40
+ return acc; // If there's no matching key in your mapping, just continue with the current accumulation
41
+ }
42
+ if (userAttributeKey === 'emailVerified') {
43
+ // Assume the value of 'email_verified' is a string of 'true' or 'false'
44
+ return Object.assign(Object.assign({}, acc), { [userAttributeKey]: Value === 'true' });
45
+ }
46
+ return Object.assign(Object.assign({}, acc), { [userAttributeKey]: Value });
47
+ }, {});
48
+ return userAttributes;
49
+ };
50
+ exports.getQpqAttributesFromCognitoUserAttributes = getQpqAttributesFromCognitoUserAttributes;
@@ -1,6 +1,2 @@
1
1
  import { CreateUserRequest, AuthenticateUserResponse } from 'quidproquo-core';
2
- export declare const getUserAttributesFromCreateUserRequest: (createUserRequest: CreateUserRequest) => {
3
- Name: string;
4
- Value: string;
5
- }[];
6
2
  export declare const createUser: (userPoolId: string, region: string, clientId: string, createUserRequest: CreateUserRequest) => Promise<AuthenticateUserResponse>;
@@ -9,39 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createUser = exports.getUserAttributesFromCreateUserRequest = void 0;
12
+ exports.createUser = void 0;
13
13
  const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
14
14
  const authenticateUser_1 = require("./authenticateUser");
15
15
  const setUserPassword_1 = require("./setUserPassword");
16
- const cognitoAttributeMap = {
17
- email: 'email',
18
- emailVerified: 'email_verified',
19
- password: 'password',
20
- address: 'address',
21
- birthDate: 'birthdate',
22
- familyName: 'family_name',
23
- gender: 'gender',
24
- givenName: 'given_name',
25
- locale: 'locale',
26
- middleName: 'middle_name',
27
- name: 'name',
28
- nickname: 'nickname',
29
- phoneNumber: 'phone_number',
30
- picture: 'picture',
31
- preferredUsername: 'preferred_username',
32
- profile: 'profile',
33
- website: 'website',
34
- zoneInfo: 'zoneinfo',
35
- };
36
- const getUserAttributesFromCreateUserRequest = (createUserRequest) => {
37
- return Object.keys(createUserRequest)
38
- .map((key) => ({
39
- Name: cognitoAttributeMap[key],
40
- Value: `${createUserRequest[key]}`,
41
- }))
42
- .filter((attribute) => !!attribute.Value && attribute.Name !== 'password');
43
- };
44
- exports.getUserAttributesFromCreateUserRequest = getUserAttributesFromCreateUserRequest;
16
+ const cognitoAttributeMap_1 = require("./cognitoAttributeMap");
45
17
  const createUser = (userPoolId, region, clientId, createUserRequest) => __awaiter(void 0, void 0, void 0, function* () {
46
18
  var _a;
47
19
  const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
@@ -50,7 +22,7 @@ const createUser = (userPoolId, region, clientId, createUserRequest) => __awaite
50
22
  Username: createUserRequest.email,
51
23
  MessageAction: client_cognito_identity_provider_1.MessageActionType.SUPPRESS,
52
24
  DesiredDeliveryMediums: [client_cognito_identity_provider_1.DeliveryMediumType.EMAIL],
53
- UserAttributes: (0, exports.getUserAttributesFromCreateUserRequest)(createUserRequest),
25
+ UserAttributes: (0, cognitoAttributeMap_1.getCognitoUserAttributesFromQpqUserAttributes)(createUserRequest),
54
26
  ForceAliasCreation: false,
55
27
  };
56
28
  if (createUserRequest.phoneNumber) {
@@ -2,4 +2,4 @@ export type AuthInfo = {
2
2
  userId: string;
3
3
  username: string;
4
4
  };
5
- export declare const decodeValidJwt: (userPoolId: string, clientId: string, tokenType: 'id' | 'access', accessToken?: string) => Promise<AuthInfo | null>;
5
+ export declare const decodeValidJwt: (userPoolId: string, region: string, ignoreExpiration: boolean, accessToken?: string) => Promise<AuthInfo | null>;
@@ -8,28 +8,38 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.decodeValidJwt = void 0;
13
- const aws_jwt_verify_1 = require("aws-jwt-verify");
14
- const decodeValidJwt = (userPoolId, clientId, tokenType, accessToken) => __awaiter(void 0, void 0, void 0, function* () {
15
- var _a;
16
+ const jsonwebtoken_1 = require("jsonwebtoken");
17
+ const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
18
+ const decodeValidJwt = (userPoolId, region, ignoreExpiration, accessToken) => __awaiter(void 0, void 0, void 0, function* () {
16
19
  if (!accessToken) {
17
20
  return null;
18
21
  }
19
- const verifier = aws_jwt_verify_1.CognitoJwtVerifier.create({
20
- userPoolId: userPoolId,
21
- tokenUse: tokenType,
22
- clientId: clientId,
23
- });
24
22
  try {
25
- const payload = yield verifier.verify(accessToken);
23
+ const decodedToken = (0, jsonwebtoken_1.decode)(accessToken, { complete: true });
24
+ if (!decodedToken) {
25
+ return null;
26
+ }
27
+ const client = (0, jwks_rsa_1.default)({
28
+ jwksUri: `https://cognito-idp.${region}.amazonaws.com/${userPoolId}/.well-known/jwks.json`,
29
+ });
30
+ const key = yield client.getSigningKey(decodedToken.header.kid);
31
+ const signingKey = key.getPublicKey();
32
+ const payload = (0, jsonwebtoken_1.verify)(accessToken, signingKey, {
33
+ algorithms: ['RS256'],
34
+ ignoreExpiration,
35
+ });
26
36
  return {
27
37
  userId: payload.sub,
28
- username: ((_a = payload.username) === null || _a === void 0 ? void 0 : _a.toString()) || '',
38
+ username: payload.username,
29
39
  };
30
40
  }
31
41
  catch (e) {
32
- console.log('Invalid jwt token', e);
42
+ console.log('Failed to decode jwt token', e);
33
43
  return null;
34
44
  }
35
45
  });
@@ -22,7 +22,6 @@ const getUser = (accessToken, region) => __awaiter(void 0, void 0, void 0, funct
22
22
  AccessToken: accessToken,
23
23
  };
24
24
  const response = yield cognitoClient.send(new client_cognito_identity_provider_1.GetUserCommand(params));
25
- console.log(JSON.stringify(response, null, 2));
26
25
  const attributeTypes = (response.UserAttributes || []).filter((ua) => !!ua.Value);
27
26
  const userAttributes = attributeTypes.reduce((acc, ua) => (Object.assign(Object.assign({}, acc), { [ua.Name]: ua.Value })), {});
28
27
  const user = {
@@ -31,7 +30,6 @@ const getUser = (accessToken, region) => __awaiter(void 0, void 0, void 0, funct
31
30
  email: getUserAttribute('email', attributeTypes),
32
31
  userAttributes,
33
32
  };
34
- console.log(JSON.stringify(user, null, 2));
35
33
  return user;
36
34
  });
37
35
  exports.getUser = getUser;
@@ -0,0 +1,2 @@
1
+ import { UserAttributes } from 'quidproquo-core';
2
+ export declare const getUserAttributes: (userPoolId: string, region: string, username: string) => Promise<UserAttributes>;
@@ -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.getUserAttributes = void 0;
13
+ const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
14
+ const cognitoAttributeMap_1 = require("./cognitoAttributeMap");
15
+ const getUserAttributes = (userPoolId, region, username) => __awaiter(void 0, void 0, void 0, function* () {
16
+ const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
17
+ const params = {
18
+ UserPoolId: userPoolId,
19
+ Username: username,
20
+ };
21
+ const response = yield cognitoClient.send(new client_cognito_identity_provider_1.AdminGetUserCommand(params));
22
+ const validAttributes = (response.UserAttributes || []).filter((attr) => attr.Name && attr.Value);
23
+ const attributes = (0, cognitoAttributeMap_1.getQpqAttributesFromCognitoUserAttributes)(validAttributes);
24
+ return attributes;
25
+ });
26
+ exports.getUserAttributes = getUserAttributes;
@@ -18,6 +18,5 @@ const requestEmailVerificationCode = (region, accessToken) => __awaiter(void 0,
18
18
  AttributeName: 'email', // Request verification for the email attribute
19
19
  };
20
20
  const requestEmailVerificationCodeResponse = yield cognitoClient.send(new client_cognito_identity_provider_1.GetUserAttributeVerificationCodeCommand(params));
21
- console.log(JSON.stringify(requestEmailVerificationCodeResponse, null, 2));
22
21
  });
23
22
  exports.requestEmailVerificationCode = requestEmailVerificationCode;
@@ -24,7 +24,6 @@ const respondToAuthChallengeChallenge = (userPoolId, clientId, region, username,
24
24
  Session: session,
25
25
  ChallengeResponses: Object.assign({ USERNAME: username, SECRET_HASH: secretHash }, attributes),
26
26
  };
27
- console.log('params', JSON.stringify(params, null, 2));
28
27
  const issueDateTime = new Date().toISOString();
29
28
  const response = yield cognitoClient.send(new client_cognito_identity_provider_1.RespondToAuthChallengeCommand(params));
30
29
  // transform the response into your custom format, similar to your refreshToken function
@@ -0,0 +1,2 @@
1
+ import { UserAttributes } from 'quidproquo-core';
2
+ export declare const setUserAttributes: (userPoolId: string, region: string, username: string, userAttributes: UserAttributes) => Promise<void>;
@@ -0,0 +1,36 @@
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
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.setUserAttributes = void 0;
24
+ const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
25
+ const cognitoAttributeMap_1 = require("./cognitoAttributeMap");
26
+ const setUserAttributes = (userPoolId, region, username, userAttributes) => __awaiter(void 0, void 0, void 0, function* () {
27
+ const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
28
+ const { userId } = userAttributes, writeableUserAttributes = __rest(userAttributes, ["userId"]);
29
+ const params = {
30
+ UserPoolId: userPoolId,
31
+ Username: username,
32
+ UserAttributes: (0, cognitoAttributeMap_1.getCognitoUserAttributesFromQpqUserAttributes)(writeableUserAttributes),
33
+ };
34
+ yield cognitoClient.send(new client_cognito_identity_provider_1.AdminUpdateUserAttributesCommand(params));
35
+ });
36
+ exports.setUserAttributes = setUserAttributes;
@@ -1 +1 @@
1
- export declare const verifyJwt: (accessToken: string, userPoolId: string, clientId: string, tokenType: 'id' | 'access') => Promise<boolean>;
1
+ export declare const verifyJwt: (accessToken: string, userPoolId: string, region: string, ignoreExpiration?: boolean) => Promise<boolean>;
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.verifyJwt = void 0;
13
13
  const decodeValidJwt_1 = require("./decodeValidJwt");
14
- const verifyJwt = (accessToken, userPoolId, clientId, tokenType) => __awaiter(void 0, void 0, void 0, function* () {
15
- const info = yield (0, decodeValidJwt_1.decodeValidJwt)(userPoolId, clientId, tokenType, accessToken);
14
+ const verifyJwt = (accessToken, userPoolId, region, ignoreExpiration = false) => __awaiter(void 0, void 0, void 0, function* () {
15
+ const info = yield (0, decodeValidJwt_1.decodeValidJwt)(userPoolId, region, ignoreExpiration, accessToken);
16
16
  // if we hav info, its valid
17
17
  return !!info;
18
18
  });
@@ -0,0 +1,2 @@
1
+ export declare function convertObjectToDynamoMap(obj: any): any;
2
+ export declare function convertDynamoMapToObject(dynamoMap: any): any;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertDynamoMapToObject = exports.convertObjectToDynamoMap = void 0;
4
+ function convertObjectToDynamoMap(obj) {
5
+ const map = {};
6
+ for (const property in obj) {
7
+ const value = obj[property];
8
+ const valueType = typeof value;
9
+ switch (valueType) {
10
+ case 'string':
11
+ map[property] = { S: value };
12
+ break;
13
+ case 'number':
14
+ map[property] = { N: value.toString() };
15
+ break;
16
+ case 'boolean':
17
+ map[property] = { BOOL: value };
18
+ break;
19
+ case 'object':
20
+ if (Array.isArray(value)) {
21
+ map[property] = {
22
+ L: value.map((item) => convertObjectToDynamoMap({ temp: item }).temp),
23
+ };
24
+ }
25
+ else if (value !== null) {
26
+ map[property] = { M: convertObjectToDynamoMap(value) };
27
+ }
28
+ else {
29
+ map[property] = { NULL: true };
30
+ }
31
+ break;
32
+ default:
33
+ throw new Error(`Unsupported data type: ${valueType}`);
34
+ }
35
+ }
36
+ return map;
37
+ }
38
+ exports.convertObjectToDynamoMap = convertObjectToDynamoMap;
39
+ function convertDynamoMapToObject(dynamoMap) {
40
+ const obj = {};
41
+ for (const property in dynamoMap) {
42
+ const value = dynamoMap[property];
43
+ const valueType = Object.keys(value)[0];
44
+ switch (valueType) {
45
+ case 'S':
46
+ obj[property] = value.S;
47
+ break;
48
+ case 'N':
49
+ obj[property] = parseFloat(value.N);
50
+ break;
51
+ case 'BOOL':
52
+ obj[property] = value.BOOL;
53
+ break;
54
+ case 'NULL':
55
+ obj[property] = null;
56
+ break;
57
+ case 'L':
58
+ obj[property] = value.L.map((item) => convertDynamoMapToObject({ temp: item }).temp);
59
+ break;
60
+ case 'M':
61
+ obj[property] = convertDynamoMapToObject(value.M);
62
+ break;
63
+ default:
64
+ throw new Error(`Unsupported DynamoDB data type: ${valueType}`);
65
+ }
66
+ }
67
+ return obj;
68
+ }
69
+ exports.convertDynamoMapToObject = convertDynamoMapToObject;
@@ -3,3 +3,4 @@ export * from './getAllItems';
3
3
  export * from './getItem';
4
4
  export * from './putItem';
5
5
  export * from './updateItem';
6
+ export * from './query';
@@ -19,3 +19,4 @@ __exportStar(require("./getAllItems"), exports);
19
19
  __exportStar(require("./getItem"), exports);
20
20
  __exportStar(require("./putItem"), exports);
21
21
  __exportStar(require("./updateItem"), exports);
22
+ __exportStar(require("./query"), exports);
@@ -1,4 +1,12 @@
1
+ import { KvsKey } from 'quidproquo-core';
1
2
  export interface PutItemOptions {
2
3
  expires?: number;
3
4
  }
4
- export declare function putItem<Value>(tableName: string, key: string, value: Value, options: PutItemOptions, region: string): Promise<void>;
5
+ export type KvsKeyValue<T> = {
6
+ key: KvsKey;
7
+ value: T;
8
+ };
9
+ export type DynamoAttributeType = 'S' | 'N' | 'B';
10
+ export declare const readKvsAttributeValue: <T, K extends keyof T>(item: T, key: KvsKey) => KvsKeyValue<T[K]>;
11
+ export declare const getDynamoValueTypeFromKvsKey: (key: KvsKey) => DynamoAttributeType;
12
+ export declare function putItem<Item>(tableName: string, item: Item, attributes: KvsKey[], options: PutItemOptions, region: string): Promise<void>;
@@ -9,14 +9,46 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.putItem = void 0;
12
+ exports.putItem = exports.getDynamoValueTypeFromKvsKey = exports.readKvsAttributeValue = void 0;
13
13
  const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
- function putItem(tableName, key, value, options, region) {
14
+ const lodash_1 = require("lodash");
15
+ const convertObjectToDynamoMap_1 = require("./convertObjectToDynamoMap");
16
+ const readKvsAttributeValue = (item, key) => {
17
+ const value = (0, lodash_1.get)(item, key.key);
18
+ return {
19
+ key,
20
+ value,
21
+ };
22
+ };
23
+ exports.readKvsAttributeValue = readKvsAttributeValue;
24
+ const getDynamoValueTypeFromKvsKey = (key) => {
25
+ switch (key.type) {
26
+ case 'string':
27
+ return 'S';
28
+ case 'number':
29
+ return 'N';
30
+ case 'binary':
31
+ return 'B';
32
+ }
33
+ };
34
+ exports.getDynamoValueTypeFromKvsKey = getDynamoValueTypeFromKvsKey;
35
+ function putItem(tableName, item, attributes, options, region) {
15
36
  return __awaiter(this, void 0, void 0, function* () {
16
37
  const dynamoClient = new client_dynamodb_1.DynamoDBClient({ region });
38
+ // Read all the values from the item
39
+ const dynamoProps = attributes
40
+ .filter((a, index, self) => index === self.findIndex((t) => t.key === a.key))
41
+ .reduce((acc, attribute) => {
42
+ const { key, value } = (0, exports.readKvsAttributeValue)(item, attribute);
43
+ const attributeValue = {
44
+ [(0, exports.getDynamoValueTypeFromKvsKey)(key)]: value,
45
+ };
46
+ acc[key.key] = attributeValue;
47
+ return acc;
48
+ }, {});
17
49
  yield dynamoClient.send(new client_dynamodb_1.PutItemCommand({
18
50
  TableName: tableName,
19
- Item: Object.assign({ key: { S: key }, value: { S: JSON.stringify(value) } }, (options.expires ? { expires: { N: options.expires.toString() } } : {})),
51
+ Item: (0, convertObjectToDynamoMap_1.convertObjectToDynamoMap)(item),
20
52
  }));
21
53
  });
22
54
  }
@@ -0,0 +1,7 @@
1
+ import { KvsQueryOperation, KvsQueryCondition, KvsLogicalOperator } from 'quidproquo-core';
2
+ import { AttributeValue } from '@aws-sdk/client-dynamodb';
3
+ export declare const isKvsQueryCondition: (query: KvsQueryOperation) => query is KvsQueryCondition;
4
+ export declare const isKvsLogicalOperator: (query: KvsQueryOperation) => query is KvsLogicalOperator;
5
+ export declare const buildDynamoQueryExpression: (query?: KvsQueryOperation) => string | undefined;
6
+ export declare const buildExpressionAttributeValues: (queries: (KvsQueryOperation | undefined)[]) => Record<string, AttributeValue>;
7
+ export declare const buildExpressionAttributeNames: (queries: (KvsQueryOperation | undefined)[]) => Record<string, string>;
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildExpressionAttributeNames = exports.buildExpressionAttributeValues = exports.buildDynamoQueryExpression = exports.isKvsLogicalOperator = exports.isKvsQueryCondition = void 0;
7
+ const crypto_1 = __importDefault(require("crypto"));
8
+ const quidproquo_core_1 = require("quidproquo-core");
9
+ // TODO: Come up with a better way of generating item name / values
10
+ // probably a map ~ however this will most likely never fail.
11
+ const getHash = (name) => {
12
+ const c = crypto_1.default.createHash('md5').update(name).digest('hex');
13
+ return c;
14
+ };
15
+ const getItemName = (name) => {
16
+ return `#${getHash(name)}`;
17
+ };
18
+ const getValueName = (value) => {
19
+ return `:${getHash(`${typeof value}-${JSON.stringify(value)}`)}`;
20
+ };
21
+ const buildDynamoQueryExpressionBetween = (query) => {
22
+ if (!query.key || !query.valueB || !query.valueB) {
23
+ throw new Error(`Invalid query condition ${quidproquo_core_1.KvsQueryOperationType.Between}`);
24
+ }
25
+ return `${getItemName(query.key)} BETWEEN ${getValueName(query.valueA)} AND ${getValueName(query.valueB)}`;
26
+ };
27
+ const buildDynamoQueryExpressionEqual = (query) => {
28
+ return `${getItemName(query.key)} = ${getValueName(query.valueA)}`;
29
+ };
30
+ const buildDynamoQueryExpressionNotEqual = (query) => {
31
+ return `${getItemName(query.key)} <> ${getValueName(query.valueA)}`;
32
+ };
33
+ const buildDynamoQueryExpressionLessThan = (query) => {
34
+ return `${getItemName(query.key)} < ${getValueName(query.valueA)}`;
35
+ };
36
+ const buildDynamoQueryExpressionLessThanOrEqual = (query) => {
37
+ return `${getItemName(query.key)} <= ${getValueName(query.valueA)}`;
38
+ };
39
+ const buildDynamoQueryExpressionGreaterThan = (query) => {
40
+ return `${getItemName(query.key)} > ${getValueName(query.valueA)}`;
41
+ };
42
+ const buildDynamoQueryExpressionGreaterThanOrEqual = (query) => {
43
+ return `${getItemName(query.key)} >= ${getValueName(query.valueA)}`;
44
+ };
45
+ const buildDynamoQueryExpressionIn = (query) => {
46
+ return `${getItemName(query.key)} IN (${query.valueA
47
+ .map((v) => getValueName(v))
48
+ .join(', ')})`;
49
+ };
50
+ const buildDynamoQueryExpressionExists = (query) => {
51
+ return `attribute_exists(${getItemName(query.key)})`;
52
+ };
53
+ const buildDynamoQueryExpressionNotExists = (query) => {
54
+ return `attribute_not_exists(${getItemName(query.key)})`;
55
+ };
56
+ const buildDynamoQueryExpressionBeginsWith = (query) => {
57
+ return `begins_with(${getItemName(query.key)}, ${getValueName(query.valueA)})`;
58
+ };
59
+ const buildDynamoQueryExpressionContains = (query) => {
60
+ return `contains(${getItemName(query.key)}, ${getValueName(query.valueA)})`;
61
+ };
62
+ const buildDynamoQueryExpressionNotContains = (query) => {
63
+ return `NOT contains(${getItemName(query.key)}, ${getValueName(query.valueA)})`;
64
+ };
65
+ const buildDynamoQueryExpressionOr = (query) => {
66
+ return query.conditions.map((c) => `(${buildDynamoQueryExpressionRoot(c)})`).join(' OR ');
67
+ };
68
+ const buildDynamoQueryExpressionAnd = (query) => {
69
+ return query.conditions.map((c) => `(${buildDynamoQueryExpressionRoot(c)})`).join(' AND ');
70
+ };
71
+ const isKvsQueryCondition = (query) => {
72
+ return 'key' in query && 'operation' in query;
73
+ };
74
+ exports.isKvsQueryCondition = isKvsQueryCondition;
75
+ const isKvsLogicalOperator = (query) => {
76
+ return 'conditions' in query && 'operation' in query;
77
+ };
78
+ exports.isKvsLogicalOperator = isKvsLogicalOperator;
79
+ const buildDynamoQueryExpressionRoot = (query) => {
80
+ if ((0, exports.isKvsQueryCondition)(query)) {
81
+ switch (query.operation) {
82
+ case quidproquo_core_1.KvsQueryOperationType.Equal:
83
+ return buildDynamoQueryExpressionEqual(query);
84
+ case quidproquo_core_1.KvsQueryOperationType.NotEqual:
85
+ return buildDynamoQueryExpressionNotEqual(query);
86
+ case quidproquo_core_1.KvsQueryOperationType.LessThan:
87
+ return buildDynamoQueryExpressionLessThan(query);
88
+ case quidproquo_core_1.KvsQueryOperationType.LessThanOrEqual:
89
+ return buildDynamoQueryExpressionLessThanOrEqual(query);
90
+ case quidproquo_core_1.KvsQueryOperationType.GreaterThan:
91
+ return buildDynamoQueryExpressionGreaterThan(query);
92
+ case quidproquo_core_1.KvsQueryOperationType.GreaterThanOrEqual:
93
+ return buildDynamoQueryExpressionGreaterThanOrEqual(query);
94
+ case quidproquo_core_1.KvsQueryOperationType.Between:
95
+ return buildDynamoQueryExpressionBetween(query);
96
+ case quidproquo_core_1.KvsQueryOperationType.In:
97
+ return buildDynamoQueryExpressionIn(query);
98
+ case quidproquo_core_1.KvsQueryOperationType.Exists:
99
+ return buildDynamoQueryExpressionExists(query);
100
+ case quidproquo_core_1.KvsQueryOperationType.NotExists:
101
+ return buildDynamoQueryExpressionNotExists(query);
102
+ case quidproquo_core_1.KvsQueryOperationType.BeginsWith:
103
+ return buildDynamoQueryExpressionBeginsWith(query);
104
+ case quidproquo_core_1.KvsQueryOperationType.Contains:
105
+ return buildDynamoQueryExpressionContains(query);
106
+ case quidproquo_core_1.KvsQueryOperationType.NotContains:
107
+ return buildDynamoQueryExpressionNotContains(query);
108
+ }
109
+ }
110
+ else if ((0, exports.isKvsLogicalOperator)(query)) {
111
+ switch (query.operation) {
112
+ case quidproquo_core_1.KvsLogicalOperatorType.And:
113
+ return buildDynamoQueryExpressionAnd(query);
114
+ case quidproquo_core_1.KvsLogicalOperatorType.Or:
115
+ return buildDynamoQueryExpressionOr(query);
116
+ }
117
+ }
118
+ throw new Error(`Invalid query operation: ${JSON.stringify(query)}`);
119
+ };
120
+ const buildAttributeValue = (value) => {
121
+ switch (typeof value) {
122
+ case 'string':
123
+ return { S: value };
124
+ case 'number':
125
+ return { N: value.toString() };
126
+ case 'boolean':
127
+ return { BOOL: value };
128
+ case 'object':
129
+ if (Array.isArray(value)) {
130
+ // check if all elements in the array are strings
131
+ if (value.every((item) => typeof item === 'string')) {
132
+ return { L: value.map((item) => ({ S: item })) };
133
+ }
134
+ throw new Error(`Invalid attribute value array content: ${JSON.stringify(value)}`);
135
+ }
136
+ throw new Error(`Invalid attribute value type: ${typeof value}`);
137
+ default:
138
+ throw new Error(`Invalid attribute value type: ${typeof value}`);
139
+ }
140
+ };
141
+ const buildDynamoQueryExpression = (query) => {
142
+ if (!query) {
143
+ return undefined;
144
+ }
145
+ return buildDynamoQueryExpressionRoot(query);
146
+ };
147
+ exports.buildDynamoQueryExpression = buildDynamoQueryExpression;
148
+ const buildExpressionAttributeValues = (queries) => {
149
+ const values = {};
150
+ const traverse = (query) => {
151
+ if ((0, exports.isKvsQueryCondition)(query)) {
152
+ if (query.valueA !== undefined) {
153
+ const valueNameA = getValueName(query.valueA);
154
+ values[valueNameA] = buildAttributeValue(query.valueA);
155
+ }
156
+ if (query.valueB !== undefined) {
157
+ const valueNameB = getValueName(query.valueB);
158
+ values[valueNameB] = buildAttributeValue(query.valueB);
159
+ }
160
+ }
161
+ else if ((0, exports.isKvsLogicalOperator)(query)) {
162
+ for (const condition of query.conditions) {
163
+ traverse(condition);
164
+ }
165
+ }
166
+ };
167
+ queries.filter((q) => !!q).forEach((q) => traverse(q));
168
+ return values;
169
+ };
170
+ exports.buildExpressionAttributeValues = buildExpressionAttributeValues;
171
+ const buildExpressionAttributeNames = (queries) => {
172
+ const names = {};
173
+ const traverse = (query) => {
174
+ if ((0, exports.isKvsQueryCondition)(query)) {
175
+ const itemName = getItemName(query.key);
176
+ names[itemName] = query.key;
177
+ }
178
+ else if ((0, exports.isKvsLogicalOperator)(query)) {
179
+ for (const condition of query.conditions) {
180
+ traverse(condition);
181
+ }
182
+ }
183
+ };
184
+ queries.filter((q) => !!q).forEach((q) => traverse(q));
185
+ return names;
186
+ };
187
+ exports.buildExpressionAttributeNames = buildExpressionAttributeNames;
@@ -0,0 +1 @@
1
+ export * from './buildDynamoQuery';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./buildDynamoQuery"), exports);
@@ -0,0 +1,2 @@
1
+ import { KeyValueStoreQPQConfigSetting, KvsQueryOperation } from 'quidproquo-core';
2
+ export declare const getDynamoTableIndexByConfigAndQuery: (setting: KeyValueStoreQPQConfigSetting, query: KvsQueryOperation) => string | undefined;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDynamoTableIndexByConfigAndQuery = void 0;
4
+ const buildDynamoQuery_1 = require("./buildDynamoQuery");
5
+ const getDynamoTableIndexByConfigAndQuery = (setting, query) => {
6
+ // Function to extract keys from a query
7
+ const extractKeysFromQuery = (query) => {
8
+ if ((0, buildDynamoQuery_1.isKvsQueryCondition)(query)) {
9
+ return [query.key];
10
+ }
11
+ else if ((0, buildDynamoQuery_1.isKvsLogicalOperator)(query)) {
12
+ return query.conditions.flatMap(extractKeysFromQuery);
13
+ }
14
+ return [];
15
+ };
16
+ const queriedKeys = extractKeysFromQuery(query);
17
+ // Find a matching index
18
+ for (const index of setting.indexes) {
19
+ if (queriedKeys.includes(index.partitionKey.key)) {
20
+ return index.partitionKey.key;
21
+ }
22
+ }
23
+ // No matching index found
24
+ return undefined;
25
+ };
26
+ exports.getDynamoTableIndexByConfigAndQuery = getDynamoTableIndexByConfigAndQuery;
@@ -0,0 +1,2 @@
1
+ import { KvsQueryOperation } from 'quidproquo-core';
2
+ export declare function query<Item>(tableName: string, region: string, keyExpression: KvsQueryOperation, filterExpression?: KvsQueryOperation, indexName?: string): Promise<Item[]>;
@@ -0,0 +1,38 @@
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.query = void 0;
13
+ const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
+ const convertObjectToDynamoMap_1 = require("./convertObjectToDynamoMap");
15
+ const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
16
+ function query(tableName, region, keyExpression, filterExpression, indexName) {
17
+ var _a;
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ // Instantiate DynamoDB client
20
+ const dynamoClient = new client_dynamodb_1.DynamoDBClient({ region });
21
+ const params = {
22
+ TableName: tableName,
23
+ KeyConditionExpression: (0, qpqDynamoOrm_1.buildDynamoQueryExpression)(keyExpression),
24
+ FilterExpression: (0, qpqDynamoOrm_1.buildDynamoQueryExpression)(filterExpression),
25
+ ExpressionAttributeValues: (0, qpqDynamoOrm_1.buildExpressionAttributeValues)([keyExpression, filterExpression]),
26
+ ExpressionAttributeNames: (0, qpqDynamoOrm_1.buildExpressionAttributeNames)([keyExpression, filterExpression]),
27
+ IndexName: indexName,
28
+ };
29
+ // TODO: Remove this log
30
+ console.log(params);
31
+ // Create QueryCommand
32
+ const command = new client_dynamodb_1.QueryCommand(params);
33
+ // TODO: Catch errors and throw QPQ ones
34
+ const data = yield dynamoClient.send(command);
35
+ return (((_a = data.Items) === null || _a === void 0 ? void 0 : _a.map((i) => (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(i))) || []);
36
+ });
37
+ }
38
+ exports.query = query;
@@ -0,0 +1,2 @@
1
+ import { KvsQueryOperation } from 'quidproquo-core';
2
+ export declare function scan<Item>(tableName: string, region: string, filterExpression?: KvsQueryOperation): Promise<Item[]>;
@@ -0,0 +1,35 @@
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.scan = void 0;
13
+ const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
14
+ const convertObjectToDynamoMap_1 = require("./convertObjectToDynamoMap");
15
+ const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
16
+ function scan(tableName, region, filterExpression) {
17
+ var _a;
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ // Instantiate DynamoDB client
20
+ const dynamoClient = new client_dynamodb_1.DynamoDBClient({ region });
21
+ const params = {
22
+ TableName: tableName,
23
+ FilterExpression: (0, qpqDynamoOrm_1.buildDynamoQueryExpression)(filterExpression),
24
+ ExpressionAttributeValues: (0, qpqDynamoOrm_1.buildExpressionAttributeValues)([filterExpression]),
25
+ ExpressionAttributeNames: (0, qpqDynamoOrm_1.buildExpressionAttributeNames)([filterExpression]),
26
+ };
27
+ console.log(params);
28
+ // Create ScanCommand
29
+ const command = new client_dynamodb_1.ScanCommand(params);
30
+ // TODO: Catch errors and throw QPQ ones
31
+ const data = yield dynamoClient.send(command);
32
+ return (((_a = data.Items) === null || _a === void 0 ? void 0 : _a.map((i) => (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(i))) || []);
33
+ });
34
+ }
35
+ exports.scan = scan;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-actionprocessor-awslambda",
3
- "version": "0.0.100",
3
+ "version": "0.0.102",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.js",
@@ -38,12 +38,17 @@
38
38
  "@aws-sdk/client-ssm": "^3.278.0",
39
39
  "aws-jwt-verify": "^3.4.0",
40
40
  "aws-sdk": "^2.1322.0",
41
+ "jsonwebtoken": "^9.0.0",
42
+ "jwks-rsa": "^3.0.1",
43
+ "lodash": "^4.17.21",
41
44
  "node-match-path": "^0.6.3",
42
45
  "quidproquo-core": "*",
43
46
  "quidproquo-webserver": "*"
44
47
  },
45
48
  "devDependencies": {
46
49
  "@types/aws-lambda": "^8.10.109",
50
+ "@types/jsonwebtoken": "^9.0.2",
51
+ "@types/lodash": "^4.14.194",
47
52
  "@types/node": "^18.11.9",
48
53
  "quidproquo-tsconfig": "*",
49
54
  "typescript": "^4.9.3"
@@ -1,6 +0,0 @@
1
- import { QPQConfig } from 'quidproquo-core';
2
- import { KeyValueStoreSetActionProcessor } from 'quidproquo-core';
3
- declare const _default: (qpqConfig: QPQConfig) => {
4
- "@quidproquo-core/KeyValueStore/Set": KeyValueStoreSetActionProcessor<any>;
5
- };
6
- export default _default;