@@ -245,26 +245,25 @@ export class SignedXml {
245
245
* @returns `true` if the signature is valid
246
246
* @throws Error if no key info resolver is provided.
247
247
*/
248
- checkSignature ( xml : string ) : boolean ;
248
+ checkSignature ( xml : Document | string ) : boolean ;
249
249
/**
250
250
* Validates the signature of the provided XML document synchronously using the configured key info provider.
251
251
*
252
252
* @param xml The XML document containing the signature to be validated.
253
253
* @param callback Callback function to handle the validation result asynchronously.
254
254
* @throws Error if the last parameter is provided and is not a function, or if no key info resolver is provided.
255
255
*/
256
- checkSignature ( xml : string , callback : ( error : Error | null , isValid ?: boolean ) => void ) : void ;
256
+ checkSignature ( xml : Document | string , callback : ( error : Error | null , isValid ?: boolean ) => void ) : void ;
257
257
checkSignature (
258
- xml : string ,
258
+ xml : Document | string ,
259
259
callback ?: ( error : Error | null , isValid ?: boolean ) => void ,
260
260
) : unknown {
261
261
if ( callback != null && typeof callback !== "function" ) {
262
262
throw new Error ( "Last parameter must be a callback function" ) ;
263
263
}
264
264
265
- this . signedXml = xml ;
266
-
267
- const doc = new xmldom . DOMParser ( ) . parseFromString ( xml ) ;
265
+ const doc = typeof xml === "string" ? new xmldom . DOMParser ( ) . parseFromString ( xml ) : xml ;
266
+ this . signedXml = doc . toString ( ) ;
268
267
269
268
// Reset the references as only references from our re-parsed signedInfo node can be trusted
270
269
this . references = [ ] ;
@@ -347,7 +346,7 @@ export class SignedXml {
347
346
348
347
// Check the signature verification to know whether to reset signature value or not.
349
348
const sigRes = signer . verifySignature ( unverifiedSignedInfoCanon , key , this . signatureValue ) ;
350
- if ( sigRes === true ) {
349
+ if ( sigRes ) {
351
350
if ( callback ) {
352
351
callback ( null , true ) ;
353
352
} else {
0 commit comments