@n8n/engine 0.16.0 → 0.17.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/dist/auth/authenticate.d.ts +3 -0
- package/dist/auth/authenticate.js +29 -0
- package/dist/auth/authenticate.js.map +1 -0
- package/dist/auth/identity-token.d.ts +14 -0
- package/dist/auth/identity-token.js +66 -0
- package/dist/auth/identity-token.js.map +1 -0
- package/dist/auth/identity.types.d.ts +7 -0
- package/dist/auth/identity.types.js +3 -0
- package/dist/auth/identity.types.js.map +1 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.js +15 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/build.tsbuildinfo +1 -1
- package/dist/database/create-stores.d.ts +3 -2
- package/dist/database/create-stores.js.map +1 -1
- package/dist/database/entities/workflow-execution.entity.d.ts +2 -3
- package/dist/database/entities/workflow-execution.entity.js +3 -3
- package/dist/database/entities/workflow-execution.entity.js.map +1 -1
- package/dist/database/entities/workflow-step-execution.entity.d.ts +1 -0
- package/dist/database/entities/workflow-step-execution.entity.js +7 -3
- package/dist/database/entities/workflow-step-execution.entity.js.map +1 -1
- package/dist/database/index.d.ts +1 -0
- package/dist/database/index.js.map +1 -1
- package/dist/database/migrations/1778529600000-CreateWorkflowExecution.js +1 -1
- package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js +13 -2
- package/dist/database/migrations/1784890100000-CreateWorkflowStepExecution.js.map +1 -1
- package/dist/database/typeorm-execution-store.js +1 -1
- package/dist/database/typeorm-execution-store.js.map +1 -1
- package/dist/database/typeorm-step-store.d.ts +5 -5
- package/dist/database/typeorm-step-store.js +57 -13
- package/dist/database/typeorm-step-store.js.map +1 -1
- package/dist/execution/completion.d.ts +2 -0
- package/dist/execution/completion.js +21 -0
- package/dist/execution/completion.js.map +1 -0
- package/dist/execution/execution-start-handler.js +3 -1
- package/dist/execution/execution-start-handler.js.map +1 -1
- package/dist/execution/execution-store.d.ts +3 -4
- package/dist/execution/execution-store.js.map +1 -1
- package/dist/execution/execution.types.d.ts +8 -0
- package/dist/execution/execution.types.js +6 -1
- package/dist/execution/execution.types.js.map +1 -1
- package/dist/execution/index.d.ts +3 -2
- package/dist/execution/index.js +3 -1
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/iteration-mapping.d.ts +14 -0
- package/dist/execution/iteration-mapping.js +48 -0
- package/dist/execution/iteration-mapping.js.map +1 -0
- package/dist/execution/loop-ledger.d.ts +7 -0
- package/dist/execution/loop-ledger.js +38 -0
- package/dist/execution/loop-ledger.js.map +1 -0
- package/dist/execution/settlement.d.ts +6 -4
- package/dist/execution/settlement.js +73 -17
- package/dist/execution/settlement.js.map +1 -1
- package/dist/execution/start-execution.service.d.ts +2 -3
- package/dist/execution/start-execution.service.js +1 -1
- package/dist/execution/start-execution.service.js.map +1 -1
- package/dist/execution/step-ready-handler.d.ts +7 -1
- package/dist/execution/step-ready-handler.js +29 -10
- package/dist/execution/step-ready-handler.js.map +1 -1
- package/dist/execution/step-settled-handler.d.ts +1 -2
- package/dist/execution/step-settled-handler.js +27 -23
- package/dist/execution/step-settled-handler.js.map +1 -1
- package/dist/execution/step-store.d.ts +8 -5
- package/dist/execution/step-store.js.map +1 -1
- package/dist/graph/graph-validation.error.d.ts +3 -0
- package/dist/graph/graph-validation.error.js +11 -0
- package/dist/graph/graph-validation.error.js.map +1 -0
- package/dist/graph/index.d.ts +4 -1
- package/dist/graph/index.js +7 -2
- package/dist/graph/index.js.map +1 -1
- package/dist/graph/loops.d.ts +10 -0
- package/dist/graph/loops.js +161 -0
- package/dist/graph/loops.js.map +1 -0
- package/dist/graph/validate-executable-graph.d.ts +1 -3
- package/dist/graph/validate-executable-graph.js +9 -15
- package/dist/graph/validate-executable-graph.js.map +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.js +7 -12
- package/dist/index.js.map +1 -1
- package/dist/runtime/create-engine-runtime.d.ts +18 -0
- package/dist/runtime/create-engine-runtime.js +26 -0
- package/dist/runtime/create-engine-runtime.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +6 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/serve.js +18 -30
- package/dist/serve.js.map +1 -1
- package/dist/server/create-engine-server.d.ts +3 -9
- package/dist/server/create-engine-server.js +5 -9
- package/dist/server/create-engine-server.js.map +1 -1
- package/dist/server/error-response.d.ts +7 -0
- package/dist/server/error-response.js +12 -0
- package/dist/server/error-response.js.map +1 -0
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +3 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/workflow-executions.js +7 -9
- package/dist/server/routes/workflow-executions.js.map +1 -1
- package/dist/testing/start-engine-server.d.ts +3 -2
- package/dist/testing/start-engine-server.js +2 -2
- package/dist/testing/start-engine-server.js.map +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAuthenticationMiddleware = createAuthenticationMiddleware;
|
|
4
|
+
const error_response_1 = require("../server/error-response");
|
|
5
|
+
const BEARER_PREFIX = /^bearer /i;
|
|
6
|
+
function createAuthenticationMiddleware(verifier) {
|
|
7
|
+
return (req, res, next) => {
|
|
8
|
+
const reject = (reason) => {
|
|
9
|
+
const path = req.originalUrl.split('?')[0];
|
|
10
|
+
console.warn(`engine: rejected ${req.method} ${path} - ${reason}`);
|
|
11
|
+
(0, error_response_1.fail)(res, 401, { error: 'unauthenticated' });
|
|
12
|
+
};
|
|
13
|
+
const header = req.header('authorization');
|
|
14
|
+
if (!header || !BEARER_PREFIX.test(header)) {
|
|
15
|
+
reject('no bearer token');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const token = header.replace(BEARER_PREFIX, '');
|
|
19
|
+
try {
|
|
20
|
+
req.caller = verifier.verify(token);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
reject('token rejected');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
next();
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=authenticate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../src/auth/authenticate.ts"],"names":[],"mappings":";;;AAGA,6DAAgD;AAEhD,MAAM,aAAa,GAAG,WAAW,CAAC;AAGlC,wCAA+C,QAA0B;IACxE,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAEzB,MAAM,MAAM,GAAG,CAAC,MAAc,EAAQ,EAAE;YAEvC,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3C,OAAO,CAAC,IAAI,CAAC,oBAAoB,GAAG,CAAC,MAAM,IAAI,IAAI,MAAM,MAAM,EAAE,CAAC,CAAC;YACnE,IAAA,qBAAI,EAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5C,MAAM,CAAC,iBAAiB,CAAC,CAAC;YAC1B,OAAO;QACR,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAEhD,IAAI,CAAC;YACJ,GAAG,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;QAAC,MAAM,CAAC;YACR,MAAM,CAAC,gBAAgB,CAAC,CAAC;YACzB,OAAO;QACR,CAAC;QAED,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AuthenticatedCaller, IdentityVerifier } from './identity.types';
|
|
2
|
+
export declare const IDENTITY_ISSUER = "n8n-cp";
|
|
3
|
+
export declare const IDENTITY_AUDIENCE = "n8n-engine-dp";
|
|
4
|
+
export declare const IDENTITY_TOKEN_TTL_SECONDS = 60;
|
|
5
|
+
export declare const IDENTITY_TOKEN_CLOCK_TOLERANCE_SECONDS = 30;
|
|
6
|
+
export declare const MIN_SECRET_LENGTH = 32;
|
|
7
|
+
export declare class InvalidIdentityTokenError extends Error {
|
|
8
|
+
}
|
|
9
|
+
export declare function mintIdentityToken(secret: string, caller: AuthenticatedCaller): string;
|
|
10
|
+
export declare class SharedSecretIdentityVerifier implements IdentityVerifier {
|
|
11
|
+
private readonly secret;
|
|
12
|
+
constructor(secret: string);
|
|
13
|
+
verify(token: string): AuthenticatedCaller;
|
|
14
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SharedSecretIdentityVerifier = exports.InvalidIdentityTokenError = exports.MIN_SECRET_LENGTH = exports.IDENTITY_TOKEN_CLOCK_TOLERANCE_SECONDS = exports.IDENTITY_TOKEN_TTL_SECONDS = exports.IDENTITY_AUDIENCE = exports.IDENTITY_ISSUER = void 0;
|
|
7
|
+
exports.mintIdentityToken = mintIdentityToken;
|
|
8
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
exports.IDENTITY_ISSUER = 'n8n-cp';
|
|
11
|
+
exports.IDENTITY_AUDIENCE = 'n8n-engine-dp';
|
|
12
|
+
exports.IDENTITY_TOKEN_TTL_SECONDS = 60;
|
|
13
|
+
exports.IDENTITY_TOKEN_CLOCK_TOLERANCE_SECONDS = 30;
|
|
14
|
+
exports.MIN_SECRET_LENGTH = 32;
|
|
15
|
+
const identityClaimsSchema = zod_1.z.object({
|
|
16
|
+
sub: zod_1.z.string().min(1),
|
|
17
|
+
tenant_id: zod_1.z.string().min(1),
|
|
18
|
+
iat: zod_1.z.number().int(),
|
|
19
|
+
exp: zod_1.z.number().int(),
|
|
20
|
+
});
|
|
21
|
+
class InvalidIdentityTokenError extends Error {
|
|
22
|
+
}
|
|
23
|
+
exports.InvalidIdentityTokenError = InvalidIdentityTokenError;
|
|
24
|
+
function mintIdentityToken(secret, caller) {
|
|
25
|
+
return jsonwebtoken_1.default.sign({ sub: caller.cpId, tenant_id: caller.tenantId }, secret, {
|
|
26
|
+
algorithm: 'HS256',
|
|
27
|
+
issuer: exports.IDENTITY_ISSUER,
|
|
28
|
+
audience: exports.IDENTITY_AUDIENCE,
|
|
29
|
+
expiresIn: exports.IDENTITY_TOKEN_TTL_SECONDS,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
class SharedSecretIdentityVerifier {
|
|
33
|
+
secret;
|
|
34
|
+
constructor(secret) {
|
|
35
|
+
this.secret = secret;
|
|
36
|
+
if (!secret || secret.length < exports.MIN_SECRET_LENGTH) {
|
|
37
|
+
throw new Error(`Identity verifier secret must be at least ${exports.MIN_SECRET_LENGTH} chars`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
verify(token) {
|
|
41
|
+
const now = Math.floor(Date.now() / 1000);
|
|
42
|
+
let claims;
|
|
43
|
+
try {
|
|
44
|
+
claims = jsonwebtoken_1.default.verify(token, this.secret, {
|
|
45
|
+
algorithms: ['HS256'],
|
|
46
|
+
issuer: exports.IDENTITY_ISSUER,
|
|
47
|
+
audience: exports.IDENTITY_AUDIENCE,
|
|
48
|
+
maxAge: exports.IDENTITY_TOKEN_TTL_SECONDS,
|
|
49
|
+
clockTolerance: exports.IDENTITY_TOKEN_CLOCK_TOLERANCE_SECONDS,
|
|
50
|
+
clockTimestamp: now,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
throw new InvalidIdentityTokenError();
|
|
55
|
+
}
|
|
56
|
+
const parsed = identityClaimsSchema.safeParse(claims);
|
|
57
|
+
if (!parsed.success)
|
|
58
|
+
throw new InvalidIdentityTokenError();
|
|
59
|
+
if (parsed.data.iat > now + exports.IDENTITY_TOKEN_CLOCK_TOLERANCE_SECONDS) {
|
|
60
|
+
throw new InvalidIdentityTokenError();
|
|
61
|
+
}
|
|
62
|
+
return { cpId: parsed.data.sub, tenantId: parsed.data.tenant_id };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.SharedSecretIdentityVerifier = SharedSecretIdentityVerifier;
|
|
66
|
+
//# sourceMappingURL=identity-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-token.js","sourceRoot":"","sources":["../../src/auth/identity-token.ts"],"names":[],"mappings":";;;;;;;AAAA,gEAA+B;AAC/B,6BAAwB;AAIX,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,iBAAiB,GAAG,eAAe,CAAC;AACpC,QAAA,0BAA0B,GAAG,EAAE,CAAC;AAChC,QAAA,sCAAsC,GAAG,EAAE,CAAC;AAC5C,QAAA,iBAAiB,GAAG,EAAE,CAAC;AAEpC,MAAM,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACrB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;CACrB,CAAC,CAAC;AAGH,+BAAuC,SAAQ,KAAK;CAA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C;QAC3D,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,GAAG,QAAA,sCAAsC,EAAE,CAAC;YACpE,MAAM,IAAI,yBAAyB,EAAE,CAAC;QACvC,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;IACnE,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.types.js","sourceRoot":"","sources":["../../src/auth/identity.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createAuthenticationMiddleware } from './authenticate';
|
|
2
|
+
export { IDENTITY_AUDIENCE, IDENTITY_ISSUER, IDENTITY_TOKEN_CLOCK_TOLERANCE_SECONDS, IDENTITY_TOKEN_TTL_SECONDS, InvalidIdentityTokenError, MIN_SECRET_LENGTH, mintIdentityToken, SharedSecretIdentityVerifier, } from './identity-token';
|
|
3
|
+
export type { AuthenticatedCaller, IdentityVerifier } from './identity.types';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedSecretIdentityVerifier = exports.mintIdentityToken = exports.MIN_SECRET_LENGTH = exports.InvalidIdentityTokenError = exports.IDENTITY_TOKEN_TTL_SECONDS = exports.IDENTITY_TOKEN_CLOCK_TOLERANCE_SECONDS = exports.IDENTITY_ISSUER = exports.IDENTITY_AUDIENCE = exports.createAuthenticationMiddleware = void 0;
|
|
4
|
+
var authenticate_1 = require("./authenticate");
|
|
5
|
+
Object.defineProperty(exports, "createAuthenticationMiddleware", { enumerable: true, get: function () { return authenticate_1.createAuthenticationMiddleware; } });
|
|
6
|
+
var identity_token_1 = require("./identity-token");
|
|
7
|
+
Object.defineProperty(exports, "IDENTITY_AUDIENCE", { enumerable: true, get: function () { return identity_token_1.IDENTITY_AUDIENCE; } });
|
|
8
|
+
Object.defineProperty(exports, "IDENTITY_ISSUER", { enumerable: true, get: function () { return identity_token_1.IDENTITY_ISSUER; } });
|
|
9
|
+
Object.defineProperty(exports, "IDENTITY_TOKEN_CLOCK_TOLERANCE_SECONDS", { enumerable: true, get: function () { return identity_token_1.IDENTITY_TOKEN_CLOCK_TOLERANCE_SECONDS; } });
|
|
10
|
+
Object.defineProperty(exports, "IDENTITY_TOKEN_TTL_SECONDS", { enumerable: true, get: function () { return identity_token_1.IDENTITY_TOKEN_TTL_SECONDS; } });
|
|
11
|
+
Object.defineProperty(exports, "InvalidIdentityTokenError", { enumerable: true, get: function () { return identity_token_1.InvalidIdentityTokenError; } });
|
|
12
|
+
Object.defineProperty(exports, "MIN_SECRET_LENGTH", { enumerable: true, get: function () { return identity_token_1.MIN_SECRET_LENGTH; } });
|
|
13
|
+
Object.defineProperty(exports, "mintIdentityToken", { enumerable: true, get: function () { return identity_token_1.mintIdentityToken; } });
|
|
14
|
+
Object.defineProperty(exports, "SharedSecretIdentityVerifier", { enumerable: true, get: function () { return identity_token_1.SharedSecretIdentityVerifier; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;AAAA,+CAAgE;AAAvD,8HAAA,8BAA8B,OAAA;AACvC,mDAS0B;AARzB,mHAAA,iBAAiB,OAAA;AACjB,iHAAA,eAAe,OAAA;AACf,wIAAA,sCAAsC,OAAA;AACtC,4HAAA,0BAA0B,OAAA;AAC1B,2HAAA,yBAAyB,OAAA;AACzB,mHAAA,iBAAiB,OAAA;AACjB,mHAAA,iBAAiB,OAAA;AACjB,8HAAA,4BAA4B,OAAA"}
|