@owf/eudi-tl 0.4.0-alpha-20260901082001

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/index.mjs ADDED
@@ -0,0 +1,732 @@
1
+ import { base64, compareBytes, hexEncode } from "@owf/identity-common";
2
+ import { SubjectKeyIdentifierExtension, X509Certificate } from "@peculiar/x509";
3
+ import { DOMParser, XMLSerializer } from "@xmldom/xmldom";
4
+ import { z } from "zod";
5
+ import * as xadesjs from "xadesjs";
6
+ import * as xpath from "xpath";
7
+ //#region src/constants.ts
8
+ /**
9
+ * Well-known ETSI TS 119 612 URIs.
10
+ *
11
+ * These are the standard values used by eIDAS national trusted lists. Profiled
12
+ * lists may use their own profile-specific URIs (validated via a caller-supplied
13
+ * {@link ProfileRule}); this library's parser is agnostic to both.
14
+ */
15
+ /** Standard `TSLType` values (TS 119 612 clause 5.3.3). */
16
+ const TSLType = {
17
+ EUgeneric: "http://uri.etsi.org/TrstSvc/TrustedList/TSLType/EUgeneric",
18
+ EUlistofthelists: "http://uri.etsi.org/TrstSvc/TrustedList/TSLType/EUlistofthelists"
19
+ };
20
+ /** Standard `ServiceStatus` values (TS 119 612 clause 5.5.4). */
21
+ const ServiceStatus = {
22
+ Granted: "http://uri.etsi.org/TrstSvc/TrustedList/Svcstatus/granted",
23
+ Withdrawn: "http://uri.etsi.org/TrstSvc/TrustedList/Svcstatus/withdrawn",
24
+ UnderSupervision: "http://uri.etsi.org/TrstSvc/TrustedList/Svcstatus/undersupervision",
25
+ SupervisionCeased: "http://uri.etsi.org/TrstSvc/TrustedList/Svcstatus/supervisionceased",
26
+ SupervisionInCessation: "http://uri.etsi.org/TrstSvc/TrustedList/Svcstatus/supervisionincessation",
27
+ Accredited: "http://uri.etsi.org/TrstSvc/TrustedList/Svcstatus/accredited",
28
+ AccreditationCeased: "http://uri.etsi.org/TrstSvc/TrustedList/Svcstatus/accreditationceased",
29
+ AccreditationRevoked: "http://uri.etsi.org/TrstSvc/TrustedList/Svcstatus/accreditationrevoked",
30
+ SetByNationalLaw: "http://uri.etsi.org/TrstSvc/TrustedList/Svcstatus/setbynationallaw",
31
+ RecognisedAtNationalLevel: "http://uri.etsi.org/TrstSvc/TrustedList/Svcstatus/recognisedatnationallevel",
32
+ DeprecatedAtNationalLevel: "http://uri.etsi.org/TrstSvc/TrustedList/Svcstatus/deprecatedatnationallevel"
33
+ };
34
+ /**
35
+ * Service statuses that denote a currently active / trustworthy service under
36
+ * TS 119 612. Use as the `serviceStatus` filter when extracting trust anchors
37
+ * from a standard eIDAS list; withdrawn/ceased services are excluded.
38
+ */
39
+ const ACTIVE_SERVICE_STATUSES = [
40
+ ServiceStatus.Granted,
41
+ ServiceStatus.UnderSupervision,
42
+ ServiceStatus.Accredited,
43
+ ServiceStatus.SetByNationalLaw,
44
+ ServiceStatus.RecognisedAtNationalLevel
45
+ ];
46
+ /** Common standard `ServiceTypeIdentifier` values (TS 119 612 Annex D). */
47
+ const ServiceType = {
48
+ /** Qualified certificate CA. */
49
+ CA_QC: "http://uri.etsi.org/TrstSvc/Svctype/CA/QC",
50
+ /** Public key certificate CA. */
51
+ CA_PKC: "http://uri.etsi.org/TrstSvc/Svctype/CA/PKC",
52
+ /** Qualified timestamping authority. */
53
+ TSA_QTST: "http://uri.etsi.org/TrstSvc/Svctype/TSA/QTST",
54
+ /** Qualified electronic delivery service. */
55
+ EDS_Q: "http://uri.etsi.org/TrstSvc/Svctype/EDS/Q",
56
+ /** Qualified registered electronic mail delivery service. */
57
+ EDS_REM_Q: "http://uri.etsi.org/TrstSvc/Svctype/EDS/REM/Q",
58
+ /** Qualified preservation service for electronic signatures/seals. */
59
+ PSES_Q: "http://uri.etsi.org/TrstSvc/Svctype/PSES/Q",
60
+ /** Qualified validation service for qualified electronic signatures. */
61
+ QESValidation_Q: "http://uri.etsi.org/TrstSvc/Svctype/QESValidation/Q",
62
+ /** OCSP responder for qualified certificates. */
63
+ OCSP_QC: "http://uri.etsi.org/TrstSvc/Svctype/Certstatus/OCSP/QC"
64
+ };
65
+ //#endregion
66
+ //#region src/eu-lotl-anchors.ts
67
+ /**
68
+ * The signing certificates published by the LOTL identified in
69
+ * {@link EU_LOTL_ANCHORS_PROVENANCE}. Any of them may sign a future issue of the
70
+ * list, so the whole published set is pinned, not just the current signer.
71
+ */
72
+ const EU_LOTL_SIGNING_CERTIFICATES = [
73
+ {
74
+ certificate: "MIIIljCCBn6gAwIBAgIUMkdxaYjTAuT2WRKfmeup7zDClNgwDQYJKoZIhvcNAQENBQAwXzELMAkGA1UEBhMCUFQxKjAoBgNVBAoMIURpZ2l0YWxTaWduIENlcnRpZmljYWRvcmEgRGlnaXRhbDEkMCIGA1UEAwwbRElHSVRBTFNJR04gUVVBTElGSUVEIENBIEcxMB4XDTI1MTIxNzE0MzE1NFoXDTI5MTIxNzE0MzE1NFowggEMMQswCQYDVQQGEwJMVTFDMEEGA1UECww6Q2VydGlmaWNhdGUgUHJvZmlsZSAtIFF1YWxpZmllZCBDZXJ0aWZpY2F0ZSAtIE9yZ2FuaXphdGlvbjExMC8GA1UECwwoRGlyZWN0b3JhdGUtR2VuZXJhbCBmb3IgRGlnaXRhbCBTZXJ2aWNlczEjMCEGA1UEYQwaTEVJWEctMjU0OTAwWk5ZQTFGTFVROVUzOTMxHDAaBgNVBAoME0VVUk9QRUFOIENPTU1JU1NJT04xJDAiBgkqhkiG9w0BCQEWFUVVLVRSVVNUQGVjLmV1cm9wYS5ldTEcMBoGA1UEAwwTRVVST1BFQU4gQ09NTUlTU0lPTjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKJguyStfry/iDbqvGbthdtVqpIyQ3p04V5hVtzWWKERnp5zN4AU3E1ljqKzUFvEtUyzql6c30ntDIJS9LnbCqd7B+YVy+Ad/YXkSx1SNNcwrKMy9WiE/xxGBw3CgM4PI1Xe0wNtLEdV2Ds82ELVnE59vefFC1zN5gx7YLlI1Y433Lch7Koo7w0LGbjIYDaHVRmbT4n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CQYHBACORgEGAjBqBgYEAI5GAQUwYDAuFihodHRwczovL3FjYS1nMS5kaWdpdGFsc2lnbi5wdC9QRFNfZW4ucGRmEwJlbjAuFihodHRwczovL3FjYS1nMS5kaWdpdGFsc2lnbi5wdC9QRFNfcHQucGRmEwJwdDBLBgNVHR8ERDBCMECgPqA8hjpodHRwczovL3FjYS1nMS5kaWdpdGFsc2lnbi5wdC9ESUdJVEFMU0lHTlFVQUxJRklFRENBRzEuY3JsMB0GA1UdDgQWBBSHDNZJrZdGBhUl8nfHbH/C0pdKBTAOBgNVHQ8BAf8EBAMCBkAwDQYJKoZIhvcNAQENBQADggIBAJQhD5ZXFK6w/6ODzWs82K5E3JMqQBnHaMVXRI5mwsts3Y4h1pU0xTECqrRnn4IkwWLy5csHjJOO1RbXasI3s6LHV+WzVdebUVH92nsPs9c7msxTwohXweCX429nBVBY0h1JlpE41e/AaDHLOMBe3elrQF+3VUBnoFuTF+bDDROCw5B44ULYQ+yHvJg0LVygnhQb08l+YtRpQNTA/Q1Q9ALIuudEpL5vtAQVTBKPc0DyWGw1ElEFh++goqHAtCT76/8HOILjwC7gTNe3W7WGhT1y3ZzKfp4T3q+dpqo7+yJSHMEAjWArmuMwTF0rHZDCKVfxhKPaJaslcNww8Hwf6igaRYSbtajyWGD56ZLllRttks0yU0ZWVcPONQUbFpWRF8DU4+yVSSI5var0p2MiHzLqrrltSbZG+ykFr7Xz9rvpSKLzweRXELeuW/KcPL0qspUi/VWDZvqbun9sEoPhKG02ciNjpIKuB5L4A2vP3oH82GtTa+P5BnOmLLSDxKOHXFbFpTET7kirc3GLyxoppjwAfeV/a9Rqm+gdjpbrJuHnutj9xm2jAWThELxoNKmluSSf1uPsh3GrxIeH8gbmvKsOWG4CCU+MW+bLufFsx1ZRHzytphb6LNVHtgaJ7aUTuZHYBGI3SdZ+ogB/fjo9NM/unYnlfSRXesA8lJP+S5qt",
75
+ subject: "C=LU, OU=Certificate Profile - Qualified Certificate - Organization, OU=Directorate-General for Digital Services, 2.5.4.97=LEIXG-254900ZNYA1FLUQ9U393, O=EUROPEAN COMMISSION, E=EU-TRUST@ec.europa.eu, CN=EUROPEAN COMMISSION",
76
+ fingerprintSha256: "236103f03a8031ae8f47f9059bf8de38564cdbfebedde4a597d50f8980aa653b",
77
+ notAfter: "2029-12-17T14:31:54.000Z"
78
+ },
79
+ {
80
+ certificate: "MIIH9DCCBdygAwIBAgIUYymXhglnqt2gI4PHVh4juzinht8wDQYJKoZIhvcNAQENBQAwXzELMAkGA1UEBhMCUFQxKjAoBgNVBAoMIURpZ2l0YWxTaWduIENlcnRpZmljYWRvcmEgRGlnaXRhbDEkMCIGA1UEAwwbRElHSVRBTFNJR04gUVVBTElGSUVEIENBIEcxMB4XDTI0MDQyNjEyNDkyMloXDTI3MDQyNjEyNDkyMlowggFKMQswCQYDVQQGEwJHUjE9MDsGA1UECww0Q2VydGlmaWNhdGUgUHJvZmlsZSAtIFF1YWxpZmllZCBDZXJ0aWZpY2F0ZSAtIE1lbWJlcjEjMCEGA1UEYQwaTEVJWEctMjU0OTAwWk5ZQTFGTFVROVUzOTMxHDAaBgNVBAoME0VVUk9QRUFOIENPTU1JU1NJT04xKTAnBgNVBAsMIEVudGl0bGVtZW50IC0gRUMgU1RBVFVUT1JZIFNUQUZGMS0wKwYJKoZIhvcNAQkBFh5hcG9zdG9sb3MuYXBsYWRhc0BlYy5ldXJvcGEuZXUxEDAOBgNVBAQMB0FQTEFEQVMxEjAQBgNVBCoMCUFQT1NUT0xPUzEdMBsGA1UECwwUUmVtb3RlUVNDRE1hbmFnZW1lbnQxGjAYBgNVBAMMEUFQT1NUT0xPUyBBUExBREFTMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsILa9o3bgz0l/dR1R01MhItrd6BLkxakJxlqpnlc1hhT8R3uYGvSVwfsmjQei/YkbjMoNzakjo4voPhUIJBa907TJLGwZSghfkp0+vcg4yeCLodAQatG7iEsh5Fr5uZgwPpLXExil0234QRcw7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lbjAVBggrBgEFBQcLAjAJBgcEAIvsSQEBMBUGCCsGAQUFBwsCMAkGBwQAi+xJAQIwDQYJKoZIhvcNAQENBQADggIBALUt37pV7w5ZwRxBB5PdTGTC+XcWytkuyuRJlVu+hVD5yVC2E+4+EPB2mRUzkjeE2M/3iMpzdwaNHe2YU9lCkoUFtD7VLIEdilfGO0MnXde2BAQN1VAt0s8xLwr3DNATsrtYPbtkQ73WCNqQwuNlg4LCFXHHpzvsKzYmYz+hYgkA8daRZRJdnZx/eX05iYFtShbbz8VamNb+A1L/KmqSrt5iG8d9SLSSq9SbNrntxSLaYDJfOITjhW5KOwlXBJPA+sQDYPngHur1nLWUJg6QB8fo/YwMOTmyIciurp8QzktxfJU1wSZEpd/xZKoDWVDNjJa8p0RFbQs/l7DpP/s57p8PKcntDOvQkYCajpRFLKl/69gKdVkB6nOKHFQCTmAeCDapWsI9+jPCnriywN60ep+MMqedZ/lV8LecbJ/1E+kw6PhC6Rs4MlwmHHCe6BB/9oTK7SWW/CtIZh8ygtJ0+5JlDS/83b0F0JdnZUV2qhlZJlVOROcQljcWs7kYS8vWAqBbccAhYNpaaUh1rnKGqo2jpOo5HXhgSVHNRrC+CylNNDUGAhpgPsAD93ui6JQCjdlSzDkraWZA/GtmdpId0b7IR6HfRBs/QzeA4Rj7ChMMOFxDZPp2t6kEyPb1UOshC79fmoNRkBxmGKqMCPakQiiUoIg/BkLIUVYClIoQ8zsk",
81
+ subject: "C=GR, OU=Certificate Profile - Qualified Certificate - Member, 2.5.4.97=LEIXG-254900ZNYA1FLUQ9U393, O=EUROPEAN COMMISSION, OU=Entitlement - EC STATUTORY STAFF, E=apostolos.apladas@ec.europa.eu, SN=APLADAS, G=APOSTOLOS, OU=RemoteQSCDManagement, CN=APOSTOLOS APLADAS",
82
+ fingerprintSha256: "b63d416744e7098bf9ec2caa596a93bc2468e37f8284ba65ecc061711bcbaa18",
83
+ notAfter: "2027-04-26T12:49:22.000Z"
84
+ },
85
+ {
86
+ certificate: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V40vxgGEfSwgin6GUhHmzuRDPBQhUW4C7btUFMoAr05UT+v03d9RrnlA5bpKSlKaf2J3EGAfGR1DvvFJ+ZCFaVo+8rtcLpySS3f8ZPCqz3axaO3KeyK4LuJbdZqGArKIF0vNKGR94rr7Pq7OIIHJBuOW9LGQG0r5e8kb/KRLZBsPlHpgPVZc8M3EimqYmIg6hgPf0k+Mxhw5/IC4rikFsMTNa43yBeGrk2pvM8cIZoenmQMgf/1L0+A9Pwol+7CUQfe4Bpj0fr1Acnx/4oPnAKmMDKvXnx91fMW2b7Uen2y11TcijxYuXftq03bx8w/ms/giXYLGciDcwCF7XCXNnGuATW/GxPvOxOwu56ZDrm/oG3zfa4l/tF/S5swoFrzmTDIIM05UzHDUuQAln103BGfEYKo7vw4bNfouHfS28qGWbotUSNzHfOEqeC4LrdN7JmE8q0hZRXLFOIsPtG/S0rEkuoNl3znZPmk8oAy/xa1+3XnH1nJCVmTK0XQYaTPinAAEnDbTqUjD97zmUFEd+ecOctica4DFhQoHtUDYUOzKEKfKHVEG0ApI3dpHzcLiuLXIQl0DBvfy3wspy6HL3A==",
87
+ subject: "C=GR, OU=Certificate Profile - Qualified Certificate - Member, 2.5.4.97=LEIXG-254900ZNYA1FLUQ9U393, O=EUROPEAN COMMISSION, OU=Entitlement - EC STATUTORY STAFF, E=Ioanna.KALOGEROPOULOU@ec.europa.eu, SN=KALOGEROPOULOU, G=IOANNA, OU=RemoteQSCDManagement, CN=IOANNA KALOGEROPOULOU",
88
+ fingerprintSha256: "c0641c4f7d56c431b1c924742db7fce9c1eef7d7fd212113a2768486b3abcdc5",
89
+ notAfter: "2029-11-23T09:56:41.000Z"
90
+ },
91
+ {
92
+ certificate: "MIIG7zCCBNegAwIBAgIQEAAAAAAAnuXHXttK9Tyf2zANBgkqhkiG9w0BAQsFADBkMQswCQYDVQQGEwJCRTERMA8GA1UEBxMIQnJ1c3NlbHMxHDAaBgNVBAoTE0NlcnRpcG9zdCBOLlYuL1MuQS4xEzARBgNV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IpXLGaJXbzQGSTtyNEYrdENlh71I3OeYdw3xmzU2B3tbaWREOXtj2xjyW2tIv+vvHG6sloR1QkIkGMFfzsT7W5U6ILetv",
93
+ subject: "C=BE, CN=Patrick Kremer (Signature), SN=Kremer, G=Patrick Jean, 2.5.4.5=72020329970",
94
+ fingerprintSha256: "d2064fdd70f6982dcc516b86d9d5c56aea939417c624b2e478c0b29de54f8474",
95
+ notAfter: "2028-05-30T23:59:59.000Z"
96
+ },
97
+ {
98
+ certificate: "MIIICDCCBfCgAwIBAgIUSOnGJxOHWc5N+Nk12eZPPCwr7ZYwDQYJKoZIhvcNAQENBQAwXzELMAkGA1UEBhMCUFQxKjAoBgNVBAoMIURpZ2l0YWxTaWduIENlcnRpZmljYWRvcmEgRGlnaXRhbDEkMCIGA1UEAwwbRElHSVRBTFNJR04gUVVBTElGSUVEIENBIEcxMB4XDTI0MDUwNjEyNDUxNloXDTI3MDUwNjEyNDUxNlowggFZMQswCQYDVQQGEwJFUzE9MDsGA1UECww0Q2VydGlmaWNhdGUgUHJvZmlsZSAtIFF1YWxpZmllZCBDZXJ0aWZpY2F0ZSAtIE1lbWJlcjEjMCEGA1UEYQwaTEVJWEctMjU0OTAwWk5ZQTFGTFVROVUzOTMxHDAaBgNVBAoME0VVUk9QRUFOIENPTU1JU1NJT04xKTAnBgNVBAsMIEVudGl0bGVtZW50IC0gRUMgU1RBVFVUT1JZIFNUQUZGMTIwMAYJKoZIhvcNAQkBFiN2aWNlbnRlLmFuZHJldS1uYXZhcnJvQGVjLmV1cm9wYS5ldTEXMBUGA1UEBAwOQU5EUkVVIE5BVkFSUk8xEDAOBgNVBCoMB1ZJQ0VOVEUxHTAbBgNVBAsMFFJlbW90ZVFTQ0RNYW5hZ2VtZW50MR8wHQYDVQQDDBZWSUNFTlRFIEFORFJFVSBOQVZBUlJPMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAveJV7goW3mvqJq2kMT0cnrkFAnT/lyzbgaHVvd5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BzOi8vcWNhLWcxLmRpZ2l0YWxzaWduLnB0L1BEU19wdC5wZGYTAnB0MC4WKGh0dHBzOi8vcWNhLWcxLmRpZ2l0YWxzaWduLnB0L1BEU19lbi5wZGYTAmVuMBUGCCsGAQUFBwsCMAkGBwQAi+xJAQEwFQYIKwYBBQUHCwIwCQYHBACL7EkBAjANBgkqhkiG9w0BAQ0FAAOCAgEAHBjW4N8NKNCiJot414m/L76pB/15LKiGDi1/2V7MHe8u2GcplR1IjESrSEhhwUAW1hwDIK9xJrJ/hdDUMIQcKScSiJCqTCb0Yk39yj/gfOYaN/3fqw8Pjh9k++3Ox7KnvY3R/foFvGJlyiuqaai/JgBmc4qDBHSIDyo5gRw6v70osRPDR5sJs4Xh3FOJn9Y0JZPLF/skYtLrNVysL/4A4bbAxB2DcJ5MpoIegh/fnJ5s2BOVq2Xq8ADpeJoLFYbtlbP7NwsGgew2wKiDW963MlJL/Xa2AqcPVE/UnXFkIBCwZH+covxSEQH2iVcF8cEDHBiYHGERaSmL/uHK/F8soDO9VQwtKNxsiIKAWsQHTYcKfEgVuweyLj7TsCmh6T4pIHqaNDqWvrgEIo0ZwuBmfXVEd+JMSzSgIcJ2bPR2KNoJ14MO4FFYdAAnVlfdhipErsK6R23hlto7b3XKiMRUt9xrvPUjuEJdGI5hPm9CqGK1GxlRoKLewyX7A+OIcPMPu1KfuuUTUn+3hLJJZO5H9k4uVMJ/FOhwzc2VhRpyvNjfmFZksFvseFGvMl5EWIqp3JCo0ItkOBG59ulBwg/99Y0pT6LW9cviTzKIwDtHmQrIgYLa+lCYwWdGhIidXynvLpWiVRZJvYrPIGpzQCRcw9V2i8zT7nksj7QF9v88kto=",
99
+ subject: "C=ES, OU=Certificate Profile - Qualified Certificate - Member, 2.5.4.97=LEIXG-254900ZNYA1FLUQ9U393, O=EUROPEAN COMMISSION, OU=Entitlement - EC STATUTORY STAFF, E=vicente.andreu-navarro@ec.europa.eu, SN=ANDREU NAVARRO, G=VICENTE, OU=RemoteQSCDManagement, CN=VICENTE ANDREU NAVARRO",
100
+ fingerprintSha256: "df7e29360c34b2b8d6d5f40325c1d4d12c9922cecd33b7407674a74b2b3ca1e5",
101
+ notAfter: "2027-05-06T12:45:16.000Z"
102
+ },
103
+ {
104
+ certificate: "MIIIoDCCBoigAwIBAgIUc8IcSUtVEKAMMvHm9QWU05kXsPUwDQYJKoZIhvcNAQENBQAwXzELMAkGA1UEBhMCUFQxKjAoBgNVBAoMIURpZ2l0YWxTaWduIENlcnRpZmljYWRvcmEgRGlnaXRhbDEkMCIGA1UEAwwbRElHSVRBTFNJR04gUVVBTElGSUVEIENBIEcxMB4XDTIzMTExNzEwMTE0NloXDTI3MTExNzEwMTE0NlowggEVMQswCQYDVQQGEwJMVTFDMEEGA1UECww6Q2VydGlmaWNhdGUgUHJvZmlsZSAtIFF1YWxpZmllZCBDZXJ0aWZpY2F0ZSAtIE9yZ2FuaXphdGlvbjE5MDcGA1UECwwwRGlyZWN0b3JhdGUtR2VuZXJhbCBmb3IgRGlnaXRhbCBTZXJ2aWNlcyAoRElHSVQpMSMwIQYDVQRhDBpMRUlYRy0yNTQ5MDBaTllBMUZMVVE5VTM5MzEcMBoGA1UECgwTRVVST1BFQU4gQ09NTUlTU0lPTjElMCMGCSqGSIb3DQEJARYWZGlnaXQtZG1vQGVjLmV1cm9wYS5ldTEcMBoGA1UEAwwTRVVST1BFQU4gQ09NTUlTU0lPTjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKWYeBA9kYARElGnHoJRNpbby44G+TSJcgHI9QtyXlYjB234hSAYyJvW+gKvoownskrogfUP6GOmQgEFZX335Y0sBwfppVemEoe9H9Aj/cpT14IqdB05V4a88ASRfR0Va1xmQJrDsBZWqZHx0EEHBctIF5BjyTMAcQybha+4AOIotp3dF/7ZA3Cu4GYbN9BuQyyqfqrjMduDzzDjVwKC17aEsLev60C1FnIJ/FVEda3lJSGilD5JyUceTaRcot1rw6gjKrOVhwP/UHfevJ3JCsQsuA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MCZW4wLhYoaHR0cHM6Ly9xY2EtZzEuZGlnaXRhbHNpZ24ucHQvUERTX3B0LnBkZhMCcHQwSwYDVR0fBEQwQjBAoD6gPIY6aHR0cHM6Ly9xY2EtZzEuZGlnaXRhbHNpZ24ucHQvRElHSVRBTFNJR05RVUFMSUZJRURDQUcxLmNybDAdBgNVHQ4EFgQUlO5hwcl9/63issm59r+TIHeJSZwwDgYDVR0PAQH/BAQDAgZAMA0GCSqGSIb3DQEBDQUAA4ICAQCn8qjJhTe3SsD7cB8S8kDzt+CBnJJm7bOFc9t9IU6iKntVtjPU4T+cYiPk8TnT+/w7dBphRzjZCL1sDfSJGQ5JPBw+hBPuvzEqP4xVi5i4Jhg/GpYSaa2+dkFXlKe6Sd+ii/RnwBSnfqVfNZtasj7yX+oujGau5LSUPIkQxDrMie8KjsNtlkFjQDoioGAx8b0u6WyhAuqwEacCznft20Dim3sC7XJw8GHumrnW52rUzl4sbXoTBAt8F1zPCbEbjU0oc8SbFNPIChh+9sHUorEmHIlcg30LBHihkDCx4mK8J60Jybk57D4U2RO29VsJfDmnvNxfJZxfLHEJ2tkh+AMqlJXPDlvXQ+rZ1NmLHrbXkcHOlqR3F8BakTi2Mi5AZZfkfjZjkigEStN6Enaq6gwF7EsslqEKmhSQ8XlhxWSRqljK/cnEUw+NhrvR4WuKlvYmxlCLQj6q89Hh121aUGUhL2L2WCVBjVXqux7s4mvECDzrucl5ilaVT32HO3g8qNLGD5lum53U5v/Nv68ItyHH96unztwBebmgox8giVRdzPhmPrpSfbmeNNDKj1p9SCeOvd3P9jCUvChVvH2P2ZUjc24tWe+tzclsCJi7GbKr6kjHc1jFudjehflAbm1IZAYdDNrhXamnsRVsz7iSH20eygCArlwSQ//WIQZPFrRffg==",
105
+ subject: "C=LU, OU=Certificate Profile - Qualified Certificate - Organization, OU=Directorate-General for Digital Services (DIGIT), 2.5.4.97=LEIXG-254900ZNYA1FLUQ9U393, O=EUROPEAN COMMISSION, E=digit-dmo@ec.europa.eu, CN=EUROPEAN COMMISSION",
106
+ fingerprintSha256: "e0a620fbb6747362bb933ac44169d676a553444716cf5f31605f12a22b8396b1",
107
+ notAfter: "2027-11-17T10:11:46.000Z"
108
+ }
109
+ ];
110
+ /** Where this set came from, so the pin can be audited without re-running the script. */
111
+ const EU_LOTL_ANCHORS_PROVENANCE = {
112
+ /** The list the certificates were read from. */
113
+ source: "https://ec.europa.eu/tools/lotl/eu-lotl.xml",
114
+ /** The Official Journal act the LOTL itself references for its signers. */
115
+ officialJournal: "https://eur-lex.europa.eu/eli/C/2026/1944/oj",
116
+ /** `TSLSequenceNumber` of that list. */
117
+ tslSequenceNumber: 390,
118
+ /** `ListIssueDateTime` of that list. */
119
+ listIssueDateTime: "2026-08-03T13:16:38Z",
120
+ /** Earliest expiry in the set: refresh before this date. */
121
+ earliestNotAfter: "2027-04-26T12:49:22.000Z"
122
+ };
123
+ //#endregion
124
+ //#region src/trusted-list-exception.ts
125
+ /**
126
+ * Base exception for all trusted-list processing failures.
127
+ */
128
+ var TrustedListException = class extends Error {
129
+ constructor(message, options) {
130
+ super(message);
131
+ this.name = "TrustedListException";
132
+ this.cause = options?.cause;
133
+ }
134
+ };
135
+ /**
136
+ * The XML could not be parsed as an ETSI TS 119 612 `TrustServiceStatusList`.
137
+ */
138
+ var TrustedListParseException = class extends TrustedListException {
139
+ constructor(message, options) {
140
+ super(message, options);
141
+ this.name = "TrustedListParseException";
142
+ }
143
+ };
144
+ /**
145
+ * The trusted list's own XAdES/XMLDSig signature is missing, invalid, or does
146
+ * not match a configured trust anchor. Callers MUST treat this as fail-closed:
147
+ * a trusted list whose authenticity cannot be established must not be used to
148
+ * trust credentials.
149
+ */
150
+ var TrustedListSignatureException = class extends TrustedListException {
151
+ constructor(message, options) {
152
+ super(message, options);
153
+ this.name = "TrustedListSignatureException";
154
+ }
155
+ };
156
+ //#endregion
157
+ //#region src/types.ts
158
+ /**
159
+ * A service's digital identity (TS 119 612 `ServiceDigitalIdentity`): the
160
+ * `DigitalId` children (X509Certificate, X509SubjectName, X509SKI) that describe
161
+ * one entity are merged here. A standard list may identify a service by subject
162
+ * name and/or key identifier without embedding the full certificate.
163
+ */
164
+ const DigitalIdentitySchema = z.object({
165
+ /** base64-encoded DER of the certificate, when embedded (`X509Certificate`). */
166
+ certificate: z.string().optional(),
167
+ /** `X509SubjectName`, when present. */
168
+ subjectName: z.string().optional(),
169
+ /**
170
+ * Lowercase-hex SubjectKeyIdentifier — derived from the certificate when one
171
+ * is embedded, otherwise from the `X509SKI` element. This is the value a
172
+ * verifier sends to a wallet as an `aki` trusted authority (HAIP).
173
+ */
174
+ subjectKeyIdentifier: z.string().optional()
175
+ });
176
+ /** A past status entry for a service (`ServiceHistoryInstance`). */
177
+ const ServiceHistoryInstanceSchema = z.object({
178
+ serviceTypeIdentifier: z.string().optional(),
179
+ serviceStatus: z.string(),
180
+ statusStartingTime: z.string().optional()
181
+ });
182
+ /**
183
+ * A trust service (TSPService) entry: its type, status, digital identities,
184
+ * qualifiers, and status history.
185
+ */
186
+ const TrustedListServiceSchema = z.object({
187
+ /** `ServiceTypeIdentifier` URI. */
188
+ serviceTypeIdentifier: z.string(),
189
+ /** Current `ServiceStatus` URI. */
190
+ serviceStatus: z.string(),
191
+ /** Human-readable service name, if present. */
192
+ serviceName: z.string().optional(),
193
+ /** One entry per `ServiceDigitalIdentity`. */
194
+ digitalIdentities: z.array(DigitalIdentitySchema),
195
+ /** Qualifier URIs from `Qualifications/QualificationElement/Qualifiers`. */
196
+ qualifiers: z.array(z.string()).optional(),
197
+ /** Prior status entries from `ServiceHistory`. */
198
+ history: z.array(ServiceHistoryInstanceSchema).optional()
199
+ });
200
+ /** A Trust Service Provider (TSP) and the services it operates. */
201
+ const TrustServiceProviderSchema = z.object({
202
+ name: z.string().optional(),
203
+ services: z.array(TrustedListServiceSchema)
204
+ });
205
+ /** A pointer to another trusted list (`OtherTSLPointer`), e.g. the EU LOTL. */
206
+ const TrustedListPointerSchema = z.object({
207
+ /** `TSLLocation` URL. */
208
+ location: z.string(),
209
+ /** Pointed-to list `TSLType`, when advertised. */
210
+ tslType: z.string().optional(),
211
+ /** `SchemeTerritory` (country code), when advertised. */
212
+ schemeTerritory: z.string().optional(),
213
+ /**
214
+ * The pointer's `ServiceDigitalIdentities`: the certificates with which the
215
+ * pointed-to list is signed. This is how a list distributes the trust anchors
216
+ * of the lists it points to — the EU LOTL carries, for every national list,
217
+ * the certificate(s) of its scheme operator, so a verifier that trusts the
218
+ * LOTL does not need to pin each national list separately.
219
+ */
220
+ digitalIdentities: z.array(DigitalIdentitySchema).default([])
221
+ });
222
+ /** A parsed ETSI TS 119 612 Trusted List (`TrustServiceStatusList`). */
223
+ const TrustedListSchema = z.object({
224
+ /** `TSLType` URI. */
225
+ tslType: z.string().optional(),
226
+ /** `SchemeOperatorName` (English name when available). */
227
+ schemeOperatorName: z.string().optional(),
228
+ /** `TSLSequenceNumber`. */
229
+ sequenceNumber: z.number().optional(),
230
+ /** `ListIssueDateTime` (ISO 8601). */
231
+ listIssueDateTime: z.string().optional(),
232
+ /** `NextUpdate` (ISO 8601), when present. */
233
+ nextUpdate: z.string().optional(),
234
+ providers: z.array(TrustServiceProviderSchema),
235
+ /** `PointersToOtherTSL` entries (e.g. the EU LOTL). Not followed by v1. */
236
+ pointersToOtherLists: z.array(TrustedListPointerSchema).optional()
237
+ });
238
+ /**
239
+ * A flattened trust anchor: one digital identity with the service context it was
240
+ * published under. The normalized unit both certificate-chain validation and AKI
241
+ * emission consume — the ETSI TS 119 612 counterpart of a `@owf/eudi-lote`
242
+ * TrustedEntity service certificate.
243
+ */
244
+ const TrustAnchorSchema = z.object({
245
+ /** base64 DER certificate, when the identity embeds one. */
246
+ certificate: z.string().optional(),
247
+ subjectName: z.string().optional(),
248
+ subjectKeyIdentifier: z.string().optional(),
249
+ serviceTypeIdentifier: z.string(),
250
+ serviceStatus: z.string(),
251
+ providerName: z.string().optional()
252
+ });
253
+ //#endregion
254
+ //#region src/validate.ts
255
+ function fromZodError(error) {
256
+ return error.issues.map((issue) => ({
257
+ path: issue.path.map((p) => String(p)).join("."),
258
+ message: issue.message
259
+ }));
260
+ }
261
+ /**
262
+ * Structurally validate an object against the ETSI TS 119 612 trusted-list
263
+ * schema (the same zod-based approach `@owf/eudi-lote` uses for TS 119 602).
264
+ * For XML input, parse it first with `parseTrustedList` (XML → object), then
265
+ * validate the object here.
266
+ */
267
+ function validateTrustedList(value) {
268
+ const result = TrustedListSchema.safeParse(value);
269
+ return result.success ? {
270
+ valid: true,
271
+ errors: []
272
+ } : {
273
+ valid: false,
274
+ errors: fromZodError(result.error)
275
+ };
276
+ }
277
+ /**
278
+ * Structurally validate and return the typed trusted list, throwing
279
+ * {@link TrustedListParseException} when it does not conform to the schema.
280
+ */
281
+ function assertValidTrustedList(value) {
282
+ const result = TrustedListSchema.safeParse(value);
283
+ if (!result.success) throw new TrustedListParseException(`Invalid trusted list: ${fromZodError(result.error).map((e) => `${e.path}: ${e.message}`).join("; ")}`);
284
+ return result.data;
285
+ }
286
+ /**
287
+ * Compare ETSI URIs scheme-insensitively: deployed lists have published the
288
+ * same URI over both `http` and `https`. Internal helper, not part of the
289
+ * package's public API.
290
+ */
291
+ const stripScheme = (uri) => (uri ?? "").replace(/^https?:\/\//, "");
292
+ function profileErrors(trustedList, rule) {
293
+ const label = rule.name ?? "profile";
294
+ const errors = [];
295
+ if (stripScheme(trustedList.tslType) !== stripScheme(rule.tslType)) errors.push({
296
+ path: "tslType",
297
+ message: `[${label}] expected TSLType ${rule.tslType}, got ${trustedList.tslType ?? "none"}`
298
+ });
299
+ const allowedTypes = new Set(rule.serviceTypes.map(stripScheme));
300
+ const allowedStatuses = new Set(rule.serviceStatuses.map(stripScheme));
301
+ trustedList.providers.forEach((provider, pi) => {
302
+ provider.services.forEach((service, si) => {
303
+ if (!allowedTypes.has(stripScheme(service.serviceTypeIdentifier))) errors.push({
304
+ path: `providers.${pi}.services.${si}.serviceTypeIdentifier`,
305
+ message: `[${label}] unexpected service type ${service.serviceTypeIdentifier}`
306
+ });
307
+ if (!allowedStatuses.has(stripScheme(service.serviceStatus))) errors.push({
308
+ path: `providers.${pi}.services.${si}.serviceStatus`,
309
+ message: `[${label}] unexpected service status ${service.serviceStatus}`
310
+ });
311
+ });
312
+ });
313
+ return errors;
314
+ }
315
+ /**
316
+ * Validate that a trusted list conforms to one (or any, given several) of the
317
+ * supplied profile rules — structural schema first, then profile-specific
318
+ * constraints. Mirrors `@owf/eudi-lote`'s profile validation.
319
+ */
320
+ function validateTrustedListProfile(value, rule) {
321
+ const structural = validateTrustedList(value);
322
+ if (!structural.valid) return structural;
323
+ const trustedList = value;
324
+ const perRule = (Array.isArray(rule) ? rule : [rule]).map((r) => profileErrors(trustedList, r));
325
+ if (perRule.some((errors) => errors.length === 0)) return {
326
+ valid: true,
327
+ errors: []
328
+ };
329
+ return {
330
+ valid: false,
331
+ errors: perRule.flat()
332
+ };
333
+ }
334
+ //#endregion
335
+ //#region src/parse.ts
336
+ const TSL_NS = "http://uri.etsi.org/02231/v2#";
337
+ const SIE_NS = "http://uri.etsi.org/TrstSvc/SvcInfoExt/eSigDir-1999-93-EC-TrustedList/#";
338
+ function descendants(el, name, ns = TSL_NS) {
339
+ return Array.from(el.getElementsByTagNameNS(ns, name));
340
+ }
341
+ function firstDescendant(el, name, ns = TSL_NS) {
342
+ return descendants(el, name, ns)[0];
343
+ }
344
+ function textOf(el) {
345
+ const t = el?.textContent?.trim();
346
+ return t ? t : void 0;
347
+ }
348
+ /**
349
+ * Localized `Name`: prefer the English entry, else the first, searched only
350
+ * among the direct `Name` children of the given parent.
351
+ */
352
+ function localizedName(parent) {
353
+ if (!parent) return void 0;
354
+ const names = Array.from(parent.childNodes).filter((n) => n.namespaceURI === TSL_NS && n.localName === "Name");
355
+ if (names.length === 0) return void 0;
356
+ return textOf(names.find((n) => n.getAttribute("xml:lang") === "en") ?? names[0]);
357
+ }
358
+ /** Lowercase-hex SubjectKeyIdentifier from a certificate, best-effort. */
359
+ function skiFromCertificate(certBase64) {
360
+ try {
361
+ const ext = new X509Certificate(certBase64).getExtension(SubjectKeyIdentifierExtension);
362
+ if (ext?.keyId) return ext.keyId.toLowerCase();
363
+ } catch {}
364
+ }
365
+ /**
366
+ * One {@link DigitalIdentity} per `ServiceDigitalIdentity`, merging its
367
+ * `DigitalId` children (X509Certificate / X509SubjectName / X509SKI) — a
368
+ * standard list may identify a service without embedding the full certificate.
369
+ */
370
+ function parseDigitalIdentities(container) {
371
+ const identities = [];
372
+ for (const sdi of descendants(container, "ServiceDigitalIdentity")) {
373
+ let certificate;
374
+ let subjectName;
375
+ let x509SkiHex;
376
+ for (const digitalId of descendants(sdi, "DigitalId")) {
377
+ certificate ??= textOf(firstDescendant(digitalId, "X509Certificate"))?.replace(/\s/g, "");
378
+ subjectName ??= textOf(firstDescendant(digitalId, "X509SubjectName"));
379
+ const ski = textOf(firstDescendant(digitalId, "X509SKI"));
380
+ if (ski && !x509SkiHex) x509SkiHex = hexEncode(base64.decode(ski.replace(/\s/g, "")));
381
+ }
382
+ if (!certificate && !subjectName && !x509SkiHex) continue;
383
+ identities.push({
384
+ certificate,
385
+ subjectName,
386
+ subjectKeyIdentifier: certificate ? skiFromCertificate(certificate) ?? x509SkiHex : x509SkiHex
387
+ });
388
+ }
389
+ return identities;
390
+ }
391
+ function parseQualifiers(serviceInfo) {
392
+ const uris = descendants(serviceInfo, "Qualifier", SIE_NS).map((q) => q.getAttribute("uri") ?? "").filter((u) => u.length > 0);
393
+ return uris.length > 0 ? uris : void 0;
394
+ }
395
+ function parseHistory(service) {
396
+ const history = [];
397
+ for (const instance of descendants(service, "ServiceHistoryInstance")) {
398
+ const serviceStatus = textOf(firstDescendant(instance, "ServiceStatus"));
399
+ if (!serviceStatus) continue;
400
+ history.push({
401
+ serviceTypeIdentifier: textOf(firstDescendant(instance, "ServiceTypeIdentifier")),
402
+ serviceStatus,
403
+ statusStartingTime: textOf(firstDescendant(instance, "StatusStartingTime"))
404
+ });
405
+ }
406
+ return history.length > 0 ? history : void 0;
407
+ }
408
+ function parsePointers(schemeInfo) {
409
+ const pointers = [];
410
+ for (const pointer of descendants(schemeInfo, "OtherTSLPointer")) {
411
+ const location = textOf(firstDescendant(pointer, "TSLLocation"));
412
+ if (!location) continue;
413
+ pointers.push({
414
+ location,
415
+ tslType: textOf(firstDescendant(pointer, "TSLType")),
416
+ schemeTerritory: textOf(firstDescendant(pointer, "SchemeTerritory")),
417
+ digitalIdentities: parseDigitalIdentities(pointer)
418
+ });
419
+ }
420
+ return pointers.length > 0 ? pointers : void 0;
421
+ }
422
+ /**
423
+ * Parse an ETSI TS 119 612 `TrustServiceStatusList` XML into a normalized
424
+ * {@link TrustedList}. This does NOT verify the list signature — call
425
+ * {@link verifyTrustedListSignature} first (or use {@link loadTrustedList}).
426
+ */
427
+ function parseTrustedList(xml) {
428
+ const root = new DOMParser().parseFromString(xml, "application/xml").documentElement;
429
+ if (root?.localName !== "TrustServiceStatusList") throw new TrustedListParseException("Root element is not a TS 119 612 TrustServiceStatusList");
430
+ const schemeInfo = firstDescendant(root, "SchemeInformation");
431
+ const sequenceText = textOf(schemeInfo && firstDescendant(schemeInfo, "TSLSequenceNumber"));
432
+ const nextUpdate = schemeInfo && firstDescendant(schemeInfo, "NextUpdate");
433
+ const providers = [];
434
+ for (const tsp of descendants(root, "TrustServiceProvider")) {
435
+ const services = [];
436
+ for (const service of descendants(tsp, "TSPService")) {
437
+ const info = firstDescendant(service, "ServiceInformation");
438
+ if (!info) continue;
439
+ const serviceTypeIdentifier = textOf(firstDescendant(info, "ServiceTypeIdentifier"));
440
+ const serviceStatus = textOf(firstDescendant(info, "ServiceStatus"));
441
+ if (!serviceTypeIdentifier || !serviceStatus) continue;
442
+ services.push({
443
+ serviceTypeIdentifier,
444
+ serviceStatus,
445
+ serviceName: localizedName(firstDescendant(info, "ServiceName")),
446
+ digitalIdentities: parseDigitalIdentities(info),
447
+ qualifiers: parseQualifiers(info),
448
+ history: parseHistory(service)
449
+ });
450
+ }
451
+ providers.push({
452
+ name: localizedName(firstDescendant(tsp, "TSPName")),
453
+ services
454
+ });
455
+ }
456
+ return assertValidTrustedList({
457
+ tslType: textOf(schemeInfo && firstDescendant(schemeInfo, "TSLType")),
458
+ schemeOperatorName: localizedName(schemeInfo && firstDescendant(schemeInfo, "SchemeOperatorName")),
459
+ sequenceNumber: sequenceText ? Number(sequenceText) : void 0,
460
+ listIssueDateTime: textOf(schemeInfo && firstDescendant(schemeInfo, "ListIssueDateTime")),
461
+ nextUpdate: textOf(nextUpdate && firstDescendant(nextUpdate, "dateTime")),
462
+ providers,
463
+ pointersToOtherLists: schemeInfo ? parsePointers(schemeInfo) : void 0
464
+ });
465
+ }
466
+ /**
467
+ * The DER-encoded certificates a list publishes for the lists it points to —
468
+ * i.e. the trust anchors with which those lists are signed, ready to be passed
469
+ * as `trustAnchors` to `verifyTrustedListSignature`.
470
+ *
471
+ * This is the mechanism by which a trusted list distributes trust downwards: a
472
+ * verifier that has established trust in one list (for the EU LOTL, by pinning
473
+ * its signing certificates out of band) obtains the anchors of every list it
474
+ * points to without pinning them individually.
475
+ *
476
+ * ```ts
477
+ * const lotl = await loadTrustedList(lotlXml, { trustAnchors: getEuLotlTrustAnchors() })
478
+ * const esAnchors = getPointerSigningCertificates(lotl, { schemeTerritory: 'ES' })
479
+ * const esList = await loadTrustedList(esXml, { trustAnchors: esAnchors })
480
+ * ```
481
+ *
482
+ * Passing `{ tslType: TSLType.EUlistofthelists }` returns the LOTL's own
483
+ * currently published signing certificates (from its self-pointer), which is
484
+ * how a deployment refreshes its pinned set as the scheme operator rotates keys.
485
+ */
486
+ function getPointerSigningCertificates(trustedList, filter = {}) {
487
+ const certificates = [];
488
+ const seen = /* @__PURE__ */ new Set();
489
+ for (const pointer of trustedList.pointersToOtherLists ?? []) {
490
+ if (filter.location && pointer.location !== filter.location) continue;
491
+ if (filter.schemeTerritory && pointer.schemeTerritory?.toUpperCase() !== filter.schemeTerritory.toUpperCase()) continue;
492
+ if (filter.tslType && stripScheme(pointer.tslType) !== stripScheme(filter.tslType)) continue;
493
+ for (const identity of pointer.digitalIdentities) {
494
+ if (!identity.certificate || seen.has(identity.certificate)) continue;
495
+ seen.add(identity.certificate);
496
+ certificates.push(base64.decode(identity.certificate));
497
+ }
498
+ }
499
+ return certificates;
500
+ }
501
+ /**
502
+ * Flatten a {@link TrustedList} into individual {@link TrustAnchor} entries —
503
+ * the normalized unit consumed by certificate-chain validation and AKI
504
+ * emission.
505
+ */
506
+ function getTrustAnchors(trustedList, filter = {}) {
507
+ const anchors = [];
508
+ for (const provider of trustedList.providers) for (const service of provider.services) {
509
+ if (filter.serviceStatus && !filter.serviceStatus.includes(service.serviceStatus)) continue;
510
+ if (filter.serviceTypeIdentifier && !filter.serviceTypeIdentifier.includes(service.serviceTypeIdentifier)) continue;
511
+ for (const identity of service.digitalIdentities) {
512
+ if (filter.requireCertificate && !identity.certificate) continue;
513
+ anchors.push({
514
+ certificate: identity.certificate,
515
+ subjectName: identity.subjectName,
516
+ subjectKeyIdentifier: identity.subjectKeyIdentifier,
517
+ serviceTypeIdentifier: service.serviceTypeIdentifier,
518
+ serviceStatus: service.serviceStatus,
519
+ providerName: provider.name
520
+ });
521
+ }
522
+ }
523
+ return anchors;
524
+ }
525
+ //#endregion
526
+ //#region src/profiles.ts
527
+ /** Every standard TS 119 612 service status (clause 5.5.4). */
528
+ const ALL_SERVICE_STATUSES = Object.values(ServiceStatus);
529
+ /** The standard qualified `ServiceTypeIdentifier` values (Annex D). */
530
+ const QUALIFIED_SERVICE_TYPES = Object.values(ServiceType);
531
+ /**
532
+ * Ready-made {@link ProfileRule}s for common ETSI ecosystems, so callers don't
533
+ * have to hand-write the URIs. The engine ({@link validateTrustedListProfile})
534
+ * stays profile-agnostic; these are just convenience constants you pass into it.
535
+ *
536
+ * A profile is an allowlist: the structural schema is checked first, then the
537
+ * list's `TSLType` must match and every service's type/status must be permitted.
538
+ * That fits homogeneous, curated lists well (e.g. Age Verification). For a full
539
+ * eIDAS national list — which legitimately carries withdrawn/ceased services and
540
+ * a broad mix of qualified service types — {@link euGeneric} therefore permits
541
+ * all standard ETSI statuses and qualified service types: it asserts "this is a
542
+ * well-formed EU generic list using standard ETSI URIs", not "only currently
543
+ * active CAs". Narrow further with your own {@link ProfileRule} when you need to.
544
+ */
545
+ const TrustedListProfiles = {
546
+ /**
547
+ * EU List of Trusted Lists (LOTL). Its `TSLType` is `EUlistofthelists` and it
548
+ * carries pointers to national lists rather than trust-service providers, so
549
+ * no service type/status is permitted (a conforming LOTL has no TSP services).
550
+ */
551
+ euLotl: {
552
+ name: "eu-lotl",
553
+ tslType: TSLType.EUlistofthelists,
554
+ serviceTypes: [],
555
+ serviceStatuses: []
556
+ },
557
+ /**
558
+ * A generic EU (eIDAS national) trusted list: `TSLType` `EUgeneric`, any
559
+ * standard qualified service type, any standard service status (including
560
+ * withdrawn/ceased entries that national lists retain for history).
561
+ */
562
+ euGeneric: {
563
+ name: "eu-generic",
564
+ tslType: TSLType.EUgeneric,
565
+ serviceTypes: QUALIFIED_SERVICE_TYPES,
566
+ serviceStatuses: ALL_SERVICE_STATUSES
567
+ },
568
+ /**
569
+ * EU Age Verification trusted list, per the European Commission's "AV Trusted
570
+ * List Specifications" (DIGIT.B.3). The `TSLType` (clause 5.3.3), the single
571
+ * Proof of Age Attestation service type (`paa`, clause 5.5.1) and the two
572
+ * permitted service statuses (clause 5.5.4) are fixed by that specification —
573
+ * which states the statuses "may be used to the exclusion of any other", so
574
+ * the allowlist model captures the AV profile exactly. Deployed lists have
575
+ * used `https` for the `TSLType`; the profile compares scheme-insensitively.
576
+ */
577
+ ageVerification: {
578
+ name: "eu-age-verification",
579
+ tslType: "http://trust.tech.ec.europa.eu/lists/age-verification/tsl-type",
580
+ serviceTypes: ["http://trust.tech.ec.europa.eu/lists/age-verification/service-type/paa"],
581
+ serviceStatuses: ["http://trust.tech.ec.europa.eu/lists/age-verification/service-status/recognized", "http://trust.tech.ec.europa.eu/lists/age-verification/service-status/deprecated"]
582
+ }
583
+ };
584
+ //#endregion
585
+ //#region src/verify.ts
586
+ const XMLDSIG_NS = "http://www.w3.org/2000/09/xmldsig#";
587
+ let nodeDependenciesInitialized = false;
588
+ let installedCrypto;
589
+ /**
590
+ * Outside the browser, xml-core resolves DOM/XPath implementations through
591
+ * `setNodeDependencies`. Set lazily and once, so importing this package has no
592
+ * side effects until a signature is actually processed.
593
+ */
594
+ function ensureNodeDependencies() {
595
+ if (nodeDependenciesInitialized) return;
596
+ xadesjs.setNodeDependencies({
597
+ DOMParser,
598
+ XMLSerializer,
599
+ xpath
600
+ });
601
+ nodeDependenciesInitialized = true;
602
+ }
603
+ /**
604
+ * Install the WebCrypto implementation used to verify trusted list signatures
605
+ * ("bring your own crypto"), for callers that must route verification through a
606
+ * reviewed or policy-constrained engine. Call it once during start-up, before
607
+ * verifying; without it, the global Web Crypto API (`globalThis.crypto`,
608
+ * available in Node >= 20 and browsers) is used.
609
+ *
610
+ * Process-wide by necessity, not by design: xadesjs exposes a single global
611
+ * crypto engine rather than a per-call context
612
+ * (see {@link https://github.com/PeculiarVentures/xmldsigjs/issues/119}).
613
+ * A per-invocation option would look isolated while still swapping that global,
614
+ * so concurrent verifications with different engines would race; it is
615
+ * deliberately not offered. Should upstream gain per-call crypto, accepting it
616
+ * as a verification option is an additive, non-breaking change.
617
+ */
618
+ function setTrustedListCrypto(crypto) {
619
+ ensureNodeDependencies();
620
+ xadesjs.Application.setEngine("eudi-tl", crypto);
621
+ installedCrypto = crypto;
622
+ }
623
+ /**
624
+ * Make sure a crypto engine is installed before verifying. A caller-installed
625
+ * engine is never replaced — falling back to `globalThis.crypto` on every call
626
+ * that does not opt in would silently undo {@link setTrustedListCrypto}.
627
+ */
628
+ function ensureXmlSignatureEngine() {
629
+ ensureNodeDependencies();
630
+ if (!installedCrypto) setTrustedListCrypto(globalThis.crypto);
631
+ }
632
+ /**
633
+ * Verify the enveloped XAdES/XMLDSig signature of an ETSI TS 119 612 Trusted
634
+ * List. Throws {@link TrustedListSignatureException} when the signature is
635
+ * missing, invalid, or (with `trustAnchors`) not signed by a pinned scheme
636
+ * operator.
637
+ *
638
+ * Verified against a standard eIDAS national trusted list (RSA-SHA512,
639
+ * exclusive C14N, XAdES SignedProperties).
640
+ *
641
+ * Verification runs on the global Web Crypto API unless another implementation
642
+ * was installed with {@link setTrustedListCrypto}.
643
+ */
644
+ async function verifyTrustedListSignature(xml, options = {}) {
645
+ ensureXmlSignatureEngine();
646
+ const doc = new DOMParser().parseFromString(xml, "application/xml");
647
+ const signatures = doc.getElementsByTagNameNS(XMLDSIG_NS, "Signature");
648
+ if (signatures.length === 0) throw new TrustedListSignatureException("No ds:Signature found in the trusted list");
649
+ const signedXml = new xadesjs.SignedXml(doc);
650
+ signedXml.LoadXml(signatures[0]);
651
+ let valid;
652
+ try {
653
+ valid = await signedXml.Verify();
654
+ } catch (error) {
655
+ throw new TrustedListSignatureException(`Trusted list signature could not be verified: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
656
+ }
657
+ if (!valid) throw new TrustedListSignatureException("Trusted list signature is invalid");
658
+ const signerCertEl = signatures[0].getElementsByTagNameNS(XMLDSIG_NS, "X509Certificate")[0];
659
+ if (!signerCertEl?.textContent) throw new TrustedListSignatureException("Trusted list signature has no X509Certificate in KeyInfo");
660
+ const signerCertificateBase64 = signerCertEl.textContent.replace(/\s/g, "");
661
+ if (options.trustAnchors && options.trustAnchors.length > 0) {
662
+ const signerDer = base64.decode(signerCertificateBase64);
663
+ if (!options.trustAnchors.some((anchor) => compareBytes(anchor, signerDer))) throw new TrustedListSignatureException("Trusted list signer certificate is not among the configured trust anchors");
664
+ }
665
+ return { signerCertificateBase64 };
666
+ }
667
+ //#endregion
668
+ //#region src/eu-lotl.ts
669
+ /**
670
+ * The LOTL signing certificates shipped with this package, as DER bytes ready
671
+ * to pass as `trustAnchors`.
672
+ *
673
+ * This pinned set is the root of the eIDAS trusted-list hierarchy and cannot be
674
+ * bootstrapped from the LOTL itself — a forged list would carry a forged
675
+ * self-pointer. It is published by the European Commission in the Official
676
+ * Journal; see {@link EU_LOTL_ANCHORS_PROVENANCE} for the exact act, list issue
677
+ * and expiry of the shipped set.
678
+ *
679
+ * Certificates rotate (historically every 6–24 months), so a deployment has
680
+ * three ways to stay current without waiting for a release of this package:
681
+ *
682
+ * 1. pass its own `trustAnchors`, e.g. from configuration;
683
+ * 2. after verifying a LOTL, read the currently published set from its own
684
+ * self-pointer with `getPointerSigningCertificates(lotl, { tslType:
685
+ * TSLType.EUlistofthelists })` and persist it — rotation is announced in a
686
+ * list still signed by the previous generation of keys;
687
+ * 3. follow the pivot LOTLs advertised in the list's `SchemeInformationURI`
688
+ * when the pinned set has fallen behind entirely.
689
+ */
690
+ function getEuLotlTrustAnchors() {
691
+ return EU_LOTL_SIGNING_CERTIFICATES.map((entry) => base64.decode(entry.certificate));
692
+ }
693
+ /**
694
+ * Verify the signature of the EU List of Trusted Lists against the shipped
695
+ * signing certificates. Identical to {@link verifyTrustedListSignature} except
696
+ * that `trustAnchors` defaults to {@link getEuLotlTrustAnchors} instead of to
697
+ * "integrity only" — pass your own to override.
698
+ */
699
+ function verifyEuLotlSignature(xml, options = {}) {
700
+ return verifyTrustedListSignature(xml, {
701
+ ...options,
702
+ trustAnchors: options.trustAnchors ?? getEuLotlTrustAnchors()
703
+ });
704
+ }
705
+ /**
706
+ * Verify, parse and profile-check the EU List of Trusted Lists in one step: the
707
+ * safe entry point for the top of the hierarchy. The returned list carries the
708
+ * `PointersToOtherTSL` entries from which national list anchors are derived
709
+ * with `getPointerSigningCertificates`.
710
+ */
711
+ async function loadEuLotl(xml, options = {}) {
712
+ await verifyEuLotlSignature(xml, options);
713
+ const lotl = parseTrustedList(xml);
714
+ const profile = validateTrustedListProfile(lotl, TrustedListProfiles.euLotl);
715
+ if (!profile.valid) throw new TrustedListParseException(`Not a conforming EU List of Trusted Lists: ${profile.errors.map((error) => `${error.path}: ${error.message}`).join("; ")}`);
716
+ return lotl;
717
+ }
718
+ //#endregion
719
+ //#region src/index.ts
720
+ /**
721
+ * Verify the trusted list signature and, only if it is valid, parse it. This is
722
+ * the safe entry point: it never returns a {@link TrustedList} whose
723
+ * authenticity has not been established.
724
+ */
725
+ async function loadTrustedList(xml, options = {}) {
726
+ await verifyTrustedListSignature(xml, options);
727
+ return parseTrustedList(xml);
728
+ }
729
+ //#endregion
730
+ export { ACTIVE_SERVICE_STATUSES, DigitalIdentitySchema, EU_LOTL_ANCHORS_PROVENANCE, EU_LOTL_SIGNING_CERTIFICATES, ServiceHistoryInstanceSchema, ServiceStatus, ServiceType, TSLType, TrustAnchorSchema, TrustServiceProviderSchema, TrustedListException, TrustedListParseException, TrustedListPointerSchema, TrustedListProfiles, TrustedListSchema, TrustedListServiceSchema, TrustedListSignatureException, assertValidTrustedList, getEuLotlTrustAnchors, getPointerSigningCertificates, getTrustAnchors, loadEuLotl, loadTrustedList, parseTrustedList, setTrustedListCrypto, validateTrustedList, validateTrustedListProfile, verifyEuLotlSignature, verifyTrustedListSignature };
731
+
732
+ //# sourceMappingURL=index.mjs.map