Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Vereign Client Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
Vereign Client Library
Commits
dbc2f61a
Commit
dbc2f61a
authored
5 years ago
by
Damyan Mitev
Browse files
Options
Downloads
Patches
Plain Diff
add signVCard function
parent
911bb0e4
No related branches found
No related tags found
1 merge request
!71
[VCL] Sign generated v-card upon using a profile
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
javascript/src/iframe/viamapi-iframe.js
+113
-0
113 additions, 0 deletions
javascript/src/iframe/viamapi-iframe.js
with
113 additions
and
0 deletions
javascript/src/iframe/viamapi-iframe.js
+
113
−
0
View file @
dbc2f61a
...
...
@@ -1403,6 +1403,119 @@ const connection = Penpal.connectToParent({
return
encodeResponse
(
"
200
"
,
""
,
"
Document signed
"
);
},
// passportUUID - passport to sign the vCard
// text, html - the text and html part of the email
// related, attachments - array of objects, containing hashes of images/objects, related to the html in format:
// {
// headers: {
// "Content-Type": "application/hash; algorithm=SHA-256",
// "Original-Content-Type": "image/jpeg", //original content type
// "Content-Disposition": "inline" or "attachment",
// ... //other headers
// },
// body: "base64 encoded hash"
// }
signVCard
:
async
(
passportUUID
,
text
,
html
,
parts
=
null
)
=>
{
const
authenticationPublicKey
=
localStorage
.
getItem
(
"
authenticatedIdentity
"
);
if
(
!
authenticationPublicKey
||
!
window
.
loadedIdentities
[
authenticationPublicKey
]
||
!
extendPinCodeTtl
(
authenticationPublicKey
)
)
{
return
encodeResponse
(
"
400
"
,
""
,
"
Identity not authenticated
"
);
}
const
vCardImageResponse
=
await
executeRestfulFunction
(
"
private
"
,
window
.
viamApi
,
window
.
viamApi
.
passportGetVCardImage
,
null
,
passportUUID
);
if
(
vCardImageResponse
.
code
!==
"
200
"
)
{
return
encodeResponse
(
"
400
"
,
""
,
vCardImageResponse
.
status
);
}
const
vCardImageData
=
vCardImageResponse
.
data
;
if
(
vCardImageData
.
contentType
!==
"
image/png
"
)
{
return
encodeResponse
(
"
400
"
,
""
,
"
Content type of vCard mmust be 'image/png'
"
);
}
if
(
!
parts
)
{
parts
=
[];
}
if
(
html
)
{
const
htmlPart
=
{
headers
:
{
"
Content-Type
"
:
"
text/html
"
},
body
:
stringToUtf8Base64
(
html
)
};
parts
.
unshift
(
htmlPart
);
}
if
(
text
)
{
const
textPart
=
{
headers
:
{
"
Content-Type
"
:
"
text/plain
"
},
body
:
stringToUtf8Base64
(
text
)
};
parts
.
unshift
(
textPart
);
}
const
certResponse
=
await
getCertificateForPassport
(
passportUUID
,
true
);
if
(
certResponse
.
code
!==
"
200
"
)
{
return
encodeResponse
(
"
400
"
,
""
,
certResponse
.
status
);
}
const
{
x509Certificate
:
passportCertificate
,
privateKey
:
passportPrivateKey
,
chain
:
passportChain
}
=
certResponse
.
data
;
const
keys
=
await
createOneTimePassportCertificate
(
makeid
()
+
"
-
"
+
passportUUID
,
null
,
passportPrivateKey
,
passportCertificate
);
const
{
privateKeyPEM
:
privateKeyOneTime
,
certificatePEM
:
certificateOneTime
}
=
keys
;
passportChain
.
reverse
();
passportChain
.
push
(
passportCertificate
);
passportChain
.
push
(
certificateOneTime
);
passportChain
.
reverse
();
const
signVCardResponse
=
await
executeRestfulFunction
(
"
private
"
,
window
.
viamApi
,
window
.
viamApi
.
signSignVCardForChain
,
null
,
vCardImageData
,
privateKeyOneTime
,
passportChain
,
parts
);
if
(
signVCardResponse
.
code
!==
"
200
"
)
{
return
encodeResponse
(
"
400
"
,
""
,
signVCardResponse
.
status
);
}
return
encodeResponse
(
"
200
"
,
signVCardResponse
.
data
,
"
vCard signed
"
);
},
documentCreateDocument
:
async
(
passportUUID
,
path
,
contentType
,
title
)
=>
{
const
authenticationPublicKey
=
localStorage
.
getItem
(
"
authenticatedIdentity
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment