@friggframework/core 2.0.0--canary.686.219e1e7.0 → 2.0.0--canary.686.00d79d8.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/modules/module.js CHANGED
@@ -21,9 +21,17 @@ class Module extends Delegate {
21
21
  * @param {string} params.userId The user id
22
22
  * @param {Object} params.entity The entity record from the database
23
23
  * @param {string} [params.state] Optional OAuth state value forwarded to the API client (round-trips through the OAuth provider).
24
- * @param {Object} [params.resolvedEnv] definition.env already resolved by Module.create(); defaults to the static definition.env.
24
+ * @param {Object} [params.resolvedEnv] definition.env as Module.create() resolved it (may be undefined).
25
+ * @param {boolean} [params.envResolved=false] true when resolvedEnv carries the resolved env, even an undefined one; otherwise the static definition.env is used.
25
26
  */
26
- constructor({ definition, userId = null, entity: entityObj = null, state = null, resolvedEnv = null }) {
27
+ constructor({
28
+ definition,
29
+ userId = null,
30
+ entity: entityObj = null,
31
+ state = null,
32
+ resolvedEnv,
33
+ envResolved = false,
34
+ }) {
27
35
  super({ definition, userId, entity: entityObj });
28
36
 
29
37
  this.validateDefinition(definition);
@@ -58,9 +66,10 @@ class Module extends Delegate {
58
66
  // A pre-resolved env (Module.create()) supports definition.env as an
59
67
  // async function, e.g. OAuth app credentials loaded from the database
60
68
  // by the db-credentials extension; otherwise the static object.
61
- // No resolved env (the null default; an explicit undefined takes it
62
- // too) means the static definition.env applies.
63
- const envValues = resolvedEnv ?? this.definition.env;
69
+ // "Resolved" is an explicit flag, not a non-null value: a function env
70
+ // may legitimately resolve to undefined (no static env, no DB row),
71
+ // and falling back to definition.env would then read the function.
72
+ const envValues = envResolved ? resolvedEnv : this.definition.env;
64
73
  if (typeof envValues === 'function') {
65
74
  // Spreading a function yields no keys, so the API client would
66
75
  // silently get no client_id / client_secret.
@@ -106,7 +115,7 @@ class Module extends Delegate {
106
115
  */
107
116
  static async create({ definition, userId = null, entity = null, state = null }) {
108
117
  const resolvedEnv = await Module.resolveEnv(definition);
109
- return new Module({ definition, userId, entity, state, resolvedEnv });
118
+ return new Module({ definition, userId, entity, state, resolvedEnv, envResolved: true });
110
119
  }
111
120
 
112
121
  getName() {
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.686.219e1e7.0",
4
+ "version": "2.0.0--canary.686.00d79d8.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
7
7
  "@aws-sdk/client-kms": "^3.588.0",
@@ -48,9 +48,9 @@
48
48
  }
49
49
  },
50
50
  "devDependencies": {
51
- "@friggframework/eslint-config": "2.0.0--canary.686.219e1e7.0",
52
- "@friggframework/prettier-config": "2.0.0--canary.686.219e1e7.0",
53
- "@friggframework/test": "2.0.0--canary.686.219e1e7.0",
51
+ "@friggframework/eslint-config": "2.0.0--canary.686.00d79d8.0",
52
+ "@friggframework/prettier-config": "2.0.0--canary.686.00d79d8.0",
53
+ "@friggframework/test": "2.0.0--canary.686.00d79d8.0",
54
54
  "@prisma/client": "^6.19.3",
55
55
  "@types/lodash": "4.17.15",
56
56
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -90,5 +90,5 @@
90
90
  "publishConfig": {
91
91
  "access": "public"
92
92
  },
93
- "gitHead": "219e1e7c2a387b3ddf1fa20ca10d0b87093bd38e"
93
+ "gitHead": "00d79d89a9657b62bf89544cbfdf3338e84aea0c"
94
94
  }
@@ -51,6 +51,8 @@ class NetlifyBackgroundProvider extends QueueProvider {
51
51
  this.signingSecret = options.signingSecret;
52
52
  this.env = options.env || process.env;
53
53
  this.now = options.now || Date.now;
54
+ // verifyEvent() proves an HTTP delivery came from Frigg.
55
+ this.verifiesHttpDelivery = true;
54
56
  }
55
57
 
56
58
  // Read on every call, not in the constructor: secrets may be loaded into
@@ -50,6 +50,8 @@ class QStashQueueProvider extends QueueProvider {
50
50
  this.destinationUrl = options.destinationUrl;
51
51
  this.env = options.env || process.env;
52
52
  this.clockToleranceSeconds = options.clockToleranceSeconds || 0;
53
+ // verifyEvent() proves an HTTP delivery came from QStash.
54
+ this.verifiesHttpDelivery = true;
53
55
  }
54
56
 
55
57
  // Read per call: secrets may reach the environment after construction.
@@ -49,7 +49,10 @@ class QueueProvider {
49
49
  *
50
50
  * The default refuses: an adapter that does not know how to verify its
51
51
  * events must not have them run. An adapter whose transport already
52
- * authenticates the caller (SQS triggering a Lambda) overrides this.
52
+ * authenticates the caller (SQS triggering a Lambda) overrides this, and
53
+ * must not set `verifiesHttpDelivery`: an HTTP entry point (Netlify's
54
+ * worker-background) consults only adapters that set it to true, since
55
+ * a transport-trust answer says nothing about an HTTP caller.
53
56
  *
54
57
  * @param {Object} event - Raw event from the runtime
55
58
  * @returns {Promise<{ ok: boolean, reason?: string, unsigned?: boolean }>}