XAdES-EPES allows for more complex signing policies. When using SignedXml.Sign, you can provide a policy object in the options.
The policy object supports:
hash: The hash algorithm name.identifier: An object with qualifier (e.g., "OIDAsURI") and value.qualifiers: An array of qualifier objects, such as noticeRef which contains organization and noticeNumbers.
Example configuration for policy:
policy: {
hash: "SHA-256",
identifier: {
qualifier: "OIDAsURI",
value: "qualifier.uri",
},
qualifiers: [
{
noticeRef: {
organization: "PeculiarVentures",
noticeNumbers: [1, 2, 3, 4, 5]
}
}
]
}
// ... setup engine and keys ...
var xadesXml = new xadesjs.SignedXml();
const signature = await xadesXml.Sign(
alg,
key,
xml,
{
references: [{ hash, transforms: ["c14n", "enveloped"] }],
policy: {
hash,
identifier: { qualifier: "OIDAsURI", value: "qualifier.uri" },
qualifiers: [{ noticeRef: { organization: "PeculiarVentures", noticeNumbers: [1, 2, 3, 4, 5] } }]
},
productionPlace: { country: "Russia", state: "Marij El", city: "Yoshkar-Ola", code: "424000" },
signingCertificate: x509
}
);
// Append signature to original XML
xml.documentElement.appendChild(signature.GetXml());