@teleporthq/teleport-plugin-next-workflows 0.44.6 → 0.44.8
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/__tests__/credential-columns-reply.test.ts +286 -0
- package/__tests__/credential-result-reply.test.ts +509 -0
- package/dist/cjs/api-route-generator.d.ts.map +1 -1
- package/dist/cjs/api-route-generator.js +6 -2
- package/dist/cjs/api-route-generator.js.map +1 -1
- package/dist/cjs/credential-columns-code.d.ts +17 -0
- package/dist/cjs/credential-columns-code.d.ts.map +1 -0
- package/dist/cjs/credential-columns-code.js +61 -0
- package/dist/cjs/credential-columns-code.js.map +1 -0
- package/dist/cjs/credential-results.d.ts +18 -0
- package/dist/cjs/credential-results.d.ts.map +1 -0
- package/dist/cjs/credential-results.js +72 -0
- package/dist/cjs/credential-results.js.map +1 -0
- package/dist/cjs/data-api-route-generator.d.ts +1 -0
- package/dist/cjs/data-api-route-generator.d.ts.map +1 -1
- package/dist/cjs/data-api-route-generator.js +13 -5
- package/dist/cjs/data-api-route-generator.js.map +1 -1
- package/dist/cjs/executor-generator.d.ts.map +1 -1
- package/dist/cjs/executor-generator.js +20 -3
- package/dist/cjs/executor-generator.js.map +1 -1
- package/dist/cjs/nodes/account/account-hash-password.d.ts.map +1 -1
- package/dist/cjs/nodes/account/account-hash-password.js +1 -0
- package/dist/cjs/nodes/account/account-hash-password.js.map +1 -1
- package/dist/cjs/nodes/types.d.ts +6 -0
- package/dist/cjs/nodes/types.d.ts.map +1 -1
- package/dist/cjs/server-runtime-code.d.ts +8 -0
- package/dist/cjs/server-runtime-code.d.ts.map +1 -1
- package/dist/cjs/server-runtime-code.js +106 -0
- package/dist/cjs/server-runtime-code.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/api-route-generator.d.ts.map +1 -1
- package/dist/esm/api-route-generator.js +6 -2
- package/dist/esm/api-route-generator.js.map +1 -1
- package/dist/esm/credential-columns-code.d.ts +17 -0
- package/dist/esm/credential-columns-code.d.ts.map +1 -0
- package/dist/esm/credential-columns-code.js +57 -0
- package/dist/esm/credential-columns-code.js.map +1 -0
- package/dist/esm/credential-results.d.ts +18 -0
- package/dist/esm/credential-results.d.ts.map +1 -0
- package/dist/esm/credential-results.js +68 -0
- package/dist/esm/credential-results.js.map +1 -0
- package/dist/esm/data-api-route-generator.d.ts +1 -0
- package/dist/esm/data-api-route-generator.d.ts.map +1 -1
- package/dist/esm/data-api-route-generator.js +11 -3
- package/dist/esm/data-api-route-generator.js.map +1 -1
- package/dist/esm/executor-generator.d.ts.map +1 -1
- package/dist/esm/executor-generator.js +20 -3
- package/dist/esm/executor-generator.js.map +1 -1
- package/dist/esm/nodes/account/account-hash-password.d.ts.map +1 -1
- package/dist/esm/nodes/account/account-hash-password.js +1 -0
- package/dist/esm/nodes/account/account-hash-password.js.map +1 -1
- package/dist/esm/nodes/types.d.ts +6 -0
- package/dist/esm/nodes/types.d.ts.map +1 -1
- package/dist/esm/server-runtime-code.d.ts +8 -0
- package/dist/esm/server-runtime-code.d.ts.map +1 -1
- package/dist/esm/server-runtime-code.js +106 -0
- package/dist/esm/server-runtime-code.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/api-route-generator.ts +6 -2
- package/src/credential-columns-code.ts +59 -0
- package/src/credential-results.ts +71 -0
- package/src/data-api-route-generator.ts +11 -3
- package/src/executor-generator.ts +20 -3
- package/src/nodes/account/account-hash-password.ts +1 -0
- package/src/nodes/types.ts +6 -0
- package/src/server-runtime-code.ts +106 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateCredentialColumnsCode = void 0;
|
|
4
|
+
const teleport_shared_1 = require("@teleporthq/teleport-shared");
|
|
5
|
+
const data_api_route_generator_1 = require("./data-api-route-generator");
|
|
6
|
+
/**
|
|
7
|
+
* Runtime helpers that leave the auth users table's credential columns out of
|
|
8
|
+
* the rows a server segment answers the browser with — the columns
|
|
9
|
+
* `TableAccess.AUTH_CREDENTIAL_COLUMNS` names, the ones every browser read of
|
|
10
|
+
* the data route is already served without. A data node of a server segment
|
|
11
|
+
* reads through the data route as the app's own server code, so its rows come
|
|
12
|
+
* back whole, and the segment's reply (or a streamed node result) is the
|
|
13
|
+
* browser's copy of them.
|
|
14
|
+
*
|
|
15
|
+
* Only the results of the nodes that read rows (`DATA_NODE_TYPES`) are
|
|
16
|
+
* touched: all the credentials of a row of the users table, the unambiguous
|
|
17
|
+
* ones of a raw statement's row, whose table is not known. A row is the
|
|
18
|
+
* result itself (a create or update spreads its row into it), an object it
|
|
19
|
+
* holds, or an element of an array it holds; column values are not walked.
|
|
20
|
+
*/
|
|
21
|
+
const generateCredentialColumnsCode = () => `
|
|
22
|
+
var __CREDENTIAL_COLUMNS = ${JSON.stringify(teleport_shared_1.TableAccess.AUTH_CREDENTIAL_COLUMNS)};
|
|
23
|
+
var __UNAMBIGUOUS_CREDENTIAL_COLUMNS = ${JSON.stringify(teleport_shared_1.TableAccess.UNAMBIGUOUS_CREDENTIAL_COLUMNS)};
|
|
24
|
+
var __CREDENTIAL_TABLES = ${JSON.stringify(teleport_shared_1.TableAccess.AUTH_CREDENTIAL_TABLES)};
|
|
25
|
+
var __ROW_NODE_TYPES = ${JSON.stringify(Array.from(data_api_route_generator_1.DATA_NODE_TYPES))};
|
|
26
|
+
|
|
27
|
+
function credentialColumnsOf(node) {
|
|
28
|
+
if (!node || __ROW_NODE_TYPES.indexOf(node.type) === -1) return [];
|
|
29
|
+
var tableName = node.config && typeof node.config.tableName === 'string' ? node.config.tableName : '';
|
|
30
|
+
if (!tableName) return __UNAMBIGUOUS_CREDENTIAL_COLUMNS;
|
|
31
|
+
var parts = tableName.trim().toLowerCase().replace(/"/g, '').split('.');
|
|
32
|
+
return __CREDENTIAL_TABLES.indexOf(parts[parts.length - 1]) !== -1 ? __CREDENTIAL_COLUMNS : [];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function withoutColumns(row, columns) {
|
|
36
|
+
if (!row || typeof row !== 'object' || Array.isArray(row)) return row;
|
|
37
|
+
var kept = {};
|
|
38
|
+
Object.keys(row).forEach(function(key) {
|
|
39
|
+
if (columns.indexOf(String(key).toLowerCase()) === -1) kept[key] = row[key];
|
|
40
|
+
});
|
|
41
|
+
return kept;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function withoutRowsColumns(value, columns) {
|
|
45
|
+
if (Array.isArray(value)) return value.map(function(row) { return withoutColumns(row, columns); });
|
|
46
|
+
return withoutColumns(value, columns);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function withoutCredentialColumns(node, result) {
|
|
50
|
+
var columns = credentialColumnsOf(node);
|
|
51
|
+
if (columns.length === 0 || !result || typeof result !== 'object') return result;
|
|
52
|
+
if (Array.isArray(result)) return withoutRowsColumns(result, columns);
|
|
53
|
+
var kept = withoutColumns(result, columns);
|
|
54
|
+
Object.keys(kept).forEach(function(key) {
|
|
55
|
+
if (kept[key] && typeof kept[key] === 'object') kept[key] = withoutRowsColumns(kept[key], columns);
|
|
56
|
+
});
|
|
57
|
+
return kept;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
exports.generateCredentialColumnsCode = generateCredentialColumnsCode;
|
|
61
|
+
//# sourceMappingURL=credential-columns-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-columns-code.js","sourceRoot":"","sources":["../../src/credential-columns-code.ts"],"names":[],"mappings":";;;AAAA,iEAAyD;AACzD,yEAA4D;AAE5D;;;;;;;;;;;;;;GAcG;AACI,MAAM,6BAA6B,GAAG,GAAW,EAAE,CAAC;6BAC9B,IAAI,CAAC,SAAS,CAAC,6BAAW,CAAC,uBAAuB,CAAC;yCACvC,IAAI,CAAC,SAAS,CACrD,6BAAW,CAAC,8BAA8B,CAC3C;4BAC2B,IAAI,CAAC,SAAS,CAAC,6BAAW,CAAC,sBAAsB,CAAC;yBACrD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,0CAAe,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCnE,CAAA;AAxCY,QAAA,6BAA6B,iCAwCzC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The node types whose result is a credential, read off the node registry
|
|
3
|
+
* (`resultIsCredential`): today the password-hashing node. Its result stays on
|
|
4
|
+
* the server. A server segment replies it to the browser only sealed —
|
|
5
|
+
* encrypted with a key derived from the app secret, signed like every other
|
|
6
|
+
* result — and a later server segment opens it again, so a workflow that
|
|
7
|
+
* hashes in one segment and writes in another still works (see the server
|
|
8
|
+
* runtime: `sealResult`, `openSealedResults`).
|
|
9
|
+
*/
|
|
10
|
+
export declare const CREDENTIAL_RESULT_NODE_TYPES: string[];
|
|
11
|
+
/**
|
|
12
|
+
* `credentialResultNodeIds(segmentConfig)`: the nodes of a segment whose
|
|
13
|
+
* result is a credential — every node of a credential type, and every map
|
|
14
|
+
* loop whose results are such a node's results (the loop's last body step, as
|
|
15
|
+
* the route runs it; a loop of loops follows its inner loop).
|
|
16
|
+
*/
|
|
17
|
+
export declare const generateCredentialResultsCode: () => string;
|
|
18
|
+
//# sourceMappingURL=credential-results.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-results.d.ts","sourceRoot":"","sources":["../../src/credential-results.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,EAAE,MAAM,EAEhD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,QAAO,MAiDhD,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateCredentialResultsCode = exports.CREDENTIAL_RESULT_NODE_TYPES = void 0;
|
|
4
|
+
const nodes_1 = require("./nodes");
|
|
5
|
+
/**
|
|
6
|
+
* The node types whose result is a credential, read off the node registry
|
|
7
|
+
* (`resultIsCredential`): today the password-hashing node. Its result stays on
|
|
8
|
+
* the server. A server segment replies it to the browser only sealed —
|
|
9
|
+
* encrypted with a key derived from the app secret, signed like every other
|
|
10
|
+
* result — and a later server segment opens it again, so a workflow that
|
|
11
|
+
* hashes in one segment and writes in another still works (see the server
|
|
12
|
+
* runtime: `sealResult`, `openSealedResults`).
|
|
13
|
+
*/
|
|
14
|
+
exports.CREDENTIAL_RESULT_NODE_TYPES = Object.keys(nodes_1.nodeRegistry).filter((nodeType) => nodes_1.nodeRegistry[nodeType].resultIsCredential === true);
|
|
15
|
+
/**
|
|
16
|
+
* `credentialResultNodeIds(segmentConfig)`: the nodes of a segment whose
|
|
17
|
+
* result is a credential — every node of a credential type, and every map
|
|
18
|
+
* loop whose results are such a node's results (the loop's last body step, as
|
|
19
|
+
* the route runs it; a loop of loops follows its inner loop).
|
|
20
|
+
*/
|
|
21
|
+
const generateCredentialResultsCode = () => `
|
|
22
|
+
var __CREDENTIAL_RESULT_NODE_TYPES = ${JSON.stringify(exports.CREDENTIAL_RESULT_NODE_TYPES)};
|
|
23
|
+
|
|
24
|
+
function lastLoopBodyNodeId(loopId, sortedNodes, edges) {
|
|
25
|
+
var start = edges.find(function(e) { return e.source === loopId && e.sourceHandle === 'loop'; });
|
|
26
|
+
if (!start) return null;
|
|
27
|
+
var body = {};
|
|
28
|
+
var queue = [start.target];
|
|
29
|
+
while (queue.length > 0) {
|
|
30
|
+
var current = queue.shift();
|
|
31
|
+
if (body[current] || current === loopId) continue;
|
|
32
|
+
body[current] = true;
|
|
33
|
+
edges.forEach(function(e) {
|
|
34
|
+
if (e.source === current && (e.sourceHandle === 'loop-body-out' || !e.sourceHandle) && e.target !== loopId) {
|
|
35
|
+
queue.push(e.target);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
var last = null;
|
|
40
|
+
sortedNodes.forEach(function(n) { if (body[n.id]) last = n.id; });
|
|
41
|
+
return last;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function credentialResultNodeIds(segmentConfig) {
|
|
45
|
+
var nodes = (segmentConfig && segmentConfig.nodes) || [];
|
|
46
|
+
var edges = (segmentConfig && segmentConfig.edges) || [];
|
|
47
|
+
var ids = {};
|
|
48
|
+
nodes.forEach(function(n) {
|
|
49
|
+
if (__CREDENTIAL_RESULT_NODE_TYPES.indexOf(n.type) !== -1) ids[n.id] = true;
|
|
50
|
+
});
|
|
51
|
+
var sortedNodes = nodes.slice().sort(function(a, b) { return (a.stepNumber || 0) - (b.stepNumber || 0); });
|
|
52
|
+
var mapLoops = nodes.filter(function(n) {
|
|
53
|
+
var loopType = n.config && n.config.loopType;
|
|
54
|
+
return n.type === 'general-loop' && !!loopType && loopType !== 'forEach';
|
|
55
|
+
});
|
|
56
|
+
var grew = true;
|
|
57
|
+
while (grew) {
|
|
58
|
+
grew = false;
|
|
59
|
+
mapLoops.forEach(function(loop) {
|
|
60
|
+
if (ids[loop.id]) return;
|
|
61
|
+
var last = lastLoopBodyNodeId(loop.id, sortedNodes, edges);
|
|
62
|
+
if (last && ids[last]) {
|
|
63
|
+
ids[loop.id] = true;
|
|
64
|
+
grew = true;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return ids;
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
exports.generateCredentialResultsCode = generateCredentialResultsCode;
|
|
72
|
+
//# sourceMappingURL=credential-results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-results.js","sourceRoot":"","sources":["../../src/credential-results.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC;;;;;;;;GAQG;AACU,QAAA,4BAA4B,GAAa,MAAM,CAAC,IAAI,CAAC,oBAAY,CAAC,CAAC,MAAM,CACpF,CAAC,QAAQ,EAAE,EAAE,CAAC,oBAAY,CAAC,QAAQ,CAAC,CAAC,kBAAkB,KAAK,IAAI,CACjE,CAAA;AAED;;;;;GAKG;AACI,MAAM,6BAA6B,GAAG,GAAW,EAAE,CAAC;uCACpB,IAAI,CAAC,SAAS,CAAC,oCAA4B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDlF,CAAA;AAjDY,QAAA,6BAA6B,iCAiDzC"}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* fields) are validated to prevent SQL injection.
|
|
12
12
|
*/
|
|
13
13
|
import { ContentTables } from '@teleporthq/teleport-shared';
|
|
14
|
+
export declare const DATA_NODE_TYPES: ReadonlySet<string>;
|
|
14
15
|
export declare const needsDataAPIRoute: (usedNodeTypes: Set<string>) => boolean;
|
|
15
16
|
export interface DataAPIRouteOptions {
|
|
16
17
|
authUsersTableName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-api-route-generator.d.ts","sourceRoot":"","sources":["../../src/data-api-route-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,aAAa,EAAe,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"data-api-route-generator.d.ts","sourceRoot":"","sources":["../../src/data-api-route-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,aAAa,EAAe,MAAM,6BAA6B,CAAA;AAExE,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,CAW9C,CAAA;AAEF,eAAO,MAAM,iBAAiB,kBAAmB,IAAI,MAAM,CAAC,KAAG,OAO9D,CAAA;AAED,MAAM,WAAW,mBAAmB;IAIlC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAQ3B,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAI/B,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB,EAAE,aAAa,CAAC,MAAM,CASzD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,gBAAgB,CAAC,CACtD,CAAA;AAEpC,eAAO,MAAM,oBAAoB,aAAa,mBAAmB,KAAQ,MA8qCxE,CAAA"}
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
* fields) are validated to prevent SQL injection.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.generateDataAPIRoute = exports.BROWSER_ROW_POLICIES = exports.BROWSER_READABLE_TABLES = exports.needsDataAPIRoute = void 0;
|
|
15
|
+
exports.generateDataAPIRoute = exports.BROWSER_ROW_POLICIES = exports.BROWSER_READABLE_TABLES = exports.needsDataAPIRoute = exports.DATA_NODE_TYPES = void 0;
|
|
16
16
|
const sql_validator_1 = require("./sql-validator");
|
|
17
17
|
const session_cookie_resolver_1 = require("./session-cookie-resolver");
|
|
18
18
|
const teleport_shared_1 = require("@teleporthq/teleport-shared");
|
|
19
|
-
|
|
19
|
+
exports.DATA_NODE_TYPES = new Set([
|
|
20
20
|
'data-select',
|
|
21
21
|
'data-create-item',
|
|
22
22
|
'data-update-item',
|
|
@@ -30,7 +30,7 @@ const DATA_NODE_TYPES = new Set([
|
|
|
30
30
|
]);
|
|
31
31
|
const needsDataAPIRoute = (usedNodeTypes) => {
|
|
32
32
|
for (const nt of usedNodeTypes) {
|
|
33
|
-
if (DATA_NODE_TYPES.has(nt)) {
|
|
33
|
+
if (exports.DATA_NODE_TYPES.has(nt)) {
|
|
34
34
|
return true;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -651,6 +651,13 @@ function dropMissingOptionalColumns(tableName, entries, colTypes) {
|
|
|
651
651
|
return kept;
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
+
// The row a create or update answers with, whoever asked, without the auth
|
|
655
|
+
// users table's credentials (the columns a browser read is served without):
|
|
656
|
+
// a server-side caller hands that answer on to the browser as its result.
|
|
657
|
+
function withoutCredentialColumns(row, tableName) {
|
|
658
|
+
return row ? __taWithoutCredentials([row], tableName)[0] : row;
|
|
659
|
+
}
|
|
660
|
+
|
|
654
661
|
async function handleCreate(client, body) {
|
|
655
662
|
var tableName = body.tableName;
|
|
656
663
|
var columnMappings = body.columnMappings || {};
|
|
@@ -725,7 +732,7 @@ async function handleCreate(client, body) {
|
|
|
725
732
|
var item = result.rows && result.rows[0] ? result.rows[0] : null;
|
|
726
733
|
var idIdx = columns.indexOf('id');
|
|
727
734
|
var resolvedId = item ? (item.id || null) : (idIdx >= 0 ? values[idIdx] : null);
|
|
728
|
-
return { item: item, id: resolvedId };
|
|
735
|
+
return { item: withoutCredentialColumns(item, tableName), id: resolvedId };
|
|
729
736
|
}
|
|
730
737
|
|
|
731
738
|
async function handleUpdate(client, body) {
|
|
@@ -777,7 +784,8 @@ async function handleUpdate(client, body) {
|
|
|
777
784
|
sql += ' RETURNING *';
|
|
778
785
|
|
|
779
786
|
var result = await safeQuery(client, sql, queryParams, 'update');
|
|
780
|
-
|
|
787
|
+
var updated = result.rows[0] || null;
|
|
788
|
+
return { updatedCount: result.rowCount || 0, item: withoutCredentialColumns(updated, tableName), id: (updated && updated.id) || null };
|
|
781
789
|
}
|
|
782
790
|
|
|
783
791
|
async function handleDelete(client, body) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-api-route-generator.js","sourceRoot":"","sources":["../../src/data-api-route-generator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,mDAA0D;AAC1D,uEAAoF;AACpF,iEAAwE;
|
|
1
|
+
{"version":3,"file":"data-api-route-generator.js","sourceRoot":"","sources":["../../src/data-api-route-generator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,mDAA0D;AAC1D,uEAAoF;AACpF,iEAAw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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA+2BgC,IAAI,CAAC,SAAS,CAAC,+BAAuB,CAAC;6BAC1C,IAAI,CAAC,SAAS,CAAC,4BAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8RhE,CAAA;AACD,CAAC,CAAA;AA9qCY,QAAA,oBAAoB,wBA8qChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor-generator.d.ts","sourceRoot":"","sources":["../../src/executor-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGlB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"executor-generator.d.ts","sourceRoot":"","sources":["../../src/executor-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGlB,MAAM,gBAAgB,CAAA;AAKvB,MAAM,WAAW,yBAAyB;IACxC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,iBAAiB,CAAA;CACjC;AAID,eAAO,MAAM,8BAA8B,aAAa,yBAAyB,KAAQ,MAw/CxF,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAO,MA+nB5C,CAAA"}
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generateClientRuntimeCode = exports.generateSharedRuntimeUtilsCode = void 0;
|
|
4
4
|
const email_locale_1 = require("./email-locale");
|
|
5
5
|
const signed_in_destination_code_1 = require("./auth-return/signed-in-destination-code");
|
|
6
|
+
const credential_columns_code_1 = require("./credential-columns-code");
|
|
7
|
+
const credential_results_1 = require("./credential-results");
|
|
6
8
|
const NO_EMAIL_LOCALES = { locales: [], defaultLocale: '' };
|
|
7
9
|
const generateSharedRuntimeUtilsCode = (options = {}) => {
|
|
8
10
|
return `/**
|
|
@@ -1401,6 +1403,15 @@ var SEGMENT_REPLY_PRIVATE_KEYS = {
|
|
|
1401
1403
|
// nodes after it in the same segment and never leaves the server (a statement's
|
|
1402
1404
|
// rows read only to build what the browser may see, a sender's recipients).
|
|
1403
1405
|
// Nothing in a later segment can read it.
|
|
1406
|
+
//
|
|
1407
|
+
// A data node's rows are replied without the auth users table's credentials
|
|
1408
|
+
// (see credential-columns-code.ts).
|
|
1409
|
+
//
|
|
1410
|
+
// A node whose result is a credential (a password hash) is left out here too,
|
|
1411
|
+
// whatever its config says: the server runtime replies it sealed, readable by
|
|
1412
|
+
// a later server segment only (see credential-results.ts).
|
|
1413
|
+
${(0, credential_columns_code_1.generateCredentialColumnsCode)()}
|
|
1414
|
+
${(0, credential_results_1.generateCredentialResultsCode)()}
|
|
1404
1415
|
// The nodes whose result the client branches on: never kept on the server.
|
|
1405
1416
|
function isBranchingNodeType(type) {
|
|
1406
1417
|
return type === 'general-if-statement' || type === 'general-switch';
|
|
@@ -1409,10 +1420,10 @@ function isBranchingNodeType(type) {
|
|
|
1409
1420
|
function segmentReply(segmentConfig, context, snapshot) {
|
|
1410
1421
|
var reply = {};
|
|
1411
1422
|
var own = {};
|
|
1412
|
-
var kept =
|
|
1423
|
+
var kept = credentialResultNodeIds(segmentConfig);
|
|
1413
1424
|
var nodes = (segmentConfig && segmentConfig.nodes) || [];
|
|
1414
1425
|
for (var ni = 0; ni < nodes.length; ni++) {
|
|
1415
|
-
own[nodes[ni].id] =
|
|
1426
|
+
own[nodes[ni].id] = nodes[ni];
|
|
1416
1427
|
if (nodes[ni].config && nodes[ni].config.keepResultOnServer === true && !isBranchingNodeType(nodes[ni].type)) {
|
|
1417
1428
|
kept[nodes[ni].id] = true;
|
|
1418
1429
|
}
|
|
@@ -1423,7 +1434,11 @@ function segmentReply(segmentConfig, context, snapshot) {
|
|
|
1423
1434
|
if (SEGMENT_REPLY_PRIVATE_KEYS[key] || kept[key]) continue;
|
|
1424
1435
|
var value = context[key];
|
|
1425
1436
|
if (value === undefined) continue;
|
|
1426
|
-
if (own[key]
|
|
1437
|
+
if (own[key]) {
|
|
1438
|
+
reply[key] = withoutCredentialColumns(own[key], value);
|
|
1439
|
+
continue;
|
|
1440
|
+
}
|
|
1441
|
+
if (!snapshot || !Object.prototype.hasOwnProperty.call(snapshot, key)) {
|
|
1427
1442
|
reply[key] = value;
|
|
1428
1443
|
continue;
|
|
1429
1444
|
}
|
|
@@ -1491,6 +1506,8 @@ module.exports = {
|
|
|
1491
1506
|
loopIterationContext,
|
|
1492
1507
|
snapshotIncomingContext,
|
|
1493
1508
|
segmentReply,
|
|
1509
|
+
withoutCredentialColumns,
|
|
1510
|
+
credentialResultNodeIds,
|
|
1494
1511
|
evaluateCondition,
|
|
1495
1512
|
evaluateSingleComparison,
|
|
1496
1513
|
normalizeComparisonOperator,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor-generator.js","sourceRoot":"","sources":["../../src/executor-generator.ts"],"names":[],"mappings":";;;AAAA,iDAIuB;AACvB,yFAA0F;
|
|
1
|
+
{"version":3,"file":"executor-generator.js","sourceRoot":"","sources":["../../src/executor-generator.ts"],"names":[],"mappings":";;;AAAA,iDAIuB;AACvB,yFAA0F;AAC1F,uEAAyE;AACzE,6DAAoE;AAYpE,MAAM,gBAAgB,GAAsB,EAAE,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,CAAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6nBR,CAAA;AACD,CAAC,CAAA;AA/nBY,QAAA,yBAAyB,6BA+nBrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-hash-password.d.ts","sourceRoot":"","sources":["../../../../src/nodes/account/account-hash-password.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAA;AA8ChE,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"account-hash-password.d.ts","sourceRoot":"","sources":["../../../../src/nodes/account/account-hash-password.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,UAAU,CAAA;AA8ChE,eAAO,MAAM,mBAAmB,EAAE,oBAUjC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-hash-password.js","sourceRoot":"","sources":["../../../../src/nodes/account/account-hash-password.ts"],"names":[],"mappings":";;;AAAA,oCAAgE;AAEhE,KAAK,UAAU,qBAAqB,CAAC,MAAW,EAAE,OAAgC;IAChF,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;IAChC,MAAM,UAAU,GAAG,MAAM,CAAC,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;IACnE,2EAA2E;IAC3E,4EAA4E;IAC5E,4EAA4E;IAC5E,uEAAuE;IACvE,oEAAoE;IACpE,MAAM,aAAa,GACjB,OAAO,uBAAuB,KAAK,WAAW,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,OAAO,CAAA;IACpF,MAAM,MAAM,GAAG,aAAa,CAAC,UAAU,CAAC,CAAA;IACxC,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;IAEtC,MAAM,MAAM,GAAI,UAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAA;IAChE,MAAM,GAAG,GAAG,MAAM;SACf,UAAU,CAAC,QAAQ,CAAC;SACpB,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC;SAC5B,MAAM,CAAC,QAAQ,CAAC,CAAA;IACnB,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;IAE7C,OAAO,EAAE,IAAI,EAAE,CAAA;AACjB,CAAC;AAEY,QAAA,mBAAmB,GAAyB;IACvD,QAAQ,EAAE,uBAAuB;IACjC,YAAY,EAAE,QAAQ;IACtB,kBAAkB,EAAE,IAAI;IACxB,YAAY,EAAE;QACZ,QAAQ,EAAE,QAAQ;KACnB;IACD,eAAe;QACb,OAAO,IAAA,uBAAe,EAAC,qBAAqB,CAAC,CAAA;IAC/C,CAAC;CACF,CAAA"}
|
|
@@ -5,6 +5,12 @@ export interface NodeHandlerGenerator {
|
|
|
5
5
|
nodeType: string;
|
|
6
6
|
executionEnv: 'client' | 'server' | 'universal';
|
|
7
7
|
isTerminal?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The node's result is a credential (a password hash). A server segment
|
|
10
|
+
* never replies it as it is: the browser receives it sealed, and only the
|
|
11
|
+
* app's own later server segments can open it (see credential-results.ts).
|
|
12
|
+
*/
|
|
13
|
+
resultIsCredential?: boolean;
|
|
8
14
|
dependencies?: Record<string, string>;
|
|
9
15
|
generateHandler(): string;
|
|
10
16
|
generateServerHandler?(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/nodes/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAE/F,wBAAgB,eAAe,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAErD;AAkCD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwEhF;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAA;IAC/C,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,eAAe,IAAI,MAAM,CAAA;IACzB,qBAAqB,CAAC,IAAI,MAAM,CAAA;CACjC;AAED,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACvE,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/nodes/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAE/F,wBAAgB,eAAe,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAErD;AAkCD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwEhF;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAA;IAC/C,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,eAAe,IAAI,MAAM,CAAA;IACzB,qBAAqB,CAAC,IAAI,MAAM,CAAA;CACjC;AAED,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACvE,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB"}
|
|
@@ -27,6 +27,14 @@
|
|
|
27
27
|
* that needs a trustworthy figure (a price, an owner) reads it from the
|
|
28
28
|
* database itself.
|
|
29
29
|
*
|
|
30
|
+
* A result that is a credential (a password hash, see credential-results.ts)
|
|
31
|
+
* makes the same trip SEALED: `segmentReply` replies it encrypted with a key
|
|
32
|
+
* derived from NEXTAUTH_SECRET (AES-256-GCM) and signs the sealed form, and
|
|
33
|
+
* `claimSegmentContext` opens every sealed value a request hands it (a
|
|
34
|
+
* relayed result once its signature holds). The browser relays it without
|
|
35
|
+
* ever reading it, and a later segment's reply hands back the sealed form,
|
|
36
|
+
* never the opened one.
|
|
37
|
+
*
|
|
30
38
|
* The facts about the graph each route needs are baked into its
|
|
31
39
|
* SEGMENT_CONFIG at generation time (see segment-trust.ts).
|
|
32
40
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-runtime-code.d.ts","sourceRoot":"","sources":["../../src/server-runtime-code.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"server-runtime-code.d.ts","sourceRoot":"","sources":["../../src/server-runtime-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,yBAAyB,QAAO,MA2W5C,CAAA"}
|
|
@@ -30,6 +30,14 @@ exports.generateServerRuntimeCode = void 0;
|
|
|
30
30
|
* that needs a trustworthy figure (a price, an owner) reads it from the
|
|
31
31
|
* database itself.
|
|
32
32
|
*
|
|
33
|
+
* A result that is a credential (a password hash, see credential-results.ts)
|
|
34
|
+
* makes the same trip SEALED: `segmentReply` replies it encrypted with a key
|
|
35
|
+
* derived from NEXTAUTH_SECRET (AES-256-GCM) and signs the sealed form, and
|
|
36
|
+
* `claimSegmentContext` opens every sealed value a request hands it (a
|
|
37
|
+
* relayed result once its signature holds). The browser relays it without
|
|
38
|
+
* ever reading it, and a later segment's reply hands back the sealed form,
|
|
39
|
+
* never the opened one.
|
|
40
|
+
*
|
|
33
41
|
* The facts about the graph each route needs are baked into its
|
|
34
42
|
* SEGMENT_CONFIG at generation time (see segment-trust.ts).
|
|
35
43
|
*/
|
|
@@ -54,6 +62,59 @@ function mac(text) {
|
|
|
54
62
|
return crypto.createHmac('sha256', stepKey()).update(text).digest('hex');
|
|
55
63
|
}
|
|
56
64
|
|
|
65
|
+
var __sealKeyCache = { secret: null, key: null };
|
|
66
|
+
|
|
67
|
+
function sealKey() {
|
|
68
|
+
var secret = process.env.NEXTAUTH_SECRET || '';
|
|
69
|
+
if (__sealKeyCache.secret !== secret) {
|
|
70
|
+
__sealKeyCache = {
|
|
71
|
+
secret: secret,
|
|
72
|
+
key: crypto.createHmac('sha256', secret).update('teleport-workflow-seal:v1').digest()
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return __sealKeyCache.key;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var SEAL_IV_BYTES = 12;
|
|
79
|
+
var SEAL_TAG_BYTES = 16;
|
|
80
|
+
|
|
81
|
+
var SEAL_AAD = Buffer.from('teleport-workflow-sealed-result:v1', 'utf8');
|
|
82
|
+
|
|
83
|
+
// The sealed form of a credential result; undefined (the result is then not
|
|
84
|
+
// replied at all) without an app secret, whose key anyone could derive.
|
|
85
|
+
function sealResult(value) {
|
|
86
|
+
if (!process.env.NEXTAUTH_SECRET) return undefined;
|
|
87
|
+
var serialized;
|
|
88
|
+
try { serialized = JSON.stringify(value); } catch (e) { return undefined; }
|
|
89
|
+
if (serialized === undefined) return undefined;
|
|
90
|
+
var iv = crypto.randomBytes(SEAL_IV_BYTES);
|
|
91
|
+
var cipher = crypto.createCipheriv('aes-256-gcm', sealKey(), iv);
|
|
92
|
+
cipher.setAAD(SEAL_AAD);
|
|
93
|
+
var data = Buffer.concat([cipher.update(serialized, 'utf8'), cipher.final()]);
|
|
94
|
+
return { __sealed: Buffer.concat([iv, cipher.getAuthTag(), data]).toString('base64') };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function isSealedResult(value) {
|
|
98
|
+
return !!value && typeof value === 'object' && !Array.isArray(value) &&
|
|
99
|
+
typeof value.__sealed === 'string' && Object.keys(value).length === 1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// { value } when the sealed form opens under this app's key, else null.
|
|
103
|
+
function openSealedResult(sealed) {
|
|
104
|
+
if (!process.env.NEXTAUTH_SECRET) return null;
|
|
105
|
+
try {
|
|
106
|
+
var raw = Buffer.from(sealed.__sealed, 'base64');
|
|
107
|
+
if (raw.length <= SEAL_IV_BYTES + SEAL_TAG_BYTES) return null;
|
|
108
|
+
var decipher = crypto.createDecipheriv('aes-256-gcm', sealKey(), raw.subarray(0, SEAL_IV_BYTES));
|
|
109
|
+
decipher.setAAD(SEAL_AAD);
|
|
110
|
+
decipher.setAuthTag(raw.subarray(SEAL_IV_BYTES, SEAL_IV_BYTES + SEAL_TAG_BYTES));
|
|
111
|
+
var data = Buffer.concat([decipher.update(raw.subarray(SEAL_IV_BYTES + SEAL_TAG_BYTES)), decipher.final()]);
|
|
112
|
+
return { value: JSON.parse(data.toString('utf8')) };
|
|
113
|
+
} catch (e) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
57
118
|
// Without an app secret every key here would derive from '' — a value anyone
|
|
58
119
|
// can compute — so nothing verifies: relayed server results are dropped and no
|
|
59
120
|
// request passes as an internal call. (The generator gives every app with
|
|
@@ -209,10 +270,48 @@ function resetPreviousResult(segmentConfig, context) {
|
|
|
209
270
|
// merge will.
|
|
210
271
|
var __incomingOrders = new WeakMap();
|
|
211
272
|
|
|
273
|
+
// The sealed results this segment opened, so its reply hands the caller back
|
|
274
|
+
// the sealed form it relayed (see resealRelayedResults).
|
|
275
|
+
var __openedResults = new WeakMap();
|
|
276
|
+
|
|
277
|
+
// Opens every sealed value the request hands this segment, so its nodes read
|
|
278
|
+
// the credential itself: a relayed server result (whose signature
|
|
279
|
+
// dropUnsignedResults checked first), or a value the browser holds from one
|
|
280
|
+
// (a custom node's output, the previous result). Only this app's server
|
|
281
|
+
// seals, so what opens is what it sealed.
|
|
282
|
+
function openSealedResults(context) {
|
|
283
|
+
var opened = [];
|
|
284
|
+
Object.keys(context).forEach(function(key) {
|
|
285
|
+
if (isControlKey(key) && key !== '__previousNodeResult') return;
|
|
286
|
+
if (!isSealedResult(context[key])) return;
|
|
287
|
+
var result = openSealedResult(context[key]);
|
|
288
|
+
if (!result) return;
|
|
289
|
+
opened.push({ sealed: context[key], value: result.value });
|
|
290
|
+
context[key] = result.value;
|
|
291
|
+
});
|
|
292
|
+
__openedResults.set(context, opened);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Every reply entry that is an opened value (the value itself, or the previous
|
|
296
|
+
// result taken from it) goes back sealed.
|
|
297
|
+
function resealRelayedResults(context, reply) {
|
|
298
|
+
var opened = __openedResults.get(context) || [];
|
|
299
|
+
if (opened.length === 0) return;
|
|
300
|
+
Object.keys(reply).forEach(function(key) {
|
|
301
|
+
for (var i = 0; i < opened.length; i++) {
|
|
302
|
+
if (reply[key] === opened[i].value) {
|
|
303
|
+
reply[key] = opened[i].sealed;
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
|
|
212
310
|
function claimSegmentContext(segmentConfig, context) {
|
|
213
311
|
var orderKeys = readSignedOrder(context);
|
|
214
312
|
if (orderKeys) restoreOrder(context, orderKeys);
|
|
215
313
|
dropUnsignedResults(segmentConfig, context, orderKeys);
|
|
314
|
+
openSealedResults(context);
|
|
216
315
|
stripForeignControlKeys(segmentConfig, context);
|
|
217
316
|
__incomingOrders.set(context, Object.keys(context).filter(function(k) { return !isControlKey(k); }));
|
|
218
317
|
utils.claimSegmentContext(segmentConfig, context);
|
|
@@ -222,6 +321,13 @@ function claimSegmentContext(segmentConfig, context) {
|
|
|
222
321
|
|
|
223
322
|
function segmentReply(segmentConfig, context, snapshot) {
|
|
224
323
|
var reply = utils.segmentReply(segmentConfig, context, snapshot);
|
|
324
|
+
resealRelayedResults(context, reply);
|
|
325
|
+
var credentialIds = utils.credentialResultNodeIds(segmentConfig);
|
|
326
|
+
Object.keys(credentialIds).forEach(function(id) {
|
|
327
|
+
if (context[id] === undefined) return;
|
|
328
|
+
var sealed = sealResult(context[id]);
|
|
329
|
+
if (sealed) reply[id] = sealed;
|
|
330
|
+
});
|
|
225
331
|
var sigs = {};
|
|
226
332
|
var incoming = context.__sig && typeof context.__sig === 'object' && !Array.isArray(context.__sig) ? context.__sig : {};
|
|
227
333
|
Object.keys(incoming).forEach(function(id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-runtime-code.js","sourceRoot":"","sources":["../../src/server-runtime-code.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"server-runtime-code.js","sourceRoot":"","sources":["../../src/server-runtime-code.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACI,MAAM,yBAAyB,GAAG,GAAW,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2WtD,CAAA;AA3WY,QAAA,yBAAyB,6BA2WrC"}
|