@friggframework/core 2.0.0--canary.686.3e27a92.0 → 2.0.0--canary.663.8de669c.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/CLAUDE.md +0 -28
- package/README.md +0 -105
- package/application/commands/integration-commands.js +10 -20
- package/application/commands/scheduler-commands.js +7 -11
- package/application/commands/user-commands.js +5 -17
- package/application/index.js +2 -6
- package/core/Worker.js +7 -31
- package/core/create-handler.js +0 -9
- package/credential/repositories/credential-repository-documentdb.js +0 -34
- package/credential/repositories/credential-repository-interface.js +0 -15
- package/credential/repositories/credential-repository-mongo.js +0 -23
- package/credential/repositories/credential-repository-postgres.js +0 -28
- package/database/config.js +24 -48
- package/database/documentdb-utils.js +1 -6
- package/database/encryption/encryption-config.js +31 -10
- package/database/encryption/encryption-schema-registry.js +12 -93
- package/database/prisma.js +2 -4
- package/generated/prisma-mongodb/edge.js +4 -43
- package/generated/prisma-mongodb/index-browser.js +1 -40
- package/generated/prisma-mongodb/index.d.ts +111 -4739
- package/generated/prisma-mongodb/index.js +4 -43
- package/generated/prisma-mongodb/package.json +1 -1
- package/generated/prisma-mongodb/schema.prisma +0 -92
- package/generated/prisma-mongodb/wasm.js +4 -43
- package/generated/prisma-postgresql/edge.js +4 -43
- package/generated/prisma-postgresql/index-browser.js +1 -40
- package/generated/prisma-postgresql/index.d.ts +33 -4966
- package/generated/prisma-postgresql/index.js +4 -43
- package/generated/prisma-postgresql/package.json +1 -1
- package/generated/prisma-postgresql/schema.prisma +0 -87
- package/generated/prisma-postgresql/wasm.js +4 -43
- package/handlers/app-definition-loader.js +19 -121
- package/handlers/app-handler-helpers.js +3 -25
- package/handlers/backend-utils.js +25 -31
- package/handlers/middleware/admin-auth.js +1 -14
- package/handlers/routers/auth.js +10 -46
- package/handlers/routers/health.js +4 -13
- package/handlers/routers/integration-defined-routers.js +92 -144
- package/handlers/routers/integration-webhook-routers.js +64 -102
- package/handlers/workers/integration-defined-workers.js +2 -5
- package/index.js +1 -65
- package/infrastructure/scheduler/index.js +6 -19
- package/infrastructure/scheduler/scheduler-service-factory.js +7 -55
- package/integrations/index.js +0 -1
- package/integrations/integration-router.js +96 -131
- package/integrations/repositories/integration-repository-documentdb.js +3 -35
- package/integrations/repositories/integration-repository-interface.js +1 -17
- package/integrations/repositories/integration-repository-mongo.js +76 -59
- package/integrations/repositories/integration-repository-postgres.js +76 -62
- package/integrations/tests/doubles/test-integration-repository.js +1 -12
- package/integrations/use-cases/create-integration.js +20 -55
- package/integrations/use-cases/get-integrations-for-user.js +40 -80
- package/integrations/use-cases/index.js +1 -7
- package/integrations/utils/map-integration-dto.js +14 -43
- package/modules/index.js +0 -14
- package/modules/module-factory.js +0 -12
- package/modules/module.js +2 -53
- package/modules/repositories/module-repository-documentdb.js +6 -51
- package/modules/repositories/module-repository-interface.js +2 -19
- package/modules/repositories/module-repository-mongo.js +74 -67
- package/modules/repositories/module-repository-postgres.js +74 -66
- package/modules/repositories/module-repository.js +1 -2
- package/modules/requester/requester.js +2 -27
- package/modules/use-cases/get-entities-for-user.js +13 -26
- package/modules/use-cases/get-entity-options-by-id.js +4 -10
- package/modules/use-cases/get-entity-options-by-type.js +1 -1
- package/modules/use-cases/get-module-instance-from-type.js +1 -1
- package/modules/use-cases/get-module.js +4 -10
- package/modules/use-cases/process-authorization-callback.js +19 -53
- package/modules/use-cases/refresh-entity-options.js +4 -10
- package/modules/use-cases/test-module-auth.js +4 -10
- package/package.json +5 -6
- package/prisma-mongodb/schema.prisma +0 -92
- package/prisma-postgresql/schema.prisma +0 -87
- package/queues/index.js +0 -25
- package/types/index.d.ts +0 -2
- package/user/repositories/user-repository-documentdb.js +2 -27
- package/user/repositories/user-repository-interface.js +0 -18
- package/user/repositories/user-repository-mongo.js +0 -24
- package/user/repositories/user-repository-postgres.js +0 -18
- package/user/use-cases/authenticate-user.js +1 -7
- package/user/use-cases/get-user-from-adopter-jwt.js +124 -95
- package/user/use-cases/get-user-from-x-frigg-headers.js +80 -83
- package/user/user.js +1 -64
- package/credential/use-cases/credential-operations-for-user.js +0 -202
- package/credential/use-cases/reauthorize-credential-for-user.js +0 -73
- package/database/organization-where.js +0 -18
- package/database/unique-violation.js +0 -25
- package/extensions/bootstrap-runner.js +0 -43
- package/extensions/extension-loader.js +0 -187
- package/extensions/index.js +0 -41
- package/extensions/initialize-app.js +0 -123
- package/extensions/route-mounter.js +0 -103
- package/extensions/schema-composer.js +0 -188
- package/infrastructure/scheduler/netlify-scheduler-adapter.js +0 -216
- package/infrastructure/scheduler/scheduled-job-repository.js +0 -118
- package/integrations/repositories/integration-not-found.js +0 -14
- package/integrations/schedule-config.js +0 -80
- package/integrations/use-cases/dispatch-ongoing-syncs.js +0 -100
- package/integrations/use-cases/integration-operations-for-user.js +0 -256
- package/integrations/use-cases/resolve-integration-ownership.js +0 -177
- package/management-api/create-management-api-router.js +0 -49
- package/management-api/error-response.js +0 -116
- package/management-api/management-api-config.js +0 -151
- package/management-api/meta-router.js +0 -76
- package/management-api/openapi/build-openapi.js +0 -144
- package/management-api/openapi/components.js +0 -408
- package/management-api/openapi/v1-operations.js +0 -83
- package/management-api/openapi/v2-operations.js +0 -264
- package/management-api/route-registry.js +0 -411
- package/management-api/test-support/http-client.js +0 -39
- package/management-api/use-cases/get-management-api-meta.js +0 -57
- package/management-api/v1-deprecation.js +0 -120
- package/management-api/v2/create-v2-router.js +0 -85
- package/management-api/v2/dependencies.js +0 -281
- package/management-api/v2/dto.js +0 -143
- package/management-api/v2/handlers/authorization.js +0 -94
- package/management-api/v2/handlers/credentials.js +0 -33
- package/management-api/v2/handlers/entities.js +0 -77
- package/management-api/v2/handlers/integrations.js +0 -128
- package/management-api/v2/handlers/proxy.js +0 -34
- package/management-api/v2/request.js +0 -85
- package/management-api/v2/test-support/fake-dependencies.js +0 -103
- package/modules/domain/authorization-session.js +0 -144
- package/modules/entity-scope.js +0 -15
- package/modules/entity-type-registry.js +0 -311
- package/modules/proxy/proxy-errors.js +0 -20
- package/modules/proxy/proxy-path.js +0 -179
- package/modules/proxy/proxy-policy.js +0 -248
- package/modules/repositories/authorization-session-repository-documentdb.js +0 -112
- package/modules/repositories/authorization-session-repository-factory.js +0 -31
- package/modules/repositories/authorization-session-repository-interface.js +0 -47
- package/modules/repositories/authorization-session-repository-prisma.js +0 -87
- package/modules/repositories/entity-not-found.js +0 -18
- package/modules/requester/proxy-request.js +0 -244
- package/modules/scope-config.js +0 -192
- package/modules/scope-policy.js +0 -112
- package/modules/scope-resolution.js +0 -288
- package/modules/scope-visibility.js +0 -247
- package/modules/tests/doubles/in-memory-authorization-session-repository.js +0 -45
- package/modules/tests/doubles/ownership-matching.js +0 -18
- package/modules/use-cases/authorize-entity-for-user.js +0 -61
- package/modules/use-cases/create-entity-from-credential.js +0 -113
- package/modules/use-cases/entity-operations-for-user.js +0 -162
- package/modules/use-cases/entity-types.js +0 -139
- package/modules/use-cases/execute-entity-proxy-request.js +0 -286
- package/modules/use-cases/get-authorization-requirements.js +0 -100
- package/modules/use-cases/get-entity-module-for-user.js +0 -113
- package/modules/use-cases/manage-access.js +0 -21
- package/modules/use-cases/multi-step-authorization.js +0 -329
- package/prisma-postgresql/migrations/20261003000000_add_authorization_session/migration.sql +0 -28
- package/prisma-postgresql/migrations/20261015000000_add_organization_membership/migration.sql +0 -26
- package/prisma-postgresql/migrations/20261016000000_add_entity_integration_organization/migration.sql +0 -25
- package/prisma-postgresql/migrations/20261017000000_add_scheduled_job/migration.sql +0 -28
- package/providers/index.js +0 -23
- package/providers/resolve-provider.js +0 -93
- package/providers/runtime-detection.js +0 -124
- package/queues/providers/index.js +0 -11
- package/queues/providers/netlify-background-provider.js +0 -150
- package/queues/providers/qstash-queue-provider.js +0 -219
- package/queues/providers/sqs-queue-provider.js +0 -70
- package/queues/queue-client-interface.js +0 -55
- package/queues/queue-message-auth.js +0 -193
- package/queues/queue-provider-factory.js +0 -101
- package/queues/queue-provider.js +0 -65
- package/queues/sqs-queue-client.js +0 -81
- package/types/modules/index.d.ts +0 -197
- package/types/user/index.d.ts +0 -134
- package/user/adopter-jwt-config.js +0 -177
- package/user/adopter-jwt-errors.js +0 -59
- package/user/adopter-token-verifier.js +0 -122
- package/user/app-user-helpers.js +0 -97
- package/user/create-user-authentication.js +0 -64
- package/user/membership.js +0 -51
- package/user/repositories/organization-membership-record.js +0 -19
- package/user/repositories/organization-membership-repository-documentdb.js +0 -106
- package/user/repositories/organization-membership-repository-factory.js +0 -42
- package/user/repositories/organization-membership-repository-interface.js +0 -57
- package/user/repositories/organization-membership-repository-mongo.js +0 -13
- package/user/repositories/organization-membership-repository-postgres.js +0 -29
- package/user/repositories/organization-membership-repository-prisma.js +0 -81
- package/user/tests/doubles/adopter-jwt-fixtures.js +0 -220
- package/user/use-cases/ensure-organization-membership.js +0 -92
- package/user/use-cases/find-individual-users-by-organization.js +0 -54
|
@@ -58,12 +58,7 @@ async function insertOne(client, collection, document) {
|
|
|
58
58
|
|
|
59
59
|
// Provide helpful context for common errors
|
|
60
60
|
if (error.code === 11000) {
|
|
61
|
-
|
|
62
|
-
// (see database/unique-violation.js).
|
|
63
|
-
throw Object.assign(
|
|
64
|
-
new Error(`${errorMsg} - Duplicate key violation`),
|
|
65
|
-
{ code: 11000 }
|
|
66
|
-
);
|
|
61
|
+
throw new Error(`${errorMsg} - Duplicate key violation`);
|
|
67
62
|
}
|
|
68
63
|
throw new Error(errorMsg);
|
|
69
64
|
}
|
|
@@ -18,9 +18,6 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
const { logger } = require('./logger');
|
|
21
|
-
const {
|
|
22
|
-
isDeployedRuntime: isDeployedProviderRuntime,
|
|
23
|
-
} = require('../../providers/runtime-detection');
|
|
24
21
|
|
|
25
22
|
const LOCAL_BYPASS_STAGES = ['dev', 'test', 'local'];
|
|
26
23
|
const OPT_OUT_VAR = 'FRIGG_ENCRYPTION_DISABLED';
|
|
@@ -43,18 +40,42 @@ function isTrue(value) {
|
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
/**
|
|
46
|
-
* True when the process runs as a deployed function, on AWS Lambda or on
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* runtime
|
|
51
|
-
*
|
|
43
|
+
* True when the process runs as a deployed function, on AWS Lambda or on
|
|
44
|
+
* another provider's platform.
|
|
45
|
+
*
|
|
46
|
+
* - AWS Lambda sets AWS_LAMBDA_FUNCTION_NAME, LAMBDA_TASK_ROOT and
|
|
47
|
+
* AWS_EXECUTION_ENV (AWS_Lambda_<runtime>). Other AWS hosts (CloudShell,
|
|
48
|
+
* CodeBuild, ECS) set AWS_EXECUTION_ENV to other values and count as local:
|
|
49
|
+
* CLI commands run from CI must not trip the deployed-stage check.
|
|
50
|
+
* - Other providers: FRIGG_PROVIDER names a non-AWS provider. Frigg's
|
|
51
|
+
* generated function entry points for that provider set it (provider-netlify
|
|
52
|
+
* sets 'netlify'), so it is present in every deployed function. Netlify
|
|
53
|
+
* exposes SITE_ID, CONTEXT and NETLIFY at build time only, so they cannot
|
|
54
|
+
* tell a running function from a laptop.
|
|
55
|
+
*
|
|
56
|
+
* A local run is never deployed: serverless-offline and `serverless invoke
|
|
57
|
+
* local` (which set the Lambda variables themselves) mark IS_OFFLINE /
|
|
58
|
+
* IS_LOCAL, `netlify dev` marks NETLIFY_DEV, and Jest marks JEST_WORKER_ID.
|
|
52
59
|
*
|
|
53
60
|
* @param {Object} [env=process.env]
|
|
54
61
|
* @returns {boolean}
|
|
55
62
|
*/
|
|
56
63
|
function isDeployedRuntime(env = process.env) {
|
|
57
|
-
|
|
64
|
+
const localRun =
|
|
65
|
+
isTrue(env.IS_OFFLINE) ||
|
|
66
|
+
isTrue(env.IS_LOCAL) ||
|
|
67
|
+
isTrue(env.NETLIFY_DEV) ||
|
|
68
|
+
isSet(env.JEST_WORKER_ID);
|
|
69
|
+
if (localRun) return false;
|
|
70
|
+
|
|
71
|
+
const onAwsRuntime =
|
|
72
|
+
isSet(env.AWS_LAMBDA_FUNCTION_NAME) ||
|
|
73
|
+
isSet(env.LAMBDA_TASK_ROOT) ||
|
|
74
|
+
String(env.AWS_EXECUTION_ENV ?? '').startsWith('AWS_Lambda_');
|
|
75
|
+
if (onAwsRuntime) return true;
|
|
76
|
+
|
|
77
|
+
const provider = String(env.FRIGG_PROVIDER ?? '').trim().toLowerCase();
|
|
78
|
+
return provider !== '' && provider !== 'aws';
|
|
58
79
|
}
|
|
59
80
|
|
|
60
81
|
function missingKeyMessage(stage) {
|
|
@@ -39,12 +39,6 @@ const CORE_ENCRYPTION_SCHEMA = {
|
|
|
39
39
|
Token: {
|
|
40
40
|
fields: ['token'],
|
|
41
41
|
},
|
|
42
|
-
|
|
43
|
-
// Multi-step authorization (Management API v2): earlier steps can collect
|
|
44
|
-
// emails, usernames or one-time codes.
|
|
45
|
-
AuthorizationSession: {
|
|
46
|
-
fields: ['stepData'],
|
|
47
|
-
},
|
|
48
42
|
};
|
|
49
43
|
|
|
50
44
|
let customSchema = {};
|
|
@@ -180,13 +174,6 @@ function loadModuleEncryptionSchemas(integrations) {
|
|
|
180
174
|
return;
|
|
181
175
|
}
|
|
182
176
|
|
|
183
|
-
// NOTE: this path does not exist ('../integrations' resolves to
|
|
184
|
-
// database/integrations), so today this function throws MODULE_NOT_FOUND,
|
|
185
|
-
// loadCustomEncryptionSchema swallows it, and module credentialFields are
|
|
186
|
-
// effectively NOT registered. Fixing it changes which fields are encrypted
|
|
187
|
-
// and needs a decrypt that tolerates plaintext, so it ships separately:
|
|
188
|
-
// branch claude/internal-mcp-03b-module-credential-encryption. Left as is
|
|
189
|
-
// here on purpose (ADR-059 must not change what gets encrypted).
|
|
190
177
|
const { getModulesDefinitionFromIntegrationClasses } = require('../integrations/utils/map-integration-dto');
|
|
191
178
|
|
|
192
179
|
const moduleDefinitions = getModulesDefinitionFromIntegrationClasses(integrations);
|
|
@@ -218,80 +205,22 @@ function loadModuleEncryptionSchemas(integrations) {
|
|
|
218
205
|
*
|
|
219
206
|
* Used by both Prisma (MongoDB/PostgreSQL) and DocumentDB encryption services.
|
|
220
207
|
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
* @param {Array<Object>} extensions - Normalized extensions (extension-loader)
|
|
227
|
-
*/
|
|
228
|
-
function loadExtensionEncryptionSchemas(extensions) {
|
|
229
|
-
if (!extensions || !Array.isArray(extensions) || extensions.length === 0) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
for (const ext of extensions) {
|
|
234
|
-
if (!ext.encryption || typeof ext.encryption !== 'object') {
|
|
235
|
-
continue;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const schema = {};
|
|
239
|
-
for (const [modelName, config] of Object.entries(ext.encryption)) {
|
|
240
|
-
if (config && Array.isArray(config.fields) && config.fields.length > 0) {
|
|
241
|
-
schema[modelName] = { fields: config.fields };
|
|
242
|
-
}
|
|
243
|
-
}
|
|
208
|
+
function loadCustomEncryptionSchema() {
|
|
209
|
+
try {
|
|
210
|
+
// Lazy require to avoid circular dependency issues
|
|
211
|
+
const path = require('node:path');
|
|
212
|
+
const { findNearestBackendPackageJson } = require('../../utils');
|
|
244
213
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
);
|
|
249
|
-
// registerCustomSchema replaces the registered schema, so merge:
|
|
250
|
-
// an extension adds its models to the app's encryption.schema
|
|
251
|
-
// rather than dropping it.
|
|
252
|
-
const merged = { ...customSchema };
|
|
253
|
-
for (const [modelName, config] of Object.entries(schema)) {
|
|
254
|
-
const existing = merged[modelName]?.fields || [];
|
|
255
|
-
merged[modelName] = {
|
|
256
|
-
...merged[modelName],
|
|
257
|
-
fields: [...new Set([...existing, ...config.fields])],
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
registerCustomSchema(merged);
|
|
214
|
+
const backendPackagePath = findNearestBackendPackageJson();
|
|
215
|
+
if (!backendPackagePath) {
|
|
216
|
+
return; // No backend found, skip custom schema
|
|
261
217
|
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
218
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
const {
|
|
268
|
-
getPresetAppDefinition,
|
|
269
|
-
} = require('../../handlers/app-definition-loader');
|
|
270
|
-
// A definition preset with setAppDefinition() (provider-netlify's
|
|
271
|
-
// preamble) wins: on Netlify process.cwd() cannot find the backend.
|
|
272
|
-
const preset = getPresetAppDefinition();
|
|
273
|
-
if (preset) {
|
|
274
|
-
return preset;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
const path = require('node:path');
|
|
278
|
-
const { findNearestBackendPackageJson } = require('../../utils');
|
|
279
|
-
|
|
280
|
-
const backendPackagePath = findNearestBackendPackageJson();
|
|
281
|
-
if (!backendPackagePath) {
|
|
282
|
-
return null; // No backend found, skip custom schema
|
|
283
|
-
}
|
|
219
|
+
const backendDir = path.dirname(backendPackagePath);
|
|
220
|
+
const backendIndexPath = path.join(backendDir, 'index.js');
|
|
284
221
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const backendModule = require(backendIndexPath);
|
|
289
|
-
return backendModule?.Definition || null;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function loadCustomEncryptionSchema() {
|
|
293
|
-
try {
|
|
294
|
-
const appDefinition = readAppDefinitionForEncryption();
|
|
222
|
+
const backendModule = require(backendIndexPath);
|
|
223
|
+
const appDefinition = backendModule?.Definition;
|
|
295
224
|
|
|
296
225
|
if (!appDefinition) {
|
|
297
226
|
return; // No app definition found
|
|
@@ -311,15 +240,6 @@ function loadCustomEncryptionSchema() {
|
|
|
311
240
|
registerEncryptionOptOut(disable);
|
|
312
241
|
}
|
|
313
242
|
|
|
314
|
-
// Load app-level extension encryption schemas. Before the module
|
|
315
|
-
// schemas: loadModuleEncryptionSchemas currently throws (see the
|
|
316
|
-
// NOTE inside it) and the throw would skip anything after it.
|
|
317
|
-
const { loadExtensions } = require('../../extensions/extension-loader');
|
|
318
|
-
const extensions = loadExtensions(appDefinition);
|
|
319
|
-
if (extensions.length > 0) {
|
|
320
|
-
loadExtensionEncryptionSchemas(extensions);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
243
|
// Load module-level encryption schemas from integrations
|
|
324
244
|
const integrations = appDefinition.integrations;
|
|
325
245
|
if (integrations && Array.isArray(integrations)) {
|
|
@@ -476,7 +396,6 @@ module.exports = {
|
|
|
476
396
|
registerEncryptionOptOut,
|
|
477
397
|
loadCustomEncryptionSchema,
|
|
478
398
|
loadModuleEncryptionSchemas,
|
|
479
|
-
loadExtensionEncryptionSchemas,
|
|
480
399
|
extractCredentialFieldsFromModules,
|
|
481
400
|
validateCustomSchema,
|
|
482
401
|
validateOptOut,
|
package/database/prisma.js
CHANGED
|
@@ -41,15 +41,13 @@ const prismaClientSingleton = () => {
|
|
|
41
41
|
const paths = [
|
|
42
42
|
// Lambda layer location (when using Prisma Lambda layer)
|
|
43
43
|
`/opt/nodejs/node_modules/generated/prisma-${dbType}`,
|
|
44
|
-
// __dirname-based absolute path (Netlify functions and bundlers)
|
|
45
|
-
require('node:path').resolve(__dirname, `../generated/prisma-${dbType}`),
|
|
46
44
|
// Local development location (relative to core package)
|
|
47
45
|
`../generated/prisma-${dbType}`,
|
|
48
46
|
];
|
|
49
47
|
|
|
50
|
-
for (const
|
|
48
|
+
for (const path of paths) {
|
|
51
49
|
try {
|
|
52
|
-
return require(
|
|
50
|
+
return require(path).PrismaClient;
|
|
53
51
|
} catch (err) {
|
|
54
52
|
// Continue to next path
|
|
55
53
|
}
|