@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.
Files changed (45) hide show
  1. package/LICENSE +160 -0
  2. package/README.en.md +87 -0
  3. package/README.md +89 -0
  4. package/THIRD_PARTY_LICENSES.json +3867 -0
  5. package/THIRD_PARTY_NOTICES.md +10 -0
  6. package/dist/container.worker.d.ts +1 -0
  7. package/dist/container.worker.js +39 -0
  8. package/dist/index.d.ts +11 -0
  9. package/dist/index.js +53 -0
  10. package/dist/inspect.d.ts +7 -0
  11. package/dist/inspect.js +4 -0
  12. package/dist/openpgp/client.d.ts +16 -0
  13. package/dist/openpgp/client.js +148 -0
  14. package/dist/openpgp/formatDetection.d.ts +3 -0
  15. package/dist/openpgp/formatDetection.js +45 -0
  16. package/dist/openpgp/types.d.ts +72 -0
  17. package/dist/openpgp/types.js +1 -0
  18. package/dist/rpgp-wasm/rpgp_wrapper.d.ts +43 -0
  19. package/dist/rpgp-wasm/rpgp_wrapper.js +578 -0
  20. package/dist/rpgp-wasm/rpgp_wrapper_bg.wasm +0 -0
  21. package/dist/rpgp-wasm/rpgp_wrapper_bg.wasm.d.ts +10 -0
  22. package/dist/signature.d.ts +24 -0
  23. package/dist/signature.js +1040 -0
  24. package/dist/signature.worker.d.ts +1 -0
  25. package/dist/signature.worker.js +108 -0
  26. package/dist/signatureAsn1.d.ts +150 -0
  27. package/dist/signatureAsn1.js +1486 -0
  28. package/dist/structured/asic.d.ts +3 -0
  29. package/dist/structured/asic.js +188 -0
  30. package/dist/structured/containerClient.d.ts +12 -0
  31. package/dist/structured/containerClient.js +71 -0
  32. package/dist/structured/containerProtocol.d.ts +20 -0
  33. package/dist/structured/containerProtocol.js +1 -0
  34. package/dist/structured/jws.d.ts +3 -0
  35. package/dist/structured/jws.js +382 -0
  36. package/dist/structured/limits.d.ts +20 -0
  37. package/dist/structured/limits.js +41 -0
  38. package/dist/structured/types.d.ts +53 -0
  39. package/dist/structured/types.js +1 -0
  40. package/dist/structured/zipPreflight.d.ts +14 -0
  41. package/dist/structured/zipPreflight.js +173 -0
  42. package/dist/workerProtocol.d.ts +40 -0
  43. package/dist/workerProtocol.js +1 -0
  44. package/file-viewer.capability.json +56 -0
  45. package/package.json +106 -0
