Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
N
node-bigstream
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bs
node-bigstream
Commits
a76b28f7
Commit
a76b28f7
authored
May 26, 2020
by
Kamron Aroonrua
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pgpcrypt
parent
b0211482
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
19 deletions
+43
-19
perform.js
plugins/dt/dt-pgpcrypt/perform.js
+43
-19
No files found.
plugins/dt/dt-pgpcrypt/perform.js
View file @
a76b28f7
var
ctx
=
require
(
'../../../context'
);
var
Utils
=
ctx
.
getLib
(
'lib/util/plugin-utils'
);
var
pgplib
=
require
(
'./pgp'
)
function
perform_function
(
context
,
request
,
response
){
var
job_id
=
context
.
jobconfig
.
job_id
;
...
...
@@ -15,6 +16,7 @@ function perform_function(context,request,response){
var
req_publickey
=
param
.
publickey
||
""
var
req_privatekey
=
param
.
privatekey
||
""
var
req_passphrase
=
param
.
passphrase
||
""
var
req_output
=
param
.
output
||
"binary"
var
env
=
{
'type'
:
output_type
,
...
...
@@ -25,6 +27,7 @@ function perform_function(context,request,response){
req_publickey
=
Utils
.
vm_execute_text
(
env
,
req_publickey
);
req_privatekey
=
Utils
.
vm_execute_text
(
env
,
req_privatekey
);
req_passphrase
=
Utils
.
vm_execute_text
(
env
,
req_passphrase
);
req_output
=
Utils
.
vm_execute_text
(
env
,
req_output
);
//parsing param from meta
if
(
typeof
meta
.
_param
==
'object'
)
...
...
@@ -34,30 +37,51 @@ function perform_function(context,request,response){
req_publickey
=
(
_prm
.
publickey
)?
_prm
.
publickey
:
req_publickey
;
req_privatekey
=
(
_prm
.
privatekey
)?
_prm
.
privatekey
:
req_privatekey
;
req_passphrase
=
(
_prm
.
passphrase
)?
_prm
.
passphrase
:
req_passphrase
;
req_output
=
(
_prm
.
output
)?
_prm
.
output
:
req_output
;
}
if
([
'decrypt'
,
'dec'
].
indexOf
(
req_function
)
>=
0
){
pgplib
.
decrypt
({
privatekey
:
req_privatekey
,
passphrase
:
req_passphrase
,
armor_in
:
(
typeof
data
==
'string'
),
data
:
data
}).
then
(
d
=>
{
var
dout
=
d
;
if
([
'utf8'
,
'text'
].
indexOf
(
req_output
)
>=
0
){
dout
=
d
.
toString
(
'utf8'
);
}
else
if
(
req_output
==
'base64'
){
dout
=
d
.
toString
(
'base64'
);
}
ok_out
(
d
);
}).
catch
(
e
=>
{
error_out
(
'decrypt error'
);
})
}
else
if
([
'encrypt'
,
'enc'
].
indexOf
(
req_function
)
>=
0
){
pgplib
.
encrypt
({
publickey
:
req_publickey
,
armor_out
:
([
'armor'
,
'text'
].
indexOf
(
req_output
)
>=
0
),
data
:
data
}).
then
(
d
=>
{
ok_out
(
d
);
}).
catch
(
e
=>
{
error_out
(
'decrypt error'
);
})
}
else
{
error_out
(
'invalid function'
)
}
respmeta
[
'_status_code'
]
=
(
err
)?
0
:
resp
.
statusCode
;
respmeta
[
'_error'
]
=
(
err
)?
true
:
false
;
response
.
meta
=
respmeta
;
function
ok_out
(
out
)
{
response
.
meta
=
meta
;
response
.
success
(
out
,
output_type
);
}
if
(
!
err
){
if
(
resp_encode
==
'json'
){
try
{
var
j
=
JSON
.
parse
(
body
);
response
.
success
(
j
,
output_type
);
}
catch
(
err
){
response
.
success
({},
output_type
);
}
}
else
{
response
.
success
(
body
,
output_type
);
}
}
else
{
response
.
success
(
null
,
output_type
);
}
function
error_out
(
msg
)
{
response
.
error
(
msg
);
}
//response.success();
...
...
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