Commit 0ebe2c46 authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

NCALayer - добавлена регистрация в синержи по эцп

parent d48880be
......@@ -49,7 +49,6 @@ this.NCALayer = {
this.webSocket.onmessage = function(event) {
const result = parseNcaLayerMsg(event);
console.log('webSocket.onmessage', result);
if(result.hasOwnProperty('code')) {
if(result.code == 200) {
if (result.responseObject.hasOwnProperty('keyId')) {
......@@ -149,7 +148,23 @@ this.NCALayer = {
},
registerSynergyEDS: async function(){
if(this.successHandler) this.successHandler(this.info);
try {
const url = `../Synergy/rest/api/registerEDS`;
const response = await fetch(url, {
method: 'POST',
headers: {"Content-Type": "application/json; charset=UTF-8"},
body: JSON.stringify({"cert": this.info.xml})
});
const result = await response.json();
if(!response.ok) throw new Error(result.errorMessage);
if(this.successHandler) this.successHandler(result);
} catch (err) {
console.log(`ERROR [registerSynergyEDS]: ${err.message}`);
if(this.successHandler) this.successHandler({errorCode: 13, errorMessage: err.message});
}
},
authSynergyEDS: async function(){
......@@ -244,6 +259,27 @@ this.NCALayer = {
this.successHandler = null;
}
this.getAuthUUID().then(res => {
const timerID = setInterval(() => {
if(this.connect) {
this.signXML(res.uuid);
clearInterval(timerID);
}
}, 500);
});
},
registerEDS: function(handler) {
if(!this.webSocket) this.initNCALayerSocket();
this.keysConstType = 'registerEDS';
this.info = {};
if(handler && typeof handler == 'function') {
this.successHandler = handler;
} else {
this.successHandler = null;
}
this.getAuthUUID().then(res => {
const timerID = setInterval(() => {
if(this.connect) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment