@friggframework/core 2.0.0--canary.461.61382d8.0 → 2.0.0--canary.461.5767fa4.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.
Files changed (118) hide show
  1. package/generated/prisma-mongodb/client.d.ts +1 -0
  2. package/generated/prisma-mongodb/client.js +4 -0
  3. package/generated/prisma-mongodb/default.d.ts +1 -0
  4. package/generated/prisma-mongodb/default.js +4 -0
  5. package/generated/prisma-mongodb/edge.d.ts +1 -0
  6. package/generated/prisma-mongodb/edge.js +336 -0
  7. package/generated/prisma-mongodb/index-browser.js +318 -0
  8. package/generated/prisma-mongodb/index.d.ts +22993 -0
  9. package/generated/prisma-mongodb/index.js +361 -0
  10. package/generated/prisma-mongodb/package.json +183 -0
  11. package/generated/prisma-mongodb/query-engine-debian-openssl-3.0.x +0 -0
  12. package/generated/prisma-mongodb/query-engine-rhel-openssl-3.0.x +0 -0
  13. package/generated/prisma-mongodb/runtime/binary.d.ts +1 -0
  14. package/generated/prisma-mongodb/runtime/binary.js +289 -0
  15. package/generated/prisma-mongodb/runtime/edge-esm.js +34 -0
  16. package/generated/prisma-mongodb/runtime/edge.js +34 -0
  17. package/generated/prisma-mongodb/runtime/index-browser.d.ts +370 -0
  18. package/generated/prisma-mongodb/runtime/index-browser.js +16 -0
  19. package/generated/prisma-mongodb/runtime/library.d.ts +3977 -0
  20. package/generated/prisma-mongodb/runtime/react-native.js +83 -0
  21. package/generated/prisma-mongodb/runtime/wasm-compiler-edge.js +84 -0
  22. package/generated/prisma-mongodb/runtime/wasm-engine-edge.js +36 -0
  23. package/generated/prisma-mongodb/schema.prisma +364 -0
  24. package/generated/prisma-mongodb/wasm-edge-light-loader.mjs +4 -0
  25. package/generated/prisma-mongodb/wasm-worker-loader.mjs +4 -0
  26. package/generated/prisma-mongodb/wasm.d.ts +1 -0
  27. package/generated/prisma-mongodb/wasm.js +343 -0
  28. package/generated/prisma-postgresql/client.d.ts +1 -0
  29. package/generated/prisma-postgresql/client.js +4 -0
  30. package/generated/prisma-postgresql/default.d.ts +1 -0
  31. package/generated/prisma-postgresql/default.js +4 -0
  32. package/generated/prisma-postgresql/edge.d.ts +1 -0
  33. package/generated/prisma-postgresql/edge.js +358 -0
  34. package/generated/prisma-postgresql/index-browser.js +340 -0
  35. package/generated/prisma-postgresql/index.d.ts +25171 -0
  36. package/generated/prisma-postgresql/index.js +383 -0
  37. package/generated/prisma-postgresql/package.json +183 -0
  38. package/generated/prisma-postgresql/query-engine-debian-openssl-3.0.x +0 -0
  39. package/generated/prisma-postgresql/query-engine-rhel-openssl-3.0.x +0 -0
  40. package/generated/prisma-postgresql/query_engine_bg.js +2 -0
  41. package/generated/prisma-postgresql/query_engine_bg.wasm +0 -0
  42. package/generated/prisma-postgresql/runtime/binary.d.ts +1 -0
  43. package/generated/prisma-postgresql/runtime/binary.js +289 -0
  44. package/generated/prisma-postgresql/runtime/edge-esm.js +34 -0
  45. package/generated/prisma-postgresql/runtime/edge.js +34 -0
  46. package/generated/prisma-postgresql/runtime/index-browser.d.ts +370 -0
  47. package/generated/prisma-postgresql/runtime/index-browser.js +16 -0
  48. package/generated/prisma-postgresql/runtime/library.d.ts +3977 -0
  49. package/generated/prisma-postgresql/runtime/react-native.js +83 -0
  50. package/generated/prisma-postgresql/runtime/wasm-compiler-edge.js +84 -0
  51. package/generated/prisma-postgresql/runtime/wasm-engine-edge.js +36 -0
  52. package/generated/prisma-postgresql/schema.prisma +347 -0
  53. package/generated/prisma-postgresql/wasm-edge-light-loader.mjs +4 -0
  54. package/generated/prisma-postgresql/wasm-worker-loader.mjs +4 -0
  55. package/generated/prisma-postgresql/wasm.d.ts +1 -0
  56. package/generated/prisma-postgresql/wasm.js +365 -0
  57. package/package.json +5 -5
  58. package/application/commands/integration-commands.test.js +0 -123
  59. package/core/Worker.test.js +0 -159
  60. package/database/encryption/encryption-integration.test.js +0 -553
  61. package/database/encryption/encryption-schema-registry.test.js +0 -392
  62. package/database/encryption/field-encryption-service.test.js +0 -525
  63. package/database/encryption/mongo-decryption-fix-verification.test.js +0 -348
  64. package/database/encryption/postgres-decryption-fix-verification.test.js +0 -371
  65. package/database/encryption/postgres-relation-decryption.test.js +0 -245
  66. package/database/encryption/prisma-encryption-extension.test.js +0 -439
  67. package/database/repositories/migration-status-repository-s3.test.js +0 -158
  68. package/database/use-cases/check-encryption-health-use-case.test.js +0 -192
  69. package/database/use-cases/get-migration-status-use-case.test.js +0 -171
  70. package/database/use-cases/run-database-migration-use-case.test.js +0 -310
  71. package/database/use-cases/trigger-database-migration-use-case.test.js +0 -250
  72. package/database/utils/prisma-runner.test.js +0 -486
  73. package/encrypt/Cryptor.test.js +0 -144
  74. package/errors/base-error.test.js +0 -32
  75. package/errors/fetch-error.test.js +0 -79
  76. package/errors/halt-error.test.js +0 -11
  77. package/errors/validation-errors.test.js +0 -120
  78. package/handlers/auth-flow.integration.test.js +0 -147
  79. package/handlers/integration-event-dispatcher.test.js +0 -209
  80. package/handlers/routers/db-migration.test.js +0 -51
  81. package/handlers/routers/health.test.js +0 -210
  82. package/handlers/routers/integration-webhook-routers.test.js +0 -126
  83. package/handlers/use-cases/check-integrations-health-use-case.test.js +0 -125
  84. package/handlers/webhook-flow.integration.test.js +0 -356
  85. package/handlers/workers/db-migration.test.js +0 -50
  86. package/handlers/workers/integration-defined-workers.test.js +0 -184
  87. package/integrations/tests/integration-router-multi-auth.test.js +0 -369
  88. package/integrations/tests/use-cases/create-integration.test.js +0 -131
  89. package/integrations/tests/use-cases/delete-integration-for-user.test.js +0 -150
  90. package/integrations/tests/use-cases/find-integration-context-by-external-entity-id.test.js +0 -92
  91. package/integrations/tests/use-cases/get-integration-for-user.test.js +0 -150
  92. package/integrations/tests/use-cases/get-integration-instance.test.js +0 -176
  93. package/integrations/tests/use-cases/get-integrations-for-user.test.js +0 -176
  94. package/integrations/tests/use-cases/get-possible-integrations.test.js +0 -188
  95. package/integrations/tests/use-cases/update-integration-messages.test.js +0 -142
  96. package/integrations/tests/use-cases/update-integration-status.test.js +0 -103
  97. package/integrations/tests/use-cases/update-integration.test.js +0 -141
  98. package/integrations/use-cases/create-process.test.js +0 -178
  99. package/integrations/use-cases/get-process.test.js +0 -190
  100. package/integrations/use-cases/load-integration-context-full.test.js +0 -329
  101. package/integrations/use-cases/load-integration-context.test.js +0 -114
  102. package/integrations/use-cases/update-process-metrics.test.js +0 -308
  103. package/integrations/use-cases/update-process-state.test.js +0 -256
  104. package/lambda/TimeoutCatcher.test.js +0 -68
  105. package/logs/logger.test.js +0 -76
  106. package/modules/module-hydration.test.js +0 -205
  107. package/modules/requester/requester.test.js +0 -28
  108. package/queues/queuer-util.test.js +0 -132
  109. package/user/tests/use-cases/create-individual-user.test.js +0 -24
  110. package/user/tests/use-cases/create-organization-user.test.js +0 -28
  111. package/user/tests/use-cases/create-token-for-user-id.test.js +0 -19
  112. package/user/tests/use-cases/get-user-from-adopter-jwt.test.js +0 -113
  113. package/user/tests/use-cases/get-user-from-bearer-token.test.js +0 -64
  114. package/user/tests/use-cases/get-user-from-x-frigg-headers.test.js +0 -346
  115. package/user/tests/use-cases/login-user.test.js +0 -220
  116. package/user/tests/user-password-encryption-isolation.test.js +0 -237
  117. package/user/tests/user-password-hashing.test.js +0 -235
  118. package/websocket/repositories/websocket-connection-repository.test.js +0 -227
