@flowerforce/flowerbase 1.7.6-beta.0 → 1.7.6-beta.2
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/README.md +125 -1
- package/dist/auth/providers/custom-function/controller.d.ts.map +1 -1
- package/dist/auth/providers/custom-function/controller.js +3 -8
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +11 -1
- package/dist/features/encryption/interface.d.ts +36 -0
- package/dist/features/encryption/interface.d.ts.map +1 -0
- package/dist/features/encryption/interface.js +2 -0
- package/dist/features/encryption/utils.d.ts +9 -0
- package/dist/features/encryption/utils.d.ts.map +1 -0
- package/dist/features/encryption/utils.js +34 -0
- package/dist/features/functions/controller.d.ts +2 -0
- package/dist/features/functions/controller.d.ts.map +1 -1
- package/dist/features/functions/controller.js +7 -1
- package/dist/features/rules/utils.d.ts.map +1 -1
- package/dist/features/rules/utils.js +1 -11
- package/dist/features/triggers/index.d.ts.map +1 -1
- package/dist/features/triggers/index.js +4 -0
- package/dist/features/triggers/utils.d.ts.map +1 -1
- package/dist/features/triggers/utils.js +30 -38
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/monitoring/plugin.d.ts.map +1 -1
- package/dist/monitoring/plugin.js +31 -0
- package/dist/services/mongodb-atlas/index.d.ts +3 -0
- package/dist/services/mongodb-atlas/index.d.ts.map +1 -1
- package/dist/services/mongodb-atlas/index.js +97 -17
- package/dist/services/mongodb-atlas/model.d.ts +2 -1
- package/dist/services/mongodb-atlas/model.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +14 -3
- package/dist/utils/initializer/mongodbCSFLE.d.ts +69 -0
- package/dist/utils/initializer/mongodbCSFLE.d.ts.map +1 -0
- package/dist/utils/initializer/mongodbCSFLE.js +131 -0
- package/dist/utils/initializer/registerPlugins.d.ts +5 -1
- package/dist/utils/initializer/registerPlugins.d.ts.map +1 -1
- package/dist/utils/initializer/registerPlugins.js +27 -5
- package/package.json +4 -2
- package/src/auth/providers/custom-function/controller.ts +4 -10
- package/src/constants.ts +11 -2
- package/src/features/encryption/interface.ts +46 -0
- package/src/features/encryption/utils.ts +22 -0
- package/src/features/functions/__tests__/watch-filter.test.ts +11 -1
- package/src/features/functions/controller.ts +8 -0
- package/src/features/rules/utils.ts +1 -11
- package/src/features/triggers/index.ts +5 -1
- package/src/features/triggers/utils.ts +31 -42
- package/src/index.ts +10 -2
- package/src/monitoring/plugin.ts +33 -0
- package/src/monitoring/ui.collections.js +7 -10
- package/src/monitoring/ui.css +378 -0
- package/src/monitoring/ui.endpoints.js +5 -10
- package/src/monitoring/ui.events.js +2 -4
- package/src/monitoring/ui.functions.js +64 -71
- package/src/monitoring/ui.html +8 -0
- package/src/monitoring/ui.js +189 -0
- package/src/monitoring/ui.shared.js +237 -2
- package/src/monitoring/ui.triggers.js +2 -3
- package/src/monitoring/ui.users.js +5 -9
- package/src/services/mongodb-atlas/__tests__/watch-filter.test.ts +78 -0
- package/src/services/mongodb-atlas/index.ts +102 -19
- package/src/services/mongodb-atlas/model.ts +3 -1
- package/src/types/fastify-raw-body.d.ts +0 -9
- package/src/utils/__tests__/mongodbCSFLE.test.ts +105 -0
- package/src/utils/index.ts +12 -1
- package/src/utils/initializer/mongodbCSFLE.ts +224 -0
- package/src/utils/initializer/registerPlugins.ts +45 -10
package/README.md
CHANGED
|
@@ -265,8 +265,132 @@ Example
|
|
|
265
265
|
```
|
|
266
266
|
If you're configuring the project from scratch, you can skip ahead to the [Build](#build) step.
|
|
267
267
|
|
|
268
|
-
|
|
268
|
+
## 🔐 7 Client-Side Field Level Encryption (CSFLE)
|
|
269
269
|
|
|
270
|
+
Flowerbase supports MongoDB Client-Side Field Level Encryption. When enabled, sensitive fields are encrypted by the MongoDB driver before writing to MongoDB and decrypted automatically when reading.
|
|
271
|
+
|
|
272
|
+
What Flowerbase does for you:
|
|
273
|
+
|
|
274
|
+
- Loads all `encryption.json` files under `data_sources/mongodb-atlas/**`.
|
|
275
|
+
- Builds the MongoDB `schemaMap` automatically from those files.
|
|
276
|
+
- Resolves each `keyAlias` in your schemas to a real Data Encryption Key (DEK) `keyId`.
|
|
277
|
+
- Ensures DEKs exist in the key vault (creates them if missing).
|
|
278
|
+
- Configures Fastify MongoDB plugin `autoEncryption` with the generated `schemaMap`.
|
|
279
|
+
|
|
280
|
+
### 1. Install encryption drivers
|
|
281
|
+
|
|
282
|
+
Refer to the official MongoDB documentation for CSFLE installation requirements: https://www.mongodb.com/docs/manual/core/csfle/install.
|
|
283
|
+
|
|
284
|
+
It is recommended to use the [**Automatic Encryption Shared Library**](https://www.mongodb.com/docs/manual/core/csfle/reference/install-library/?encryption-component=crypt_shared#std-label-csfle-reference-shared-library-download) instead of mongocryptd.
|
|
285
|
+
|
|
286
|
+
Note that the project should also install [mongodb-client-encryption](https://www.npmjs.com/package/mongodb-client-encryption), matching the mongodb driver version.
|
|
287
|
+
|
|
288
|
+
### 2. Add encryption schema files
|
|
289
|
+
|
|
290
|
+
Create one `encryption.json` per collection you want to encrypt:
|
|
291
|
+
|
|
292
|
+
Path example:
|
|
293
|
+
|
|
294
|
+
```text
|
|
295
|
+
src/data_sources/mongodb-atlas/<database>/<collection>/encryption.json
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Example:
|
|
299
|
+
|
|
300
|
+
```json
|
|
301
|
+
{
|
|
302
|
+
"database": "appDb",
|
|
303
|
+
"collection": "records",
|
|
304
|
+
"schema": {
|
|
305
|
+
"bsonType": "object",
|
|
306
|
+
"encryptMetadata": {
|
|
307
|
+
"keyAlias": "root-key"
|
|
308
|
+
},
|
|
309
|
+
"properties": {
|
|
310
|
+
"protectedField1": {
|
|
311
|
+
"encrypt": {
|
|
312
|
+
"bsonType": "string",
|
|
313
|
+
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Random"
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
"protectedField2": {
|
|
317
|
+
"encrypt": {
|
|
318
|
+
"bsonType": "string",
|
|
319
|
+
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic",
|
|
320
|
+
"keyAlias": "deep-key"
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Notes:
|
|
329
|
+
|
|
330
|
+
- `encryptMetadata.keyAlias` applies as default key for that object level.
|
|
331
|
+
- `encrypt.keyAlias` overrides key selection for a specific field.
|
|
332
|
+
- If a field has `encrypt` but no `keyAlias`, MongoDB uses nearest `encryptMetadata`.
|
|
333
|
+
|
|
334
|
+
### 3. Pass `mongodbEncryptionConfig` to `initialize()`
|
|
335
|
+
|
|
336
|
+
`initialize()` accepts `mongodbEncryptionConfig` to configure KMS providers and key vault settings.
|
|
337
|
+
|
|
338
|
+
#### Local KMS provider example (development)
|
|
339
|
+
|
|
340
|
+
```ts
|
|
341
|
+
import { initialize } from "@flowerforce/flowerbase";
|
|
342
|
+
|
|
343
|
+
await initialize({
|
|
344
|
+
projectId: "my-project-id",
|
|
345
|
+
mongodbUrl: process.env.MONGODB_URL,
|
|
346
|
+
jwtSecret: process.env.JWT_SECRET,
|
|
347
|
+
mongodbEncryptionConfig: {
|
|
348
|
+
kmsProviders: [
|
|
349
|
+
{
|
|
350
|
+
provider: "local",
|
|
351
|
+
keyAlias: "root-key",
|
|
352
|
+
config: {
|
|
353
|
+
// 96-byte local master key encoded as base64
|
|
354
|
+
key: process.env.LOCAL_MASTER_KEY_BASE64,
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
provider: "local",
|
|
359
|
+
keyAlias: "deep-key",
|
|
360
|
+
config: { key: process.env.LOCAL_MASTER_KEY_BASE64 },
|
|
361
|
+
},
|
|
362
|
+
],
|
|
363
|
+
keyVaultDb: "encryption",
|
|
364
|
+
keyVaultCollection: "__keyVault",
|
|
365
|
+
extraOptions: {
|
|
366
|
+
// Optional: path to crypt shared library
|
|
367
|
+
// cryptSharedLibPath: '/opt/mongo_crypt_v1/lib/mongo_crypt_v1.so'
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
});
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
#### AWS KMS provider example
|
|
374
|
+
|
|
375
|
+
```ts
|
|
376
|
+
mongodbEncryptionConfig: {
|
|
377
|
+
kmsProviders: [
|
|
378
|
+
{
|
|
379
|
+
provider: "aws",
|
|
380
|
+
keyAlias: "root-key",
|
|
381
|
+
config: {
|
|
382
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
383
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
384
|
+
},
|
|
385
|
+
masterKey: {
|
|
386
|
+
key: process.env.AWS_KMS_KEY_ARN,
|
|
387
|
+
region: process.env.AWS_REGION,
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
];
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
---
|
|
270
394
|
|
|
271
395
|
<a id="migration"></a>
|
|
272
396
|
## 🔄 [Migration Guide](#migration) - Migrating Your Realm Project
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/auth/providers/custom-function/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAUzC;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../src/auth/providers/custom-function/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAUzC;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,eAAe,iBAqIlE"}
|
|
@@ -38,10 +38,7 @@ function customFunctionController(app) {
|
|
|
38
38
|
* @returns {Promise<Object>} A promise resolving with access and refresh tokens.
|
|
39
39
|
*/
|
|
40
40
|
app.post(utils_1.AUTH_ENDPOINTS.LOGIN, {
|
|
41
|
-
schema: schema_1.LOGIN_SCHEMA
|
|
42
|
-
errorHandler: (_error, _request, reply) => {
|
|
43
|
-
reply.code(500).send({ message: 'Internal Server Error' });
|
|
44
|
-
}
|
|
41
|
+
schema: schema_1.LOGIN_SCHEMA
|
|
45
42
|
}, function (req, reply) {
|
|
46
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
44
|
var _a, _b, _c;
|
|
@@ -123,14 +120,12 @@ function customFunctionController(app) {
|
|
|
123
120
|
expiresAt: new Date(Date.now() + refreshTokenTtlMs),
|
|
124
121
|
revokedAt: null
|
|
125
122
|
});
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
access_token: accessToken,
|
|
123
|
+
return {
|
|
124
|
+
access_token: this.createAccessToken(currentUserData),
|
|
129
125
|
refresh_token: refreshToken,
|
|
130
126
|
device_id: '',
|
|
131
127
|
user_id: authUser._id.toString()
|
|
132
128
|
};
|
|
133
|
-
reply.code(200).send(responsePayload);
|
|
134
129
|
});
|
|
135
130
|
});
|
|
136
131
|
});
|
package/dist/constants.d.ts
CHANGED
|
@@ -33,6 +33,10 @@ export declare const DEFAULT_CONFIG: {
|
|
|
33
33
|
origin: string;
|
|
34
34
|
methods: ALLOWED_METHODS[];
|
|
35
35
|
};
|
|
36
|
+
MONGODB_ENCRYPTION_CONFIG: {
|
|
37
|
+
keyVaultDb: string;
|
|
38
|
+
keyVaultCollection: string;
|
|
39
|
+
};
|
|
36
40
|
};
|
|
37
41
|
export declare const API_VERSION: string;
|
|
38
42
|
export declare const HTTPS_SCHEMA: string;
|
|
@@ -63,5 +67,11 @@ export declare const S3_CONFIG: {
|
|
|
63
67
|
ACCESS_KEY_ID: string | undefined;
|
|
64
68
|
SECRET_ACCESS_KEY: string | undefined;
|
|
65
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Name of the MongoDB client to use for change streams.
|
|
72
|
+
* This may be a separate instance because streams do not work
|
|
73
|
+
* when the main client has auto encryption enabled.
|
|
74
|
+
*/
|
|
75
|
+
export declare const CHANGESTREAM = "changestream";
|
|
66
76
|
export {};
|
|
67
77
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAsBpC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmCsB,eAAe,EAAE
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAsBpC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmCsB,eAAe,EAAE;;;;;;CAMjE,CAAA;AACD,eAAO,MAAM,WAAW,QAA8C,CAAA;AACtE,eAAO,MAAM,YAAY,QAA8B,CAAA;AACvD,eAAO,MAAM,OAAO,QAAgB,CAAA;AACpC,eAAO,MAAM,YAAY,QAAiC,CAAA;AAE1D,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAAA;AAE7E,eAAO,MAAM,WAAW;;;;;;;mBAOqB,aAAa;;;;;;;;;CAOzD,CAAA;AAED,eAAO,MAAM,SAAS;;;CAGrB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,iBAAiB,CAAA"}
|
package/dist/constants.js
CHANGED
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.S3_CONFIG = exports.AUTH_CONFIG = exports.AUTH_DB_NAME = exports.DB_NAME = exports.HTTPS_SCHEMA = exports.API_VERSION = exports.DEFAULT_CONFIG = void 0;
|
|
15
|
+
exports.CHANGESTREAM = exports.S3_CONFIG = exports.AUTH_CONFIG = exports.AUTH_DB_NAME = exports.DB_NAME = exports.HTTPS_SCHEMA = exports.API_VERSION = exports.DEFAULT_CONFIG = void 0;
|
|
16
16
|
const utils_1 = require("./auth/utils");
|
|
17
17
|
const parseBoolean = (value) => {
|
|
18
18
|
if (!value)
|
|
@@ -63,6 +63,10 @@ exports.DEFAULT_CONFIG = {
|
|
|
63
63
|
CORS_OPTIONS: {
|
|
64
64
|
origin: "*",
|
|
65
65
|
methods: ["GET", "POST", "PUT", "DELETE"]
|
|
66
|
+
},
|
|
67
|
+
MONGODB_ENCRYPTION_CONFIG: {
|
|
68
|
+
keyVaultDb: "encryption",
|
|
69
|
+
keyVaultCollection: "__keyVault"
|
|
66
70
|
}
|
|
67
71
|
};
|
|
68
72
|
exports.API_VERSION = `/api/client/${exports.DEFAULT_CONFIG.API_VERSION}`;
|
|
@@ -89,3 +93,9 @@ exports.S3_CONFIG = {
|
|
|
89
93
|
ACCESS_KEY_ID: process.env.S3_ACCESS_KEY_ID,
|
|
90
94
|
SECRET_ACCESS_KEY: process.env.S3_SECRET_ACCESS_KEY
|
|
91
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Name of the MongoDB client to use for change streams.
|
|
98
|
+
* This may be a separate instance because streams do not work
|
|
99
|
+
* when the main client has auto encryption enabled.
|
|
100
|
+
*/
|
|
101
|
+
exports.CHANGESTREAM = "changestream";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { UUID } from "mongodb";
|
|
2
|
+
export type EncryptionSchemaProperty = EncryptionSchema | {
|
|
3
|
+
encrypt: {
|
|
4
|
+
algorithm: string;
|
|
5
|
+
bsonType: string;
|
|
6
|
+
keyAlias?: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export type EncryptionSchema = {
|
|
10
|
+
bsonType: "object";
|
|
11
|
+
properties: Record<string, EncryptionSchemaProperty>;
|
|
12
|
+
encryptMetadata?: {
|
|
13
|
+
keyAlias: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type MappedEncryptionSchemaProperty = MappedEncryptionSchema | {
|
|
17
|
+
encrypt: {
|
|
18
|
+
algorithm: string;
|
|
19
|
+
bsonType: string;
|
|
20
|
+
keyId?: [UUID];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type MappedEncryptionSchema = {
|
|
24
|
+
bsonType: "object";
|
|
25
|
+
properties: Record<string, MappedEncryptionSchemaProperty>;
|
|
26
|
+
encryptMetadata?: {
|
|
27
|
+
keyId: [UUID];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type EncryptionSchemaFile = {
|
|
31
|
+
database: string;
|
|
32
|
+
collection: string;
|
|
33
|
+
schema: EncryptionSchema;
|
|
34
|
+
};
|
|
35
|
+
export type EncryptionSchemas = Record<string, EncryptionSchema>;
|
|
36
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/features/encryption/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAEnC,MAAM,MAAM,wBAAwB,GAChC,gBAAgB,GAChB;IACA,OAAO,EAAE;QACP,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,EAAE,MAAM,CAAA;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;CACF,CAAA;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,QAAQ,CAAA;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAA;IACpD,eAAe,CAAC,EAAE;QAChB,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAC;CACH,CAAA;AAGD,MAAM,MAAM,8BAA8B,GACtC,sBAAsB,GACtB;IACA,OAAO,EAAE;QACP,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,EAAE,MAAM,CAAA;QAChB,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;KACf,CAAA;CACF,CAAA;AAEH,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,QAAQ,CAAA;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAA;IAC1D,eAAe,CAAC,EAAE;QAChB,KAAK,EAAE,CAAC,IAAI,CAAC,CAAA;KACd,CAAC;CACH,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,gBAAgB,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EncryptionSchemas } from "./interface";
|
|
2
|
+
/**
|
|
3
|
+
* @experimental
|
|
4
|
+
* Schemas used for Client-Side Level Encryption configuration.
|
|
5
|
+
*
|
|
6
|
+
* **Important:** These schemas do not perform JSON validation.
|
|
7
|
+
*/
|
|
8
|
+
export declare const loadEncryptionSchemas: (rootDir?: string) => Promise<EncryptionSchemas>;
|
|
9
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/encryption/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAErE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAU,gBAAuB,KAAG,OAAO,CAAC,iBAAiB,CAW9F,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.loadEncryptionSchemas = void 0;
|
|
16
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
+
const utils_1 = require("../../utils");
|
|
18
|
+
/**
|
|
19
|
+
* @experimental
|
|
20
|
+
* Schemas used for Client-Side Level Encryption configuration.
|
|
21
|
+
*
|
|
22
|
+
* **Important:** These schemas do not perform JSON validation.
|
|
23
|
+
*/
|
|
24
|
+
const loadEncryptionSchemas = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (rootDir = process.cwd()) {
|
|
25
|
+
const schemasRoot = node_path_1.default.join(rootDir, 'data_sources', 'mongodb-atlas');
|
|
26
|
+
const files = (0, utils_1.recursivelyCollectFiles)(schemasRoot);
|
|
27
|
+
const schemaFiles = files.filter((x) => x.endsWith('encryption.json'));
|
|
28
|
+
return schemaFiles.reduce((acc, filePath) => {
|
|
29
|
+
const { collection, database, schema } = (0, utils_1.readJsonContent)(filePath);
|
|
30
|
+
acc[`${database}.${collection}`] = schema;
|
|
31
|
+
return acc;
|
|
32
|
+
}, {});
|
|
33
|
+
});
|
|
34
|
+
exports.loadEncryptionSchemas = loadEncryptionSchemas;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { Document } from 'mongodb';
|
|
1
2
|
import { FunctionController } from './interface';
|
|
2
3
|
export declare const mapWatchFilterToChangeStreamMatch: (value: unknown) => unknown;
|
|
3
4
|
export declare const mapWatchFilterToDocumentQuery: (value: unknown) => unknown;
|
|
5
|
+
export declare const shouldSkipReadabilityLookupForChange: (change: Document) => boolean;
|
|
4
6
|
/**
|
|
5
7
|
* > Creates a pre handler for every query
|
|
6
8
|
* @param app -> the fastify instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/features/functions/controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/features/functions/controller.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAIvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAmHhD,eAAO,MAAM,iCAAiC,GAAI,OAAO,OAAO,KAAG,OA0BlE,CAAA;AAID,eAAO,MAAM,6BAA6B,GAAI,OAAO,OAAO,KAAG,OAgD9D,CAAA;AAqHD,eAAO,MAAM,oCAAoC,GAAI,QAAQ,QAAQ,YAClC,CAAA;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,kBAyRjC,CAAA"}
|
|
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.functionsController = exports.mapWatchFilterToDocumentQuery = exports.mapWatchFilterToChangeStreamMatch = void 0;
|
|
23
|
+
exports.functionsController = exports.shouldSkipReadabilityLookupForChange = exports.mapWatchFilterToDocumentQuery = exports.mapWatchFilterToChangeStreamMatch = void 0;
|
|
24
24
|
const bson_1 = require("bson");
|
|
25
25
|
const services_1 = require("../../services");
|
|
26
26
|
const context_1 = require("../../utils/context");
|
|
@@ -262,6 +262,8 @@ const isReadableDocumentResult = (value) => !!value &&
|
|
|
262
262
|
typeof value === 'object' &&
|
|
263
263
|
!Array.isArray(value) &&
|
|
264
264
|
Object.keys(value).length > 0;
|
|
265
|
+
const shouldSkipReadabilityLookupForChange = (change) => change.operationType === 'delete';
|
|
266
|
+
exports.shouldSkipReadabilityLookupForChange = shouldSkipReadabilityLookupForChange;
|
|
265
267
|
/**
|
|
266
268
|
* > Creates a pre handler for every query
|
|
267
269
|
* @param app -> the fastify instance
|
|
@@ -431,6 +433,10 @@ const functionsController = (app_1, _a) => __awaiter(void 0, [app_1, _a], void 0
|
|
|
431
433
|
const docId = (_b = (_a = change === null || change === void 0 ? void 0 : change.documentKey) === null || _a === void 0 ? void 0 : _a._id) !== null && _b !== void 0 ? _b : (_c = change === null || change === void 0 ? void 0 : change.fullDocument) === null || _c === void 0 ? void 0 : _c._id;
|
|
432
434
|
if (typeof docId === 'undefined')
|
|
433
435
|
return;
|
|
436
|
+
if ((0, exports.shouldSkipReadabilityLookupForChange)(change)) {
|
|
437
|
+
subscriberRes.write(`data: ${serializeEjson(change)}\n\n`);
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
434
440
|
const readQuery = subscriber.documentFilter
|
|
435
441
|
? { $and: [subscriber.documentFilter, { _id: docId }] }
|
|
436
442
|
: { _id: docId };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/rules/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/rules/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAe,MAAM,aAAa,CAAA;AAEhD,eAAO,MAAM,SAAS,GAAU,gBAAuB,KAAG,OAAO,CAAC,KAAK,CA6BtE,CAAA"}
|
|
@@ -13,21 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.loadRules = void 0;
|
|
16
|
-
const fs_1 = __importDefault(require("fs"));
|
|
17
16
|
const node_path_1 = __importDefault(require("node:path"));
|
|
18
17
|
const utils_1 = require("../../utils");
|
|
19
18
|
const loadRules = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (rootDir = process.cwd()) {
|
|
20
19
|
const rulesRoot = node_path_1.default.join(rootDir, 'data_sources', 'mongodb-atlas');
|
|
21
|
-
const
|
|
22
|
-
return fs_1.default.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
23
|
-
const fullPath = node_path_1.default.join(dir, entry.name);
|
|
24
|
-
if (entry.isDirectory()) {
|
|
25
|
-
return recursivelyCollectFiles(fullPath);
|
|
26
|
-
}
|
|
27
|
-
return entry.isFile() ? [fullPath] : [];
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
const files = recursivelyCollectFiles(rulesRoot);
|
|
20
|
+
const files = (0, utils_1.recursivelyCollectFiles)(rulesRoot);
|
|
31
21
|
const rulesFiles = files.filter((x) => x.endsWith('rules.json'));
|
|
32
22
|
const removeEmptyFieldRules = (rulesConfig) => {
|
|
33
23
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAA;AAG/C;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAU,0CAIpC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAA;AAG/C;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAU,0CAIpC,sBAAsB,kBAyExB,CAAA"}
|
|
@@ -32,6 +32,10 @@ const activateTriggers = (_a) => __awaiter(void 0, [_a], void 0, function* ({ fa
|
|
|
32
32
|
var _e;
|
|
33
33
|
console.log('START ACTIVATION TRIGGERS');
|
|
34
34
|
try {
|
|
35
|
+
// Ensure the changestream MongoDB client exist, or use the main client
|
|
36
|
+
if (!fastify.mongo[constants_1.CHANGESTREAM]) {
|
|
37
|
+
fastify.mongo[constants_1.CHANGESTREAM] = fastify.mongo;
|
|
38
|
+
}
|
|
35
39
|
const triggersToActivate = [...triggersList];
|
|
36
40
|
if (constants_1.AUTH_CONFIG.on_user_creation_function_name) {
|
|
37
41
|
const alreadyDeclared = triggersToActivate.some((trigger) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/utils.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAW,QAAQ,EAAE,MAAM,aAAa,CAAA;AA0E9D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAU,gBAAuB,KAAG,OAAO,CAAC,QAAQ,CAkB5E,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/triggers/utils.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAW,QAAQ,EAAE,MAAM,aAAa,CAAA;AA0E9D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAU,gBAAuB,KAAG,OAAO,CAAC,QAAQ,CAkB5E,CAAA;AA+mBD,eAAO,MAAM,gBAAgB;kHAxlB1B,aAAa;iHAggBb,aAAa;uHA/Yb,aAAa;CA2ef,CAAA"}
|
|
@@ -220,7 +220,7 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
220
220
|
const { database, isAutoTrigger, operation_types = [], operation_type } = config;
|
|
221
221
|
const providerFilter = normalizeProviders((_b = config.providers) !== null && _b !== void 0 ? _b : []);
|
|
222
222
|
const authCollection = (_c = constants_1.AUTH_CONFIG.authCollection) !== null && _c !== void 0 ? _c : 'auth_users';
|
|
223
|
-
const collection = app.mongo.client.db(database || constants_1.AUTH_DB_NAME).collection(authCollection);
|
|
223
|
+
const collection = app.mongo[constants_1.CHANGESTREAM].client.db(database || constants_1.AUTH_DB_NAME).collection(authCollection);
|
|
224
224
|
const operationCandidates = operation_type ? mapOpInverse[operation_type] : operation_types;
|
|
225
225
|
const normalizedOps = normalizeOperationTypes(operationCandidates);
|
|
226
226
|
const baseMeta = {
|
|
@@ -252,14 +252,6 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
252
252
|
if (shouldIgnoreStreamError(error))
|
|
253
253
|
return;
|
|
254
254
|
console.error('Authentication trigger change stream error', error);
|
|
255
|
-
emitTriggerEvent({
|
|
256
|
-
status: 'error',
|
|
257
|
-
triggerName,
|
|
258
|
-
triggerType,
|
|
259
|
-
functionName,
|
|
260
|
-
meta: Object.assign(Object.assign({}, baseMeta), { event: 'CHANGE_STREAM' }),
|
|
261
|
-
error
|
|
262
|
-
});
|
|
263
255
|
});
|
|
264
256
|
changeStream.on('change', function (change) {
|
|
265
257
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -329,6 +321,13 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
329
321
|
updateDescription
|
|
330
322
|
};
|
|
331
323
|
try {
|
|
324
|
+
emitTriggerEvent({
|
|
325
|
+
status: 'fired',
|
|
326
|
+
triggerName,
|
|
327
|
+
triggerType,
|
|
328
|
+
functionName,
|
|
329
|
+
meta: Object.assign(Object.assign({}, baseMeta), { event: 'LOGOUT' })
|
|
330
|
+
});
|
|
332
331
|
yield (0, context_1.GenerateContext)({
|
|
333
332
|
args: [Object.assign({ user: userData }, op)],
|
|
334
333
|
app,
|
|
@@ -340,13 +339,6 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
340
339
|
services,
|
|
341
340
|
runAsSystem: true
|
|
342
341
|
});
|
|
343
|
-
emitTriggerEvent({
|
|
344
|
-
status: 'fired',
|
|
345
|
-
triggerName,
|
|
346
|
-
triggerType,
|
|
347
|
-
functionName,
|
|
348
|
-
meta: Object.assign(Object.assign({}, baseMeta), { event: 'LOGOUT' })
|
|
349
|
-
});
|
|
350
342
|
}
|
|
351
343
|
catch (error) {
|
|
352
344
|
emitTriggerEvent({
|
|
@@ -381,6 +373,13 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
381
373
|
updateDescription
|
|
382
374
|
};
|
|
383
375
|
try {
|
|
376
|
+
emitTriggerEvent({
|
|
377
|
+
status: 'fired',
|
|
378
|
+
triggerName,
|
|
379
|
+
triggerType,
|
|
380
|
+
functionName,
|
|
381
|
+
meta: Object.assign(Object.assign({}, baseMeta), { event: 'DELETE' })
|
|
382
|
+
});
|
|
384
383
|
yield (0, context_1.GenerateContext)({
|
|
385
384
|
args: isAutoTrigger ? [userData] : [Object.assign({ user: userData }, op)],
|
|
386
385
|
app,
|
|
@@ -392,13 +391,6 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
392
391
|
services,
|
|
393
392
|
runAsSystem: true
|
|
394
393
|
});
|
|
395
|
-
emitTriggerEvent({
|
|
396
|
-
status: 'fired',
|
|
397
|
-
triggerName,
|
|
398
|
-
triggerType,
|
|
399
|
-
functionName,
|
|
400
|
-
meta: Object.assign(Object.assign({}, baseMeta), { event: 'DELETE' })
|
|
401
|
-
});
|
|
402
394
|
}
|
|
403
395
|
catch (error) {
|
|
404
396
|
emitTriggerEvent({
|
|
@@ -435,6 +427,13 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
435
427
|
updateDescription
|
|
436
428
|
};
|
|
437
429
|
try {
|
|
430
|
+
emitTriggerEvent({
|
|
431
|
+
status: 'fired',
|
|
432
|
+
triggerName,
|
|
433
|
+
triggerType,
|
|
434
|
+
functionName,
|
|
435
|
+
meta: Object.assign(Object.assign({}, baseMeta), { event: 'UPDATE' })
|
|
436
|
+
});
|
|
438
437
|
yield (0, context_1.GenerateContext)({
|
|
439
438
|
args: isAutoTrigger ? [userData] : [Object.assign({ user: userData }, op)],
|
|
440
439
|
app,
|
|
@@ -446,13 +445,6 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
446
445
|
services,
|
|
447
446
|
runAsSystem: true
|
|
448
447
|
});
|
|
449
|
-
emitTriggerEvent({
|
|
450
|
-
status: 'fired',
|
|
451
|
-
triggerName,
|
|
452
|
-
triggerType,
|
|
453
|
-
functionName,
|
|
454
|
-
meta: Object.assign(Object.assign({}, baseMeta), { event: 'UPDATE' })
|
|
455
|
-
});
|
|
456
448
|
}
|
|
457
449
|
catch (error) {
|
|
458
450
|
emitTriggerEvent({
|
|
@@ -526,6 +518,13 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
526
518
|
updateDescription
|
|
527
519
|
};
|
|
528
520
|
try {
|
|
521
|
+
emitTriggerEvent({
|
|
522
|
+
status: 'fired',
|
|
523
|
+
triggerName,
|
|
524
|
+
triggerType,
|
|
525
|
+
functionName,
|
|
526
|
+
meta: Object.assign(Object.assign({}, baseMeta), { event: 'CREATE' })
|
|
527
|
+
});
|
|
529
528
|
yield (0, context_1.GenerateContext)({
|
|
530
529
|
args: isAutoTrigger ? [userData] : [Object.assign({ user: userData }, op)],
|
|
531
530
|
app,
|
|
@@ -537,13 +536,6 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
537
536
|
services,
|
|
538
537
|
runAsSystem: true
|
|
539
538
|
});
|
|
540
|
-
emitTriggerEvent({
|
|
541
|
-
status: 'fired',
|
|
542
|
-
triggerName,
|
|
543
|
-
triggerType,
|
|
544
|
-
functionName,
|
|
545
|
-
meta: Object.assign(Object.assign({}, baseMeta), { event: 'CREATE' })
|
|
546
|
-
});
|
|
547
539
|
}
|
|
548
540
|
catch (error) {
|
|
549
541
|
emitTriggerEvent({
|
|
@@ -583,7 +575,7 @@ const handleAuthenticationTrigger = (_a) => __awaiter(void 0, [_a], void 0, func
|
|
|
583
575
|
const handleDataBaseTrigger = (_a) => __awaiter(void 0, [_a], void 0, function* ({ config, triggerHandler, functionsList, services, app, triggerName, triggerType, functionName }) {
|
|
584
576
|
const { database, collection: collectionName, operation_types = [], match = {}, project = {} } = config;
|
|
585
577
|
const normalizedOperations = normalizeOperationTypes(operation_types);
|
|
586
|
-
const collection = app.mongo.client.db(database).collection(collectionName);
|
|
578
|
+
const collection = app.mongo[constants_1.CHANGESTREAM].client.db(database).collection(collectionName);
|
|
587
579
|
const pipeline = [
|
|
588
580
|
{
|
|
589
581
|
$match: Object.assign({ operationType: { $in: normalizedOperations } }, match)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import 'dotenv/config';
|
|
2
|
+
import { type MongoDbEncryptionConfig } from './utils/initializer/mongodbCSFLE';
|
|
2
3
|
export * from './model';
|
|
3
4
|
export type ALLOWED_METHODS = "GET" | "POST" | "PUT" | "DELETE";
|
|
4
5
|
export type CorsConfig = {
|
|
@@ -13,6 +14,7 @@ export type InitializeConfig = {
|
|
|
13
14
|
host?: string;
|
|
14
15
|
corsConfig?: CorsConfig;
|
|
15
16
|
basePath?: string;
|
|
17
|
+
mongodbEncryptionConfig?: MongoDbEncryptionConfig;
|
|
16
18
|
};
|
|
17
19
|
/**
|
|
18
20
|
* > Used to initialize fastify app
|
|
@@ -22,5 +24,5 @@ export type InitializeConfig = {
|
|
|
22
24
|
* @param port -> the serve port number
|
|
23
25
|
* @param mongodbUrl -> the database connection string
|
|
24
26
|
*/
|
|
25
|
-
export declare function initialize({ projectId, host, jwtSecret, port, mongodbUrl, corsConfig, basePath }: InitializeConfig): Promise<void>;
|
|
27
|
+
export declare function initialize({ projectId, host, jwtSecret, port, mongodbUrl, corsConfig, basePath, mongodbEncryptionConfig }: InitializeConfig): Promise<void>;
|
|
26
28
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AAetB,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAC/E,cAAc,SAAS,CAAA;AAGvB,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE/D,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,eAAe,EAAE,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,uBAAuB,CAAC,EAAE,uBAAuB,CAAA;CAClD,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,EAC/B,SAAS,EACT,IAA0B,EAC1B,SAAqC,EACrC,IAA0B,EAC1B,UAAuC,EACvC,UAAwC,EACxC,QAAQ,EACR,uBAAuB,EACxB,EAAE,gBAAgB,iBA6HlB"}
|
package/dist/index.js
CHANGED
|
@@ -57,8 +57,9 @@ const utils_1 = require("./features/endpoints/utils");
|
|
|
57
57
|
const functions_1 = require("./features/functions");
|
|
58
58
|
const utils_2 = require("./features/functions/utils");
|
|
59
59
|
const utils_3 = require("./features/rules/utils");
|
|
60
|
+
const utils_4 = require("./features/encryption/utils");
|
|
60
61
|
const triggers_1 = require("./features/triggers");
|
|
61
|
-
const
|
|
62
|
+
const utils_5 = require("./features/triggers/utils");
|
|
62
63
|
const services_1 = require("./services");
|
|
63
64
|
const state_1 = require("./state");
|
|
64
65
|
const exposeRoutes_1 = require("./utils/initializer/exposeRoutes");
|
|
@@ -73,7 +74,7 @@ __exportStar(require("./model"), exports);
|
|
|
73
74
|
* @param mongodbUrl -> the database connection string
|
|
74
75
|
*/
|
|
75
76
|
function initialize(_a) {
|
|
76
|
-
return __awaiter(this, arguments, void 0, function* ({ projectId, host = constants_1.DEFAULT_CONFIG.HOST, jwtSecret = constants_1.DEFAULT_CONFIG.JWT_SECRET, port = constants_1.DEFAULT_CONFIG.PORT, mongodbUrl = constants_1.DEFAULT_CONFIG.MONGODB_URL, corsConfig = constants_1.DEFAULT_CONFIG.CORS_OPTIONS, basePath }) {
|
|
77
|
+
return __awaiter(this, arguments, void 0, function* ({ projectId, host = constants_1.DEFAULT_CONFIG.HOST, jwtSecret = constants_1.DEFAULT_CONFIG.JWT_SECRET, port = constants_1.DEFAULT_CONFIG.PORT, mongodbUrl = constants_1.DEFAULT_CONFIG.MONGODB_URL, corsConfig = constants_1.DEFAULT_CONFIG.CORS_OPTIONS, basePath, mongodbEncryptionConfig }) {
|
|
77
78
|
var _b, _c;
|
|
78
79
|
if (!jwtSecret || jwtSecret.trim().length === 0) {
|
|
79
80
|
throw new Error('JWT secret missing: set JWT_SECRET or pass jwtSecret to initialize()');
|
|
@@ -93,12 +94,14 @@ function initialize(_a) {
|
|
|
93
94
|
logInfo("CURRENT HOST", host);
|
|
94
95
|
const functionsList = yield (0, utils_2.loadFunctions)(resolvedBasePath);
|
|
95
96
|
logInfo("Functions LOADED");
|
|
96
|
-
const triggersList = yield (0,
|
|
97
|
+
const triggersList = yield (0, utils_5.loadTriggers)(resolvedBasePath);
|
|
97
98
|
logInfo("Triggers LOADED");
|
|
98
99
|
const endpointsList = yield (0, utils_1.loadEndpoints)(resolvedBasePath);
|
|
99
100
|
logInfo("Endpoints LOADED");
|
|
100
101
|
const rulesList = yield (0, utils_3.loadRules)(resolvedBasePath);
|
|
101
102
|
logInfo("Rules LOADED");
|
|
103
|
+
const encryptionSchemas = yield (0, utils_4.loadEncryptionSchemas)(resolvedBasePath);
|
|
104
|
+
logInfo("Encryption schemas LOADED");
|
|
102
105
|
const stateConfig = {
|
|
103
106
|
functions: functionsList,
|
|
104
107
|
triggers: triggersList,
|
|
@@ -168,7 +171,9 @@ function initialize(_a) {
|
|
|
168
171
|
mongodbUrl,
|
|
169
172
|
jwtSecret,
|
|
170
173
|
functionsList,
|
|
171
|
-
corsConfig
|
|
174
|
+
corsConfig,
|
|
175
|
+
encryptionSchemas,
|
|
176
|
+
mongodbEncryptionConfig
|
|
172
177
|
});
|
|
173
178
|
logInfo('Plugins registration COMPLETED');
|
|
174
179
|
yield (0, exposeRoutes_1.exposeRoutes)(fastify);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/monitoring/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAA;AAE5E,OAAO,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/monitoring/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAA;AAE5E,OAAO,oBAAoB,CAAA;AA2B3B,QAAA,MAAM,sBAAsB,QACrB,eAAe,SACd;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,kBA4WH,CAAA;AAE1B,eAAe,sBAAsB,CAAA"}
|