@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const scope = self;
|
|
2
|
+
let wasmPromise;
|
|
3
|
+
const loadWasm = async () => {
|
|
4
|
+
if (wasmPromise)
|
|
5
|
+
return wasmPromise;
|
|
6
|
+
wasmPromise = (async () => {
|
|
7
|
+
try {
|
|
8
|
+
const wasmUrl = new URL('./rpgp-wasm/rpgp_wrapper_bg.wasm', import.meta.url);
|
|
9
|
+
const module = (await import('./rpgp-wasm/rpgp_wrapper.js'));
|
|
10
|
+
await module.default({ module_or_path: wasmUrl });
|
|
11
|
+
return module;
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
wasmPromise = undefined;
|
|
15
|
+
throw Object.assign(new Error(error instanceof Error ? error.message : String(error)), {
|
|
16
|
+
code: 'wasm-initialization-failed'
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
return wasmPromise;
|
|
21
|
+
};
|
|
22
|
+
const errorResponse = (id, error) => ({
|
|
23
|
+
id,
|
|
24
|
+
ok: false,
|
|
25
|
+
error: {
|
|
26
|
+
code: typeof error === 'object' && error && 'code' in error
|
|
27
|
+
? String(error.code)
|
|
28
|
+
: 'internal-parser-error',
|
|
29
|
+
message: error instanceof Error ? error.message : String(error)
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const normalizeInspectionResult = (value) => {
|
|
33
|
+
const result = value;
|
|
34
|
+
if (result.literalData && !(result.literalData.data instanceof Uint8Array)) {
|
|
35
|
+
result.literalData.data = Uint8Array.from(result.literalData.data);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
scope.addEventListener('message', async (event) => {
|
|
40
|
+
const request = event.data;
|
|
41
|
+
if (!request ||
|
|
42
|
+
typeof request.id !== 'string' ||
|
|
43
|
+
!['classify', 'inspect', 'verify-detached'].includes(request.type)) {
|
|
44
|
+
scope.postMessage(errorResponse(typeof (request === null || request === void 0 ? void 0 : request.id) === 'string' ? request.id : 'unknown', Object.assign(new Error('Invalid signature Worker request.'), { code: 'invalid-input' })));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
if ((request.type === 'classify' || request.type === 'inspect') &&
|
|
49
|
+
!(request.input instanceof ArrayBuffer)) {
|
|
50
|
+
throw Object.assign(new Error('Signature Worker input must be an ArrayBuffer.'), {
|
|
51
|
+
code: 'invalid-input'
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (request.type === 'inspect' &&
|
|
55
|
+
(!Array.isArray(request.publicKeys) ||
|
|
56
|
+
!request.publicKeys.every((value) => value instanceof ArrayBuffer))) {
|
|
57
|
+
throw Object.assign(new Error('OpenPGP inspection public keys are malformed.'), {
|
|
58
|
+
code: 'invalid-input'
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (request.type === 'verify-detached' &&
|
|
62
|
+
(!(request.content instanceof ArrayBuffer) ||
|
|
63
|
+
!(request.signature instanceof ArrayBuffer) ||
|
|
64
|
+
!Array.isArray(request.publicKeys) ||
|
|
65
|
+
!request.publicKeys.every((value) => value instanceof ArrayBuffer))) {
|
|
66
|
+
throw Object.assign(new Error('Detached verification request is malformed.'), {
|
|
67
|
+
code: 'invalid-input'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const wasm = await loadWasm();
|
|
71
|
+
let response;
|
|
72
|
+
switch (request.type) {
|
|
73
|
+
case 'classify':
|
|
74
|
+
response = {
|
|
75
|
+
id: request.id,
|
|
76
|
+
ok: true,
|
|
77
|
+
type: 'classify',
|
|
78
|
+
result: wasm.classify_openpgp(new Uint8Array(request.input), request.limits)
|
|
79
|
+
};
|
|
80
|
+
break;
|
|
81
|
+
case 'inspect':
|
|
82
|
+
response = {
|
|
83
|
+
id: request.id,
|
|
84
|
+
ok: true,
|
|
85
|
+
type: 'inspect',
|
|
86
|
+
result: normalizeInspectionResult(wasm.inspect_openpgp(new Uint8Array(request.input), request.publicKeys.map((value) => new Uint8Array(value)), request.limits))
|
|
87
|
+
};
|
|
88
|
+
break;
|
|
89
|
+
case 'verify-detached':
|
|
90
|
+
response = {
|
|
91
|
+
id: request.id,
|
|
92
|
+
ok: true,
|
|
93
|
+
type: 'verify-detached',
|
|
94
|
+
result: wasm.verify_detached_signature(new Uint8Array(request.content), new Uint8Array(request.signature), request.publicKeys.map((value) => new Uint8Array(value)), request.limits)
|
|
95
|
+
};
|
|
96
|
+
break;
|
|
97
|
+
default:
|
|
98
|
+
throw Object.assign(new Error('Unknown signature Worker request.'), {
|
|
99
|
+
code: 'invalid-input'
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
scope.postMessage(response);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
scope.postMessage(errorResponse(request.id, error));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export type SignatureContainerKind = 'cms-signed-data' | 'cms-certificates' | 'cms-content' | 'timestamp-request' | 'timestamp-response' | 'timestamp-token' | 'timestamped-data' | 'unknown';
|
|
2
|
+
export interface SignatureCertificateSummary {
|
|
3
|
+
index: number;
|
|
4
|
+
version?: number;
|
|
5
|
+
serialNumber: string;
|
|
6
|
+
subject: string;
|
|
7
|
+
issuer: string;
|
|
8
|
+
notBefore?: string;
|
|
9
|
+
notAfter?: string;
|
|
10
|
+
signatureAlgorithmOid?: string;
|
|
11
|
+
signatureAlgorithm?: string;
|
|
12
|
+
publicKeyAlgorithmOid?: string;
|
|
13
|
+
publicKeyAlgorithm?: string;
|
|
14
|
+
publicKeyCurveOid?: string;
|
|
15
|
+
subjectKeyIdentifier?: string;
|
|
16
|
+
fingerprintSha256?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SignatureSignerSummary {
|
|
19
|
+
index: number;
|
|
20
|
+
sid: string;
|
|
21
|
+
digestAlgorithmOid?: string;
|
|
22
|
+
digestAlgorithm?: string;
|
|
23
|
+
signatureAlgorithmOid?: string;
|
|
24
|
+
signatureAlgorithm?: string;
|
|
25
|
+
signingTime?: string;
|
|
26
|
+
messageDigest?: string;
|
|
27
|
+
contentTypeOid?: string;
|
|
28
|
+
certificateIndex?: number;
|
|
29
|
+
digestMatches?: boolean;
|
|
30
|
+
cryptographicSignatureValid?: boolean;
|
|
31
|
+
verificationError?: string;
|
|
32
|
+
signatureTimestampTokens: number;
|
|
33
|
+
signingCertificateV2: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface TimestampAccuracySummary {
|
|
36
|
+
seconds?: number;
|
|
37
|
+
millis?: number;
|
|
38
|
+
micros?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface TimestampInfoSummary {
|
|
41
|
+
version?: number;
|
|
42
|
+
policyOid?: string;
|
|
43
|
+
serialNumber?: string;
|
|
44
|
+
generationTime?: string;
|
|
45
|
+
accuracy?: TimestampAccuracySummary;
|
|
46
|
+
ordering?: boolean;
|
|
47
|
+
nonce?: string;
|
|
48
|
+
tsa?: string;
|
|
49
|
+
messageImprintAlgorithmOid?: string;
|
|
50
|
+
messageImprintAlgorithm?: string;
|
|
51
|
+
messageImprint?: string;
|
|
52
|
+
messageImprintMatchesOriginal?: boolean;
|
|
53
|
+
certReq?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface TimestampResponseSummary {
|
|
56
|
+
status?: number;
|
|
57
|
+
statusLabel?: string;
|
|
58
|
+
statusText: string[];
|
|
59
|
+
failureInfo?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface SignatureInspection {
|
|
62
|
+
kind: SignatureContainerKind;
|
|
63
|
+
detectedFormat: string;
|
|
64
|
+
sourceSize: number;
|
|
65
|
+
contentTypeOid?: string;
|
|
66
|
+
contentType?: string;
|
|
67
|
+
signedContentTypeOid?: string;
|
|
68
|
+
signedContentType?: string;
|
|
69
|
+
digestAlgorithms: string[];
|
|
70
|
+
embeddedContent?: Uint8Array;
|
|
71
|
+
detached: boolean;
|
|
72
|
+
requiresOriginalContent: boolean;
|
|
73
|
+
originalContentSupplied: boolean;
|
|
74
|
+
certificates: SignatureCertificateSummary[];
|
|
75
|
+
signers: SignatureSignerSummary[];
|
|
76
|
+
timestamp?: TimestampInfoSummary;
|
|
77
|
+
timestampResponse?: TimestampResponseSummary;
|
|
78
|
+
crlCount: number;
|
|
79
|
+
timestampedData?: {
|
|
80
|
+
dataUri?: string;
|
|
81
|
+
filename?: string;
|
|
82
|
+
mediaType?: string;
|
|
83
|
+
hashProtected?: boolean;
|
|
84
|
+
temporalEvidenceEntries: number;
|
|
85
|
+
};
|
|
86
|
+
warnings: string[];
|
|
87
|
+
}
|
|
88
|
+
export interface SignatureAsn1Limits {
|
|
89
|
+
maxInputBytes: number;
|
|
90
|
+
maxOriginalContentBytes: number;
|
|
91
|
+
maxAsn1Nodes: number;
|
|
92
|
+
maxAsn1NestingDepth: number;
|
|
93
|
+
maxDigestAlgorithms: number;
|
|
94
|
+
maxCertificates: number;
|
|
95
|
+
maxCrls: number;
|
|
96
|
+
maxSigners: number;
|
|
97
|
+
maxAttributesPerSigner: number;
|
|
98
|
+
maxEmbeddedContentBytes: number;
|
|
99
|
+
maxTimestampEvidenceEntries: number;
|
|
100
|
+
maxEvidenceChains: number;
|
|
101
|
+
maxEvidenceTimestampsPerChain: number;
|
|
102
|
+
maxEvidenceTimestamps: number;
|
|
103
|
+
maxReducedHashTreeNodes: number;
|
|
104
|
+
}
|
|
105
|
+
export declare const DEFAULT_SIGNATURE_ASN1_LIMITS: Readonly<SignatureAsn1Limits>;
|
|
106
|
+
export interface InspectSignatureOptions {
|
|
107
|
+
sourceFilename?: string;
|
|
108
|
+
extensionHint?: string;
|
|
109
|
+
originalContent?: ArrayBuffer | Uint8Array;
|
|
110
|
+
/** Per-call reductions of the absolute hostile-input ceilings. Limits cannot be raised. */
|
|
111
|
+
limits?: Partial<SignatureAsn1Limits>;
|
|
112
|
+
}
|
|
113
|
+
export interface EvidenceArchiveTimestampSummary {
|
|
114
|
+
chainIndex: number;
|
|
115
|
+
index: number;
|
|
116
|
+
digestAlgorithmOid?: string;
|
|
117
|
+
digestAlgorithm?: string;
|
|
118
|
+
reducedHashTreeNodes: number;
|
|
119
|
+
timestamp?: TimestampInfoSummary;
|
|
120
|
+
timestampSignerCount: number;
|
|
121
|
+
timestampSignaturesValid?: boolean;
|
|
122
|
+
evidenceDigestMatchesOriginal?: boolean;
|
|
123
|
+
warnings: string[];
|
|
124
|
+
}
|
|
125
|
+
export interface EvidenceRecordInspection {
|
|
126
|
+
kind: 'evidence-record';
|
|
127
|
+
detectedFormat: 'RFC 4998 EvidenceRecord';
|
|
128
|
+
sourceSize: number;
|
|
129
|
+
version?: number;
|
|
130
|
+
digestAlgorithms: string[];
|
|
131
|
+
archiveTimestampChains: number;
|
|
132
|
+
archiveTimestamps: EvidenceArchiveTimestampSummary[];
|
|
133
|
+
originalContentSupplied: boolean;
|
|
134
|
+
originalEvidenceMatches?: boolean;
|
|
135
|
+
fullyValidated: false;
|
|
136
|
+
warnings: string[];
|
|
137
|
+
}
|
|
138
|
+
export interface InspectEvidenceRecordOptions {
|
|
139
|
+
originalContent?: ArrayBuffer | Uint8Array;
|
|
140
|
+
/** Per-call reductions of the absolute hostile-input ceilings. Limits cannot be raised. */
|
|
141
|
+
limits?: Partial<SignatureAsn1Limits>;
|
|
142
|
+
}
|
|
143
|
+
export declare const inspectSignatureContainer: (input: ArrayBuffer | Uint8Array, options?: InspectSignatureOptions) => Promise<SignatureInspection>;
|
|
144
|
+
/**
|
|
145
|
+
* Bounded RFC 4998 structural inspection. Only the first archive timestamp can
|
|
146
|
+
* be compared directly with supplied original bytes when no reduced hash tree
|
|
147
|
+
* is present. Renewal chains are reported but never over-claimed as validated.
|
|
148
|
+
*/
|
|
149
|
+
export declare const inspectEvidenceRecord: (input: ArrayBuffer | Uint8Array, options?: InspectEvidenceRecordOptions) => Promise<EvidenceRecordInspection>;
|
|
150
|
+
export declare const signatureOidLabels: Readonly<Record<string, string>>;
|