|
@@ -7,7 +7,8 @@ let ComPDFKitJS = {
|
|
|
opened_Font: [],
|
|
|
opened_FontNames: [],
|
|
|
opened_DefFont: [],
|
|
|
- opened_image: []
|
|
|
+ opened_image: [],
|
|
|
+ opened_cert: []
|
|
|
}
|
|
|
|
|
|
let DataArray = []
|
|
@@ -31,6 +32,8 @@ let U8StringData = ''
|
|
|
let PDFRange = {}
|
|
|
let TextRectArray = []
|
|
|
ImageAreaInfo = {}
|
|
|
+SignerArray = []
|
|
|
+CertArray = []
|
|
|
|
|
|
import MessageHandler from "../message_handler"
|
|
|
import { convertFileToBuffer, convertBase64ToBytes } from '../fileHandler';
|
|
@@ -214,6 +217,10 @@ class CPDFWorker {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+ messageHandler.on('GetSignatures', (data) => {
|
|
|
+ return getSignatures(data)
|
|
|
+ })
|
|
|
+
|
|
|
messageHandler.on('PushRenderTask', (data) => {
|
|
|
const { pagePtr, scale, left, right, bottom, top } = data
|
|
|
|
|
@@ -2374,6 +2381,95 @@ function getWidgetAnnotation({
|
|
|
return annotation
|
|
|
}
|
|
|
|
|
|
+function getSignatures({
|
|
|
+ doc
|
|
|
+}) {
|
|
|
+ const signatureList = []
|
|
|
+ const count = Module._GetSignatureCount(doc)
|
|
|
+ console.log(count)
|
|
|
+
|
|
|
+ for (let i = 0; i < count; i++) {
|
|
|
+ // 获取签名指针
|
|
|
+ const signaturePtr = Module._InitSignature(doc, i)
|
|
|
+ if (signaturePtr) {
|
|
|
+ const signerList = []
|
|
|
+ const signature = {
|
|
|
+ signaturePtr,
|
|
|
+ signerList
|
|
|
+ }
|
|
|
+ // 获取签名者信息
|
|
|
+ SignerArray = []
|
|
|
+ Module._GetSigner(signaturePtr)
|
|
|
+
|
|
|
+ let needCheck = false
|
|
|
+ for (let j = 0; j < SignerArray.length; j++) {
|
|
|
+ const signerPtr = SignerArray[j]
|
|
|
+
|
|
|
+ if (signerPtr) {
|
|
|
+ const certificateList = []
|
|
|
+ const signer = {
|
|
|
+ signerPtr,
|
|
|
+ isSignVerified: false,
|
|
|
+ isCertValid: false,
|
|
|
+ certificateList
|
|
|
+ }
|
|
|
+
|
|
|
+ const certPtr = Module._GetSignCert(signerPtr)
|
|
|
+
|
|
|
+ console.log('certPtr', certPtr)
|
|
|
+ const result = false
|
|
|
+ if (certPtr) {
|
|
|
+ // TODO: 验证证书
|
|
|
+ // result = Module._VerifyGetChain(signerPtr, certPtr, 0, 10000)
|
|
|
+ // if (result === 1) {
|
|
|
+ // signer.IsCertTrusted = true
|
|
|
+ // for (let f = 0; f < signer.certificateList.length; f++) {
|
|
|
+ // signer.certificateList[f].IsTrusted = true
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // needCheck = true
|
|
|
+ // }
|
|
|
+
|
|
|
+ CertArray = []
|
|
|
+ Module._GetSignCertChain(certPtr)
|
|
|
+
|
|
|
+ for (let k = 0; k < CertArray.length; k++) {
|
|
|
+ const certPtr = CertArray[k]
|
|
|
+ const certificate = {
|
|
|
+ certPtr
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO: 获取证书信息
|
|
|
+
|
|
|
+ certificateList.push(certificate)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const timeSpanPtr = Module._GetTimeStampSignature(signerPtr)
|
|
|
+ if (timeSpanPtr) {
|
|
|
+ // TODO: 验证时间戳
|
|
|
+ // result = Module._VerifyTimestamp(signaturePtr, signerPtr, 0, 10000)
|
|
|
+ // if (result == 1) {
|
|
|
+ // signer.IsSignVerified = true;
|
|
|
+ // } else {
|
|
|
+ // signer.IsSignVerified = false;
|
|
|
+ // }
|
|
|
+ }
|
|
|
+
|
|
|
+ signerList.push(signer)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Module._GetSignatureName(signaturePtr)
|
|
|
+ const data = U8StringData
|
|
|
+
|
|
|
+ console.log('data', data)
|
|
|
+ signatureList.push(signature)
|
|
|
+ console.log('signatureList', signatureList)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
async function copyDocument(doc, password) {
|
|
|
DataArray = []
|
|
|
Module._SaveDocumentByStream(doc, 2);
|