@friggframework/core 2.0.0--canary.499.832ff75.0 → 2.0.0--canary.499.e23a5e0.1
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { Cryptor } = require('../encrypt/Cryptor');
|
|
2
|
-
const { getEncryptedFields } = require('./encryption/encryption-schema-registry');
|
|
2
|
+
const { getEncryptedFields, loadCustomEncryptionSchema } = require('./encryption/encryption-schema-registry');
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Encryption service specifically for DocumentDB repositories
|
|
@@ -43,12 +43,13 @@ class DocumentDBEncryptionService {
|
|
|
43
43
|
* Encryption is bypassed in dev/test/local stages.
|
|
44
44
|
* Production uses AWS KMS (if available) or AES encryption.
|
|
45
45
|
*
|
|
46
|
-
* Note: Custom encryption schema is loaded eagerly at module initialization
|
|
47
|
-
* (see encryption-schema-registry.js), so it's already available here.
|
|
48
|
-
*
|
|
49
46
|
* @private
|
|
50
47
|
*/
|
|
51
48
|
_initializeCryptor() {
|
|
49
|
+
// Load custom encryption schema from app definition BEFORE checking configuration
|
|
50
|
+
// This ensures custom fields (like User.username) are registered before any encryption operations
|
|
51
|
+
loadCustomEncryptionSchema();
|
|
52
|
+
|
|
52
53
|
// Match logic from packages/core/database/prisma.js
|
|
53
54
|
const stage = process.env.STAGE || process.env.NODE_ENV || 'development';
|
|
54
55
|
const bypassEncryption = ['dev', 'test', 'local'].includes(stage.toLowerCase());
|
|
@@ -116,8 +116,7 @@ function registerCustomSchema(schema) {
|
|
|
116
116
|
* This ensures that custom encryption schemas defined in the backend's index.js
|
|
117
117
|
* are registered before any repositories attempt to encrypt data.
|
|
118
118
|
*
|
|
119
|
-
*
|
|
120
|
-
* Safe to call multiple times (registerCustomSchema checks for duplicates).
|
|
119
|
+
* Used by both Prisma (MongoDB/PostgreSQL) and DocumentDB encryption services.
|
|
121
120
|
*/
|
|
122
121
|
function loadCustomEncryptionSchema() {
|
|
123
122
|
try {
|
|
@@ -140,10 +139,10 @@ function loadCustomEncryptionSchema() {
|
|
|
140
139
|
return; // No app definition found
|
|
141
140
|
}
|
|
142
141
|
|
|
143
|
-
const
|
|
142
|
+
const customSchema = appDefinition.encryption?.schema;
|
|
144
143
|
|
|
145
|
-
if (
|
|
146
|
-
registerCustomSchema(
|
|
144
|
+
if (customSchema && Object.keys(customSchema).length > 0) {
|
|
145
|
+
registerCustomSchema(customSchema);
|
|
147
146
|
}
|
|
148
147
|
} catch (error) {
|
|
149
148
|
// Silently ignore errors - custom schema is optional
|
|
@@ -176,11 +175,6 @@ function resetCustomSchema() {
|
|
|
176
175
|
customSchema = {};
|
|
177
176
|
}
|
|
178
177
|
|
|
179
|
-
// Eagerly load custom encryption schema when module is first imported
|
|
180
|
-
// This ensures the schema is available before any encryption operations occur,
|
|
181
|
-
// preventing race conditions in concurrent execution environments (e.g., Lambda)
|
|
182
|
-
loadCustomEncryptionSchema();
|
|
183
|
-
|
|
184
178
|
module.exports = {
|
|
185
179
|
CORE_ENCRYPTION_SCHEMA,
|
|
186
180
|
getEncryptedFields,
|
package/database/prisma.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const {
|
|
2
2
|
createEncryptionExtension,
|
|
3
3
|
} = require('./encryption/prisma-encryption-extension');
|
|
4
|
+
const { loadCustomEncryptionSchema } = require('./encryption/encryption-schema-registry');
|
|
4
5
|
const { logger } = require('./encryption/logger');
|
|
5
6
|
const { Cryptor } = require('../encrypt/Cryptor');
|
|
6
7
|
const config = require('./config');
|
|
@@ -106,8 +107,8 @@ const prismaClientSingleton = () => {
|
|
|
106
107
|
|
|
107
108
|
if (encryptionConfig.enabled) {
|
|
108
109
|
try {
|
|
109
|
-
//
|
|
110
|
-
|
|
110
|
+
// Load custom encryption schema from appDefinition before creating extension
|
|
111
|
+
loadCustomEncryptionSchema();
|
|
111
112
|
|
|
112
113
|
const cryptor = new Cryptor({
|
|
113
114
|
shouldUseAws: encryptionConfig.method === 'kms',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.499.
|
|
4
|
+
"version": "2.0.0--canary.499.e23a5e0.1",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
|
|
7
7
|
"@aws-sdk/client-kms": "^3.588.0",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@friggframework/eslint-config": "2.0.0--canary.499.
|
|
42
|
-
"@friggframework/prettier-config": "2.0.0--canary.499.
|
|
43
|
-
"@friggframework/test": "2.0.0--canary.499.
|
|
41
|
+
"@friggframework/eslint-config": "2.0.0--canary.499.e23a5e0.1",
|
|
42
|
+
"@friggframework/prettier-config": "2.0.0--canary.499.e23a5e0.1",
|
|
43
|
+
"@friggframework/test": "2.0.0--canary.499.e23a5e0.1",
|
|
44
44
|
"@prisma/client": "^6.17.0",
|
|
45
45
|
"@types/lodash": "4.17.15",
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "e23a5e04522d8b828cbd41db65f9b00e80949119"
|
|
84
84
|
}
|