@embedpdf/core-signature 3.0.0-next.13 → 3.0.0-next.15
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/dist/engine-BPmX1KyF.cjs +108 -0
- package/dist/engine-BPmX1KyF.cjs.map +1 -0
- package/dist/engine-C7lxkbZP.js +53 -0
- package/dist/engine-C7lxkbZP.js.map +1 -0
- package/dist/index.cjs +380 -288
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -19
- package/dist/index.d.ts +50 -19
- package/dist/index.js +337 -223
- package/dist/index.js.map +1 -1
- package/dist/oids-BUfXTCCm.cjs +87 -0
- package/dist/oids-BUfXTCCm.cjs.map +1 -0
- package/dist/oids-BhZXI2ZX.js +58 -0
- package/dist/oids-BhZXI2ZX.js.map +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ interface ParsedCmsInternal {
|
|
|
31
31
|
certificates: pkijs.Certificate[];
|
|
32
32
|
/** DER of the signing-certificate-v2 attribute's first certHash, when present. */
|
|
33
33
|
essCertHash: Uint8Array | null;
|
|
34
|
+
/** A timestamp token's encapsulated TSTInfo (`content: 'tst-info'`); null for a detached CMS. */
|
|
35
|
+
eContent: Uint8Array | null;
|
|
34
36
|
}
|
|
35
37
|
/** Parse a detached CMS SignedData with exactly one signer. Throws `CmsError`. */
|
|
36
38
|
declare function parseDetachedCms(cms: Uint8Array): ParsedCms;
|
|
@@ -81,6 +83,11 @@ interface BuildDetachedCmsInput {
|
|
|
81
83
|
declare function buildDetachedCms(input: BuildDetachedCmsInput): Promise<Uint8Array>;
|
|
82
84
|
//#endregion
|
|
83
85
|
//#region src/gate.d.ts
|
|
86
|
+
/**
|
|
87
|
+
* The shape the CMS must have: a PDF signature's (`pkcs7`, `cades-b`), or a
|
|
88
|
+
* document timestamp's RFC 3161 token (`timestamp`).
|
|
89
|
+
*/
|
|
90
|
+
type CompletionProfile = SignatureProfile | 'timestamp';
|
|
84
91
|
type CompletionRefusal = 'malformed' | 'too-large' | 'algorithm-mismatch' | 'digest-mismatch' | 'signature-invalid' | 'profile-violation';
|
|
85
92
|
type CompletionGate = {
|
|
86
93
|
ok: true;
|
|
@@ -100,7 +107,7 @@ type CompletionGate = {
|
|
|
100
107
|
declare function verifyForCompletion(input: {
|
|
101
108
|
cms: Uint8Array;
|
|
102
109
|
prepared: SignaturePrepared;
|
|
103
|
-
profile:
|
|
110
|
+
profile: CompletionProfile;
|
|
104
111
|
}): Promise<CompletionGate>;
|
|
105
112
|
//#endregion
|
|
106
113
|
//#region src/trust.d.ts
|
|
@@ -144,26 +151,36 @@ declare function validateChain(cms: Uint8Array | ParsedCmsInternal, trust: Trust
|
|
|
144
151
|
/** A service that turns a digest into a finished detached CMS (most hosted signing APIs). */
|
|
145
152
|
interface CmsSigner {
|
|
146
153
|
readonly kind: 'cms';
|
|
154
|
+
/**
|
|
155
|
+
* The CMS for a digest: a detached signature, or for `'ETSI.RFC3161'` (a
|
|
156
|
+
* document timestamp) the RFC 3161 token a timestamp authority returns.
|
|
157
|
+
*/
|
|
147
158
|
sign(input: {
|
|
148
159
|
digest: Uint8Array;
|
|
149
160
|
algorithm: Exclude<DigestAlgorithm, 'sha1'>;
|
|
150
|
-
subFilter: SignatureSubFilter;
|
|
161
|
+
subFilter: SignatureSubFilter | 'ETSI.RFC3161';
|
|
151
162
|
}): Promise<Uint8Array>;
|
|
152
163
|
}
|
|
153
164
|
type SignerPort = CmsSigner | RawSigner;
|
|
154
|
-
|
|
155
|
-
|
|
165
|
+
/**
|
|
166
|
+
* What `prepare` takes, plus the key that signs the digest. For a document
|
|
167
|
+
* timestamp (`kind: 'timestamp'`) the key is a timestamp authority: a CMS
|
|
168
|
+
* key that returns an RFC 3161 token.
|
|
169
|
+
*/
|
|
170
|
+
type SignInput = SignaturePrepareInput & {
|
|
171
|
+
key: SignerPort;
|
|
156
172
|
};
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
173
|
+
/**
|
|
174
|
+
* The CMS shape a `/SubFilter` promises (`'timestamp'` for an RFC 3161
|
|
175
|
+
* token); `InvalidArg` for one this package doesn't know.
|
|
176
|
+
*/
|
|
161
177
|
declare function profileFor(subFilter: SignatureSubFilter): SignatureProfile;
|
|
178
|
+
declare function profileFor(subFilter: SignatureSubFilter | 'ETSI.RFC3161'): CompletionProfile;
|
|
162
179
|
/**
|
|
163
|
-
* Sign a field in one call: `prepare` on the engine, the
|
|
180
|
+
* Sign a field in one call: `prepare` on the engine, the key turns the
|
|
164
181
|
* digest into a CMS (or a raw signature this package wraps), the gate
|
|
165
182
|
* checks the CMS matches what was prepared, `complete` installs it. Any
|
|
166
|
-
* failure
|
|
183
|
+
* failure cancels the candidate and rethrows; the document is never left
|
|
167
184
|
* with a pending signing.
|
|
168
185
|
*/
|
|
169
186
|
declare function sign(doc: DocumentHandle, input: SignInput): Promise<SignatureCompleteResult>;
|
|
@@ -218,7 +235,7 @@ interface ValidateSignaturesOptions {
|
|
|
218
235
|
* Validate every signature of a document: integrity from the engine's
|
|
219
236
|
* bytes, cryptography from the CMS, trust from the caller's anchors.
|
|
220
237
|
*/
|
|
221
|
-
declare function validateSignatures(doc: DocumentHandle,
|
|
238
|
+
declare function validateSignatures(doc: DocumentHandle, options?: ValidateSignaturesOptions): Promise<SignatureVerdict[]>;
|
|
222
239
|
//#endregion
|
|
223
240
|
//#region src/signers/webcrypto.d.ts
|
|
224
241
|
/**
|
|
@@ -241,30 +258,44 @@ interface TestSigner extends RawSigner {
|
|
|
241
258
|
* self-signed certificate, never persisted. Trust it with
|
|
242
259
|
* `{ anchors: async () => [signer.certificate] }`.
|
|
243
260
|
*/
|
|
244
|
-
declare function createTestSigner(
|
|
261
|
+
declare function createTestSigner(options?: {
|
|
245
262
|
commonName?: string;
|
|
246
263
|
algorithm?: 'RSA-PKCS1-v1_5' | 'RSA-PSS' | 'ECDSA';
|
|
247
264
|
hash?: 'sha256' | 'sha384' | 'sha512';
|
|
248
265
|
}): Promise<TestSigner>;
|
|
266
|
+
interface TestTimestampAuthority extends CmsSigner {
|
|
267
|
+
/** DER of the authority's self-signed certificate. */
|
|
268
|
+
readonly certificate: Uint8Array;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* A throwaway RFC 3161 timestamp authority for tests and demos: it stamps
|
|
272
|
+
* whatever digest it is given with the current time, signed by a fresh
|
|
273
|
+
* self-signed key. The key for `sign(doc, { kind: 'timestamp', key })`;
|
|
274
|
+
* never use it to stamp a real document.
|
|
275
|
+
*/
|
|
276
|
+
declare function createTestTimestampAuthority(options?: {
|
|
277
|
+
commonName?: string;
|
|
278
|
+
}): Promise<TestTimestampAuthority>;
|
|
249
279
|
/** A WebCrypto signing key pair; `extractable: false` keeps the private key inside the runtime for good. */
|
|
250
280
|
declare function generateSigningKeyPair(algorithm: 'RSA-PKCS1-v1_5' | 'RSA-PSS' | 'ECDSA', hash: 'sha256' | 'sha384' | 'sha512', extractable: boolean): Promise<CryptoKeyPair>;
|
|
251
281
|
//#endregion
|
|
252
282
|
//#region src/signers/remote.d.ts
|
|
253
283
|
/**
|
|
254
|
-
* A `CmsSigner` over the customer's own signing service
|
|
255
|
-
* digest goes out, a finished detached CMS
|
|
256
|
-
*
|
|
284
|
+
* A `CmsSigner` over the customer's own signing service, HSM or timestamp
|
|
285
|
+
* authority: the engine's digest goes out, a finished detached CMS (or, for
|
|
286
|
+
* `'ETSI.RFC3161'`, an RFC 3161 token) comes back. Nothing but the digest
|
|
287
|
+
* (and which hash and profile it is for) ever leaves the runtime.
|
|
257
288
|
*/
|
|
258
289
|
declare function remoteSigner(input: {
|
|
259
290
|
sign: (request: {
|
|
260
291
|
digest: Uint8Array;
|
|
261
292
|
algorithm: 'sha256' | 'sha384' | 'sha512';
|
|
262
|
-
subFilter: 'adbe.pkcs7.detached' | 'ETSI.CAdES.detached';
|
|
293
|
+
subFilter: 'adbe.pkcs7.detached' | 'ETSI.CAdES.detached' | 'ETSI.RFC3161';
|
|
263
294
|
}) => Promise<Uint8Array>;
|
|
264
295
|
}): CmsSigner;
|
|
265
296
|
//#endregion
|
|
266
297
|
//#region src/signers/personal.d.ts
|
|
267
|
-
/** What a personal signer keeps: a
|
|
298
|
+
/** What a personal signer keeps: a non-extractable private key and its self-signed certificate. */
|
|
268
299
|
interface PersonalKeyRecord {
|
|
269
300
|
privateKey: CryptoKey;
|
|
270
301
|
certificate: Uint8Array;
|
|
@@ -302,7 +333,7 @@ declare function memoryKeyStore(): PersonalKeyStore;
|
|
|
302
333
|
* itself (structured clone), so the key survives reloads without ever
|
|
303
334
|
* existing as bytes.
|
|
304
335
|
*/
|
|
305
|
-
declare function indexedDbKeyStore(dbName: string,
|
|
336
|
+
declare function indexedDbKeyStore(dbName: string, options?: {
|
|
306
337
|
storeName?: string;
|
|
307
338
|
}): PersonalKeyStore;
|
|
308
339
|
//#endregion
|
|
@@ -324,5 +355,5 @@ declare function selfSignedCertificate(input: {
|
|
|
324
355
|
/** The subject common name of a DER certificate, or null when it has none. */
|
|
325
356
|
declare function certificateCommonName(der: Uint8Array): string | null;
|
|
326
357
|
//#endregion
|
|
327
|
-
export { type BuildDetachedCmsInput, CmsError, type CmsSigner, type CompletionGate, type CompletionRefusal, type CryptographyVerdict, type IntegrityVerdict, type ModificationsVerdict, type ParsedCms, type PersonalKeyRecord, type PersonalKeyStore, type PersonalSigner, type RawSignatureAlgorithm, type RawSigner, type SignInput, type SignatureProfile, type SignatureVerdict, type SignerPort,
|
|
358
|
+
export { type BuildDetachedCmsInput, CmsError, type CmsSigner, type CompletionGate, type CompletionProfile, type CompletionRefusal, type CryptographyVerdict, type IntegrityVerdict, type ModificationsVerdict, type ParsedCms, type PersonalKeyRecord, type PersonalKeyStore, type PersonalSigner, type RawSignatureAlgorithm, type RawSigner, type SignInput, type SignatureProfile, type SignatureVerdict, type SignerPort, type TestSigner, type TestTimestampAuthority, type TrustPort, type TrustStatus, type TrustVerdict, type ValidateSignaturesOptions, type ValidationTime, buildDetachedCms, certificateCommonName, createTestSigner, createTestTimestampAuthority, generateSigningKeyPair, indexedDbKeyStore, memoryKeyStore, parseDetachedCms, personalSigner, profileFor, remoteSigner, selfSignedCertificate, sign, validateChain, validateSignatures, verifyCmsSignature, verifyForCompletion, webCryptoSigner };
|
|
328
359
|
//# sourceMappingURL=index.d.ts.map
|