@haiiro/docuflow 0.0.12 → 0.0.13
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/README.md +38 -8
- package/manifest.json +99 -13
- package/package.json +6 -3
- package/public/app/docflow-app.css +2 -0
- package/public/app/docflow-app.js +94 -0
- package/src/front-components/docflow-documents.front-component.mjs +3 -3
- package/src/front-components/docflow-processes.front-component.mjs +19 -19
- package/src/front-components/docflow-processes.front-component.tsx +18 -2
- package/src/front-components/docflow-tasks.front-component.mjs +3 -3
- package/src/front-components/launch-process.front-component.mjs +75 -0
- package/src/front-components/launch-process.front-component.tsx +270 -0
- package/src/front-components/process-steps.front-component.mjs +24 -24
- package/src/front-components/process-steps.front-component.tsx +54 -9
- package/src/front-components/task-form.front-component.mjs +21 -21
- package/src/logic-functions/bitrix-app.logic-function.mjs +160 -87
- package/src/logic-functions/bitrix-app.logic-function.ts +22 -59
- package/src/logic-functions/bitrix-install.logic-function.mjs +0 -11
- package/src/logic-functions/bitrix-install.logic-function.ts +0 -3
- package/src/logic-functions/docflow-app-session.logic-function.mjs +60043 -0
- package/src/logic-functions/docflow-app-session.logic-function.ts +54 -0
- package/src/logic-functions/docflow-app.logic-function.mjs +60122 -0
- package/src/logic-functions/docflow-app.logic-function.ts +37 -0
- package/src/logic-functions/launch-process.logic-function.mjs +113 -29
- package/src/logic-functions/launch-process.logic-function.ts +83 -22
- package/src/logic-functions/save-launch-fields.logic-function.mjs +176 -9
- package/src/logic-functions/save-launch-fields.logic-function.ts +24 -6
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { defineLogicFunction } from 'twenty-sdk/define';
|
|
2
|
+
import {
|
|
3
|
+
type LogicFunctionExecutionContext,
|
|
4
|
+
type RoutePayload,
|
|
5
|
+
} from 'twenty-sdk/logic-function';
|
|
6
|
+
|
|
7
|
+
import { readAccessTokenClaims } from 'src/shared/app/docflow-app.util';
|
|
8
|
+
import { jsonResponse } from 'src/server/http-response';
|
|
9
|
+
import { DOCFLOW_APP_SESSION_LOGIC_FUNCTION_UNIVERSAL_IDENTIFIER } from 'src/universal-identifiers';
|
|
10
|
+
|
|
11
|
+
// The session of the standalone page: the token the CRM gave this call on
|
|
12
|
+
// behalf of the signed-in person (30 minutes, the person's rights). Called
|
|
13
|
+
// with the CRM sign-in cookie on the CRM address and in the sign-in popup;
|
|
14
|
+
// with the current token to renew it inside the Bitrix24 frame, where the
|
|
15
|
+
// cookie does not reach.
|
|
16
|
+
const handler = async (event: RoutePayload, context: LogicFunctionExecutionContext) => {
|
|
17
|
+
// Only the page itself: another site must not get a token through the
|
|
18
|
+
// person's cookie.
|
|
19
|
+
if (event.headers['sec-fetch-site'] === 'cross-site') {
|
|
20
|
+
return jsonResponse(403, { message: 'Запрос с другого сайта' });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const token = process.env.TWENTY_APP_ACCESS_TOKEN ?? '';
|
|
24
|
+
const isOnBehalfOfPerson =
|
|
25
|
+
context.userWorkspaceId !== null &&
|
|
26
|
+
token.length > 0 &&
|
|
27
|
+
token !== process.env.TWENTY_APP_APPLICATION_ACCESS_TOKEN;
|
|
28
|
+
const claims = isOnBehalfOfPerson ? readAccessTokenClaims(token) : undefined;
|
|
29
|
+
|
|
30
|
+
if (claims?.userId === undefined || claims.expiresAt === undefined) {
|
|
31
|
+
return jsonResponse(401, { message: 'Войдите в CRM' });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return jsonResponse(200, {
|
|
35
|
+
token,
|
|
36
|
+
expiresAt: claims.expiresAt,
|
|
37
|
+
userId: claims.userId,
|
|
38
|
+
workspaceMemberId: context.workspaceMemberId,
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default defineLogicFunction({
|
|
43
|
+
universalIdentifier: DOCFLOW_APP_SESSION_LOGIC_FUNCTION_UNIVERSAL_IDENTIFIER,
|
|
44
|
+
name: 'docflow-app-session',
|
|
45
|
+
description: 'Сессия отдельной страницы документооборота от имени вошедшего сотрудника',
|
|
46
|
+
timeoutSeconds: 10,
|
|
47
|
+
handler,
|
|
48
|
+
httpRouteTriggerSettings: {
|
|
49
|
+
path: '/docflow/app/session',
|
|
50
|
+
httpMethod: 'POST',
|
|
51
|
+
isAuthRequired: true,
|
|
52
|
+
forwardedRequestHeaders: ['sec-fetch-site'],
|
|
53
|
+
},
|
|
54
|
+
});
|