@@ -24,9 +24,13 @@ function validateStandardExample(signedXml) {
2424
2525 // Create a validator with configuration
2626 const validator = new XmlDSigValidator ( {
27- publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
27+ keySelector : {
28+ publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
29+ } ,
2830 throwOnError : false , // Return errors in result instead of throwing
29- maxTransforms : 5 , // Allow up to 5 transforms per reference
31+ security : {
32+ maxTransforms : 5 , // Allow up to 5 transforms per reference
33+ } ,
3034 } ) ;
3135
3236 try {
@@ -55,10 +59,14 @@ function validateWithCustomIdAttributesExample(signedXml) {
5559
5660 // Create a validator with custom ID attributes
5761 const validator = new XmlDSigValidator ( {
58- publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
62+ keySelector : {
63+ publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
64+ } ,
5965 idAttributeQNames : [ "customId" , "id" , "Id" ] , // Same order as used in signing
6066 throwOnError : false ,
61- maxTransforms : 3 ,
67+ security : {
68+ maxTransforms : 3 ,
69+ } ,
6270 } ) ;
6371
6472 try {
@@ -80,13 +88,17 @@ function validateWSSecurityModeExample(signedXml) {
8088
8189 // Create a validator with WS-Security mode
8290 const validator = new XmlDSigValidator ( {
83- publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
91+ keySelector : {
92+ publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
93+ } ,
8494 idAttributeQNames : [ "wsu:Id" ] ,
8595 namespaceMap : {
8696 wsu : "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" ,
8797 } ,
8898 throwOnError : false ,
89- maxTransforms : 4 ,
99+ security : {
100+ maxTransforms : 4 ,
101+ } ,
90102 implicitTransforms : [ Algorithms . transform . EXCLUSIVE_C14N ] , // Default transforms
91103 } ) ;
92104
@@ -112,14 +124,18 @@ function validateWithKeyInfoCertExample(signedXml) {
112124
113125 // Create a validator with getCertFromKeyInfo function
114126 const validator = new XmlDSigValidator ( {
115- getCertFromKeyInfo : ( keyInfo ) => {
116- console . log ( "Extracting certificate from KeyInfo..." ) ;
117- // In a real scenario, you would extract the certificate from KeyInfo
118- // For this example, we'll just return the test certificate
119- return fs . readFileSync ( "./test/static/client_public.pem" , "utf8" ) ;
127+ keySelector : {
128+ getCertFromKeyInfo : ( keyInfo ) => {
129+ console . log ( "Extracting certificate from KeyInfo..." ) ;
130+ // In a real scenario, you would extract the certificate from KeyInfo
131+ // For this example, we'll just return the test certificate
132+ return fs . readFileSync ( "./test/static/client_public.pem" , "utf8" ) ;
133+ } ,
120134 } ,
121135 throwOnError : false ,
122- maxTransforms : 6 ,
136+ security : {
137+ maxTransforms : 6 ,
138+ } ,
123139 } ) ;
124140
125141 try {
@@ -142,7 +158,9 @@ function validateWithCertificateOverrideExample(signedXml) {
142158 // Create a validator with a specific certificate
143159 const specificCert = fs . readFileSync ( "./test/static/client_public.pem" ) ;
144160 const validator = new XmlDSigValidator ( {
145- publicCert : specificCert ,
161+ keySelector : {
162+ publicCert : specificCert ,
163+ } ,
146164 throwOnError : false ,
147165 } ) ;
148166
@@ -164,7 +182,9 @@ function validateReusableExample(signedXml) {
164182 console . log ( "\n=== Reusable Validator Example ===" ) ;
165183
166184 const validator = new XmlDSigValidator ( {
167- publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
185+ keySelector : {
186+ publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
187+ } ,
168188 throwOnError : false ,
169189 } ) ;
170190
@@ -195,7 +215,9 @@ function validateMultipleSignaturesExample() {
195215 const signedTwice = multipleSignaturesExample ( ) ;
196216
197217 const validator = new XmlDSigValidator ( {
198- publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
218+ keySelector : {
219+ publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
220+ } ,
199221 } ) ;
200222
201223 // This will fail because multiple signatures are present
@@ -220,7 +242,9 @@ function validateErrorHandlingExample() {
220242 console . log ( "\n=== Error Handling Example ===" ) ;
221243
222244 const validator = new XmlDSigValidator ( {
223- publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
245+ keySelector : {
246+ publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
247+ } ,
224248 throwOnError : false , // Don't throw, return errors in result
225249 } ) ;
226250
@@ -240,7 +264,9 @@ function validateErrorHandlingExample() {
240264
241265 // Test with throwOnError: true
242266 const throwingValidator = new XmlDSigValidator ( {
243- publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
267+ keySelector : {
268+ publicCert : fs . readFileSync ( "./test/static/client_public.pem" ) ,
269+ } ,
244270 throwOnError : true ,
245271 } ) ;
246272
0 commit comments