@@ -0,0 +1,382 @@
1
+ import { normalizeSignatureContainerLimits } from './limits.js';
2
+ const textEncoder = new TextEncoder();
3
+ const strictUtf8 = new TextDecoder('utf-8', { fatal: true });
4
+ const JADES_HEADER_NAMES = new Set([
5
+ 'sigT',
6
+ 'x5t#S256',
7
+ 'x5c',
8
+ 'etsiU',
9
+ 'etsiQcs',
10
+ 'etsiP',
11
+ 'srCms',
12
+ 'rSig',
13
+ 'sigD',
14
+ 'adoTst'
15
+ ]);
16
+ const assertJws = (condition, message) => {
17
+ if (!condition)
18
+ throw new Error(`Invalid JWS: ${message}`);
19
+ };
20
+ const ownRecord = (value, label) => {
21
+ assertJws(Boolean(value) && typeof value === 'object' && !Array.isArray(value), `${label} must be a JSON object.`);
22
+ const input = value;
23
+ const output = Object.create(null);
24
+ for (const key of Object.keys(input)) {
25
+ assertJws(key !== '__proto__' && key !== 'prototype' && key !== 'constructor', `${label} contains a forbidden property.`);
26
+ output[key] = input[key];
27
+ }
28
+ return output;
29
+ };
30
+ const decodeBase64Url = (value, label, maxBytes) => {
31
+ assertJws(/^[A-Za-z0-9_-]*$/u.test(value), `${label} is not base64url.`);
32
+ assertJws(value.length <= Math.ceil((maxBytes * 4) / 3) + 4, `${label} exceeds ${maxBytes} decoded bytes.`);
33
+ const remainder = value.length % 4;
34
+ assertJws(remainder !== 1, `${label} has invalid base64url length.`);
35
+ const padded = value.replace(/-/gu, '+').replace(/_/gu, '/') + '='.repeat((4 - remainder) % 4);
36
+ let binary;
37
+ try {
38
+ binary = globalThis.atob(padded);
39
+ }
40
+ catch {
41
+ throw new Error(`Invalid JWS: ${label} cannot be decoded.`);
42
+ }
43
+ assertJws(binary.length <= maxBytes, `${label} exceeds ${maxBytes} decoded bytes.`);
44
+ const output = new Uint8Array(binary.length);
45
+ for (let index = 0; index < binary.length; index += 1)
46
+ output[index] = binary.charCodeAt(index);
47
+ return output;
48
+ };
49
+ const encodeBase64Url = (bytes) => {
50
+ let binary = '';
51
+ const chunkSize = 0x8000;
52
+ for (let offset = 0; offset < bytes.length; offset += chunkSize) {
53
+ binary += String.fromCharCode(...bytes.subarray(offset, Math.min(bytes.length, offset + chunkSize)));
54
+ }
55
+ return globalThis.btoa(binary).replace(/=/gu, '').replace(/\+/gu, '-').replace(/\//gu, '_');
56
+ };
57
+ const parseProtectedHeader = (segment, maxHeaderBytes) => {
58
+ const bytes = decodeBase64Url(segment, 'protected header', maxHeaderBytes);
59
+ let parsed;
60
+ try {
61
+ parsed = JSON.parse(strictUtf8.decode(bytes));
62
+ }
63
+ catch {
64
+ throw new Error('Invalid JWS: protected header is not strict UTF-8 JSON.');
65
+ }
66
+ return ownRecord(parsed, 'protected header');
67
+ };
68
+ const parseJsonInput = (bytes, maxJsonBytes) => {
69
+ assertJws(bytes.byteLength <= maxJsonBytes, `JSON serialization exceeds ${maxJsonBytes} bytes.`);
70
+ try {
71
+ return ownRecord(JSON.parse(strictUtf8.decode(bytes)), 'JWS JSON serialization');
72
+ }
73
+ catch (error) {
74
+ if (error instanceof Error && error.message.startsWith('Invalid JWS:'))
75
+ throw error;
76
+ const symptom = new Error('Invalid JWS: JSON serialization is malformed or not strict UTF-8.');
77
+ symptom.cause = error;
78
+ throw symptom;
79
+ }
80
+ };
81
+ const parseSignatures = (input, bytes, maxJsonBytes, maxHeaderBytes, maxSignatures) => {
82
+ const trimmed = input.trim();
83
+ if (!trimmed.startsWith('{')) {
84
+ const segments = trimmed.split('.');
85
+ assertJws(segments.length === 3, 'compact serialization must contain exactly three segments.');
86
+ return {
87
+ serialization: 'compact',
88
+ payloadField: segments[1],
89
+ signatures: [
90
+ {
91
+ protectedSegment: segments[0],
92
+ protectedHeader: parseProtectedHeader(segments[0], maxHeaderBytes),
93
+ unprotectedHeader: Object.create(null),
94
+ signatureSegment: segments[2]
95
+ }
96
+ ]
97
+ };
98
+ }
99
+ const json = parseJsonInput(bytes, maxJsonBytes);
100
+ const payloadField = json.payload;
101
+ assertJws(payloadField === undefined || typeof payloadField === 'string', 'payload must be a string when present.');
102
+ const rawSignatures = Array.isArray(json.signatures)
103
+ ? json.signatures
104
+ : [{ protected: json.protected, header: json.header, signature: json.signature }];
105
+ assertJws(rawSignatures.length > 0 && rawSignatures.length <= maxSignatures, `signature count must be between 1 and ${maxSignatures}.`);
106
+ const signatures = rawSignatures.map((raw, index) => {
107
+ const value = ownRecord(raw, `signature ${index + 1}`);
108
+ assertJws(typeof value.signature === 'string', `signature ${index + 1} is missing its signature value.`);
109
+ const protectedSegment = value.protected === undefined ? '' : value.protected;
110
+ assertJws(typeof protectedSegment === 'string', `signature ${index + 1} protected header must be a string.`);
111
+ return {
112
+ protectedSegment,
113
+ protectedHeader: protectedSegment
114
+ ? parseProtectedHeader(protectedSegment, maxHeaderBytes)
115
+ : Object.create(null),
116
+ unprotectedHeader: value.header === undefined
117
+ ? Object.create(null)
118
+ : ownRecord(value.header, `signature ${index + 1} unprotected header`),
119
+ signatureSegment: value.signature
120
+ };
121
+ });
122
+ return {
123
+ serialization: Array.isArray(json.signatures)
124
+ ? 'json-general'
125
+ : 'json-flattened',
126
+ payloadField,
127
+ signatures
128
+ };
129
+ };
130
+ const concatBytes = (...parts) => {
131
+ const size = parts.reduce((sum, part) => sum + part.byteLength, 0);
132
+ const result = new Uint8Array(size);
133
+ let offset = 0;
134
+ for (const part of parts) {
135
+ result.set(part, offset);
136
+ offset += part.byteLength;
137
+ }
138
+ return result;
139
+ };
140
+ const algorithmParameters = (algorithm) => {
141
+ const hash = algorithm.endsWith('256')
142
+ ? 'SHA-256'
143
+ : algorithm.endsWith('384')
144
+ ? 'SHA-384'
145
+ : algorithm.endsWith('512')
146
+ ? 'SHA-512'
147
+ : undefined;
148
+ if (/^RS(?:256|384|512)$/u.test(algorithm))
149
+ return {
150
+ importAlgorithm: { name: 'RSASSA-PKCS1-v1_5', hash },
151
+ verifyAlgorithm: { name: 'RSASSA-PKCS1-v1_5' },
152
+ keyType: 'RSA'
153
+ };
154
+ if (/^PS(?:256|384|512)$/u.test(algorithm))
155
+ return {
156
+ importAlgorithm: { name: 'RSA-PSS', hash },
157
+ verifyAlgorithm: { name: 'RSA-PSS', saltLength: Number(algorithm.slice(2)) / 8 },
158
+ keyType: 'RSA'
159
+ };
160
+ if (/^ES(?:256|384|512)$/u.test(algorithm)) {
161
+ const namedCurve = algorithm === 'ES256' ? 'P-256' : algorithm === 'ES384' ? 'P-384' : 'P-521';
162
+ return {
163
+ importAlgorithm: { name: 'ECDSA', namedCurve },
164
+ verifyAlgorithm: { name: 'ECDSA', hash },
165
+ keyType: 'EC',
166
+ namedCurve
167
+ };
168
+ }
169
+ if (algorithm === 'EdDSA')
170
+ return {
171
+ importAlgorithm: { name: 'Ed25519' },
172
+ verifyAlgorithm: { name: 'Ed25519' },
173
+ keyType: 'OKP'
174
+ };
175
+ return undefined;
176
+ };
177
+ const isCryptoKey = (value) => typeof value === 'object' &&
178
+ value !== null &&
179
+ 'algorithm' in value &&
180
+ 'usages' in value &&
181
+ 'type' in value;
182
+ const importVerificationKey = async (candidate, algorithm) => {
183
+ const parameters = algorithmParameters(algorithm);
184
+ if (!parameters)
185
+ throw new Error(`Unsupported or unsafe JWS algorithm ${algorithm}.`);
186
+ if (isCryptoKey(candidate.key)) {
187
+ if (candidate.key.type !== 'public' || !candidate.key.usages.includes('verify'))
188
+ throw new Error('JWS verification requires a public CryptoKey with verify usage.');
189
+ return candidate.key;
190
+ }
191
+ const jwk = candidate.key;
192
+ if ('d' in jwk || 'k' in jwk)
193
+ throw new Error('Private or symmetric JWK material is not accepted by the preview verifier.');
194
+ if (jwk.kty !== parameters.keyType)
195
+ throw new Error(`JWK type ${jwk.kty || 'unknown'} does not match ${algorithm}.`);
196
+ if (parameters.namedCurve && jwk.crv !== parameters.namedCurve)
197
+ throw new Error(`JWK curve ${jwk.crv || 'unknown'} does not match ${algorithm}.`);
198
+ return globalThis.crypto.subtle.importKey('jwk', jwk, parameters.importAlgorithm, false, ['verify']);
199
+ };
200
+ const verifyOne = async (signature, signatureBytes, signingInput, keys) => {
201
+ const algorithm = signature.protectedHeader.alg;
202
+ assertJws(typeof algorithm === 'string' && algorithm.length > 0, 'alg must be present in the protected header.');
203
+ assertJws(algorithm !== 'none' && !algorithm.startsWith('HS'), `algorithm ${algorithm} is not accepted by this public-key verifier.`);
204
+ const parameters = algorithmParameters(algorithm);
205
+ assertJws(parameters, `algorithm ${algorithm} is unsupported.`);
206
+ const keyId = typeof signature.protectedHeader.kid === 'string'
207
+ ? signature.protectedHeader.kid
208
+ : typeof signature.unprotectedHeader.kid === 'string'
209
+ ? signature.unprotectedHeader.kid
210
+ : undefined;
211
+ const candidates = keyId
212
+ ? keys.filter((candidate) => !candidate.kid || candidate.kid === keyId)
213
+ : keys;
214
+ if (!candidates.length)
215
+ return {
216
+ valid: undefined,
217
+ error: keyId
218
+ ? `No verification key matched kid ${keyId}.`
219
+ : 'A public verification key is required.'
220
+ };
221
+ let lastError;
222
+ for (const candidate of candidates.slice(0, 64)) {
223
+ try {
224
+ const key = await importVerificationKey(candidate, algorithm);
225
+ const valid = await globalThis.crypto.subtle.verify(parameters.verifyAlgorithm, key, signatureBytes, signingInput);
226
+ if (valid)
227
+ return { valid: true };
228
+ }
229
+ catch (error) {
230
+ lastError = error;
231
+ }
232
+ }
233
+ return {
234
+ valid: false,
235
+ error: lastError instanceof Error
236
+ ? lastError.message
237
+ : 'No supplied public key verified the signature.'
238
+ };
239
+ };
240
+ const checkHeaderBoundary = (signature) => {
241
+ const protectedKeys = new Set(Object.keys(signature.protectedHeader));
242
+ for (const key of Object.keys(signature.unprotectedHeader)) {
243
+ assertJws(!protectedKeys.has(key), `header parameter ${key} appears in both protected and unprotected headers.`);
244
+ }
245
+ assertJws(typeof signature.protectedHeader.alg === 'string', 'alg must be integrity protected.');
246
+ const critical = signature.protectedHeader.crit;
247
+ if (critical !== undefined) {
248
+ assertJws(Array.isArray(critical) && critical.every((value) => typeof value === 'string'), 'crit must be an array of header names.');
249
+ const unique = new Set(critical);
250
+ assertJws(unique.size === critical.length, 'crit contains duplicate names.');
251
+ for (const name of unique)
252
+ assertJws(name === 'b64', `unsupported critical header ${name}.`);
253
+ }
254
+ const b64 = signature.protectedHeader.b64;
255
+ assertJws(b64 === undefined || typeof b64 === 'boolean', 'b64 must be boolean.');
256
+ if (b64 === false)
257
+ assertJws(Array.isArray(critical) && critical.includes('b64'), 'b64=false must be declared critical.');
258
+ };
259
+ export const isProbablyJws = (bytes, filename) => {
260
+ if (filename === null || filename === void 0 ? void 0 : filename.toLowerCase().endsWith('.jws'))
261
+ return true;
262
+ if (bytes.byteLength > 64 * 1024 * 1024)
263
+ return false;
264
+ const head = new TextDecoder('utf-8', { fatal: false })
265
+ .decode(bytes.subarray(0, Math.min(bytes.byteLength, 4096)))
266
+ .trim();
267
+ if (/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/u.test(head) && bytes.byteLength <= 4096)
268
+ return true;
269
+ return head.startsWith('{') && (head.includes('"signature"') || head.includes('"signatures"'));
270
+ };
271
+ export const inspectJws = async (input, options = {}) => {
272
+ const limits = normalizeSignatureContainerLimits(options.limits);
273
+ const bytes = typeof input === 'string'
274
+ ? textEncoder.encode(input)
275
+ : input instanceof Uint8Array
276
+ ? input
277
+ : new Uint8Array(input);
278
+ assertJws(bytes.byteLength > 0 && bytes.byteLength <= limits.maxContainerBytes, `input exceeds ${limits.maxContainerBytes} bytes.`);
279
+ let source;
280
+ try {
281
+ source = strictUtf8.decode(bytes);
282
+ }
283
+ catch {
284
+ throw new Error('Invalid JWS: serialization must be strict UTF-8.');
285
+ }
286
+ const parsed = parseSignatures(source, bytes, limits.maxJsonBytes, Math.min(limits.maxJsonBytes, 64 * 1024), limits.maxJwsSignatures);
287
+ const detachedPayload = options.detachedPayload
288
+ ? options.detachedPayload instanceof Uint8Array
289
+ ? options.detachedPayload
290
+ : new Uint8Array(options.detachedPayload)
291
+ : undefined;
292
+ assertJws(!detachedPayload || detachedPayload.byteLength <= limits.maxEntryBytes, `detached payload exceeds ${limits.maxEntryBytes} bytes.`);
293
+ const warnings = [
294
+ 'JWS parsing and public-key signature verification do not establish key trust, signer identity, policy compliance or legal validity.',
295
+ 'jku, x5u and other remote key or certificate locations are displayed as metadata and are never fetched automatically.'
296
+ ];
297
+ let sharedPayload;
298
+ const detached = parsed.payloadField === undefined || parsed.payloadField === '';
299
+ let payloadEncoded = true;
300
+ const inspections = [];
301
+ for (let index = 0; index < parsed.signatures.length; index += 1) {
302
+ const signature = parsed.signatures[index];
303
+ checkHeaderBoundary(signature);
304
+ const encoded = signature.protectedHeader.b64 !== false;
305
+ if (index === 0)
306
+ payloadEncoded = encoded;
307
+ else
308
+ assertJws(payloadEncoded === encoded, 'all signatures must use the same b64 payload mode.');
309
+ let payload;
310
+ let payloadSegment;
311
+ if (detached) {
312
+ payload = detachedPayload;
313
+ payloadSegment = payload
314
+ ? encoded
315
+ ? textEncoder.encode(encodeBase64Url(payload))
316
+ : payload
317
+ : undefined;
318
+ }
319
+ else if (encoded) {
320
+ payload = decodeBase64Url(parsed.payloadField, 'payload', limits.maxEntryBytes);
321
+ payloadSegment = textEncoder.encode(parsed.payloadField);
322
+ }
323
+ else {
324
+ payload = textEncoder.encode(parsed.payloadField);
325
+ assertJws(payload.byteLength <= limits.maxEntryBytes, `payload exceeds ${limits.maxEntryBytes} bytes.`);
326
+ payloadSegment = payload;
327
+ }
328
+ if (payload) {
329
+ sharedPayload || (sharedPayload = payload);
330
+ assertJws(sharedPayload.byteLength === payload.byteLength &&
331
+ sharedPayload.every((value, offset) => value === payload[offset]), 'signatures resolved to inconsistent payload bytes.');
332
+ }
333
+ const signatureBytes = decodeBase64Url(signature.signatureSegment, `signature ${index + 1}`, 64 * 1024);
334
+ const signingInput = payloadSegment
335
+ ? concatBytes(textEncoder.encode(`${signature.protectedSegment}.`), payloadSegment)
336
+ : undefined;
337
+ let cryptographicValid;
338
+ let verificationError;
339
+ try {
340
+ if (!signingInput) {
341
+ verificationError =
342
+ 'Detached payload is required before the cryptographic signature can be checked.';
343
+ }
344
+ else {
345
+ const result = await verifyOne(signature, signatureBytes, signingInput, options.verificationKeys || []);
346
+ cryptographicValid = result.valid;
347
+ verificationError = result.error;
348
+ }
349
+ }
350
+ catch (error) {
351
+ cryptographicValid = false;
352
+ verificationError = error instanceof Error ? error.message : String(error);
353
+ }
354
+ const algorithm = signature.protectedHeader.alg;
355
+ const keyId = (signature.protectedHeader.kid || signature.unprotectedHeader.kid);
356
+ inspections.push({
357
+ index,
358
+ algorithm,
359
+ keyId,
360
+ protectedHeader: signature.protectedHeader,
361
+ unprotectedHeader: signature.unprotectedHeader,
362
+ signatureBytes: signatureBytes.byteLength,
363
+ cryptographicValid,
364
+ verificationError,
365
+ jadesProperties: [
366
+ ...new Set([
367
+ ...Object.keys(signature.protectedHeader),
368
+ ...Object.keys(signature.unprotectedHeader)
369
+ ].filter((name) => JADES_HEADER_NAMES.has(name)))
370
+ ]
371
+ });
372
+ }
373
+ return {
374
+ serialization: parsed.serialization,
375
+ sourceSize: bytes.byteLength,
376
+ detached,
377
+ payloadEncoded,
378
+ payload: sharedPayload,
379
+ signatures: inspections,
380
+ warnings
381
+ };
382
+ };
@@ -0,0 +1,20 @@
1
+ export interface SignatureContainerLimits {
2
+ maxContainerBytes: number;
3
+ maxEntries: number;
4
+ maxEntryBytes: number;
5
+ maxTotalUncompressedBytes: number;
6
+ maxCompressionRatio: number;
7
+ maxPathBytes: number;
8
+ maxDocuments: number;
9
+ maxSignatureMembers: number;
10
+ maxXmlBytes: number;
11
+ maxJsonBytes: number;
12
+ maxJwsSignatures: number;
13
+ maxWorkerMs: number;
14
+ }
15
+ export declare const DEFAULT_SIGNATURE_CONTAINER_LIMITS: Readonly<SignatureContainerLimits>;
16
+ /**
17
+ * Host overrides may lower or moderately raise operational limits, but they can
18
+ * never disable the package's absolute hostile-input boundary.
19
+ */
20
+ export declare const normalizeSignatureContainerLimits: (requested?: Partial<SignatureContainerLimits>) => SignatureContainerLimits;
@@ -0,0 +1,41 @@
1
+ export const DEFAULT_SIGNATURE_CONTAINER_LIMITS = Object.freeze({
2
+ maxContainerBytes: 64 * 1024 * 1024,
3
+ maxEntries: 1024,
4
+ maxEntryBytes: 32 * 1024 * 1024,
5
+ maxTotalUncompressedBytes: 128 * 1024 * 1024,
6
+ maxCompressionRatio: 200,
7
+ maxPathBytes: 1024,
8
+ maxDocuments: 512,
9
+ maxSignatureMembers: 128,
10
+ maxXmlBytes: 4 * 1024 * 1024,
11
+ maxJsonBytes: 8 * 1024 * 1024,
12
+ maxJwsSignatures: 64,
13
+ maxWorkerMs: 20000
14
+ });
15
+ const ABSOLUTE_SIGNATURE_CONTAINER_LIMITS = Object.freeze({
16
+ maxContainerBytes: 128 * 1024 * 1024,
17
+ maxEntries: 4096,
18
+ maxEntryBytes: 64 * 1024 * 1024,
19
+ maxTotalUncompressedBytes: 256 * 1024 * 1024,
20
+ maxCompressionRatio: 500,
21
+ maxPathBytes: 4096,
22
+ maxDocuments: 2048,
23
+ maxSignatureMembers: 512,
24
+ maxXmlBytes: 16 * 1024 * 1024,
25
+ maxJsonBytes: 32 * 1024 * 1024,
26
+ maxJwsSignatures: 256,
27
+ maxWorkerMs: 60000
28
+ });
29
+ const boundedInteger = (value, fallback, ceiling) => {
30
+ if (typeof value !== 'number' || !Number.isSafeInteger(value) || value <= 0)
31
+ return fallback;
32
+ return Math.min(value, ceiling);
33
+ };
34
+ /**
35
+ * Host overrides may lower or moderately raise operational limits, but they can
36
+ * never disable the package's absolute hostile-input boundary.
37
+ */
38
+ export const normalizeSignatureContainerLimits = (requested) => Object.fromEntries(Object.entries(DEFAULT_SIGNATURE_CONTAINER_LIMITS).map(([key, fallback]) => [
39
+ key,
40
+ boundedInteger(requested === null || requested === void 0 ? void 0 : requested[key], fallback, ABSOLUTE_SIGNATURE_CONTAINER_LIMITS[key])
41
+ ]));
@@ -0,0 +1,53 @@
1
+ import type { SignatureContainerLimits } from './limits.js';
2
+ export type AsicKind = 'ASiC-S' | 'ASiC-E';
3
+ export interface AsicArchiveMember {
4
+ name: string;
5
+ compressedSize: number;
6
+ uncompressedSize: number;
7
+ mediaType?: string;
8
+ data?: Uint8Array;
9
+ }
10
+ export interface AsicSignatureMember extends AsicArchiveMember {
11
+ kind: 'cades' | 'xades-or-xml' | 'timestamp' | 'evidence-record' | 'jws' | 'unknown';
12
+ referencedDocuments: string[];
13
+ }
14
+ export interface AsicInspection {
15
+ kind: AsicKind;
16
+ mediaType: string;
17
+ sourceSize: number;
18
+ entryCount: number;
19
+ totalUncompressedBytes: number;
20
+ documents: AsicArchiveMember[];
21
+ signatures: AsicSignatureMember[];
22
+ metadata: AsicArchiveMember[];
23
+ warnings: string[];
24
+ }
25
+ export interface JwsVerificationKey {
26
+ key: CryptoKey | JsonWebKey;
27
+ kid?: string;
28
+ }
29
+ export interface JwsSignatureInspection {
30
+ index: number;
31
+ algorithm?: string;
32
+ keyId?: string;
33
+ protectedHeader: Readonly<Record<string, unknown>>;
34
+ unprotectedHeader: Readonly<Record<string, unknown>>;
35
+ signatureBytes: number;
36
+ cryptographicValid?: boolean;
37
+ verificationError?: string;
38
+ jadesProperties: string[];
39
+ }
40
+ export interface JwsInspection {
41
+ serialization: 'compact' | 'json-general' | 'json-flattened';
42
+ sourceSize: number;
43
+ detached: boolean;
44
+ payloadEncoded: boolean;
45
+ payload?: Uint8Array;
46
+ signatures: JwsSignatureInspection[];
47
+ warnings: string[];
48
+ }
49
+ export interface InspectJwsOptions {
50
+ detachedPayload?: ArrayBuffer | Uint8Array;
51
+ verificationKeys?: JwsVerificationKey[];
52
+ limits?: Partial<SignatureContainerLimits>;
53
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { SignatureContainerLimits } from './limits.js';
2
+ export interface SafeZipEntry {
3
+ name: string;
4
+ compressedSize: number;
5
+ uncompressedSize: number;
6
+ compressionMethod: 0 | 8;
7
+ localHeaderOffset: number;
8
+ directory: boolean;
9
+ }
10
+ export interface SafeZipDirectory {
11
+ entries: SafeZipEntry[];
12
+ totalUncompressedBytes: number;
13
+ }
14
+ export declare const inspectZipCentralDirectory: (input: ArrayBuffer | Uint8Array, limits: SignatureContainerLimits) => SafeZipDirectory;