Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Signing verification utilities
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Seal
Building blocks
Signing verification utilities
Commits
0f47ddb7
Commit
0f47ddb7
authored
4 years ago
by
Igor Markin
Browse files
Options
Downloads
Patches
Plain Diff
Add build
parent
1400ff78
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dist/services/MimeVerificationService/MimeVerificationService.js
+7
-59
7 additions, 59 deletions
...rvices/MimeVerificationService/MimeVerificationService.js
with
7 additions
and
59 deletions
dist/services/MimeVerificationService/MimeVerificationService.js
+
7
−
59
View file @
0f47ddb7
...
@@ -9,39 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
...
@@ -9,39 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
});
};
};
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
const
normalizationStrategies_1
=
require
(
"
./normalizationStrategies
"
);
const
mime_normalizer_1
=
require
(
"
@vereign/mime-normalizer
"
);
const
dom_1
=
require
(
"
@vereign/dom
"
);
const
MailParser_1
=
require
(
"
../MailParser/MailParser
"
);
const
MailParser_1
=
require
(
"
../MailParser/MailParser
"
);
const
CryptoService_1
=
require
(
"
../CryptoService
"
);
const
CryptoService_1
=
require
(
"
../CryptoService
"
);
const
StatusesService_1
=
require
(
"
../StatusesService
"
);
const
index_1
=
require
(
"
./index
"
);
const
index_1
=
require
(
"
./index
"
);
const
rka_1
=
require
(
"
../../utils/rka
"
);
const
rka_1
=
require
(
"
../../utils/rka
"
);
const
common_1
=
require
(
"
../../utils/common
"
);
const
common_1
=
require
(
"
../../utils/common
"
);
const
VerificationError_1
=
require
(
"
../VerificationService/VerificationError
"
);
const
VerificationError_1
=
require
(
"
../VerificationService/VerificationError
"
);
const
stringUtils_1
=
require
(
"
../../utils/stringUtils
"
);
const
utils_1
=
require
(
"
./utils
"
);
const
vendorAmendingFunctions
=
{
[
StatusesService_1
.
EMAIL_VENDORS
.
GMAIL
]:
normalizationStrategies_1
.
amendGmailNodes
,
[
StatusesService_1
.
EMAIL_VENDORS
.
OUTLOOK
]:
normalizationStrategies_1
.
amendOutlookNodes
,
};
const
vendorPruningFunctions
=
{
[
StatusesService_1
.
EMAIL_VENDORS
.
GMAIL
]:
normalizationStrategies_1
.
pruneGmailElement
,
[
StatusesService_1
.
EMAIL_VENDORS
.
OUTLOOK
]:
normalizationStrategies_1
.
pruneOutlookElement
,
};
const
vendorAttributesCleanupFunctions
=
{
[
StatusesService_1
.
EMAIL_VENDORS
.
GMAIL
]:
normalizationStrategies_1
.
cleanupGMailElementAttributes
,
[
StatusesService_1
.
EMAIL_VENDORS
.
OUTLOOK
]:
normalizationStrategies_1
.
cleanupOutlookElementAttributes
,
};
const
vendorPrintingFunctions
=
{
[
StatusesService_1
.
EMAIL_VENDORS
.
OUTLOOK
]:
utils_1
.
printOutlookElement
,
};
// Load JSDOM dynamically for Node env only, because built CRA is crashing with it
let
JSDOM
;
const
loadJSDOM
=
()
=>
__awaiter
(
void
0
,
void
0
,
void
0
,
function
*
()
{
if
(
!
JSDOM
)
{
JSDOM
=
(
yield
Promise
.
resolve
().
then
(()
=>
require
(
"
jsdom
"
))).
JSDOM
;
}
});
typeof
window
===
"
undefined
"
&&
loadJSDOM
();
const
prepareMimeForPartsVerification
=
(
mimeString
,
attachmentsHashes
,
senderSystem
,
sourceHtmlRabinFingerprint
,
sourceHtmlSize
,
sourcePlainRabinFingerprint
,
sourcePlainSize
)
=>
__awaiter
(
void
0
,
void
0
,
void
0
,
function
*
()
{
const
prepareMimeForPartsVerification
=
(
mimeString
,
attachmentsHashes
,
senderSystem
,
sourceHtmlRabinFingerprint
,
sourceHtmlSize
,
sourcePlainRabinFingerprint
,
sourcePlainSize
)
=>
__awaiter
(
void
0
,
void
0
,
void
0
,
function
*
()
{
const
{
htmlPart
,
plainPart
}
=
getNormalizedMimeParts
(
mimeString
,
senderSystem
);
const
{
htmlPart
,
plainPart
}
=
getNormalizedMimeParts
(
mimeString
,
senderSystem
);
const
originalHtml
=
findSubstring
(
htmlPart
,
sourceHtmlRabinFingerprint
,
sourceHtmlSize
);
const
originalHtml
=
findSubstring
(
htmlPart
,
sourceHtmlRabinFingerprint
,
sourceHtmlSize
);
...
@@ -56,8 +31,8 @@ const prepareMimeForPartsVerification = (mimeString, attachmentsHashes, senderSy
...
@@ -56,8 +31,8 @@ const prepareMimeForPartsVerification = (mimeString, attachmentsHashes, senderSy
});
});
const
getNormalizedMimeParts
=
(
mimeString
,
senderSystem
)
=>
{
const
getNormalizedMimeParts
=
(
mimeString
,
senderSystem
)
=>
{
const
{
htmlPart
,
plainPart
,
}
=
index_1
.
default
.
getMimeHtmlAndPlainParts
(
mimeString
);
const
{
htmlPart
,
plainPart
,
}
=
index_1
.
default
.
getMimeHtmlAndPlainParts
(
mimeString
);
const
normalizedHtmlPart
=
index_1
.
default
.
normalizeVendorHtml
(
htmlPart
,
senderSystem
);
const
normalizedHtmlPart
=
normalizeVendorHtml
(
htmlPart
,
senderSystem
);
const
normalizedPlainPart
=
index_1
.
default
.
normalizePlainPart
(
plainPart
);
const
normalizedPlainPart
=
normalizePlainPart
(
plainPart
);
return
{
return
{
htmlPart
:
normalizedHtmlPart
,
htmlPart
:
normalizedHtmlPart
,
plainPart
:
normalizedPlainPart
,
plainPart
:
normalizedPlainPart
,
...
@@ -102,39 +77,12 @@ const normalizeVendorHtml = (htmlString, vendor) => {
...
@@ -102,39 +77,12 @@ const normalizeVendorHtml = (htmlString, vendor) => {
document
=
parser
.
parseFromString
(
htmlString
,
"
text/html
"
);
document
=
parser
.
parseFromString
(
htmlString
,
"
text/html
"
);
}
}
else
{
else
{
const
{
window
}
=
new
JS
DOM
(
htmlString
);
const
{
window
}
=
new
dom_1
.
DOM
(
htmlString
);
document
=
window
.
document
;
document
=
window
.
document
;
}
}
const
mimeBody
=
document
.
body
;
return
mime_normalizer_1
.
HTMLNormalizer
.
normalizeVendorHtml
(
document
,
vendor
);
const
amendNodesFunction
=
vendorAmendingFunctions
[
vendor
];
if
(
amendNodesFunction
)
{
amendNodesFunction
(
document
);
}
/**
* Remove unnecessary nodes
*/
const
elementPruningFunction
=
vendorPruningFunctions
[
vendor
];
if
(
!
elementPruningFunction
)
{
throw
new
Error
(
`Vendor "
${
vendor
}
" is not supported. Please, develop a pruning function for it.`
);
}
utils_1
.
pruneHtmlNode
(
document
,
elementPruningFunction
);
/**
* Cleanup unnecessary attributes of nodes
*/
const
elementAttributesCleanupFunction
=
vendorAttributesCleanupFunctions
[
vendor
];
if
(
elementAttributesCleanupFunction
)
{
utils_1
.
cleanupHtmlNodeAttributes
(
document
,
elementAttributesCleanupFunction
);
}
/**
* Print nodes
*/
const
vendorPrintFunction
=
vendorPrintingFunctions
[
vendor
];
return
utils_1
.
printHtmlChildren
(
mimeBody
,
vendorPrintFunction
,
0
);
};
const
normalizePlainPart
=
(
text
)
=>
{
text
=
stringUtils_1
.
removeSpacesAndLinebreaks
(
text
);
return
stringUtils_1
.
removeQRCodes
(
text
);
};
};
const
normalizePlainPart
=
mime_normalizer_1
.
PlainNormalizer
.
normalizePlain
;
exports
.
default
=
{
exports
.
default
=
{
normalizeVendorHtml
,
normalizeVendorHtml
,
getMimeHtmlAndPlainParts
,
getMimeHtmlAndPlainParts
,
...
...
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