@owf/eudi-jades 0.1.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/README.md +199 -0
- package/dist/index.d.mts +1001 -0
- package/dist/index.mjs +924 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1001 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/constants.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* JAdES Constants
|
|
6
|
+
*
|
|
7
|
+
* Algorithm definitions and OIDs as per ETSI TS 119 182-1.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Supported signature algorithms with their hash algorithms.
|
|
11
|
+
*/
|
|
12
|
+
declare const ALGORITHMS: {
|
|
13
|
+
readonly RS256: {
|
|
14
|
+
readonly hash: "SHA-256";
|
|
15
|
+
readonly family: "RSA";
|
|
16
|
+
};
|
|
17
|
+
readonly RS384: {
|
|
18
|
+
readonly hash: "SHA-384";
|
|
19
|
+
readonly family: "RSA";
|
|
20
|
+
};
|
|
21
|
+
readonly RS512: {
|
|
22
|
+
readonly hash: "SHA-512";
|
|
23
|
+
readonly family: "RSA";
|
|
24
|
+
};
|
|
25
|
+
readonly PS256: {
|
|
26
|
+
readonly hash: "SHA-256";
|
|
27
|
+
readonly family: "RSA-PSS";
|
|
28
|
+
};
|
|
29
|
+
readonly PS384: {
|
|
30
|
+
readonly hash: "SHA-384";
|
|
31
|
+
readonly family: "RSA-PSS";
|
|
32
|
+
};
|
|
33
|
+
readonly PS512: {
|
|
34
|
+
readonly hash: "SHA-512";
|
|
35
|
+
readonly family: "RSA-PSS";
|
|
36
|
+
};
|
|
37
|
+
readonly ES256: {
|
|
38
|
+
readonly hash: "SHA-256";
|
|
39
|
+
readonly family: "ECDSA";
|
|
40
|
+
readonly namedCurve: "P-256";
|
|
41
|
+
};
|
|
42
|
+
readonly ES384: {
|
|
43
|
+
readonly hash: "SHA-384";
|
|
44
|
+
readonly family: "ECDSA";
|
|
45
|
+
readonly namedCurve: "P-384";
|
|
46
|
+
};
|
|
47
|
+
readonly ES512: {
|
|
48
|
+
readonly hash: "SHA-512";
|
|
49
|
+
readonly family: "ECDSA";
|
|
50
|
+
readonly namedCurve: "P-521";
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Commitment type OIDs as per RFC 5035.
|
|
55
|
+
*/
|
|
56
|
+
declare enum CommitmentOIDs {
|
|
57
|
+
/** Proof of origin */
|
|
58
|
+
proofOfOrigin = "1.2.840.113549.1.9.16.6.1",
|
|
59
|
+
/** Proof of receipt */
|
|
60
|
+
proofOfReceipt = "1.2.840.113549.1.9.16.6.2",
|
|
61
|
+
/** Proof of delivery */
|
|
62
|
+
proofOfDelivery = "1.2.840.113549.1.9.16.6.3",
|
|
63
|
+
/** Proof of sender */
|
|
64
|
+
proofOfSender = "1.2.840.113549.1.9.16.6.4",
|
|
65
|
+
/** Proof of approval */
|
|
66
|
+
proofOfApproval = "1.2.840.113549.1.9.16.6.5",
|
|
67
|
+
/** Proof of creation */
|
|
68
|
+
proofOfCreation = "1.2.840.113549.1.9.16.6.6"
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* JAdES baseline profiles as per ETSI TS 119 182-1.
|
|
72
|
+
*/
|
|
73
|
+
declare enum JAdESProfile {
|
|
74
|
+
/** Basic - Baseline: basic signature format */
|
|
75
|
+
B_B = "B-B",
|
|
76
|
+
/** Basic with Time: signatures with timestamp */
|
|
77
|
+
B_T = "B-T",
|
|
78
|
+
/** Basic Long-Term: signatures with validation data for long-term preservation */
|
|
79
|
+
B_LT = "B-LT",
|
|
80
|
+
/** Basic Long-Term with Archive timestamps */
|
|
81
|
+
B_LTA = "B-LTA"
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Detached signature mechanism identifiers as per ETSI TS 119 182-1 Section 5.2.8.
|
|
85
|
+
*/
|
|
86
|
+
declare const DETACHED_MECHANISM_IDS: {
|
|
87
|
+
/** HTTP Headers mechanism */readonly httpHeaders: "http://uri.etsi.org/19182/HttpHeaders"; /** Object digest mechanism */
|
|
88
|
+
readonly objectDigest: "http://uri.etsi.org/19182/ObjectIdByURIHash";
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Critical header parameters that must be understood.
|
|
92
|
+
* ETSI TS 119 182-1 specifies these parameters as critical.
|
|
93
|
+
*/
|
|
94
|
+
declare const CRITICAL_PARAMETERS: readonly ["x5t#o", "sigX5ts", "sigT", "sigD", "sigPl", "sigPId", "srCms", "srAts", "adoTst", "b64"];
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/schemas.d.ts
|
|
97
|
+
/**
|
|
98
|
+
* Supported signature algorithms.
|
|
99
|
+
*/
|
|
100
|
+
declare const SignAlgSchema: z.ZodEnum<{
|
|
101
|
+
ES256: "ES256";
|
|
102
|
+
ES384: "ES384";
|
|
103
|
+
ES512: "ES512";
|
|
104
|
+
RS256: "RS256";
|
|
105
|
+
RS384: "RS384";
|
|
106
|
+
RS512: "RS512";
|
|
107
|
+
PS256: "PS256";
|
|
108
|
+
PS384: "PS384";
|
|
109
|
+
PS512: "PS512";
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* X.509 Certificate Thumbprint with algorithm specification.
|
|
113
|
+
* ETSI TS 119 182-1 Section 5.2.2.2
|
|
114
|
+
*/
|
|
115
|
+
declare const X5tOSchema: z.ZodObject<{
|
|
116
|
+
digAlg: z.ZodString;
|
|
117
|
+
digVal: z.ZodString;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
/**
|
|
120
|
+
* Signature policy descriptor.
|
|
121
|
+
* ETSI TS 119 182-1 Section 5.2.4
|
|
122
|
+
*/
|
|
123
|
+
declare const SignaturePolicySchema: z.ZodObject<{
|
|
124
|
+
sigPolicyId: z.ZodOptional<z.ZodString>;
|
|
125
|
+
sigPolicyHash: z.ZodOptional<z.ZodObject<{
|
|
126
|
+
hashAlgo: z.ZodString;
|
|
127
|
+
hashVal: z.ZodString;
|
|
128
|
+
}, z.core.$strip>>;
|
|
129
|
+
sigPolicyQualifiers: z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$loose>>>;
|
|
130
|
+
}, z.core.$strip>;
|
|
131
|
+
/**
|
|
132
|
+
* Signer identifier.
|
|
133
|
+
* ETSI TS 119 182-1 Section 5.2.3
|
|
134
|
+
*/
|
|
135
|
+
declare const SignerIdentifierSchema: z.ZodObject<{
|
|
136
|
+
issuerSerial: z.ZodOptional<z.ZodObject<{
|
|
137
|
+
issuer: z.ZodString;
|
|
138
|
+
serialNumber: z.ZodString;
|
|
139
|
+
}, z.core.$strip>>;
|
|
140
|
+
subjectKeyIdentifier: z.ZodOptional<z.ZodString>;
|
|
141
|
+
}, z.core.$strip>;
|
|
142
|
+
/**
|
|
143
|
+
* Detached signature descriptor.
|
|
144
|
+
* ETSI TS 119 182-1 Section 5.2.8
|
|
145
|
+
*/
|
|
146
|
+
declare const SigDSchema: z.ZodObject<{
|
|
147
|
+
mId: z.ZodString;
|
|
148
|
+
pars: z.ZodTuple<[z.ZodString, z.ZodString], null>;
|
|
149
|
+
hashM: z.ZodOptional<z.ZodString>;
|
|
150
|
+
ctM: z.ZodOptional<z.ZodString>;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
/**
|
|
153
|
+
* Timestamp tokens container.
|
|
154
|
+
*/
|
|
155
|
+
declare const TstTokensSchema: z.ZodObject<{
|
|
156
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
157
|
+
val: z.ZodString;
|
|
158
|
+
}, z.core.$strip>>;
|
|
159
|
+
}, z.core.$strip>;
|
|
160
|
+
/**
|
|
161
|
+
* Signature timestamp container (for B-T profile).
|
|
162
|
+
*/
|
|
163
|
+
declare const SigTstSchema: z.ZodObject<{
|
|
164
|
+
sigTst: z.ZodObject<{
|
|
165
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
166
|
+
val: z.ZodString;
|
|
167
|
+
}, z.core.$strip>>;
|
|
168
|
+
}, z.core.$strip>;
|
|
169
|
+
}, z.core.$strip>;
|
|
170
|
+
/**
|
|
171
|
+
* X.509 certificate values (for B-LT profile).
|
|
172
|
+
*/
|
|
173
|
+
declare const XValsSchema: z.ZodObject<{
|
|
174
|
+
xVals: z.ZodArray<z.ZodObject<{
|
|
175
|
+
x509Cert: z.ZodString;
|
|
176
|
+
}, z.core.$strip>>;
|
|
177
|
+
}, z.core.$strip>;
|
|
178
|
+
/**
|
|
179
|
+
* Revocation values (for B-LT profile).
|
|
180
|
+
*/
|
|
181
|
+
declare const RValsSchema: z.ZodObject<{
|
|
182
|
+
rVals: z.ZodObject<{
|
|
183
|
+
crlVals: z.ZodArray<z.ZodString>;
|
|
184
|
+
ocspVals: z.ZodArray<z.ZodString>;
|
|
185
|
+
}, z.core.$strip>;
|
|
186
|
+
}, z.core.$strip>;
|
|
187
|
+
/**
|
|
188
|
+
* Archive timestamp (for B-LTA profile).
|
|
189
|
+
*/
|
|
190
|
+
declare const ArcTstSchema: z.ZodObject<{
|
|
191
|
+
arcTst: z.ZodObject<{
|
|
192
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
193
|
+
val: z.ZodString;
|
|
194
|
+
}, z.core.$strip>>;
|
|
195
|
+
canonAlg: z.ZodOptional<z.ZodString>;
|
|
196
|
+
}, z.core.$strip>;
|
|
197
|
+
}, z.core.$strip>;
|
|
198
|
+
/**
|
|
199
|
+
* ETSI Unsigned properties for different JAdES profiles.
|
|
200
|
+
*/
|
|
201
|
+
declare const EtsiUSchema: z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
202
|
+
sigTst: z.ZodObject<{
|
|
203
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
204
|
+
val: z.ZodString;
|
|
205
|
+
}, z.core.$strip>>;
|
|
206
|
+
}, z.core.$strip>;
|
|
207
|
+
}, z.core.$strip>>, z.ZodTuple<[z.ZodObject<{
|
|
208
|
+
sigTst: z.ZodObject<{
|
|
209
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
210
|
+
val: z.ZodString;
|
|
211
|
+
}, z.core.$strip>>;
|
|
212
|
+
}, z.core.$strip>;
|
|
213
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
214
|
+
xVals: z.ZodArray<z.ZodObject<{
|
|
215
|
+
x509Cert: z.ZodString;
|
|
216
|
+
}, z.core.$strip>>;
|
|
217
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
218
|
+
rVals: z.ZodObject<{
|
|
219
|
+
crlVals: z.ZodArray<z.ZodString>;
|
|
220
|
+
ocspVals: z.ZodArray<z.ZodString>;
|
|
221
|
+
}, z.core.$strip>;
|
|
222
|
+
}, z.core.$strip>], null>, z.ZodTuple<[z.ZodObject<{
|
|
223
|
+
sigTst: z.ZodObject<{
|
|
224
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
225
|
+
val: z.ZodString;
|
|
226
|
+
}, z.core.$strip>>;
|
|
227
|
+
}, z.core.$strip>;
|
|
228
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
229
|
+
xVals: z.ZodArray<z.ZodObject<{
|
|
230
|
+
x509Cert: z.ZodString;
|
|
231
|
+
}, z.core.$strip>>;
|
|
232
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
233
|
+
rVals: z.ZodObject<{
|
|
234
|
+
crlVals: z.ZodArray<z.ZodString>;
|
|
235
|
+
ocspVals: z.ZodArray<z.ZodString>;
|
|
236
|
+
}, z.core.$strip>;
|
|
237
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
238
|
+
arcTst: z.ZodObject<{
|
|
239
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
240
|
+
val: z.ZodString;
|
|
241
|
+
}, z.core.$strip>>;
|
|
242
|
+
canonAlg: z.ZodOptional<z.ZodString>;
|
|
243
|
+
}, z.core.$strip>;
|
|
244
|
+
}, z.core.$strip>], null>]>;
|
|
245
|
+
/**
|
|
246
|
+
* JAdES Protected Header parameters as per ETSI TS 119 182-1.
|
|
247
|
+
*/
|
|
248
|
+
declare const ProtectedHeaderSchema: z.ZodObject<{
|
|
249
|
+
alg: z.ZodOptional<z.ZodEnum<{
|
|
250
|
+
ES256: "ES256";
|
|
251
|
+
ES384: "ES384";
|
|
252
|
+
ES512: "ES512";
|
|
253
|
+
RS256: "RS256";
|
|
254
|
+
RS384: "RS384";
|
|
255
|
+
RS512: "RS512";
|
|
256
|
+
PS256: "PS256";
|
|
257
|
+
PS384: "PS384";
|
|
258
|
+
PS512: "PS512";
|
|
259
|
+
}>>;
|
|
260
|
+
cty: z.ZodOptional<z.ZodString>;
|
|
261
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
262
|
+
x5u: z.ZodOptional<z.ZodString>;
|
|
263
|
+
x5c: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
264
|
+
'x5t#S256': z.ZodOptional<z.ZodString>;
|
|
265
|
+
'x5t#o': z.ZodOptional<z.ZodObject<{
|
|
266
|
+
digAlg: z.ZodString;
|
|
267
|
+
digVal: z.ZodString;
|
|
268
|
+
}, z.core.$strip>>;
|
|
269
|
+
sigX5ts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
270
|
+
digAlg: z.ZodString;
|
|
271
|
+
digVal: z.ZodString;
|
|
272
|
+
}, z.core.$strip>>>;
|
|
273
|
+
srCms: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
274
|
+
commId: z.ZodString;
|
|
275
|
+
commQuals: z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$loose>>>;
|
|
276
|
+
}, z.core.$strip>>>;
|
|
277
|
+
srAts: z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$loose>>>;
|
|
278
|
+
sigPl: z.ZodOptional<z.ZodObject<{
|
|
279
|
+
sigPolicyId: z.ZodOptional<z.ZodString>;
|
|
280
|
+
sigPolicyHash: z.ZodOptional<z.ZodObject<{
|
|
281
|
+
hashAlgo: z.ZodString;
|
|
282
|
+
hashVal: z.ZodString;
|
|
283
|
+
}, z.core.$strip>>;
|
|
284
|
+
sigPolicyQualifiers: z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$loose>>>;
|
|
285
|
+
}, z.core.$strip>>;
|
|
286
|
+
sigPId: z.ZodOptional<z.ZodObject<{
|
|
287
|
+
issuerSerial: z.ZodOptional<z.ZodObject<{
|
|
288
|
+
issuer: z.ZodString;
|
|
289
|
+
serialNumber: z.ZodString;
|
|
290
|
+
}, z.core.$strip>>;
|
|
291
|
+
subjectKeyIdentifier: z.ZodOptional<z.ZodString>;
|
|
292
|
+
}, z.core.$strip>>;
|
|
293
|
+
sigT: z.ZodOptional<z.ZodString>;
|
|
294
|
+
sigD: z.ZodOptional<z.ZodObject<{
|
|
295
|
+
mId: z.ZodString;
|
|
296
|
+
pars: z.ZodTuple<[z.ZodString, z.ZodString], null>;
|
|
297
|
+
hashM: z.ZodOptional<z.ZodString>;
|
|
298
|
+
ctM: z.ZodOptional<z.ZodString>;
|
|
299
|
+
}, z.core.$strip>>;
|
|
300
|
+
b64: z.ZodOptional<z.ZodLiteral<false>>;
|
|
301
|
+
crit: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
302
|
+
iat: z.ZodOptional<z.ZodNumber>;
|
|
303
|
+
signedAt: z.ZodOptional<z.ZodNumber>;
|
|
304
|
+
jti: z.ZodOptional<z.ZodString>;
|
|
305
|
+
typ: z.ZodOptional<z.ZodString>;
|
|
306
|
+
adoTst: z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$loose>>>;
|
|
307
|
+
}, z.core.$loose>;
|
|
308
|
+
/**
|
|
309
|
+
* Protected header schema for signing (alg required).
|
|
310
|
+
*/
|
|
311
|
+
declare const ProtectedHeaderForSigningSchema: z.ZodObject<{
|
|
312
|
+
cty: z.ZodOptional<z.ZodString>;
|
|
313
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
314
|
+
x5u: z.ZodOptional<z.ZodString>;
|
|
315
|
+
x5c: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
316
|
+
'x5t#S256': z.ZodOptional<z.ZodString>;
|
|
317
|
+
'x5t#o': z.ZodOptional<z.ZodObject<{
|
|
318
|
+
digAlg: z.ZodString;
|
|
319
|
+
digVal: z.ZodString;
|
|
320
|
+
}, z.core.$strip>>;
|
|
321
|
+
sigX5ts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
322
|
+
digAlg: z.ZodString;
|
|
323
|
+
digVal: z.ZodString;
|
|
324
|
+
}, z.core.$strip>>>;
|
|
325
|
+
srCms: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
326
|
+
commId: z.ZodString;
|
|
327
|
+
commQuals: z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$loose>>>;
|
|
328
|
+
}, z.core.$strip>>>;
|
|
329
|
+
srAts: z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$loose>>>;
|
|
330
|
+
sigPl: z.ZodOptional<z.ZodObject<{
|
|
331
|
+
sigPolicyId: z.ZodOptional<z.ZodString>;
|
|
332
|
+
sigPolicyHash: z.ZodOptional<z.ZodObject<{
|
|
333
|
+
hashAlgo: z.ZodString;
|
|
334
|
+
hashVal: z.ZodString;
|
|
335
|
+
}, z.core.$strip>>;
|
|
336
|
+
sigPolicyQualifiers: z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$loose>>>;
|
|
337
|
+
}, z.core.$strip>>;
|
|
338
|
+
sigPId: z.ZodOptional<z.ZodObject<{
|
|
339
|
+
issuerSerial: z.ZodOptional<z.ZodObject<{
|
|
340
|
+
issuer: z.ZodString;
|
|
341
|
+
serialNumber: z.ZodString;
|
|
342
|
+
}, z.core.$strip>>;
|
|
343
|
+
subjectKeyIdentifier: z.ZodOptional<z.ZodString>;
|
|
344
|
+
}, z.core.$strip>>;
|
|
345
|
+
sigT: z.ZodOptional<z.ZodString>;
|
|
346
|
+
sigD: z.ZodOptional<z.ZodObject<{
|
|
347
|
+
mId: z.ZodString;
|
|
348
|
+
pars: z.ZodTuple<[z.ZodString, z.ZodString], null>;
|
|
349
|
+
hashM: z.ZodOptional<z.ZodString>;
|
|
350
|
+
ctM: z.ZodOptional<z.ZodString>;
|
|
351
|
+
}, z.core.$strip>>;
|
|
352
|
+
b64: z.ZodOptional<z.ZodLiteral<false>>;
|
|
353
|
+
crit: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
354
|
+
iat: z.ZodOptional<z.ZodNumber>;
|
|
355
|
+
signedAt: z.ZodOptional<z.ZodNumber>;
|
|
356
|
+
jti: z.ZodOptional<z.ZodString>;
|
|
357
|
+
typ: z.ZodOptional<z.ZodString>;
|
|
358
|
+
adoTst: z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$loose>>>;
|
|
359
|
+
alg: z.ZodEnum<{
|
|
360
|
+
ES256: "ES256";
|
|
361
|
+
ES384: "ES384";
|
|
362
|
+
ES512: "ES512";
|
|
363
|
+
RS256: "RS256";
|
|
364
|
+
RS384: "RS384";
|
|
365
|
+
RS512: "RS512";
|
|
366
|
+
PS256: "PS256";
|
|
367
|
+
PS384: "PS384";
|
|
368
|
+
PS512: "PS512";
|
|
369
|
+
}>;
|
|
370
|
+
}, z.core.$loose>;
|
|
371
|
+
/**
|
|
372
|
+
* JAdES Unprotected Header parameters.
|
|
373
|
+
*/
|
|
374
|
+
declare const UnprotectedHeaderSchema: z.ZodObject<{
|
|
375
|
+
etsiU: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
376
|
+
sigTst: z.ZodObject<{
|
|
377
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
378
|
+
val: z.ZodString;
|
|
379
|
+
}, z.core.$strip>>;
|
|
380
|
+
}, z.core.$strip>;
|
|
381
|
+
}, z.core.$strip>>, z.ZodTuple<[z.ZodObject<{
|
|
382
|
+
sigTst: z.ZodObject<{
|
|
383
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
384
|
+
val: z.ZodString;
|
|
385
|
+
}, z.core.$strip>>;
|
|
386
|
+
}, z.core.$strip>;
|
|
387
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
388
|
+
xVals: z.ZodArray<z.ZodObject<{
|
|
389
|
+
x509Cert: z.ZodString;
|
|
390
|
+
}, z.core.$strip>>;
|
|
391
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
392
|
+
rVals: z.ZodObject<{
|
|
393
|
+
crlVals: z.ZodArray<z.ZodString>;
|
|
394
|
+
ocspVals: z.ZodArray<z.ZodString>;
|
|
395
|
+
}, z.core.$strip>;
|
|
396
|
+
}, z.core.$strip>], null>, z.ZodTuple<[z.ZodObject<{
|
|
397
|
+
sigTst: z.ZodObject<{
|
|
398
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
399
|
+
val: z.ZodString;
|
|
400
|
+
}, z.core.$strip>>;
|
|
401
|
+
}, z.core.$strip>;
|
|
402
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
403
|
+
xVals: z.ZodArray<z.ZodObject<{
|
|
404
|
+
x509Cert: z.ZodString;
|
|
405
|
+
}, z.core.$strip>>;
|
|
406
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
407
|
+
rVals: z.ZodObject<{
|
|
408
|
+
crlVals: z.ZodArray<z.ZodString>;
|
|
409
|
+
ocspVals: z.ZodArray<z.ZodString>;
|
|
410
|
+
}, z.core.$strip>;
|
|
411
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
412
|
+
arcTst: z.ZodObject<{
|
|
413
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
414
|
+
val: z.ZodString;
|
|
415
|
+
}, z.core.$strip>>;
|
|
416
|
+
canonAlg: z.ZodOptional<z.ZodString>;
|
|
417
|
+
}, z.core.$strip>;
|
|
418
|
+
}, z.core.$strip>], null>]>>;
|
|
419
|
+
disclosures: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
420
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
421
|
+
kb_jwt: z.ZodOptional<z.ZodString>;
|
|
422
|
+
}, z.core.$loose>;
|
|
423
|
+
/**
|
|
424
|
+
* General JWS structure with multiple signatures.
|
|
425
|
+
*/
|
|
426
|
+
declare const GeneralJWSSchema: z.ZodObject<{
|
|
427
|
+
payload: z.ZodString;
|
|
428
|
+
signatures: z.ZodArray<z.ZodObject<{
|
|
429
|
+
protected: z.ZodString;
|
|
430
|
+
signature: z.ZodString;
|
|
431
|
+
header: z.ZodOptional<z.ZodObject<{
|
|
432
|
+
etsiU: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
433
|
+
sigTst: z.ZodObject<{
|
|
434
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
435
|
+
val: z.ZodString;
|
|
436
|
+
}, z.core.$strip>>;
|
|
437
|
+
}, z.core.$strip>;
|
|
438
|
+
}, z.core.$strip>>, z.ZodTuple<[z.ZodObject<{
|
|
439
|
+
sigTst: z.ZodObject<{
|
|
440
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
441
|
+
val: z.ZodString;
|
|
442
|
+
}, z.core.$strip>>;
|
|
443
|
+
}, z.core.$strip>;
|
|
444
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
445
|
+
xVals: z.ZodArray<z.ZodObject<{
|
|
446
|
+
x509Cert: z.ZodString;
|
|
447
|
+
}, z.core.$strip>>;
|
|
448
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
449
|
+
rVals: z.ZodObject<{
|
|
450
|
+
crlVals: z.ZodArray<z.ZodString>;
|
|
451
|
+
ocspVals: z.ZodArray<z.ZodString>;
|
|
452
|
+
}, z.core.$strip>;
|
|
453
|
+
}, z.core.$strip>], null>, z.ZodTuple<[z.ZodObject<{
|
|
454
|
+
sigTst: z.ZodObject<{
|
|
455
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
456
|
+
val: z.ZodString;
|
|
457
|
+
}, z.core.$strip>>;
|
|
458
|
+
}, z.core.$strip>;
|
|
459
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
460
|
+
xVals: z.ZodArray<z.ZodObject<{
|
|
461
|
+
x509Cert: z.ZodString;
|
|
462
|
+
}, z.core.$strip>>;
|
|
463
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
464
|
+
rVals: z.ZodObject<{
|
|
465
|
+
crlVals: z.ZodArray<z.ZodString>;
|
|
466
|
+
ocspVals: z.ZodArray<z.ZodString>;
|
|
467
|
+
}, z.core.$strip>;
|
|
468
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
469
|
+
arcTst: z.ZodObject<{
|
|
470
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
471
|
+
val: z.ZodString;
|
|
472
|
+
}, z.core.$strip>>;
|
|
473
|
+
canonAlg: z.ZodOptional<z.ZodString>;
|
|
474
|
+
}, z.core.$strip>;
|
|
475
|
+
}, z.core.$strip>], null>]>>;
|
|
476
|
+
disclosures: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
477
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
478
|
+
kb_jwt: z.ZodOptional<z.ZodString>;
|
|
479
|
+
}, z.core.$loose>>;
|
|
480
|
+
}, z.core.$strip>>;
|
|
481
|
+
}, z.core.$strip>;
|
|
482
|
+
/**
|
|
483
|
+
* Flattened JWS structure (single signature).
|
|
484
|
+
*/
|
|
485
|
+
declare const FlattenedJWSSchema: z.ZodObject<{
|
|
486
|
+
protected: z.ZodString;
|
|
487
|
+
payload: z.ZodString;
|
|
488
|
+
signature: z.ZodString;
|
|
489
|
+
header: z.ZodOptional<z.ZodObject<{
|
|
490
|
+
etsiU: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
491
|
+
sigTst: z.ZodObject<{
|
|
492
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
493
|
+
val: z.ZodString;
|
|
494
|
+
}, z.core.$strip>>;
|
|
495
|
+
}, z.core.$strip>;
|
|
496
|
+
}, z.core.$strip>>, z.ZodTuple<[z.ZodObject<{
|
|
497
|
+
sigTst: z.ZodObject<{
|
|
498
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
499
|
+
val: z.ZodString;
|
|
500
|
+
}, z.core.$strip>>;
|
|
501
|
+
}, z.core.$strip>;
|
|
502
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
503
|
+
xVals: z.ZodArray<z.ZodObject<{
|
|
504
|
+
x509Cert: z.ZodString;
|
|
505
|
+
}, z.core.$strip>>;
|
|
506
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
507
|
+
rVals: z.ZodObject<{
|
|
508
|
+
crlVals: z.ZodArray<z.ZodString>;
|
|
509
|
+
ocspVals: z.ZodArray<z.ZodString>;
|
|
510
|
+
}, z.core.$strip>;
|
|
511
|
+
}, z.core.$strip>], null>, z.ZodTuple<[z.ZodObject<{
|
|
512
|
+
sigTst: z.ZodObject<{
|
|
513
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
514
|
+
val: z.ZodString;
|
|
515
|
+
}, z.core.$strip>>;
|
|
516
|
+
}, z.core.$strip>;
|
|
517
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
518
|
+
xVals: z.ZodArray<z.ZodObject<{
|
|
519
|
+
x509Cert: z.ZodString;
|
|
520
|
+
}, z.core.$strip>>;
|
|
521
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
522
|
+
rVals: z.ZodObject<{
|
|
523
|
+
crlVals: z.ZodArray<z.ZodString>;
|
|
524
|
+
ocspVals: z.ZodArray<z.ZodString>;
|
|
525
|
+
}, z.core.$strip>;
|
|
526
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
527
|
+
arcTst: z.ZodObject<{
|
|
528
|
+
tstTokens: z.ZodArray<z.ZodObject<{
|
|
529
|
+
val: z.ZodString;
|
|
530
|
+
}, z.core.$strip>>;
|
|
531
|
+
canonAlg: z.ZodOptional<z.ZodString>;
|
|
532
|
+
}, z.core.$strip>;
|
|
533
|
+
}, z.core.$strip>], null>]>>;
|
|
534
|
+
disclosures: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
535
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
536
|
+
kb_jwt: z.ZodOptional<z.ZodString>;
|
|
537
|
+
}, z.core.$loose>>;
|
|
538
|
+
}, z.core.$strip>;
|
|
539
|
+
/**
|
|
540
|
+
* Compact JWS representation.
|
|
541
|
+
*/
|
|
542
|
+
declare const CompactJWSSchema: z.ZodObject<{
|
|
543
|
+
protected: z.ZodString;
|
|
544
|
+
payload: z.ZodString;
|
|
545
|
+
signature: z.ZodString;
|
|
546
|
+
}, z.core.$strip>;
|
|
547
|
+
/**
|
|
548
|
+
* Sign options for JAdES signing.
|
|
549
|
+
*/
|
|
550
|
+
declare const SignOptionsSchema: z.ZodObject<{
|
|
551
|
+
alg: z.ZodEnum<{
|
|
552
|
+
ES256: "ES256";
|
|
553
|
+
ES384: "ES384";
|
|
554
|
+
ES512: "ES512";
|
|
555
|
+
RS256: "RS256";
|
|
556
|
+
RS384: "RS384";
|
|
557
|
+
RS512: "RS512";
|
|
558
|
+
PS256: "PS256";
|
|
559
|
+
PS384: "PS384";
|
|
560
|
+
PS512: "PS512";
|
|
561
|
+
}>;
|
|
562
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
563
|
+
certificates: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
564
|
+
}, z.core.$strip>;
|
|
565
|
+
//#endregion
|
|
566
|
+
//#region src/types.d.ts
|
|
567
|
+
/**
|
|
568
|
+
* Supported signature algorithms.
|
|
569
|
+
*/
|
|
570
|
+
type SignAlg = z.infer<typeof SignAlgSchema>;
|
|
571
|
+
/**
|
|
572
|
+
* X.509 Certificate Thumbprint with algorithm specification.
|
|
573
|
+
*/
|
|
574
|
+
type X5tO = z.infer<typeof X5tOSchema>;
|
|
575
|
+
/**
|
|
576
|
+
* Commitment reference as per ETSI TS 119 182-1 Section 5.2.5.
|
|
577
|
+
*/
|
|
578
|
+
interface CommitmentReference {
|
|
579
|
+
/** Commitment type identifier (OID or URI) */
|
|
580
|
+
commId: string | CommitmentOIDs;
|
|
581
|
+
/** Commitment qualifiers */
|
|
582
|
+
commQuals?: object[];
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Signature policy descriptor.
|
|
586
|
+
*/
|
|
587
|
+
type SignaturePolicy = z.infer<typeof SignaturePolicySchema>;
|
|
588
|
+
/**
|
|
589
|
+
* Signer identifier.
|
|
590
|
+
*/
|
|
591
|
+
type SignerIdentifier = z.infer<typeof SignerIdentifierSchema>;
|
|
592
|
+
/**
|
|
593
|
+
* Detached signature descriptor - ETSI TS 119 182-1 Section 5.2.8.
|
|
594
|
+
*/
|
|
595
|
+
type SigD = z.infer<typeof SigDSchema>;
|
|
596
|
+
/**
|
|
597
|
+
* JAdES Protected Header parameters as per ETSI TS 119 182-1.
|
|
598
|
+
*/
|
|
599
|
+
type ProtectedHeaderParams = z.infer<typeof ProtectedHeaderSchema>;
|
|
600
|
+
/**
|
|
601
|
+
* JAdES Unprotected Header parameters.
|
|
602
|
+
*/
|
|
603
|
+
type UnprotectedHeaderParams = z.infer<typeof UnprotectedHeaderSchema>;
|
|
604
|
+
/**
|
|
605
|
+
* ETSI Unsigned properties for different JAdES profiles.
|
|
606
|
+
*/
|
|
607
|
+
type EtsiU = z.infer<typeof EtsiUSchema>;
|
|
608
|
+
/**
|
|
609
|
+
* Signature timestamp container.
|
|
610
|
+
*/
|
|
611
|
+
type SigTst = z.infer<typeof SigTstSchema>;
|
|
612
|
+
/**
|
|
613
|
+
* Timestamp tokens container.
|
|
614
|
+
*/
|
|
615
|
+
type TstTokens = z.infer<typeof TstTokensSchema>;
|
|
616
|
+
/**
|
|
617
|
+
* X.509 certificate values for B-LT profile.
|
|
618
|
+
*/
|
|
619
|
+
type XVals = z.infer<typeof XValsSchema>;
|
|
620
|
+
/**
|
|
621
|
+
* Revocation values (CRL and OCSP) for B-LT profile.
|
|
622
|
+
*/
|
|
623
|
+
type RVals = z.infer<typeof RValsSchema>;
|
|
624
|
+
/**
|
|
625
|
+
* Archive timestamp for B-LTA profile.
|
|
626
|
+
*/
|
|
627
|
+
type ArcTst = z.infer<typeof ArcTstSchema>;
|
|
628
|
+
/**
|
|
629
|
+
* General JWS structure with multiple signatures.
|
|
630
|
+
*/
|
|
631
|
+
type GeneralJWS = z.infer<typeof GeneralJWSSchema>;
|
|
632
|
+
/**
|
|
633
|
+
* Compact JWS representation.
|
|
634
|
+
*/
|
|
635
|
+
type CompactJWS = z.infer<typeof CompactJWSSchema>;
|
|
636
|
+
/**
|
|
637
|
+
* Sign options for JAdES signing.
|
|
638
|
+
*/
|
|
639
|
+
type SignOptions = z.infer<typeof SignOptionsSchema> & {
|
|
640
|
+
/** Signer function */signer: (data: string) => Promise<string>;
|
|
641
|
+
};
|
|
642
|
+
/**
|
|
643
|
+
* Verify options for JAdES verification.
|
|
644
|
+
*/
|
|
645
|
+
interface VerifyOptions {
|
|
646
|
+
/** Verifier function */
|
|
647
|
+
verifier: (data: string, signature: string) => Promise<boolean>;
|
|
648
|
+
}
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region src/token.d.ts
|
|
651
|
+
/**
|
|
652
|
+
* JAdES Token class for creating conformant JAdES signatures.
|
|
653
|
+
*/
|
|
654
|
+
declare class Token<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
655
|
+
private protectedHeader;
|
|
656
|
+
private unprotectedHeader;
|
|
657
|
+
private readonly payload;
|
|
658
|
+
private encodedPayload;
|
|
659
|
+
private signature;
|
|
660
|
+
/**
|
|
661
|
+
* Create a new JAdES Token.
|
|
662
|
+
*
|
|
663
|
+
* @param payload - The payload to sign. If undefined, creates a detached signature.
|
|
664
|
+
*/
|
|
665
|
+
constructor(payload?: T);
|
|
666
|
+
/**
|
|
667
|
+
* Set the protected header parameters.
|
|
668
|
+
*
|
|
669
|
+
* @param header - Protected header parameters
|
|
670
|
+
* @returns this for method chaining
|
|
671
|
+
*/
|
|
672
|
+
setProtectedHeader(header: ProtectedHeaderParams): this;
|
|
673
|
+
/**
|
|
674
|
+
* Set the unprotected header parameters.
|
|
675
|
+
*
|
|
676
|
+
* @param header - Unprotected header parameters
|
|
677
|
+
* @returns this for method chaining
|
|
678
|
+
*/
|
|
679
|
+
setUnprotectedHeader(header: UnprotectedHeaderParams): this;
|
|
680
|
+
/**
|
|
681
|
+
* Set X.509 certificate chain (x5c header).
|
|
682
|
+
*
|
|
683
|
+
* ETSI TS 119 182-1 Section 5.1.8
|
|
684
|
+
*
|
|
685
|
+
* @param certs - Array of base64-encoded DER certificates
|
|
686
|
+
* @returns this for method chaining
|
|
687
|
+
*/
|
|
688
|
+
setX5c(certs: string[]): this;
|
|
689
|
+
/**
|
|
690
|
+
* Set X.509 certificate URL (x5u header).
|
|
691
|
+
*
|
|
692
|
+
* ETSI TS 119 182-1 Section 5.1.5
|
|
693
|
+
*
|
|
694
|
+
* @param uri - URI to certificate resource
|
|
695
|
+
* @returns this for method chaining
|
|
696
|
+
*/
|
|
697
|
+
setX5u(uri: string): this;
|
|
698
|
+
/**
|
|
699
|
+
* Set X.509 certificate SHA-256 thumbprint (x5t#S256 header).
|
|
700
|
+
*
|
|
701
|
+
* ETSI TS 119 182-1 Section 5.1.7
|
|
702
|
+
*
|
|
703
|
+
* @param thumbprint - Base64url-encoded SHA-256 thumbprint
|
|
704
|
+
* @returns this for method chaining
|
|
705
|
+
*/
|
|
706
|
+
setX5tS256(thumbprint: string): this;
|
|
707
|
+
/**
|
|
708
|
+
* Set X.509 certificate thumbprint with other algorithm (x5t#o header).
|
|
709
|
+
*
|
|
710
|
+
* ETSI TS 119 182-1 Section 5.2.2.2
|
|
711
|
+
*
|
|
712
|
+
* @param x5tO - X5tO object with algorithm and digest value
|
|
713
|
+
* @returns this for method chaining
|
|
714
|
+
*/
|
|
715
|
+
setX5tO(x5tO: X5tO): this;
|
|
716
|
+
/**
|
|
717
|
+
* Set signing time (sigT header).
|
|
718
|
+
*
|
|
719
|
+
* ETSI TS 119 182-1 Section 5.2.1
|
|
720
|
+
*
|
|
721
|
+
* @param time - ISO 8601 timestamp (defaults to current time)
|
|
722
|
+
* @returns this for method chaining
|
|
723
|
+
*/
|
|
724
|
+
setSigningTime(time?: string): this;
|
|
725
|
+
/**
|
|
726
|
+
* Set signedAt timestamp in protected header.
|
|
727
|
+
*
|
|
728
|
+
* @param sec - Unix timestamp in seconds (defaults to current time)
|
|
729
|
+
* @returns this for method chaining
|
|
730
|
+
*/
|
|
731
|
+
setSignedAt(sec?: number): this;
|
|
732
|
+
/**
|
|
733
|
+
* Set issued at timestamp (iat) in protected header.
|
|
734
|
+
*
|
|
735
|
+
* @param sec - Unix timestamp in seconds (defaults to current time)
|
|
736
|
+
* @returns this for method chaining
|
|
737
|
+
*/
|
|
738
|
+
setIssuedAt(sec?: number): this;
|
|
739
|
+
/**
|
|
740
|
+
* Set key ID (kid header).
|
|
741
|
+
*
|
|
742
|
+
* @param kid - Key identifier
|
|
743
|
+
* @returns this for method chaining
|
|
744
|
+
*/
|
|
745
|
+
setKid(kid: string): this;
|
|
746
|
+
/**
|
|
747
|
+
* Set content type (cty header).
|
|
748
|
+
*
|
|
749
|
+
* @param cty - Content type
|
|
750
|
+
* @returns this for method chaining
|
|
751
|
+
*/
|
|
752
|
+
setContentType(cty: string): this;
|
|
753
|
+
/**
|
|
754
|
+
* Set token type (typ header).
|
|
755
|
+
*
|
|
756
|
+
* @param typ - Token type
|
|
757
|
+
* @returns this for method chaining
|
|
758
|
+
*/
|
|
759
|
+
setType(typ: string): this;
|
|
760
|
+
/**
|
|
761
|
+
* Set b64 header parameter.
|
|
762
|
+
*
|
|
763
|
+
* ETSI TS 119 182-1 Section 5.1.10
|
|
764
|
+
* RFC 7797 Section 3
|
|
765
|
+
*
|
|
766
|
+
* @param b64 - If true (default), payload is base64url encoded. If false, payload is unencoded.
|
|
767
|
+
* @returns this for method chaining
|
|
768
|
+
*/
|
|
769
|
+
setB64(b64: boolean): this;
|
|
770
|
+
/**
|
|
771
|
+
* Configure detached signature mode.
|
|
772
|
+
*
|
|
773
|
+
* ETSI TS 119 182-1 Section 5.2.8
|
|
774
|
+
*
|
|
775
|
+
* @param sigD - Detached signature descriptor
|
|
776
|
+
* @returns this for method chaining
|
|
777
|
+
*/
|
|
778
|
+
setDetached(sigD: SigD): this;
|
|
779
|
+
/**
|
|
780
|
+
* Get the signing input (data to be signed).
|
|
781
|
+
*
|
|
782
|
+
* @returns The signing input string (header.payload)
|
|
783
|
+
*/
|
|
784
|
+
getSigningInput(): string;
|
|
785
|
+
/**
|
|
786
|
+
* Get the hash of the signing input for external signing.
|
|
787
|
+
*
|
|
788
|
+
* @param algorithm - Hash algorithm (defaults to algorithm from header)
|
|
789
|
+
* @returns Promise resolving to hash bytes
|
|
790
|
+
*/
|
|
791
|
+
getHash(algorithm?: string): Promise<Uint8Array>;
|
|
792
|
+
/**
|
|
793
|
+
* Set the signature (for external signing).
|
|
794
|
+
*
|
|
795
|
+
* @param signature - Base64url-encoded signature
|
|
796
|
+
* @returns this for method chaining
|
|
797
|
+
*/
|
|
798
|
+
setSignature(signature: string): this;
|
|
799
|
+
/**
|
|
800
|
+
* Sign the token using the provided signer function.
|
|
801
|
+
*
|
|
802
|
+
* @param signer - Async function that signs data and returns base64url signature
|
|
803
|
+
* @returns Promise resolving to this for method chaining
|
|
804
|
+
*/
|
|
805
|
+
sign(signer: (data: string) => Promise<string>): Promise<this>;
|
|
806
|
+
/**
|
|
807
|
+
* Export to compact JWS serialization.
|
|
808
|
+
*
|
|
809
|
+
* @returns Compact JWS string (header.payload.signature)
|
|
810
|
+
*/
|
|
811
|
+
toString(): string;
|
|
812
|
+
/**
|
|
813
|
+
* Export to General JWS JSON serialization.
|
|
814
|
+
*
|
|
815
|
+
* @returns GeneralJWS object
|
|
816
|
+
*/
|
|
817
|
+
toJSON(): GeneralJWS;
|
|
818
|
+
/**
|
|
819
|
+
* Export to flattened JWS JSON serialization.
|
|
820
|
+
*
|
|
821
|
+
* @returns Flattened JWS object
|
|
822
|
+
*/
|
|
823
|
+
toFlattenedJSON(): {
|
|
824
|
+
protected: string;
|
|
825
|
+
payload: string;
|
|
826
|
+
signature: string;
|
|
827
|
+
header?: UnprotectedHeaderParams;
|
|
828
|
+
};
|
|
829
|
+
/**
|
|
830
|
+
* Get the protected header object.
|
|
831
|
+
*/
|
|
832
|
+
getProtectedHeader(): ProtectedHeaderParams;
|
|
833
|
+
/**
|
|
834
|
+
* Get the unprotected header object.
|
|
835
|
+
*/
|
|
836
|
+
getUnprotectedHeader(): UnprotectedHeaderParams;
|
|
837
|
+
/**
|
|
838
|
+
* Get the payload.
|
|
839
|
+
*/
|
|
840
|
+
getPayload(): T | undefined;
|
|
841
|
+
private getEncodedProtectedHeader;
|
|
842
|
+
private buildFinalHeader;
|
|
843
|
+
private validateBeforeSign;
|
|
844
|
+
private getHashAlgorithm;
|
|
845
|
+
}
|
|
846
|
+
//#endregion
|
|
847
|
+
//#region src/verifier.d.ts
|
|
848
|
+
/**
|
|
849
|
+
* Result of JAdES signature verification.
|
|
850
|
+
*/
|
|
851
|
+
interface VerifyResult<T = unknown> {
|
|
852
|
+
/** Decoded protected header */
|
|
853
|
+
header: ProtectedHeaderParams;
|
|
854
|
+
/** Decoded payload */
|
|
855
|
+
payload: T;
|
|
856
|
+
/** Unprotected header (if present) */
|
|
857
|
+
unprotectedHeader?: UnprotectedHeaderParams;
|
|
858
|
+
/** Whether the signature is valid */
|
|
859
|
+
valid: boolean;
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Verify a JAdES signature in compact serialization.
|
|
863
|
+
*
|
|
864
|
+
* @param jws - Compact JWS string
|
|
865
|
+
* @param verifier - Async function that verifies signature
|
|
866
|
+
* @returns Promise resolving to verification result
|
|
867
|
+
*/
|
|
868
|
+
declare function verifyCompact<T = unknown>(jws: string, verifier: (data: string, signature: string) => Promise<boolean>): Promise<VerifyResult<T>>;
|
|
869
|
+
/**
|
|
870
|
+
* Verify a JAdES signature in General JWS JSON serialization.
|
|
871
|
+
*
|
|
872
|
+
* @param generalJws - General JWS object
|
|
873
|
+
* @param verifier - Async function that verifies signature
|
|
874
|
+
* @param signatureIndex - Index of signature to verify (default: 0)
|
|
875
|
+
* @returns Promise resolving to verification result
|
|
876
|
+
*/
|
|
877
|
+
declare function verifyGeneral<T = unknown>(generalJws: GeneralJWS, verifier: (data: string, signature: string) => Promise<boolean>, signatureIndex?: number): Promise<VerifyResult<T>>;
|
|
878
|
+
/**
|
|
879
|
+
* Verify a JAdES signature (auto-detects format).
|
|
880
|
+
*
|
|
881
|
+
* @param jws - JWS string or GeneralJWS object
|
|
882
|
+
* @param verifier - Async function that verifies signature
|
|
883
|
+
* @returns Promise resolving to verification result
|
|
884
|
+
*/
|
|
885
|
+
declare function verify<T = unknown>(jws: string | GeneralJWS, verifier: (data: string, signature: string) => Promise<boolean>): Promise<VerifyResult<T>>;
|
|
886
|
+
/**
|
|
887
|
+
* Decode a JWS without verifying the signature.
|
|
888
|
+
* Use this only for inspection - always verify before trusting the content.
|
|
889
|
+
*
|
|
890
|
+
* @param jws - JWS string or GeneralJWS object
|
|
891
|
+
* @returns Decoded header and payload
|
|
892
|
+
*/
|
|
893
|
+
declare function decode<T = unknown>(jws: string | GeneralJWS): {
|
|
894
|
+
header: ProtectedHeaderParams;
|
|
895
|
+
payload: T;
|
|
896
|
+
unprotectedHeader?: UnprotectedHeaderParams;
|
|
897
|
+
};
|
|
898
|
+
//#endregion
|
|
899
|
+
//#region src/utils.d.ts
|
|
900
|
+
/**
|
|
901
|
+
* Parse PEM-encoded certificate chain and return base64 DER strings.
|
|
902
|
+
*
|
|
903
|
+
* @param pem - One or more PEM-encoded certificates
|
|
904
|
+
* @returns Array of base64-encoded DER certificate strings
|
|
905
|
+
*/
|
|
906
|
+
declare function parseCerts(pem: string): string[];
|
|
907
|
+
/**
|
|
908
|
+
* Generate x5c header value from PEM certificates.
|
|
909
|
+
* The certificates are converted to base64-encoded DER format.
|
|
910
|
+
*
|
|
911
|
+
* ETSI TS 119 182-1 Section 5.1.8
|
|
912
|
+
*
|
|
913
|
+
* @param certs - PEM-encoded certificate(s) or array of base64 DER certs
|
|
914
|
+
* @returns Array of base64-encoded DER certificate strings
|
|
915
|
+
*/
|
|
916
|
+
declare function generateX5c(certs: string | string[]): string[];
|
|
917
|
+
/**
|
|
918
|
+
* Generate x5t#S256 header value (SHA-256 thumbprint of certificate).
|
|
919
|
+
*
|
|
920
|
+
* ETSI TS 119 182-1 Section 5.1.7
|
|
921
|
+
*
|
|
922
|
+
* @param certDer - Base64-encoded DER certificate
|
|
923
|
+
* @returns Base64url-encoded SHA-256 thumbprint
|
|
924
|
+
*/
|
|
925
|
+
declare function generateX5tS256(certDer: string): Promise<string>;
|
|
926
|
+
/**
|
|
927
|
+
* Generate x5t#o header value (certificate thumbprint with specified algorithm).
|
|
928
|
+
*
|
|
929
|
+
* ETSI TS 119 182-1 Section 5.2.2.2
|
|
930
|
+
*
|
|
931
|
+
* @param certDer - Base64-encoded DER certificate
|
|
932
|
+
* @param algorithm - Hash algorithm ('SHA-384' or 'SHA-512')
|
|
933
|
+
* @returns X5tO object with algorithm identifier and digest value
|
|
934
|
+
*/
|
|
935
|
+
declare function generateX5tO(certDer: string, algorithm?: 'SHA-384' | 'SHA-512'): Promise<X5tO>;
|
|
936
|
+
/**
|
|
937
|
+
* Generate sigX5ts header value (certificate chain thumbprints).
|
|
938
|
+
*
|
|
939
|
+
* ETSI TS 119 182-1 Section 5.2.2.3
|
|
940
|
+
*
|
|
941
|
+
* @param certsDer - Array of base64-encoded DER certificates
|
|
942
|
+
* @param algorithm - Hash algorithm ('SHA-384' or 'SHA-512')
|
|
943
|
+
* @returns Array of X5tO objects
|
|
944
|
+
*/
|
|
945
|
+
declare function generateSigX5ts(certsDer: string[], algorithm?: 'SHA-384' | 'SHA-512'): Promise<X5tO[]>;
|
|
946
|
+
/**
|
|
947
|
+
* Generate a JAdES-compliant kid from X.509 certificate.
|
|
948
|
+
*
|
|
949
|
+
* According to ETSI TS 119 182-1 Section 5.1.4, the kid should be
|
|
950
|
+
* the base64 encoding of DER-encoded IssuerSerial sequence.
|
|
951
|
+
*
|
|
952
|
+
* This implementation generates a SHA-256 thumbprint of the certificate
|
|
953
|
+
* as a simpler approach that uniquely identifies the certificate.
|
|
954
|
+
*
|
|
955
|
+
* @param certDer - Base64-encoded DER certificate
|
|
956
|
+
* @returns Base64url-encoded key identifier
|
|
957
|
+
*/
|
|
958
|
+
declare function generateKid(certDer: string): Promise<string>;
|
|
959
|
+
/**
|
|
960
|
+
* Encode an object as a base64url JSON string.
|
|
961
|
+
*
|
|
962
|
+
* @param obj - Object to encode
|
|
963
|
+
* @returns Base64url-encoded JSON string
|
|
964
|
+
*/
|
|
965
|
+
declare function encodeJSON(obj: object): string;
|
|
966
|
+
/**
|
|
967
|
+
* Decode a base64url JSON string to an object.
|
|
968
|
+
*
|
|
969
|
+
* @param encoded - Base64url-encoded JSON string
|
|
970
|
+
* @returns Decoded object
|
|
971
|
+
*/
|
|
972
|
+
declare function decodeJSON<T = unknown>(encoded: string): T;
|
|
973
|
+
/**
|
|
974
|
+
* Get current ISO 8601 timestamp for sigT header.
|
|
975
|
+
*
|
|
976
|
+
* @returns ISO 8601 timestamp string
|
|
977
|
+
*/
|
|
978
|
+
declare function getSigningTime(): string;
|
|
979
|
+
/**
|
|
980
|
+
* Validate that the protected header has at least one certificate header.
|
|
981
|
+
* As per ETSI TS 119 182-1 Section 5.1.7, a JAdES signature shall have
|
|
982
|
+
* at least one of: x5t#S256, x5c, x5t#o, sigX5ts.
|
|
983
|
+
*
|
|
984
|
+
* @param header - Protected header object
|
|
985
|
+
* @returns true if valid
|
|
986
|
+
* @throws JAdESException if no certificate header is present
|
|
987
|
+
*/
|
|
988
|
+
declare function validateCertificateHeaders(header: Record<string, unknown>): boolean;
|
|
989
|
+
//#endregion
|
|
990
|
+
//#region src/jades-exception.d.ts
|
|
991
|
+
/**
|
|
992
|
+
* JAdES Exception
|
|
993
|
+
*
|
|
994
|
+
* Custom exception for JAdES-related errors.
|
|
995
|
+
*/
|
|
996
|
+
declare class JAdESException extends Error {
|
|
997
|
+
constructor(message: string);
|
|
998
|
+
}
|
|
999
|
+
//#endregion
|
|
1000
|
+
export { ALGORITHMS, type ArcTst, ArcTstSchema, CRITICAL_PARAMETERS, CommitmentOIDs, type CommitmentReference, type CompactJWS, CompactJWSSchema, DETACHED_MECHANISM_IDS, type EtsiU, EtsiUSchema, FlattenedJWSSchema, type GeneralJWS, GeneralJWSSchema, JAdESException, JAdESProfile, ProtectedHeaderForSigningSchema, type ProtectedHeaderParams, ProtectedHeaderSchema, type RVals, RValsSchema, type SigD, SigDSchema, type SigTst, SigTstSchema, type SignAlg, SignAlgSchema, type SignOptions, SignOptionsSchema, type SignaturePolicy, SignaturePolicySchema, type SignerIdentifier, SignerIdentifierSchema, Token, type TstTokens, TstTokensSchema, type UnprotectedHeaderParams, UnprotectedHeaderSchema, type VerifyOptions, type VerifyResult, type X5tO, X5tOSchema, type XVals, XValsSchema, decode, decodeJSON, encodeJSON, generateKid, generateSigX5ts, generateX5c, generateX5tO, generateX5tS256, getSigningTime, parseCerts, validateCertificateHeaders, verify, verifyCompact, verifyGeneral };
|
|
1001
|
+
//# sourceMappingURL=index.d.mts.map
|