@lowdefy/api 0.0.0-experimental-20260707145139 → 0.0.0-experimental-20260710073520

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.
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { ConfigError } from '@lowdefy/errors';
16
- function createAuthorize({ session }) {
16
+ function createAuthorize({ session, system = false }) {
17
17
  // Next-auth getSession provides a session object if the user is authenticated
18
18
  // else session will be null
19
19
  const authenticated = !!session;
@@ -24,6 +24,9 @@ function createAuthorize({ session }) {
24
24
  });
25
25
  }
26
26
  function authorize(config) {
27
+ // A system context (scheduled, webhook, detached runs) was authorized at the
28
+ // transport layer, so nested endpoint calls are never gated on a user session.
29
+ if (system === true) return true;
27
30
  const { auth } = config;
28
31
  if (auth.public === true) return true;
29
32
  if (auth.public === false) {
@@ -36,10 +36,13 @@ async function runDetachedEndpoint(context, { endpointId, payload }) {
36
36
  endpointId
37
37
  });
38
38
  // Force a system context regardless of any session cookie sent with the request.
39
+ // system: true — nested CallApi steps are authorized like function calls (the run
40
+ // was already authorized at the transport layer), not re-gated on a user session.
39
41
  context.session = undefined;
40
42
  context.user = undefined;
41
43
  context.authorize = createAuthorize({
42
- session: undefined
44
+ session: undefined,
45
+ system: true
43
46
  });
44
47
  const routineContext = {
45
48
  steps: {},
@@ -53,10 +53,13 @@ async function runScheduledEndpoint(context, { endpointId, cron }) {
53
53
  throw new ConfigError(`No schedule matching cron "${cron}" for API Endpoint "${endpointId}".`);
54
54
  }
55
55
  // Force a system context regardless of any session cookie sent with the request.
56
+ // system: true — nested CallApi steps are authorized like function calls (the run
57
+ // was already authorized at the transport layer), not re-gated on a user session.
56
58
  context.session = undefined;
57
59
  context.user = undefined;
58
60
  context.authorize = createAuthorize({
59
- session: undefined
61
+ session: undefined,
62
+ system: true
60
63
  });
61
64
  const routineContext = {
62
65
  steps: {},
@@ -50,10 +50,13 @@ async function runWebhookEndpoint(context, { endpointId, body, query, headers })
50
50
  throw err;
51
51
  }
52
52
  // Force a system context regardless of any session cookie sent with the request.
53
+ // system: true — nested CallApi steps are authorized like function calls (the run
54
+ // was already authorized at the transport layer), not re-gated on a user session.
53
55
  context.session = undefined;
54
56
  context.user = undefined;
55
57
  context.authorize = createAuthorize({
56
- session: undefined
58
+ session: undefined,
59
+ system: true
57
60
  });
58
61
  const routineContext = {
59
62
  steps: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/api",
3
- "version": "0.0.0-experimental-20260707145139",
3
+ "version": "0.0.0-experimental-20260710073520",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -34,14 +34,14 @@
34
34
  "dist/*"
35
35
  ],
36
36
  "dependencies": {
37
- "@lowdefy/ajv": "0.0.0-experimental-20260707145139",
38
- "@lowdefy/build": "0.0.0-experimental-20260707145139",
39
- "@lowdefy/errors": "0.0.0-experimental-20260707145139",
40
- "@lowdefy/helpers": "0.0.0-experimental-20260707145139",
41
- "@lowdefy/node-utils": "0.0.0-experimental-20260707145139",
42
- "@lowdefy/nunjucks": "0.0.0-experimental-20260707145139",
43
- "@lowdefy/operators": "0.0.0-experimental-20260707145139",
44
- "@lowdefy/operators-js": "0.0.0-experimental-20260707145139"
37
+ "@lowdefy/ajv": "0.0.0-experimental-20260710073520",
38
+ "@lowdefy/build": "0.0.0-experimental-20260710073520",
39
+ "@lowdefy/errors": "0.0.0-experimental-20260710073520",
40
+ "@lowdefy/helpers": "0.0.0-experimental-20260710073520",
41
+ "@lowdefy/node-utils": "0.0.0-experimental-20260710073520",
42
+ "@lowdefy/nunjucks": "0.0.0-experimental-20260710073520",
43
+ "@lowdefy/operators": "0.0.0-experimental-20260710073520",
44
+ "@lowdefy/operators-js": "0.0.0-experimental-20260710073520"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@jest/globals": "28.1.3",