@it-enterprise/digital-signature 1.3.2 → 1.3.3
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/euscp/euscp.js +7 -7
- package/package.json +1 -1
- package/src/Models.js +39 -0
- package/src/Utils.js +11 -3
package/package.json
CHANGED
package/src/Models.js
CHANGED
|
@@ -74,6 +74,45 @@ export class DefaultSettingProvider {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
export class WebserviceSettingProvider {
|
|
78
|
+
/**
|
|
79
|
+
* @param {string} language - Язык ошибок
|
|
80
|
+
* @param {string | function} userId - id пользователя (для сохранения ключей и предпочитаемого типа ключа)
|
|
81
|
+
* @param {string} apiPath - путь к api ЕЦП
|
|
82
|
+
* @param {string} workerPath - ссылка на WebWorker
|
|
83
|
+
*/
|
|
84
|
+
constructor(language, userId, apiPath, workerPath) {
|
|
85
|
+
this.language = language;
|
|
86
|
+
this.userId = userId;
|
|
87
|
+
this.apiPath = apiPath;
|
|
88
|
+
this.workerPath = workerPath;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async getGlSign() {
|
|
92
|
+
return new GlSign(await downloadData(`${this.apiPath}/webservice.asmx/ExecuteEx?pureJSON=`, undefined, undefined, {calcId: 'GETGLSIGNBEFORELOGIN', args: '', ticket: ''}));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async getSettings() {
|
|
96
|
+
if (this._settings) {
|
|
97
|
+
return this._settings;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const json = await downloadData(`${this.apiPath}/webservice.asmx/ExecuteEx?pureJSON=`, "json", undefined, {calcId: 'GETCASANDCERTIFICATEFILES', args: '', ticket: ''});
|
|
101
|
+
this._settings = new DigitalSignatureSettings(
|
|
102
|
+
this.language,
|
|
103
|
+
this.userId,
|
|
104
|
+
`${this.apiPath}/ProxyHandler`,
|
|
105
|
+
new DefaultCertificatesProvider(
|
|
106
|
+
`${this.apiPath}/GetFile.ashx?file=${json.FILECAS}`,
|
|
107
|
+
`${this.apiPath}/GetFile.ashx?file=${json.FILECERT}`
|
|
108
|
+
),
|
|
109
|
+
this.workerPath || "/euscp.worker.js"
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
return this._settings;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
77
116
|
export class LegacySettingsProvider {
|
|
78
117
|
/**
|
|
79
118
|
* @param {string} language - Язык ошибок
|
package/src/Utils.js
CHANGED
|
@@ -6,7 +6,7 @@ import { EndUserCertificate, EndUserConstants, EndUserError } from "../euscp/eus
|
|
|
6
6
|
* @param {string?} dataType - тип данных, которые необходимо загрузить. Возможные значения: binary, json и пусто для строковых данных
|
|
7
7
|
* @returns {Promise<string | Uint8Array | object>} загруженные данные
|
|
8
8
|
*/
|
|
9
|
-
export function downloadData(url, dataType, token) {
|
|
9
|
+
export function downloadData(url, dataType, token, postData) {
|
|
10
10
|
return new Promise((resolve, reject) => {
|
|
11
11
|
url = makeUrl(url);
|
|
12
12
|
|
|
@@ -60,11 +60,19 @@ export function downloadData(url, dataType, token) {
|
|
|
60
60
|
} else if (dataType == "xml") {
|
|
61
61
|
xmlHttp.responseType = "document";
|
|
62
62
|
}
|
|
63
|
-
xmlHttp.open("GET", url, true);
|
|
63
|
+
xmlHttp.open(postData ? "POST" : "GET", url, true);
|
|
64
64
|
if (typeof token === "string") {
|
|
65
65
|
xmlHttp.setRequestHeader("Authorization", "Bearer " + token);
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
|
|
68
|
+
if (postData) {
|
|
69
|
+
var jsonData = JSON.stringify(postData);
|
|
70
|
+
xmlHttp.setRequestHeader('Content-Type', 'application/json');
|
|
71
|
+
xmlHttp.send(jsonData);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
xmlHttp.send();
|
|
75
|
+
}
|
|
68
76
|
});
|
|
69
77
|
}
|
|
70
78
|
|