@zextras/carbonio-shell-ui 8.0.3-devel.1727341165567 → 8.0.3-playground.1727430558564
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/lib/network/fetch-utils.d.ts +2 -0
- package/lib/network/fetch-utils.js +70 -0
- package/lib/network/fetch-utils.js.map +1 -0
- package/lib/network/fetch.js +15 -67
- package/lib/network/fetch.js.map +1 -1
- package/lib/network/logout.d.ts +3 -0
- package/lib/network/logout.js +35 -0
- package/lib/network/logout.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.soapFetch = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com>
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
8
|
+
*/
|
|
9
|
+
const user_agent_1 = require("./user-agent");
|
|
10
|
+
const constants_1 = require("../constants");
|
|
11
|
+
const account_1 = require("../store/account");
|
|
12
|
+
const network_1 = require("../store/network");
|
|
13
|
+
const getAccount = (acc, otherAccount) => {
|
|
14
|
+
if (otherAccount) {
|
|
15
|
+
return {
|
|
16
|
+
by: 'name',
|
|
17
|
+
_content: otherAccount
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (acc) {
|
|
21
|
+
if (acc.name) {
|
|
22
|
+
return {
|
|
23
|
+
by: 'name',
|
|
24
|
+
_content: acc.name
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (acc.id) {
|
|
28
|
+
return {
|
|
29
|
+
by: 'id',
|
|
30
|
+
_content: acc.id
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
};
|
|
36
|
+
const soapFetch = async (api, body, otherAccount, signal) => {
|
|
37
|
+
const { zimbraVersion, account } = account_1.useAccountStore.getState();
|
|
38
|
+
const { notify, session } = network_1.useNetworkStore.getState();
|
|
39
|
+
const res = await fetch(`/service/soap/${api}Request`, {
|
|
40
|
+
signal,
|
|
41
|
+
method: 'POST',
|
|
42
|
+
headers: {
|
|
43
|
+
'Content-Type': 'application/json'
|
|
44
|
+
},
|
|
45
|
+
body: JSON.stringify({
|
|
46
|
+
Body: {
|
|
47
|
+
[`${api}Request`]: body
|
|
48
|
+
},
|
|
49
|
+
Header: {
|
|
50
|
+
context: {
|
|
51
|
+
_jsns: constants_1.JSNS.all,
|
|
52
|
+
notify: notify?.[0]?.seq
|
|
53
|
+
? {
|
|
54
|
+
seq: notify?.[0]?.seq
|
|
55
|
+
}
|
|
56
|
+
: undefined,
|
|
57
|
+
session: session ?? {},
|
|
58
|
+
account: getAccount(account, otherAccount),
|
|
59
|
+
userAgent: {
|
|
60
|
+
name: user_agent_1.userAgent,
|
|
61
|
+
version: zimbraVersion
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
return res.json();
|
|
68
|
+
};
|
|
69
|
+
exports.soapFetch = soapFetch;
|
|
70
|
+
//# sourceMappingURL=fetch-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-utils.js","sourceRoot":"","sources":["../../src/network/fetch-utils.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,6CAAyC;AACzC,4CAAoC;AACpC,8CAAmD;AACnD,8CAAmD;AAInD,MAAM,UAAU,GAAG,CAClB,GAAa,EACb,YAAqB,EAC0B,EAAE;IACjD,IAAI,YAAY,EAAE,CAAC;QAClB,OAAO;YACN,EAAE,EAAE,MAAM;YACV,QAAQ,EAAE,YAAY;SACtB,CAAC;IACH,CAAC;IACD,IAAI,GAAG,EAAE,CAAC;QACT,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;YACd,OAAO;gBACN,EAAE,EAAE,MAAM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AAG,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC,CAAC;AArCW,QAAA,SAAS,aAqCpB"}
|
package/lib/network/fetch.js
CHANGED
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.shellSoap = exports.getXmlSoapFetch = exports.getSoapFetch = exports.fetchNoOp = void 0;
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
10
|
+
const fetch_utils_1 = require("./fetch-utils");
|
|
11
|
+
const logout_1 = require("./logout");
|
|
10
12
|
const user_agent_1 = require("./user-agent");
|
|
11
|
-
const utils_1 = require("./utils");
|
|
12
13
|
const constants_1 = require("../constants");
|
|
13
14
|
const functions_1 = require("../reporting/functions");
|
|
14
15
|
const account_1 = require("../store/account");
|
|
15
16
|
const network_1 = require("../store/network");
|
|
16
|
-
const
|
|
17
|
+
const utils_1 = require("../store/network/utils");
|
|
17
18
|
const fetchNoOp = () => {
|
|
18
19
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
19
20
|
(0, exports.getSoapFetch)(constants_1.SHELL_APP_ID)('NoOp', network_1.useNetworkStore.getState().pollingInterval === 500
|
|
@@ -21,29 +22,6 @@ const fetchNoOp = () => {
|
|
|
21
22
|
: { _jsns: constants_1.JSNS.mail });
|
|
22
23
|
};
|
|
23
24
|
exports.fetchNoOp = fetchNoOp;
|
|
24
|
-
const getAccount = (acc, otherAccount) => {
|
|
25
|
-
if (otherAccount) {
|
|
26
|
-
return {
|
|
27
|
-
by: 'name',
|
|
28
|
-
_content: otherAccount
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if (acc) {
|
|
32
|
-
if (acc.name) {
|
|
33
|
-
return {
|
|
34
|
-
by: 'name',
|
|
35
|
-
_content: acc.name
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
if (acc.id) {
|
|
39
|
-
return {
|
|
40
|
-
by: 'id',
|
|
41
|
-
_content: acc.id
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return undefined;
|
|
46
|
-
};
|
|
47
25
|
const getXmlAccount = (acc, otherAccount) => {
|
|
48
26
|
if (otherAccount) {
|
|
49
27
|
return `<account by="name">${otherAccount}</account>`;
|
|
@@ -80,12 +58,13 @@ const handleResponse = (api, res) => {
|
|
|
80
58
|
const { usedQuota } = account_1.useAccountStore.getState();
|
|
81
59
|
clearTimeout(noOpTimeout);
|
|
82
60
|
if (res.Body.Fault) {
|
|
83
|
-
if (
|
|
61
|
+
if (['service.AUTH_REQUIRED', 'service.AUTH_EXPIRED'].find((code) => code === res.Body.Fault.Detail?.Error?.Code)) {
|
|
84
62
|
if (constants_1.IS_FOCUS_MODE) {
|
|
85
63
|
account_1.useAccountStore.setState({ authenticated: false });
|
|
86
64
|
}
|
|
87
65
|
else {
|
|
88
|
-
(0,
|
|
66
|
+
(0, logout_1.logout)();
|
|
67
|
+
throw new Error(res.Body.Fault.Detail.Error.Code);
|
|
89
68
|
}
|
|
90
69
|
}
|
|
91
70
|
console.error(new Error(`${res.Body.Fault.Detail?.Error?.Code}: ${res.Body.Fault.Reason?.Text}`));
|
|
@@ -95,11 +74,11 @@ const handleResponse = (api, res) => {
|
|
|
95
74
|
res.Header.context?.notify?.[0]?.modified?.mbx?.[0]?.s;
|
|
96
75
|
const _context = normalizeContext(res.Header.context);
|
|
97
76
|
const seq = (0, lodash_1.maxBy)(_context.notify, 'seq')?.seq ?? 0;
|
|
98
|
-
(0,
|
|
77
|
+
(0, utils_1.handleSync)(_context);
|
|
99
78
|
account_1.useAccountStore.setState({
|
|
100
79
|
usedQuota: responseUsedQuota ?? usedQuota
|
|
101
80
|
});
|
|
102
|
-
const nextPollingInterval = (0,
|
|
81
|
+
const nextPollingInterval = (0, utils_1.getPollingInterval)(res);
|
|
103
82
|
network_1.useNetworkStore.setState({
|
|
104
83
|
noOpTimeout: setTimeout(() => (0, exports.fetchNoOp)(), nextPollingInterval),
|
|
105
84
|
pollingInterval: nextPollingInterval,
|
|
@@ -111,44 +90,13 @@ const handleResponse = (api, res) => {
|
|
|
111
90
|
// @ts-ignore
|
|
112
91
|
return res?.Body?.Fault ? res.Body : res.Body[`${api}Response`];
|
|
113
92
|
};
|
|
114
|
-
const getSoapFetch = (app) => (api, body, otherAccount, signal) =>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
'Content-Type': 'application/json'
|
|
122
|
-
},
|
|
123
|
-
body: JSON.stringify({
|
|
124
|
-
Body: {
|
|
125
|
-
[`${api}Request`]: body
|
|
126
|
-
},
|
|
127
|
-
Header: {
|
|
128
|
-
context: {
|
|
129
|
-
_jsns: constants_1.JSNS.all,
|
|
130
|
-
notify: notify?.[0]?.seq
|
|
131
|
-
? {
|
|
132
|
-
seq: notify?.[0]?.seq
|
|
133
|
-
}
|
|
134
|
-
: undefined,
|
|
135
|
-
session: session ?? {},
|
|
136
|
-
account: getAccount(account, otherAccount),
|
|
137
|
-
userAgent: {
|
|
138
|
-
name: user_agent_1.userAgent,
|
|
139
|
-
version: zimbraVersion
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
})
|
|
144
|
-
}) // TODO proper error handling
|
|
145
|
-
.then((res) => res?.json())
|
|
146
|
-
.then((res) => handleResponse(api, res))
|
|
147
|
-
.catch((e) => {
|
|
148
|
-
(0, functions_1.report)(app)(e);
|
|
149
|
-
throw e;
|
|
150
|
-
});
|
|
151
|
-
};
|
|
93
|
+
const getSoapFetch = (app) => (api, body, otherAccount, signal) => (0, fetch_utils_1.soapFetch)(api, body, otherAccount, signal)
|
|
94
|
+
// TODO proper error handling
|
|
95
|
+
.then((res) => handleResponse(api, res))
|
|
96
|
+
.catch((e) => {
|
|
97
|
+
(0, functions_1.report)(app)(e);
|
|
98
|
+
throw e;
|
|
99
|
+
});
|
|
152
100
|
exports.getSoapFetch = getSoapFetch;
|
|
153
101
|
const getXmlSoapFetch = (app) => (api, body, otherAccount) => {
|
|
154
102
|
const { zimbraVersion, account } = account_1.useAccountStore.getState();
|
package/lib/network/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/network/fetch.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/network/fetch.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mCAAoC;AAEpC,+CAA0C;AAC1C,qCAAkC;AAClC,6CAAyC;AACzC,4CAAiE;AACjE,sDAAgD;AAChD,8CAAmD;AACnD,8CAAmD;AACnD,kDAAwE;AAYjE,MAAM,SAAS,GAAG,GAAS,EAAE;IACnC,mEAAmE;IACnE,IAAA,oBAAY,EAAC,wBAAY,CAAC,CACzB,MAAM,EACN,yBAAe,CAAC,QAAQ,EAAE,CAAC,eAAe,KAAK,GAAG;QACjD,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAI,CAAC,IAAI,EAAE,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;QACrD,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAI,CAAC,IAAI,EAAE,CACvB,CAAC;AACH,CAAC,CAAC;AARW,QAAA,SAAS,aAQpB;AAEF,MAAM,aAAa,GAAG,CAAC,GAAa,EAAE,YAAqB,EAAU,EAAE;IACtE,IAAI,YAAY,EAAE,CAAC;QAClB,OAAO,sBAAsB,YAAY,YAAY,CAAC;IACvD,CAAC;IACD,IAAI,GAAG,EAAE,CAAC;QACT,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;YACd,OAAO,sBAAsB,GAAG,CAAC,IAAI,YAAY,CAAC;QACnD,CAAC;QACD,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,OAAO,oBAAoB,GAAG,CAAC,EAAE,YAAY,CAAC;QAC/C,CAAC;IACF,CAAC;IACD,OAAO,E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,CACpI,OAAO,EACP,YAAY,CACZ;gBACY,IAAI;mBACD;KAChB,CAAC,CAAC,6BAA6B;SAC9B,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;SAC1B,IAAI,CAAC,CAAC,GAA8B,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SAClE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACZ,IAAA,kBAAM,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACf,MAAM,CAAC,CAAC;IACT,CAAC,CAAsB,CAAC;AAC1B,CAAC,CAAC;AA5BU,QAAA,eAAe,mBA4BzB;AAEU,QAAA,SAAS,GAAG,IAAA,oBAAY,EAAC,wBAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* SPDX-FileCopyrightText: 2021 Zextras <https://www.zextras.com>
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.logout = void 0;
|
|
9
|
+
const fetch_utils_1 = require("./fetch-utils");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const constants_1 = require("../constants");
|
|
12
|
+
const store_1 = require("../store/login/store");
|
|
13
|
+
async function logout({ isManualLogout = false } = {}) {
|
|
14
|
+
try {
|
|
15
|
+
await (0, fetch_utils_1.soapFetch)('EndSession', {
|
|
16
|
+
_jsns: constants_1.JSNS.account,
|
|
17
|
+
logoff: true
|
|
18
|
+
});
|
|
19
|
+
await fetch('/logout', { redirect: 'manual' });
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error(error);
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
const customLogoutUrl = store_1.useLoginConfigStore.getState().carbonioWebUiLogoutURL;
|
|
26
|
+
if (isManualLogout && customLogoutUrl) {
|
|
27
|
+
(0, utils_1.goTo)(customLogoutUrl);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
(0, utils_1.goToLogin)();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.logout = logout;
|
|
35
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/network/logout.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,+CAA0C;AAC1C,mCAA0C;AAC1C,4CAAoC;AACpC,gDAA2D;AAEpD,KAAK,UAAU,MAAM,CAAC,EAC5B,cAAc,GAAG,KAAK,KACW,EAAE;IACnC,IAAI,CAAC;QACJ,MAAM,IAAA,uBAAS,EAAC,YAAY,EAAE;YAC7B,KAAK,EAAE,gBAAI,CAAC,OAAO;YACnB,MAAM,EAAE,IAAI;SACZ,CAAC,CAAC;QACH,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;YAAS,CAAC;QACV,MAAM,eAAe,GAAG,2BAAmB,CAAC,QAAQ,EAAE,CAAC,sBAAsB,CAAC;QAC9E,IAAI,cAAc,IAAI,eAAe,EAAE,CAAC;YACvC,IAAA,YAAI,EAAC,eAAe,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACP,IAAA,iBAAS,GAAE,CAAC;QACb,CAAC;IACF,CAAC;AACF,CAAC;AAnBD,wBAmBC"}
|