@@ -1,392 +0,0 @@
1
- const {
2
- CORE_ENCRYPTION_SCHEMA,
3
- getEncryptedFields,
4
- hasEncryptedFields,
5
- getEncryptedModels,
6
- registerCustomSchema,
7
- validateCustomSchema,
8
- resetCustomSchema,
9
- } = require('./encryption-schema-registry');
10
-
11
- describe('Encryption Schema Registry', () => {
12
- afterEach(() => {
13
- // Reset custom schema after each test
14
- resetCustomSchema();
15
- });
16
-
17
- describe('CORE_ENCRYPTION_SCHEMA', () => {
18
- it('should define encrypted fields for Credential model', () => {
19
- expect(CORE_ENCRYPTION_SCHEMA.Credential).toBeDefined();
20
- expect(CORE_ENCRYPTION_SCHEMA.Credential.fields).toContain(
21
- 'data.access_token'
22
- );
23
- expect(CORE_ENCRYPTION_SCHEMA.Credential.fields).toContain(
24
- 'data.refresh_token'
25
- );
26
- expect(CORE_ENCRYPTION_SCHEMA.Credential.fields).toContain(
27
- 'data.id_token'
28
- );
29
- });
30
-
31
- it('should define encrypted fields for IntegrationMapping model', () => {
32
- expect(CORE_ENCRYPTION_SCHEMA.IntegrationMapping).toBeDefined();
33
- expect(CORE_ENCRYPTION_SCHEMA.IntegrationMapping.fields).toContain(
34
- 'mapping'
35
- );
36
- });
37
-
38
- it('should define encrypted fields for User model', () => {
39
- expect(CORE_ENCRYPTION_SCHEMA.User).toBeDefined();
40
- expect(CORE_ENCRYPTION_SCHEMA.User.fields).toContain('hashword');
41
- });
42
-
43
- it('should define encrypted fields for Token model', () => {
44
- expect(CORE_ENCRYPTION_SCHEMA.Token).toBeDefined();
45
- expect(CORE_ENCRYPTION_SCHEMA.Token.fields).toContain('token');
46
- });
47
- });
48
-
49
- describe('getEncryptedFields', () => {
50
- it('should return encrypted fields for Credential model', () => {
51
- const fields = getEncryptedFields('Credential');
52
-
53
- expect(fields).toEqual([
54
- 'data.access_token',
55
- 'data.refresh_token',
56
- 'data.id_token',
57
- ]);
58
- });
59
-
60
- it('should return encrypted fields for User model', () => {
61
- const fields = getEncryptedFields('User');
62
-
63
- expect(fields).toEqual(['hashword']);
64
- });
65
-
66
- it('should return empty array for model without encrypted fields', () => {
67
- const fields = getEncryptedFields('NonExistentModel');
68
-
69
- expect(fields).toEqual([]);
70
- });
71
-
72
- it('should return empty array for undefined model', () => {
73
- const fields = getEncryptedFields(undefined);
74
-
75
- expect(fields).toEqual([]);
76
- });
77
-
78
- it('should return empty array for null model', () => {
79
- const fields = getEncryptedFields(null);
80
-
81
- expect(fields).toEqual([]);
82
- });
83
-
84
- it('should support nested JSON paths', () => {
85
- const fields = getEncryptedFields('Credential');
86
- const nestedFields = fields.filter((f) => f.includes('.'));
87
-
88
- expect(nestedFields.length).toBeGreaterThan(0);
89
- expect(nestedFields).toContain('data.access_token');
90
- });
91
- });
92
-
93
- describe('hasEncryptedFields', () => {
94
- it('should return true for models with encrypted fields', () => {
95
- expect(hasEncryptedFields('Credential')).toBe(true);
96
- expect(hasEncryptedFields('User')).toBe(true);
97
- expect(hasEncryptedFields('Token')).toBe(true);
98
- expect(hasEncryptedFields('IntegrationMapping')).toBe(true);
99
- });
100
-
101
- it('should return false for models without encrypted fields', () => {
102
- expect(hasEncryptedFields('State')).toBe(false);
103
- expect(hasEncryptedFields('NonExistentModel')).toBe(false);
104
- });
105
-
106
- it('should return false for undefined model', () => {
107
- expect(hasEncryptedFields(undefined)).toBe(false);
108
- });
109
-
110
- it('should return false for null model', () => {
111
- expect(hasEncryptedFields(null)).toBe(false);
112
- });
113
- });
114
-
115
- describe('getEncryptedModels', () => {
116
- it('should return list of all models with encryption', () => {
117
- const models = getEncryptedModels();
118
-
119
- expect(models).toContain('Credential');
120
- expect(models).toContain('IntegrationMapping');
121
- expect(models).toContain('User');
122
- expect(models).toContain('Token');
123
- });
124
-
125
- it('should return array with length equal to encrypted models', () => {
126
- const models = getEncryptedModels();
127
-
128
- expect(models.length).toBe(
129
- Object.keys(CORE_ENCRYPTION_SCHEMA).length
130
- );
131
- });
132
-
133
- it('should return unique model names', () => {
134
- const models = getEncryptedModels();
135
- const uniqueModels = [...new Set(models)];
136
-
137
- expect(models.length).toBe(uniqueModels.length);
138
- });
139
- });
140
-
141
- describe('Schema Validation', () => {
142
- it('should have valid field paths (no leading/trailing dots)', () => {
143
- const models = getEncryptedModels();
144
-
145
- models.forEach((modelName) => {
146
- const fields = getEncryptedFields(modelName);
147
-
148
- fields.forEach((fieldPath) => {
149
- expect(fieldPath).not.toMatch(/^\./);
150
- expect(fieldPath).not.toMatch(/\.$/);
151
- expect(fieldPath.length).toBeGreaterThan(0);
152
- });
153
- });
154
- });
155
-
156
- it('should not have duplicate field paths within a model', () => {
157
- const models = getEncryptedModels();
158
-
159
- models.forEach((modelName) => {
160
- const fields = getEncryptedFields(modelName);
161
- const uniqueFields = [...new Set(fields)];
162
-
163
- expect(fields.length).toBe(uniqueFields.length);
164
- });
165
- });
166
-
167
- it('should have at least one field per encrypted model', () => {
168
- const models = getEncryptedModels();
169
-
170
- models.forEach((modelName) => {
171
- const fields = getEncryptedFields(modelName);
172
-
173
- expect(fields.length).toBeGreaterThan(0);
174
- });
175
- });
176
- });
177
-
178
- describe('Custom Schema Registration', () => {
179
- describe('validateCustomSchema', () => {
180
- it('should validate a valid custom schema', () => {
181
- const customSchema = {
182
- MyModel: {
183
- fields: ['secretField', 'data.apiKey'],
184
- },
185
- };
186
-
187
- const result = validateCustomSchema(customSchema);
188
-
189
- expect(result.valid).toBe(true);
190
- expect(result.errors).toEqual([]);
191
- });
192
-
193
- it('should reject non-object schema', () => {
194
- const result = validateCustomSchema('invalid');
195
-
196
- expect(result.valid).toBe(false);
197
- expect(result.errors).toContain(
198
- 'Custom schema must be an object'
199
- );
200
- });
201
-
202
- it('should reject model without fields array', () => {
203
- const customSchema = {
204
- MyModel: {
205
- notFields: ['test'],
206
- },
207
- };
208
-
209
- const result = validateCustomSchema(customSchema);
210
-
211
- expect(result.valid).toBe(false);
212
- expect(result.errors[0]).toContain('must have a "fields" array');
213
- });
214
-
215
- it('should reject invalid field paths', () => {
216
- const customSchema = {
217
- MyModel: {
218
- fields: ['validField', '', null],
219
- },
220
- };
221
-
222
- const result = validateCustomSchema(customSchema);
223
-
224
- expect(result.valid).toBe(false);
225
- expect(result.errors.length).toBeGreaterThan(0);
226
- });
227
-
228
- it('should prevent overriding core encrypted fields', () => {
229
- const customSchema = {
230
- Credential: {
231
- fields: ['data.access_token'], // Core field
232
- },
233
- };
234
-
235
- const result = validateCustomSchema(customSchema);
236
-
237
- expect(result.valid).toBe(false);
238
- expect(result.errors[0]).toContain('Cannot override core');
239
- expect(result.errors[0]).toContain('data.access_token');
240
- });
241
-
242
- it('should allow adding new fields to core models', () => {
243
- const customSchema = {
244
- Credential: {
245
- fields: ['data.customField'], // New field
246
- },
247
- };
248
-
249
- const result = validateCustomSchema(customSchema);
250
-
251
- expect(result.valid).toBe(true);
252
- expect(result.errors).toEqual([]);
253
- });
254
- });
255
-
256
- describe('registerCustomSchema', () => {
257
- it('should register a valid custom schema', () => {
258
- const customSchema = {
259
- MyCustomModel: {
260
- fields: ['secretData', 'apiKey'],
261
- },
262
- };
263
-
264
- expect(() => registerCustomSchema(customSchema)).not.toThrow();
265
-
266
- const fields = getEncryptedFields('MyCustomModel');
267
- expect(fields).toEqual(['secretData', 'apiKey']);
268
- });
269
-
270
- it('should throw error for invalid schema', () => {
271
- const invalidSchema = {
272
- MyModel: {
273
- fields: ['validField', ''], // Empty string invalid
274
- },
275
- };
276
-
277
- expect(() => registerCustomSchema(invalidSchema)).toThrow(
278
- 'Invalid custom encryption schema'
279
- );
280
- });
281
-
282
- it('should handle empty schema gracefully', () => {
283
- expect(() => registerCustomSchema({})).not.toThrow();
284
- expect(() => registerCustomSchema(null)).not.toThrow();
285
- });
286
-
287
- it('should throw when trying to override core fields', () => {
288
- const invalidSchema = {
289
- User: {
290
- fields: ['hashword'], // Core field
291
- },
292
- };
293
-
294
- expect(() => registerCustomSchema(invalidSchema)).toThrow(
295
- 'Cannot override core'
296
- );
297
- });
298
- });
299
-
300
- describe('Custom schema merging', () => {
301
- it('should merge custom fields with core fields', () => {
302
- const customSchema = {
303
- Credential: {
304
- fields: ['data.customToken', 'data.customSecret'],
305
- },
306
- };
307
-
308
- registerCustomSchema(customSchema);
309
-
310
- const fields = getEncryptedFields('Credential');
311
-
312
- // Should include both core and custom
313
- expect(fields).toContain('data.access_token'); // Core
314
- expect(fields).toContain('data.customToken'); // Custom
315
- expect(fields).toContain('data.customSecret'); // Custom
316
- });
317
-
318
- it('should deduplicate merged fields', () => {
319
- const customSchema = {
320
- Credential: {
321
- fields: ['data.newField'],
322
- },
323
- };
324
-
325
- registerCustomSchema(customSchema);
326
-
327
- const fields = getEncryptedFields('Credential');
328
- const uniqueFields = [...new Set(fields)];
329
-
330
- expect(fields.length).toBe(uniqueFields.length);
331
- });
332
-
333
- it('should include custom models in getEncryptedModels', () => {
334
- const customSchema = {
335
- MyCustomModel: {
336
- fields: ['secret'],
337
- },
338
- };
339
-
340
- registerCustomSchema(customSchema);
341
-
342
- const models = getEncryptedModels();
343
-
344
- expect(models).toContain('MyCustomModel');
345
- expect(models).toContain('Credential'); // Core model still there
346
- });
347
-
348
- it('should report custom models have encrypted fields', () => {
349
- const customSchema = {
350
- MyCustomModel: {
351
- fields: ['secret'],
352
- },
353
- };
354
-
355
- registerCustomSchema(customSchema);
356
-
357
- expect(hasEncryptedFields('MyCustomModel')).toBe(true);
358
- });
359
- });
360
-
361
- describe('resetCustomSchema', () => {
362
- it('should clear custom schema', () => {
363
- const customSchema = {
364
- MyModel: {
365
- fields: ['secret'],
366
- },
367
- };
368
-
369
- registerCustomSchema(customSchema);
370
- expect(hasEncryptedFields('MyModel')).toBe(true);
371
-
372
- resetCustomSchema();
373
- expect(hasEncryptedFields('MyModel')).toBe(false);
374
- });
375
-
376
- it('should not affect core schema', () => {
377
- const customSchema = {
378
- MyModel: {
379
- fields: ['secret'],
380
- },
381
- };
382
-
383
- registerCustomSchema(customSchema);
384
- resetCustomSchema();
385
-
386
- // Core models still encrypted
387
- expect(hasEncryptedFields('Credential')).toBe(true);
388
- expect(hasEncryptedFields('User')).toBe(true);
389
- });
390
- });
391
- });
392
- });