@@ -31,23 +31,23 @@ const verifySignature = async (
31
31
const [ contentType ] = headers [ 'content-type' ] || [ '' ] ;
32
32
const [ baseContentType ] = contentType . split ( ';' ) ;
33
33
if ( baseContentType . toLowerCase ( ) !== 'multipart/signed' ) {
34
- return { subdata : data , verified : 0 , signatures : [ ] } ;
34
+ return { subdata : data , verificationStatus : VERIFICATION_STATUS . NOT_SIGNED , signatures : [ ] } ;
35
35
}
36
36
const [ , rawboundary ] = / b o u n d a r y \s * = \s * ( [ ^ ; ] * ) \s * ( ; | $ ) / gi. exec ( contentType ) || [ ] ;
37
37
if ( ! rawboundary ) {
38
- return { subdata : data , verified : 0 , signatures : [ ] } ;
38
+ return { subdata : data , verificationStatus : VERIFICATION_STATUS . NOT_SIGNED , signatures : [ ] } ;
39
39
}
40
40
const boundary = rawboundary [ 0 ] === '"' ? JSON . parse ( rawboundary ) || rawboundary : rawboundary ;
41
41
const [ mainPart ] = data . split ( `\n--${ boundary } --\n` ) ;
42
42
const parts = mainPart . split ( `\n--${ boundary } \n` ) ;
43
43
if ( parts . length < 3 ) {
44
- return { subdata : data , verified : 0 , signatures : [ ] } ;
44
+ return { subdata : data , verificationStatus : VERIFICATION_STATUS . NOT_SIGNED , signatures : [ ] } ;
45
45
}
46
46
const { attachments : [ sigAttachment ] = [ ] } = await parseMail ( parts [ 2 ] . trim ( ) ) ;
47
47
48
48
const { contentType : sigAttachmentContentType = '' , content : sigAttachmentContent = new Uint8Array ( ) } = sigAttachment || { } ;
49
49
if ( sigAttachmentContentType . toLowerCase ( ) !== 'application/pgp-signature' ) {
50
- return { subdata : data , verified : 0 , signatures : [ ] } ;
50
+ return { subdata : data , verificationStatus : VERIFICATION_STATUS . NOT_SIGNED , signatures : [ ] } ;
51
51
}
52
52
const sigData = utf8ArrayToString ( sigAttachmentContent ) ;
53
53
@@ -57,14 +57,14 @@ const verifySignature = async (
57
57
} catch {
58
58
// sigData will be returned as attachment by `parse`
59
59
console . error ( 'Failed to read signature over MIME message' ) ;
60
- return { subdata : data , verified : 0 , signatures : [ ] } ;
60
+ return { subdata : data , verificationStatus : VERIFICATION_STATUS . NOT_SIGNED , signatures : [ ] } ;
61
61
}
62
62
63
63
const body = parts [ 1 ] ;
64
64
65
65
const {
66
66
data : subdata ,
67
- verified ,
67
+ verificationStatus ,
68
68
signatures
69
69
} = await verifyMessage ( {
70
70
// The body is to be treated as CleartextMessage, see https://github.com/openpgpjs/openpgpjs/pull/1265#issue-830304843
@@ -74,25 +74,25 @@ const verifySignature = async (
74
74
signature
75
75
} ) ;
76
76
77
- return { subdata, verified , signatures } ;
77
+ return { subdata, verificationStatus , signatures } ;
78
78
} ;
79
79
80
80
/**
81
81
* This function parses MIME format into attachments, content, encryptedSubject. The attachment automatically
82
- * inherit the verified status from the message verified status, as they are included in the body. For more
82
+ * inherit the verification status from the message verification status, as they are included in the body. For more
83
83
* information see: https://tools.ietf.org/html/rfc2045, https://tools.ietf.org/html/rfc2046 and
84
84
* https://tools.ietf.org/html/rfc2387.
85
85
* @param options
86
86
* @param options.headerFilename - The file name a memoryhole header should have
87
87
* @param options.sender - the address of the sender of this message
88
88
* @param content - mail content to parse
89
- * @param verified
89
+ * @param verificationStatus
90
90
* @param signatures
91
91
*/
92
92
const parse = async (
93
93
{ headerFilename = 'Encrypted Headers.txt' , sender = '' } ,
94
94
mailContent = '' ,
95
- verified = VERIFICATION_STATUS . NOT_SIGNED ,
95
+ verificationStatus = VERIFICATION_STATUS . NOT_SIGNED ,
96
96
signatures : OpenPGPSignature [ ] = [ ]
97
97
) : Promise < ProcessMIMEResult > => {
98
98
// cf. https://github.com/autocrypt/memoryhole subject can be in the MIME headers
@@ -148,7 +148,7 @@ const parse = async (
148
148
return {
149
149
body : html ,
150
150
attachments,
151
- verified ,
151
+ verificationStatus ,
152
152
encryptedSubject,
153
153
mimeType : 'text/html' ,
154
154
signatures
@@ -158,7 +158,7 @@ const parse = async (
158
158
return {
159
159
body : text ,
160
160
attachments,
161
- verified ,
161
+ verificationStatus ,
162
162
encryptedSubject,
163
163
mimeType : 'text/plain' ,
164
164
signatures
@@ -168,7 +168,7 @@ const parse = async (
168
168
return {
169
169
body : '' ,
170
170
attachments,
171
- verified ,
171
+ verificationStatus ,
172
172
encryptedSubject,
173
173
mimeType : undefined ,
174
174
signatures
@@ -188,7 +188,7 @@ export interface ProcessMIMEOptions {
188
188
export interface ProcessMIMEResult {
189
189
body : string ,
190
190
attachments : MIMEAttachment [ ] ,
191
- verified : VERIFICATION_STATUS ,
191
+ verificationStatus : VERIFICATION_STATUS ,
192
192
encryptedSubject : string ,
193
193
mimeType ?: 'text/html' | 'text/plain' ,
194
194
signatures : OpenPGPSignature [ ]
@@ -203,7 +203,7 @@ export interface ProcessMIMEResult {
203
203
* @param options.sender - the address of the sender of this message
204
204
*/
205
205
export default async function processMIME ( { data, ...options } : ProcessMIMEOptions ) : Promise < ProcessMIMEResult > {
206
- const { subdata, verified , signatures } = await verifySignature ( options , data ) ;
206
+ const { subdata, verificationStatus , signatures } = await verifySignature ( options , data ) ;
207
207
208
- return parse ( options , subdata , verified , signatures ) ;
208
+ return parse ( options , subdata , verificationStatus , signatures ) ;
209
209
}
0 commit comments