@file-viewer/renderer-signature 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +160 -0
- package/README.en.md +87 -0
- package/README.md +89 -0
- package/THIRD_PARTY_LICENSES.json +3867 -0
- package/THIRD_PARTY_NOTICES.md +10 -0
- package/dist/container.worker.d.ts +1 -0
- package/dist/container.worker.js +39 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +53 -0
- package/dist/inspect.d.ts +7 -0
- package/dist/inspect.js +4 -0
- package/dist/openpgp/client.d.ts +16 -0
- package/dist/openpgp/client.js +148 -0
- package/dist/openpgp/formatDetection.d.ts +3 -0
- package/dist/openpgp/formatDetection.js +45 -0
- package/dist/openpgp/types.d.ts +72 -0
- package/dist/openpgp/types.js +1 -0
- package/dist/rpgp-wasm/rpgp_wrapper.d.ts +43 -0
- package/dist/rpgp-wasm/rpgp_wrapper.js +578 -0
- package/dist/rpgp-wasm/rpgp_wrapper_bg.wasm +0 -0
- package/dist/rpgp-wasm/rpgp_wrapper_bg.wasm.d.ts +10 -0
- package/dist/signature.d.ts +24 -0
- package/dist/signature.js +1040 -0
- package/dist/signature.worker.d.ts +1 -0
- package/dist/signature.worker.js +108 -0
- package/dist/signatureAsn1.d.ts +150 -0
- package/dist/signatureAsn1.js +1486 -0
- package/dist/structured/asic.d.ts +3 -0
- package/dist/structured/asic.js +188 -0
- package/dist/structured/containerClient.d.ts +12 -0
- package/dist/structured/containerClient.js +71 -0
- package/dist/structured/containerProtocol.d.ts +20 -0
- package/dist/structured/containerProtocol.js +1 -0
- package/dist/structured/jws.d.ts +3 -0
- package/dist/structured/jws.js +382 -0
- package/dist/structured/limits.d.ts +20 -0
- package/dist/structured/limits.js +41 -0
- package/dist/structured/types.d.ts +53 -0
- package/dist/structured/types.js +1 -0
- package/dist/structured/zipPreflight.d.ts +14 -0
- package/dist/structured/zipPreflight.js +173 -0
- package/dist/workerProtocol.d.ts +40 -0
- package/dist/workerProtocol.js +1 -0
- package/file-viewer.capability.json +56 -0
- package/package.json +106 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
34
|
+
made available under the License, as indicated by a copyright notice that is
|
|
35
|
+
included in or attached to the work.
|
|
36
|
+
|
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
40
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
41
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
42
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including the original version
|
|
45
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
46
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work by
|
|
47
|
+
the copyright owner or by an individual or Legal Entity authorized to submit on
|
|
48
|
+
behalf of the copyright owner. For the purposes of this definition, "submitted"
|
|
49
|
+
means any form of electronic, verbal, or written communication sent to the
|
|
50
|
+
Licensor or its representatives, including but not limited to communication on
|
|
51
|
+
electronic mailing lists, source code control systems, and issue tracking systems
|
|
52
|
+
that are managed by, or on behalf of, the Licensor for the purpose of discussing
|
|
53
|
+
and improving the Work, but excluding communication that is conspicuously marked
|
|
54
|
+
or otherwise designated in writing by the copyright owner as "Not a
|
|
55
|
+
Contribution."
|
|
56
|
+
|
|
57
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
58
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
59
|
+
incorporated within the Work.
|
|
60
|
+
|
|
61
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
62
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
63
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
64
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
65
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
66
|
+
Object form.
|
|
67
|
+
|
|
68
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
|
69
|
+
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
|
70
|
+
no-charge, royalty-free, irrevocable (except as stated in this section) patent
|
|
71
|
+
license to make, have made, use, offer to sell, sell, import, and otherwise
|
|
72
|
+
transfer the Work, where such license applies only to those patent claims
|
|
73
|
+
licensable by such Contributor that are necessarily infringed by their
|
|
74
|
+
Contribution(s) alone or by combination of their Contribution(s) with the Work to
|
|
75
|
+
which such Contribution(s) was submitted. If You institute patent litigation
|
|
76
|
+
against any entity (including a cross-claim or counterclaim in a lawsuit)
|
|
77
|
+
alleging that the Work or a Contribution incorporated within the Work
|
|
78
|
+
constitutes direct or contributory patent infringement, then any patent licenses
|
|
79
|
+
granted to You under this License for that Work shall terminate as of the date
|
|
80
|
+
such litigation is filed.
|
|
81
|
+
|
|
82
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
83
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
84
|
+
Source or Object form, provided that You meet the following conditions:
|
|
85
|
+
|
|
86
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of
|
|
87
|
+
this License; and
|
|
88
|
+
|
|
89
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
90
|
+
You changed the files; and
|
|
91
|
+
|
|
92
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
93
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
94
|
+
Source form of the Work, excluding those notices that do not pertain to any part
|
|
95
|
+
of the Derivative Works; and
|
|
96
|
+
|
|
97
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
98
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
99
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
100
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
101
|
+
following places: within a NOTICE text file distributed as part of the Derivative
|
|
102
|
+
Works; within the Source form or documentation, if provided along with the
|
|
103
|
+
Derivative Works; or, within a display generated by the Derivative Works, if and
|
|
104
|
+
wherever such third-party notices normally appear. The contents of the NOTICE
|
|
105
|
+
file are for informational purposes only and do not modify the License. You may
|
|
106
|
+
add Your own attribution notices within Derivative Works that You distribute,
|
|
107
|
+
alongside or as an addendum to the NOTICE text from the Work, provided that such
|
|
108
|
+
additional attribution notices cannot be construed as modifying the License.
|
|
109
|
+
|
|
110
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
111
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
112
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
113
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
114
|
+
with the conditions stated in this License.
|
|
115
|
+
|
|
116
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
117
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
118
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
119
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
120
|
+
supersede or modify the terms of any separate license agreement you may have
|
|
121
|
+
executed with Licensor regarding such Contributions.
|
|
122
|
+
|
|
123
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
124
|
+
trademarks, service marks, or product names of the Licensor, except as required
|
|
125
|
+
for reasonable and customary use in describing the origin of the Work and
|
|
126
|
+
reproducing the content of the NOTICE file.
|
|
127
|
+
|
|
128
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
129
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
130
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
131
|
+
KIND, either express or implied, including, without limitation, any warranties or
|
|
132
|
+
conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
133
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
134
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
135
|
+
associated with Your exercise of permissions under this License.
|
|
136
|
+
|
|
137
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
138
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
139
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
140
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
141
|
+
direct, indirect, special, incidental, or consequential damages of any character
|
|
142
|
+
arising as a result of this License or out of the use or inability to use the
|
|
143
|
+
Work (including but not limited to damages for loss of goodwill, work stoppage,
|
|
144
|
+
computer failure or malfunction, or any and all other commercial damages or
|
|
145
|
+
losses), even if such Contributor has been advised of the possibility of such
|
|
146
|
+
damages.
|
|
147
|
+
|
|
148
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
149
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
150
|
+
acceptance of support, warranty, indemnity, or other liability obligations and/or
|
|
151
|
+
rights consistent with this License. However, in accepting such obligations, You
|
|
152
|
+
may act only on Your own behalf and on Your sole responsibility, not on behalf of
|
|
153
|
+
any other Contributor, and only if You agree to indemnify, defend, and hold each
|
|
154
|
+
Contributor harmless for any liability incurred by, or claims asserted against,
|
|
155
|
+
such Contributor by reason of your accepting any such warranty or additional
|
|
156
|
+
liability.
|
|
157
|
+
|
|
158
|
+
END OF TERMS AND CONDITIONS
|
|
159
|
+
|
|
160
|
+
Copyright 2026 Flyfish Viewer
|
package/README.en.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# @file-viewer/renderer-signature
|
|
2
|
+
|
|
3
|
+
Optional, browser-local renderer for digital signatures, timestamps, evidence containers, and OpenPGP. It covers CMS/PKCS#7, selected CAdES attributes, RFC 3161, RFC 5544, ASiC, RFC 4998, JWS/JAdES metadata, and OpenPGP, then delegates safely extracted documents back to File Viewer's nested-renderer pipeline.
|
|
4
|
+
|
|
5
|
+
## Supported formats
|
|
6
|
+
|
|
7
|
+
- CMS / PKCS#7: `.p7m`, `.p7s`, `.p7b`, `.p7c`, `.pkcs7`, `.cms`, `.cmsc`
|
|
8
|
+
- Timestamps: RFC 3161 `.tsq`, `.tsr`, `.tst`; RFC 5544 `.tsd`
|
|
9
|
+
- Associated containers: ASiC-S / ASiC-E `.asics`, `.scs`, `.asice`, `.sce`
|
|
10
|
+
- Archival evidence: RFC 4998 `.ers`
|
|
11
|
+
- JSON Web Signature: compact, flattened JSON, and general JSON `.jws`
|
|
12
|
+
- OpenPGP: `.asc`, `.sig`, `.pgp`, `.gpg`
|
|
13
|
+
|
|
14
|
+
After the signature renderer is explicitly selected, it uses both the extension and the file contents. It does not take over the existing PDF, XML, JSON, EML, or MSG routes. ASiC documents, encapsulated CMS content, JWS payloads, and safely extracted OpenPGP literal data can continue through `renderNestedBuffer`. External `dataUri`, `jku`, `x5u`, OCSP, CRL, AIA, TSA, keyserver, and WKD URLs are never fetched automatically.
|
|
15
|
+
|
|
16
|
+
## Opt-in registration
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { signatureRenderer } from '@file-viewer/renderer-signature'
|
|
20
|
+
|
|
21
|
+
const options = {
|
|
22
|
+
rendererMode: 'replace',
|
|
23
|
+
renderers: [signatureRenderer]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Register the relevant PDF, XML, image, or Office renderer as well when extracted documents should be previewed. This package is not added to the frozen legacy `preset-all` or historical `*-full` dependency matrix, so existing upgrades do not unexpectedly download cryptographic WASM. A new project created with the File Viewer CLI's `full` selection installs every renderer from the catalog, including `signature`; users can also select it alone.
|
|
28
|
+
|
|
29
|
+
## Host inputs
|
|
30
|
+
|
|
31
|
+
`options.signature` accepts:
|
|
32
|
+
|
|
33
|
+
- `originalContent` / `originalFilename` for detached CMS, timestamps, ERS, or JWS;
|
|
34
|
+
- `openPgpPublicKeys` for detached, cleartext, and unencrypted embedded OpenPGP signature verification;
|
|
35
|
+
- `jwsVerificationKeys` for asymmetric public JWKs;
|
|
36
|
+
- `openPgpLimits` / `containerLimits`, bounded by non-disableable absolute ceilings;
|
|
37
|
+
- `workerFactory` for strict Trusted Types/CSP applications.
|
|
38
|
+
|
|
39
|
+
Strict Trusted Types example:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const policy = trustedTypes.createPolicy('file-viewer-workers', {
|
|
43
|
+
createScriptURL: (value) => value
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const signature = {
|
|
47
|
+
workerFactory(kind: 'openpgp' | 'container') {
|
|
48
|
+
const url =
|
|
49
|
+
kind === 'openpgp'
|
|
50
|
+
? new URL('/file-viewer-assets/signature.worker.js', window.location.origin)
|
|
51
|
+
: new URL('/file-viewer-assets/container.worker.js', window.location.origin)
|
|
52
|
+
return new Worker(policy.createScriptURL(url.href), { type: 'module' })
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The policy must accept only application-resolved, fixed package URLs. Never pass document-derived strings to `createScriptURL`.
|
|
58
|
+
|
|
59
|
+
## OpenPGP and size boundary
|
|
60
|
+
|
|
61
|
+
The OpenPGP backend uses permissively licensed rPGP `0.20.0` inside a dedicated, lazy Worker/WASM path. It does not use OpenPGP.js, GnuPG, or LGPL source. The narrow public boundary supports classification, bounded metadata inspection, and multi-signature verification for detached, cleartext, and unencrypted embedded/compressed messages; it does not expose rPGP internals or secret key material.
|
|
62
|
+
|
|
63
|
+
The optimized artifact has hard release gates of 1,600,000 B raw / 450,000 B Brotli for WASM and 1,800,000 B for the npm tarball. The verifier performs two byte-for-byte reproducibility builds. Default limits are 32 MiB input, 16 MiB extracted output, 4,096 packets, 16 nesting levels, 128 user IDs, 128 subkeys, and 256 signatures.
|
|
64
|
+
|
|
65
|
+
Direct ASN.1 calls to `inspectSignatureContainer` and `inspectEvidenceRecord` also bound input, original content, node and nesting counts, algorithms, certificates, CRLs, signers, attributes, extracted bytes, timestamp chains, and hash-tree nodes. Per-call `options.limits` can only lower these absolute ceilings.
|
|
66
|
+
|
|
67
|
+
Encrypted messages report only recipient identifiers, integrity protection, and algorithms visible in the container. Automatic decryption, signing, key generation, private-key unlocking, system-keyring import, and online key discovery are intentionally unavailable.
|
|
68
|
+
|
|
69
|
+
## Validation boundary
|
|
70
|
+
|
|
71
|
+
Successful parsing is not signature verification. A valid cryptographic signature does not establish certificate or key trust, identity, policy compliance, qualified-signature status, or legal validity. The UI separates structural parsing, content-digest checks, cryptographic verification, and checks that were not performed.
|
|
72
|
+
|
|
73
|
+
ASiC input is checked before inflation for central/local-header consistency, data-range overlap, unsafe paths, duplicates, symlinks, encryption, ZIP64, unsupported compression, CRC, compression ratio, entry size, and aggregate output. RFC 4998 verifies only relationships that can be established from the supplied data and does not claim complete archival-policy validation. XAdES/XMLDSig inside ASiC is bounded structural/reference inspection, and JAdES is metadata only. PAdES, S/MIME, PGP/MIME, and full XML canonicalization or XMLDSig/XAdES/JAdES profile validation remain outside this renderer because they require host integration with their existing PDF, XML, and message renderers.
|
|
74
|
+
|
|
75
|
+
## Build and verification
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
rustup target add wasm32-unknown-unknown
|
|
79
|
+
cargo install wasm-bindgen-cli --version 0.2.127 --locked
|
|
80
|
+
pnpm --filter @file-viewer/renderer-signature build
|
|
81
|
+
pnpm --filter @file-viewer/renderer-signature verify
|
|
82
|
+
pnpm verify:issue-206-signature
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The release gate pins `wasm-bindgen-cli 0.2.127` and runs `wasm-opt -Oz --all-features`. Browser acceptance covers Chromium, Firefox, WebKit, strict CSP/Trusted Types, hostile DOM payloads, path traversal, compression bombs, zero external requests, and Worker cleanup after unmount.
|
|
86
|
+
|
|
87
|
+
See `THIRD_PARTY_LICENSES.json` for the exact runtime closure, selected license branches, and license texts. `THIRD_PARTY_NOTICES.md` provides the short summary.
|
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @file-viewer/renderer-signature
|
|
2
|
+
|
|
3
|
+
File Viewer 的可选、本地运行的数字签名与时间戳渲染器。它覆盖 CMS/PKCS#7、CAdES 属性、RFC 3161、RFC 5544、ASiC、RFC 4998、JWS/JAdES 元数据以及 OpenPGP,并能把安全提取出的文档交回 File Viewer 的嵌套渲染管线。
|
|
4
|
+
|
|
5
|
+
[English](./README.en.md)
|
|
6
|
+
|
|
7
|
+
## 支持范围
|
|
8
|
+
|
|
9
|
+
- CMS / PKCS#7:`.p7m`、`.p7s`、`.p7b`、`.p7c`、`.pkcs7`、`.cms`、`.cmsc`
|
|
10
|
+
- 时间戳:RFC 3161 `.tsq`、`.tsr`、`.tst`,RFC 5544 `.tsd`
|
|
11
|
+
- 关联签名容器:ASiC-S / ASiC-E `.asics`、`.scs`、`.asice`、`.sce`
|
|
12
|
+
- 归档证据:RFC 4998 `.ers`
|
|
13
|
+
- JSON Web Signature:Compact、Flattened JSON、General JSON `.jws`
|
|
14
|
+
- OpenPGP:`.asc`、`.sig`、`.pgp`、`.gpg`
|
|
15
|
+
|
|
16
|
+
签名 renderer 被显式选中后会同时检查扩展名与内容,不会抢占普通 PDF、XML、JSON、EML 或 MSG 的既有路由。ASiC 文档、CMS 封装内容、JWS payload 和可安全提取的 OpenPGP literal data 会通过 `renderNestedBuffer` 继续预览。外部 `dataUri`、`jku`、`x5u`、OCSP、CRL、AIA、TSA、keyserver 和 WKD 地址不会自动请求。
|
|
17
|
+
|
|
18
|
+
## 按需安装
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { signatureRenderer } from '@file-viewer/renderer-signature'
|
|
22
|
+
|
|
23
|
+
const options = {
|
|
24
|
+
rendererMode: 'replace',
|
|
25
|
+
renderers: [signatureRenderer]
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
需要预览容器内的 PDF、XML、图片或 Office 文档时,同时注册相应 renderer。此包不会进入冻结的旧版 `preset-all` 或历史 `*-full` 依赖矩阵,避免既有用户升级时突然下载密码学 WASM;File Viewer CLI 的新项目 `full` 选择会按清单安装全部 renderer,也可以只勾选 `signature`。
|
|
30
|
+
|
|
31
|
+
## 主机输入
|
|
32
|
+
|
|
33
|
+
`options.signature` 支持:
|
|
34
|
+
|
|
35
|
+
- `originalContent` / `originalFilename`:分离式 CMS、时间戳、ERS 或 JWS 的原文;
|
|
36
|
+
- `openPgpPublicKeys`:OpenPGP 分离签名、cleartext 签名和未加密内嵌签名的公开验证密钥;
|
|
37
|
+
- `jwsVerificationKeys`:JWS 的非对称公开 JWK;
|
|
38
|
+
- `openPgpLimits` / `containerLimits`:只能在绝对安全上限内调整的资源限制;
|
|
39
|
+
- `workerFactory`:严格 Trusted Types/CSP 环境提供的 Worker 创建边界。
|
|
40
|
+
|
|
41
|
+
严格 Trusted Types 示例:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
const policy = trustedTypes.createPolicy('file-viewer-workers', {
|
|
45
|
+
createScriptURL: (value) => value
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const signature = {
|
|
49
|
+
workerFactory(kind: 'openpgp' | 'container') {
|
|
50
|
+
const url =
|
|
51
|
+
kind === 'openpgp'
|
|
52
|
+
? new URL('/file-viewer-assets/signature.worker.js', window.location.origin)
|
|
53
|
+
: new URL('/file-viewer-assets/container.worker.js', window.location.origin)
|
|
54
|
+
return new Worker(policy.createScriptURL(url.href), { type: 'module' })
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
策略只能接受应用自己解析出的固定包内 URL,不能把文档内容传入 `createScriptURL`。
|
|
60
|
+
|
|
61
|
+
## OpenPGP 与体积边界
|
|
62
|
+
|
|
63
|
+
OpenPGP 后端使用 MIT/Apache-2.0 的 rPGP `0.20.0`,在专用 Worker 中懒加载 WASM;不使用 OpenPGP.js、GnuPG 或 LGPL 源码。公开 API 只暴露分类、受限元数据检查,以及分离、cleartext、未加密内嵌/压缩消息的多签名验证,不暴露 rPGP 底层对象或私钥材料。
|
|
64
|
+
|
|
65
|
+
当前优化产物的硬门禁为:WASM 不超过 1,600,000 B raw / 450,000 B Brotli,npm tarball 不超过 1,800,000 B。构建会做两次字节级可复现校验。默认解析上限为 32 MiB 输入、16 MiB 提取输出、4096 个包、16 层嵌套、128 个 user ID、128 个子密钥和 256 个签名。
|
|
66
|
+
|
|
67
|
+
直接调用 ASN.1 API 时,`inspectSignatureContainer` 和 `inspectEvidenceRecord` 还会限制输入、原文、节点、嵌套、摘要算法、证书、CRL、签名人、属性、提取内容、时间证据链和 hash-tree 数量;`options.limits` 只能调低,不能突破绝对上限。
|
|
68
|
+
|
|
69
|
+
加密消息只报告收件人标识、完整性保护及容器中可见的算法元数据。自动解密、签名、密钥生成、私钥解锁、系统 keyring 导入和在线密钥发现均未开放。
|
|
70
|
+
|
|
71
|
+
## 验证边界
|
|
72
|
+
|
|
73
|
+
解析成功不等于签名有效;签名有效也不等于证书或密钥可信、身份可信、策略合规、合格电子签名或法律有效。界面会分别标记结构解析、内容摘要、密码学签名和未执行的信任/策略检查。
|
|
74
|
+
|
|
75
|
+
ASiC 会在解压前检查中央目录与本地头一致性、数据区间、路径、重复项、符号链接、加密、ZIP64、压缩方法、CRC、压缩率、单项与累计解压量;不安全包直接失败。RFC 4998 当前验证可证明的摘要关系并展示归档时间戳链,不声称完成长期归档策略验证。XAdES/XMLDSig 在 ASiC 中仅做有界结构与引用映射,JAdES 仅报告元数据;PAdES、S/MIME、PGP/MIME 和完整 XML canonicalization / XMLDSig / XAdES / JAdES profile validation 需要对应既有 renderer 的显式集成,当前不伪装成已完成。
|
|
76
|
+
|
|
77
|
+
## 构建与验收
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
rustup target add wasm32-unknown-unknown
|
|
81
|
+
cargo install wasm-bindgen-cli --version 0.2.127 --locked
|
|
82
|
+
pnpm --filter @file-viewer/renderer-signature build
|
|
83
|
+
pnpm --filter @file-viewer/renderer-signature verify
|
|
84
|
+
pnpm verify:issue-206-signature
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
发布门禁固定使用 `wasm-bindgen-cli 0.2.127` 和 `wasm-opt -Oz --all-features`。浏览器回归覆盖 Chromium、Firefox、WebKit、严格 CSP/Trusted Types、恶意 DOM 载荷、路径穿越、压缩炸弹、外网请求禁止和 Worker 卸载归零。
|
|
88
|
+
|
|
89
|
+
完整运行时依赖、选择的许可证分支和对应许可证正文见 `THIRD_PARTY_LICENSES.json`;摘要见 `THIRD_PARTY_NOTICES.md`。
|