@friggframework/core 1.0.3-v1-alpha-package-update.6 → 1.1.0-v1-alpha.0
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/database/index.js +14 -8
- package/encrypt/CHANGELOG.md +13 -0
- package/encrypt/README.md +10 -0
- package/encrypt/encrypt.js +12 -4
- package/encrypt/encrypt.test.js +2 -1
- package/encrypt/index.js +2 -1
- package/errors/fetch-error.js +5 -1
- package/index.js +119 -19
- package/integrations/jest-setup.js +1 -1
- package/integrations/jest-teardown.js +1 -1
- package/logs/logger.test.js +1 -1
- package/module-plugin/jest-setup.js +1 -1
- package/module-plugin/jest-teardown.js +1 -1
- package/module-plugin/module-factory.js +1 -1
- package/module-plugin/requester/requester.js +2 -1
- package/package.json +6 -4
- package/syncs/manager.js +0 -2
package/database/index.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
const
|
|
2
|
-
const {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const {
|
|
1
|
+
const { mongoose} = require('./mongoose');
|
|
2
|
+
const {
|
|
3
|
+
connectToDatabase,
|
|
4
|
+
disconnectFromDatabase,
|
|
5
|
+
createObjectId,
|
|
6
|
+
} = require('./mongo');
|
|
7
|
+
const {IndividualUser} = require('./models/IndividualUser');
|
|
8
|
+
const {OrganizationUser} = require('./models/OrganizationUser');
|
|
9
|
+
const {State} = require('./models/State');
|
|
10
|
+
const {Token} = require('./models/Token');
|
|
11
|
+
const {UserModel} = require('./models/UserModel');
|
|
8
12
|
|
|
9
13
|
module.exports = {
|
|
10
|
-
...mongo,
|
|
11
14
|
mongoose,
|
|
15
|
+
connectToDatabase,
|
|
16
|
+
disconnectFromDatabase,
|
|
17
|
+
createObjectId,
|
|
12
18
|
IndividualUser,
|
|
13
19
|
OrganizationUser,
|
|
14
20
|
State,
|
package/encrypt/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# v1.1.8 (Fri Feb 02 2024)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- Added variable BYPASS_ENCRYPTION_STAGE to encrypt module [#248](https://github.com/friggframework/frigg/pull/248) ([@leofmds](https://github.com/leofmds))
|
|
6
|
+
- Added variable BYPASS_ENCRYPTION_STAGE to encrypt module ([@leofmds](https://github.com/leofmds))
|
|
7
|
+
|
|
8
|
+
#### Authors: 1
|
|
9
|
+
|
|
10
|
+
- Leonardo Ferreira ([@leofmds](https://github.com/leofmds))
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
1
14
|
# v1.1.7 (Tue Apr 04 2023)
|
|
2
15
|
|
|
3
16
|
:tada: This release contains work from a new contributor! :tada:
|
package/encrypt/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
# encrypt
|
|
2
2
|
|
|
3
3
|
This package exports the `encrypt` mongoose plugin used in [Frigg](https://friggframework.org). You can find its documentation [on Frigg's website](https://docs.friggframework.org/packages/encrypt).
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
| Environment variable | Description |
|
|
8
|
+
|-------------------------|------------------------------------------------------------------------------------------------------------|
|
|
9
|
+
| KMS_KEY_ARN | The AWS KMS Key ARN, if using it to encryption/decryption. |
|
|
10
|
+
| AES_KEY | AES key, used in conjunction with AES_KEY_ID. AES option is mutually exclusive with KMS_KEY_ARN. |
|
|
11
|
+
| AES_KEY_ID | AES key ID, used in conjunction with AES_KEY. |
|
|
12
|
+
| STAGE | The stage in which the application is running. It is usually defined in Serverless configuration, if used. |
|
|
13
|
+
| BYPASS_ENCRYPTION_STAGE | Stages to bypass encryption/decryption, separated by comma. |
|
package/encrypt/encrypt.js
CHANGED
|
@@ -14,14 +14,22 @@ const findOneEvents = [
|
|
|
14
14
|
'findOneAndReplace',
|
|
15
15
|
];
|
|
16
16
|
|
|
17
|
+
const shouldBypassEncryption = (STAGE) => {
|
|
18
|
+
const defaultBypassStages = ['dev', 'test', 'local'];
|
|
19
|
+
const bypassStageEnv = process.env.BYPASS_ENCRYPTION_STAGE;
|
|
20
|
+
// If the env is set to anything or an empty string, use the env. Otherwise, use the default array
|
|
21
|
+
const useEnv = !String(bypassStageEnv) || !!bypassStageEnv;
|
|
22
|
+
const bypassStages = useEnv
|
|
23
|
+
? bypassStageEnv.split(',').map((stage) => stage.trim())
|
|
24
|
+
: defaultBypassStages;
|
|
25
|
+
return bypassStages.includes(STAGE);
|
|
26
|
+
};
|
|
27
|
+
|
|
17
28
|
// The Mongoose plug-in function
|
|
18
29
|
function Encrypt(schema, options) {
|
|
19
30
|
const { STAGE, KMS_KEY_ARN, AES_KEY_ID } = process.env;
|
|
20
|
-
const isEnabledForStage =
|
|
21
|
-
['staging', 'QA', 'prod', 'encryption-test'].indexOf(STAGE) > -1;
|
|
22
31
|
|
|
23
|
-
|
|
24
|
-
if (!isEnabledForStage) {
|
|
32
|
+
if (shouldBypassEncryption(STAGE)) {
|
|
25
33
|
return;
|
|
26
34
|
}
|
|
27
35
|
|
package/encrypt/encrypt.test.js
CHANGED
|
@@ -8,7 +8,7 @@ const {
|
|
|
8
8
|
createModel,
|
|
9
9
|
saveTestDocument,
|
|
10
10
|
} = require('./test-encrypt');
|
|
11
|
-
const { TestMongo } = require('
|
|
11
|
+
const { TestMongo } = require('@friggframework/devtools');
|
|
12
12
|
|
|
13
13
|
const testMongo = new TestMongo();
|
|
14
14
|
const originalEnv = process.env;
|
|
@@ -34,6 +34,7 @@ describe('Encrypt', () => {
|
|
|
34
34
|
process.env = {
|
|
35
35
|
...originalEnv,
|
|
36
36
|
STAGE: 'not-encryption-test',
|
|
37
|
+
BYPASS_ENCRYPTION_STAGE: 'not-encryption-test',
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
try {
|
package/encrypt/index.js
CHANGED
package/errors/fetch-error.js
CHANGED
|
@@ -7,6 +7,8 @@ const { stripIndent } = require('common-tags');
|
|
|
7
7
|
// https://developer.mozilla.org/en-US/docs/Web/API/fetch
|
|
8
8
|
|
|
9
9
|
class FetchError extends BaseError {
|
|
10
|
+
response = null;
|
|
11
|
+
|
|
10
12
|
constructor(options = {}) {
|
|
11
13
|
const { resource, init, response, responseBody } = options;
|
|
12
14
|
const method = init?.method ?? 'GET';
|
|
@@ -17,7 +19,7 @@ class FetchError extends BaseError {
|
|
|
17
19
|
return JSON.stringify({ init }, null, 2);
|
|
18
20
|
})()
|
|
19
21
|
: JSON.stringify({ init }, null, 2)
|
|
20
|
-
: '';
|
|
22
|
+
: '';
|
|
21
23
|
|
|
22
24
|
let responseBodyText = '<response body is unavailable>';
|
|
23
25
|
if (typeof responseBody === 'string') {
|
|
@@ -59,6 +61,8 @@ class FetchError extends BaseError {
|
|
|
59
61
|
];
|
|
60
62
|
|
|
61
63
|
super(messageParts.filter(Boolean).join('\n'));
|
|
64
|
+
|
|
65
|
+
this.response = response;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
static async create(options = {}) {
|
package/index.js
CHANGED
|
@@ -1,24 +1,124 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
1
|
+
const {
|
|
2
|
+
expectShallowEqualDbObject,
|
|
3
|
+
get,
|
|
4
|
+
getAll,
|
|
5
|
+
verifyType,
|
|
6
|
+
getParamAndVerifyParamType,
|
|
7
|
+
getArrayParamAndVerifyParamType,
|
|
8
|
+
getAndVerifyType,
|
|
9
|
+
} = require('./assertions/index');
|
|
10
|
+
const { Delegate, Worker, loadInstalledModules, createHandler } = require('./core/index');
|
|
11
|
+
const {
|
|
12
|
+
mongoose,
|
|
13
|
+
connectToDatabase,
|
|
14
|
+
disconnectFromDatabase,
|
|
15
|
+
createObjectId,
|
|
16
|
+
IndividualUser,
|
|
17
|
+
OrganizationUser,
|
|
18
|
+
State,
|
|
19
|
+
Token,
|
|
20
|
+
UserModel
|
|
21
|
+
} = require('./database/index');
|
|
22
|
+
const { Encrypt, Cryptor } = require('./encrypt/encrypt');
|
|
23
|
+
const {
|
|
24
|
+
BaseError,
|
|
25
|
+
FetchError,
|
|
26
|
+
HaltError,
|
|
27
|
+
RequiredPropertyError,
|
|
28
|
+
ParameterTypeError,
|
|
29
|
+
} = require('./errors/index');
|
|
30
|
+
const {
|
|
31
|
+
IntegrationBase,
|
|
32
|
+
IntegrationModel,
|
|
33
|
+
Options,
|
|
34
|
+
IntegrationMapping,
|
|
35
|
+
IntegrationFactory,
|
|
36
|
+
IntegrationHelper,
|
|
37
|
+
createIntegrationRouter,
|
|
38
|
+
checkRequiredParams,
|
|
39
|
+
createFriggBackend
|
|
40
|
+
} = require('./integrations/index');
|
|
41
|
+
const { TimeoutCatcher } = require('./lambda/index');
|
|
42
|
+
const {
|
|
43
|
+
debug,
|
|
44
|
+
initDebugLog,
|
|
45
|
+
flushDebugLog
|
|
46
|
+
} = require('./logs/index');
|
|
47
|
+
const {
|
|
48
|
+
Credential,
|
|
49
|
+
EntityManager,
|
|
50
|
+
Entity,
|
|
51
|
+
ModuleManager,
|
|
52
|
+
ApiKeyRequester,
|
|
53
|
+
BasicAuthRequester,
|
|
54
|
+
OAuth2Requester,
|
|
55
|
+
Requester,
|
|
56
|
+
ModuleConstants,
|
|
57
|
+
ModuleFactory,
|
|
58
|
+
Auther
|
|
59
|
+
} = require('./module-plugin/index');
|
|
11
60
|
|
|
12
61
|
// const {Sync } = require('./syncs/model');
|
|
13
62
|
|
|
14
63
|
module.exports = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
64
|
+
// assertions
|
|
65
|
+
expectShallowEqualDbObject,
|
|
66
|
+
get,
|
|
67
|
+
getAll,
|
|
68
|
+
verifyType,
|
|
69
|
+
getParamAndVerifyParamType,
|
|
70
|
+
getArrayParamAndVerifyParamType,
|
|
71
|
+
getAndVerifyType,
|
|
72
|
+
// core
|
|
73
|
+
Delegate,
|
|
74
|
+
Worker,
|
|
75
|
+
loadInstalledModules,
|
|
76
|
+
createHandler,
|
|
77
|
+
// database
|
|
78
|
+
mongoose,
|
|
79
|
+
connectToDatabase,
|
|
80
|
+
disconnectFromDatabase,
|
|
81
|
+
createObjectId,
|
|
82
|
+
IndividualUser,
|
|
83
|
+
OrganizationUser,
|
|
84
|
+
State,
|
|
85
|
+
Token,
|
|
86
|
+
UserModel,
|
|
87
|
+
// encrypt
|
|
88
|
+
Encrypt,
|
|
89
|
+
Cryptor,
|
|
90
|
+
// errors
|
|
91
|
+
BaseError,
|
|
92
|
+
FetchError,
|
|
93
|
+
HaltError,
|
|
94
|
+
RequiredPropertyError,
|
|
95
|
+
ParameterTypeError,
|
|
96
|
+
// integrations
|
|
97
|
+
IntegrationBase,
|
|
98
|
+
IntegrationModel,
|
|
99
|
+
Options,
|
|
100
|
+
IntegrationMapping,
|
|
101
|
+
IntegrationFactory,
|
|
102
|
+
IntegrationHelper,
|
|
103
|
+
checkRequiredParams,
|
|
104
|
+
createIntegrationRouter,
|
|
105
|
+
createFriggBackend,
|
|
106
|
+
// lambda
|
|
107
|
+
TimeoutCatcher,
|
|
108
|
+
// logs
|
|
109
|
+
debug,
|
|
110
|
+
initDebugLog,
|
|
111
|
+
flushDebugLog,
|
|
112
|
+
// module plugin
|
|
113
|
+
Credential,
|
|
114
|
+
EntityManager,
|
|
115
|
+
Entity,
|
|
116
|
+
ModuleManager,
|
|
117
|
+
ApiKeyRequester,
|
|
118
|
+
BasicAuthRequester,
|
|
119
|
+
OAuth2Requester,
|
|
120
|
+
Requester,
|
|
121
|
+
ModuleConstants,
|
|
122
|
+
ModuleFactory,
|
|
123
|
+
Auther
|
|
24
124
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const { globalSetup } = require('
|
|
1
|
+
const { globalSetup } = require('@friggframework/devtools');
|
|
2
2
|
module.exports = globalSetup;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const { globalTeardown } = require('
|
|
1
|
+
const { globalTeardown } = require('@friggframework/devtools');
|
|
2
2
|
module.exports = globalTeardown;
|
package/logs/logger.test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const { globalTeardown } = require('
|
|
1
|
+
const { globalTeardown } = require('@friggframework/devtools');
|
|
2
2
|
module.exports = globalTeardown;
|
|
@@ -23,7 +23,8 @@ class Requester extends Delegate {
|
|
|
23
23
|
|
|
24
24
|
if (
|
|
25
25
|
contentType.match(/^application\/json/) ||
|
|
26
|
-
contentType.match(/^application\/vnd.api\+json/)
|
|
26
|
+
contentType.match(/^application\/vnd.api\+json/) ||
|
|
27
|
+
contentType.match(/^application\/hal\+json/)
|
|
27
28
|
) {
|
|
28
29
|
return resp.json();
|
|
29
30
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0-v1-alpha.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hapi/boom": "^10.0.1",
|
|
7
7
|
"aws-sdk": "^2.1200.0",
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
"common-tags": "^1.8.2",
|
|
10
10
|
"express": "^4.18.2",
|
|
11
11
|
"express-async-handler": "^1.2.0",
|
|
12
|
-
"jest-runner-groups": "^2.2.0",
|
|
13
12
|
"lodash": "^4.17.21",
|
|
14
13
|
"lodash.get": "^4.4.2",
|
|
15
|
-
"mongodb-memory-server": "^8.9.0",
|
|
16
14
|
"mongoose": "6.11.6",
|
|
17
15
|
"node-fetch": "^2.6.7"
|
|
18
16
|
},
|
|
19
17
|
"devDependencies": {
|
|
18
|
+
"@friggframework/devtools": "v1-alpha",
|
|
19
|
+
"@friggframework/prettier-config": "^1.0.6",
|
|
20
20
|
"@types/lodash": "^4.14.191",
|
|
21
21
|
"@typescript-eslint/eslint-plugin": "^5.55.0",
|
|
22
22
|
"chai": "^4.3.6",
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"eslint-plugin-n": "^15.6.1",
|
|
27
27
|
"eslint-plugin-promise": "^6.1.1",
|
|
28
28
|
"jest": "^28.1.3",
|
|
29
|
+
"jest-runner-groups": "^2.2.0",
|
|
30
|
+
"mongodb-memory-server": "^8.9.0",
|
|
29
31
|
"prettier": "^2.8.5",
|
|
30
32
|
"sinon": "^14.0.0",
|
|
31
33
|
"typescript": "^5.0.2"
|
|
@@ -46,5 +48,5 @@
|
|
|
46
48
|
},
|
|
47
49
|
"homepage": "https://github.com/friggframework/frigg#readme",
|
|
48
50
|
"description": "",
|
|
49
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "0900fdc8d00b013f41e24e08d827078bedd12d29"
|
|
50
52
|
}
|
package/syncs/manager.js
CHANGED
|
@@ -8,7 +8,6 @@ const { Sync } = require("./model");
|
|
|
8
8
|
|
|
9
9
|
class SyncManager {
|
|
10
10
|
constructor(params) {
|
|
11
|
-
super(params);
|
|
12
11
|
// TODO verify type????????
|
|
13
12
|
// this.primaryModule = getAndVerifyType(params, 'primary', ModuleManager);
|
|
14
13
|
// this.secondaryModule = getAndVerifyType(
|
|
@@ -36,7 +35,6 @@ class SyncManager {
|
|
|
36
35
|
|
|
37
36
|
this.integration = get(params, "integration", null); // TODO Change to type validation
|
|
38
37
|
|
|
39
|
-
Sync = new Sync();
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
// calls getAllSyncObjects() on the modules and then finds the difference between each. The Primary Module
|