Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
synergy-components
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
synergy-components
Commits
d48880be
Commit
d48880be
authored
Dec 24, 2024
by
Samir Sadyhov
🤔
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NCALayer - добавлена авторизации в синержи по эцп
parent
dfef9af0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
2 deletions
+91
-2
constructor/library/NCALayer.js
constructor/library/NCALayer.js
+91
-2
No files found.
constructor/library/NCALayer.js
View file @
d48880be
...
@@ -8,6 +8,12 @@ NCALayer.sign('AUTH', null, result => {
...
@@ -8,6 +8,12 @@ NCALayer.sign('AUTH', null, result => {
NCALayer.sign('SIGN','documentID', result => {
NCALayer.sign('SIGN','documentID', result => {
console.log(result)
console.log(result)
});
});
авторизация в синержи по эцп
NCALayer.authEDS(result => {
console.log(result)
});
*/
*/
this
.
NCALayer
=
{
this
.
NCALayer
=
{
...
@@ -43,6 +49,7 @@ this.NCALayer = {
...
@@ -43,6 +49,7 @@ this.NCALayer = {
this
.
webSocket
.
onmessage
=
function
(
event
)
{
this
.
webSocket
.
onmessage
=
function
(
event
)
{
const
result
=
parseNcaLayerMsg
(
event
);
const
result
=
parseNcaLayerMsg
(
event
);
console
.
log
(
'
webSocket.onmessage
'
,
result
);
if
(
result
.
hasOwnProperty
(
'
code
'
))
{
if
(
result
.
hasOwnProperty
(
'
code
'
))
{
if
(
result
.
code
==
200
)
{
if
(
result
.
code
==
200
)
{
if
(
result
.
responseObject
.
hasOwnProperty
(
'
keyId
'
))
{
if
(
result
.
responseObject
.
hasOwnProperty
(
'
keyId
'
))
{
...
@@ -63,8 +70,17 @@ this.NCALayer = {
...
@@ -63,8 +70,17 @@ this.NCALayer = {
if
(
me
.
successHandler
)
me
.
successHandler
(
me
.
info
);
if
(
me
.
successHandler
)
me
.
successHandler
(
me
.
info
);
}
}
}
else
{
}
else
{
me
.
info
=
{...
me
.
info
,
...
result
.
responseObject
};
me
.
info
.
xml
=
result
.
responseObject
;
if
(
result
.
responseObject
.
hasOwnProperty
(
'
signedData
'
))
me
.
verificationKey
();
if
(
result
.
responseObject
.
hasOwnProperty
(
'
signedData
'
))
{
me
.
verificationKey
();
}
else
{
if
(
me
.
keysConstType
==
'
authEDS
'
)
{
me
.
authSynergyEDS
();
}
else
if
(
me
.
keysConstType
==
'
registerEDS
'
)
{
me
.
registerSynergyEDS
();
}
}
}
}
}
else
{
}
else
{
console
.
log
(
'
[NCALayer onmessage error]
'
,
result
);
console
.
log
(
'
[NCALayer onmessage error]
'
,
result
);
...
@@ -102,6 +118,20 @@ this.NCALayer = {
...
@@ -102,6 +118,20 @@ this.NCALayer = {
},
100
);
},
100
);
},
},
signXML
:
function
(
uuid
){
const
param
=
{
module
:
'
kz.gov.pki.knca.commonUtils
'
,
method
:
'
signXml
'
,
args
:
[
this
.
storageName
,
"
AUTH
"
,
`<xml>
${
uuid
}
</xml>`
,
""
,
""
]
};
if
(
!
this
.
webSocket
)
this
.
webSocket
=
this
.
getNCALayerSocket
();
setTimeout
(()
=>
{
this
.
webSocket
.
send
(
JSON
.
stringify
(
param
));
},
100
);
},
signDocument
:
async
function
(
socket
){
signDocument
:
async
function
(
socket
){
const
{
rawdata
}
=
await
AS
.
FORMS
.
ApiUtils
.
simpleAsyncGet
(
`rest/api/docflow/doc/document_info?documentID=
${
this
.
documentID
}
&locale=
${
AS
.
OPTIONS
.
locale
}
`
);
const
{
rawdata
}
=
await
AS
.
FORMS
.
ApiUtils
.
simpleAsyncGet
(
`rest/api/docflow/doc/document_info?documentID=
${
this
.
documentID
}
&locale=
${
AS
.
OPTIONS
.
locale
}
`
);
...
@@ -118,6 +148,30 @@ this.NCALayer = {
...
@@ -118,6 +148,30 @@ this.NCALayer = {
},
100
);
},
100
);
},
},
registerSynergyEDS
:
async
function
(){
if
(
this
.
successHandler
)
this
.
successHandler
(
this
.
info
);
},
authSynergyEDS
:
async
function
(){
try
{
const
url
=
`../Synergy/rest/api/authEDS`
;
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 [authSynergyEDS]:
${
err
.
message
}
`
);
if
(
this
.
successHandler
)
this
.
successHandler
({
errorCode
:
13
,
errorMessage
:
err
.
message
});
}
},
verificationKey
:
async
function
()
{
verificationKey
:
async
function
()
{
try
{
try
{
const
{
dataForSign
,
certificate
,
signedData
,
CN
}
=
this
.
info
;
const
{
dataForSign
,
certificate
,
signedData
,
CN
}
=
this
.
info
;
...
@@ -163,6 +217,41 @@ this.NCALayer = {
...
@@ -163,6 +217,41 @@ this.NCALayer = {
clearInterval
(
timerID
);
clearInterval
(
timerID
);
}
}
},
500
);
},
500
);
},
getAuthUUID
:
async
function
(){
return
new
Promise
(
async
resolve
=>
{
try
{
const
response
=
await
fetch
(
`../Synergy/rest/api/uuidForSignature`
,
{
method
:
'
GET
'
});
if
(
!
response
.
ok
)
throw
new
Error
(
await
response
.
text
());
resolve
(
response
.
json
());
}
catch
(
err
)
{
console
.
log
(
`ERROR [ getAsfDataUUID ]:
${
err
.
message
}
`
);
resolve
(
null
);
}
});
},
authEDS
:
function
(
handler
)
{
if
(
!
this
.
webSocket
)
this
.
initNCALayerSocket
();
this
.
keysConstType
=
'
authEDS
'
;
this
.
info
=
{};
if
(
handler
&&
typeof
handler
==
'
function
'
)
{
this
.
successHandler
=
handler
;
}
else
{
this
.
successHandler
=
null
;
}
this
.
getAuthUUID
().
then
(
res
=>
{
const
timerID
=
setInterval
(()
=>
{
if
(
this
.
connect
)
{
this
.
signXML
(
res
.
uuid
);
clearInterval
(
timerID
);
}
},
500
);
});
}
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment