@peculiar/certificates-viewer 4.4.0 → 4.5.0

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.
Files changed (106) hide show
  1. package/components/download.js +17 -4
  2. package/components/download.js.map +1 -1
  3. package/dist/cjs/{certification_request-Bipg1Az7.js → certification_request-DS5FED4F.js} +19 -6
  4. package/dist/cjs/certification_request-DS5FED4F.js.map +1 -0
  5. package/dist/cjs/index.cjs.js +2 -2
  6. package/dist/cjs/{miscellaneous-C0sOAo-1.js → miscellaneous-UxtK1SWb.js} +3 -3
  7. package/dist/cjs/{miscellaneous-C0sOAo-1.js.map → miscellaneous-UxtK1SWb.js.map} +1 -1
  8. package/dist/cjs/peculiar-attribute-certificate-viewer_4.cjs.entry.js +4 -4
  9. package/dist/cjs/peculiar-certificate-decoder.cjs.entry.js +4 -4
  10. package/dist/cjs/peculiar-certificate-viewer.cjs.entry.js +3 -3
  11. package/dist/cjs/peculiar-certificates-viewer.cjs.entry.js +2 -2
  12. package/dist/cjs/{pkcs10_certificate_request-BDz0P_px.js → pkcs10_certificate_request-DaWYvR0i.js} +3 -3
  13. package/dist/cjs/{pkcs10_certificate_request-BDz0P_px.js.map → pkcs10_certificate_request-DaWYvR0i.js.map} +1 -1
  14. package/dist/cjs/{x509_certificate-DRvXOszL.js → x509_certificate-DBpSGIUT.js} +3 -3
  15. package/dist/cjs/{x509_certificate-DRvXOszL.js.map → x509_certificate-DBpSGIUT.js.map} +1 -1
  16. package/dist/cjs/{x509_crl-DVGVym_S.js → x509_crl-BBnJqOIF.js} +4 -4
  17. package/dist/cjs/{x509_crl-DVGVym_S.js.map → x509_crl-BBnJqOIF.js.map} +1 -1
  18. package/dist/collection/constants/oids.js +16 -3
  19. package/dist/collection/constants/oids.js.map +1 -1
  20. package/dist/collection/crypto/utils.js +1 -1
  21. package/dist/collection/crypto/utils.js.map +1 -1
  22. package/dist/esm/{certification_request-BTbyumBe.js → certification_request-Wtz6WM17.js} +19 -6
  23. package/dist/esm/certification_request-Wtz6WM17.js.map +1 -0
  24. package/dist/esm/index.js +2 -2
  25. package/dist/esm/{miscellaneous-CGtCg3Q9.js → miscellaneous-CsGuJ6zr.js} +3 -3
  26. package/dist/esm/{miscellaneous-CGtCg3Q9.js.map → miscellaneous-CsGuJ6zr.js.map} +1 -1
  27. package/dist/esm/peculiar-attribute-certificate-viewer_4.entry.js +4 -4
  28. package/dist/esm/peculiar-certificate-decoder.entry.js +4 -4
  29. package/dist/esm/peculiar-certificate-viewer.entry.js +3 -3
  30. package/dist/esm/peculiar-certificates-viewer.entry.js +2 -2
  31. package/dist/esm/{pkcs10_certificate_request-CrA_WcgY.js → pkcs10_certificate_request-Cn7_Z7a1.js} +3 -3
  32. package/dist/esm/{pkcs10_certificate_request-CrA_WcgY.js.map → pkcs10_certificate_request-Cn7_Z7a1.js.map} +1 -1
  33. package/dist/esm/{x509_certificate-DX7sKoAD.js → x509_certificate-ObET7_Te.js} +3 -3
  34. package/dist/{esm-es5/x509_certificate-DX7sKoAD.js.map → esm/x509_certificate-ObET7_Te.js.map} +1 -1
  35. package/dist/esm/{x509_crl-DRjoh8Yp.js → x509_crl-CeW7yzP9.js} +4 -4
  36. package/dist/esm/{x509_crl-DRjoh8Yp.js.map → x509_crl-CeW7yzP9.js.map} +1 -1
  37. package/dist/esm-es5/{certification_request-BTbyumBe.js → certification_request-Wtz6WM17.js} +3 -3
  38. package/dist/esm-es5/certification_request-Wtz6WM17.js.map +1 -0
  39. package/dist/esm-es5/index.js +1 -1
  40. package/dist/esm-es5/{miscellaneous-CGtCg3Q9.js → miscellaneous-CsGuJ6zr.js} +2 -2
  41. package/dist/esm-es5/{miscellaneous-CGtCg3Q9.js.map → miscellaneous-CsGuJ6zr.js.map} +1 -1
  42. package/dist/esm-es5/peculiar-attribute-certificate-viewer_4.entry.js +1 -1
  43. package/dist/esm-es5/peculiar-certificate-decoder.entry.js +1 -1
  44. package/dist/esm-es5/peculiar-certificate-viewer.entry.js +1 -1
  45. package/dist/esm-es5/peculiar-certificates-viewer.entry.js +1 -1
  46. package/dist/esm-es5/{pkcs10_certificate_request-CrA_WcgY.js → pkcs10_certificate_request-Cn7_Z7a1.js} +2 -2
  47. package/dist/esm-es5/{pkcs10_certificate_request-CrA_WcgY.js.map → pkcs10_certificate_request-Cn7_Z7a1.js.map} +1 -1
  48. package/dist/esm-es5/{x509_certificate-DX7sKoAD.js → x509_certificate-ObET7_Te.js} +2 -2
  49. package/dist/{esm/x509_certificate-DX7sKoAD.js.map → esm-es5/x509_certificate-ObET7_Te.js.map} +1 -1
  50. package/dist/esm-es5/{x509_crl-DRjoh8Yp.js → x509_crl-CeW7yzP9.js} +2 -2
  51. package/dist/esm-es5/{x509_crl-DRjoh8Yp.js.map → x509_crl-CeW7yzP9.js.map} +1 -1
  52. package/dist/peculiar/index.esm.js +1 -1
  53. package/dist/peculiar/{p-80fc5538.entry.js → p-0e8ab957.entry.js} +2 -2
  54. package/dist/peculiar/{p-e7266b0a.entry.js → p-3e4062f6.entry.js} +16 -16
  55. package/dist/peculiar/{p-092074e8.system.entry.js → p-5608ba3e.system.entry.js} +2 -2
  56. package/dist/peculiar/{p-ab220e36.system.entry.js → p-5b829829.system.entry.js} +2 -2
  57. package/dist/peculiar/{p-73a75d1e.system.entry.js → p-63aa01ad.system.entry.js} +2 -2
  58. package/dist/peculiar/{p-c2a805b3.entry.js → p-69b461b4.entry.js} +3 -3
  59. package/dist/peculiar/{p-85667993.entry.js → p-7a3bf94e.entry.js} +2 -2
  60. package/dist/peculiar/{p-Bw_icgVx.js → p-B3myni_G.js} +2 -2
  61. package/dist/peculiar/{p-Bw_icgVx.js.map → p-B3myni_G.js.map} +1 -1
  62. package/dist/peculiar/{p-C_7Koml8.system.js.map → p-CFhlbr47.system.js.map} +1 -1
  63. package/dist/peculiar/{p-lnQq6VON.system.js → p-CKoxwzVA.system.js} +2 -2
  64. package/dist/peculiar/{p-lnQq6VON.system.js.map → p-CKoxwzVA.system.js.map} +1 -1
  65. package/dist/peculiar/{p-FVz6FuoZ.system.js.map → p-C_vT-OYk.system.js.map} +1 -1
  66. package/dist/peculiar/{p-wgYkE8CV.system.js → p-CcANm2qm.system.js} +2 -2
  67. package/dist/peculiar/p-CcANm2qm.system.js.map +1 -0
  68. package/dist/peculiar/{p-Ct0zEUB_.js → p-CttQwkXH.js} +6 -6
  69. package/dist/peculiar/{p-Ct0zEUB_.js.map → p-CttQwkXH.js.map} +1 -1
  70. package/dist/peculiar/p-D5BWI7FK.system.js +1 -1
  71. package/dist/peculiar/{p-B7TxZGea.system.js → p-DPre0WhP.system.js} +4 -4
  72. package/dist/peculiar/{p-B7TxZGea.system.js.map → p-DPre0WhP.system.js.map} +1 -1
  73. package/dist/peculiar/{p-BbPo3hge.system.js.map → p-DX5B2Msh.system.js.map} +1 -1
  74. package/dist/peculiar/{p-B0CjUC4o.system.js → p-DgcB4Nqx.system.js} +8 -8
  75. package/dist/peculiar/p-DgcB4Nqx.system.js.map +1 -0
  76. package/dist/peculiar/{p-RW7UbzcZ.system.js.map → p-Dk86_qlM.system.js.map} +1 -1
  77. package/dist/peculiar/{p-DxdVL_Kj.system.js → p-L1KL0R34.system.js} +2 -2
  78. package/dist/peculiar/{p-DxdVL_Kj.system.js.map → p-L1KL0R34.system.js.map} +1 -1
  79. package/dist/peculiar/{p-BTbyumBe.js → p-Wtz6WM17.js} +8 -8
  80. package/dist/peculiar/p-Wtz6WM17.js.map +1 -0
  81. package/dist/peculiar/{p-1b3855ec.system.entry.js → p-bafc3336.system.entry.js} +16 -16
  82. package/dist/peculiar/{p-4IvcYmU7.js → p-lNFxlG5A.js} +4 -4
  83. package/dist/peculiar/{p-4IvcYmU7.js.map → p-lNFxlG5A.js.map} +1 -1
  84. package/dist/peculiar/{p-CpTwQbPC.js → p-t-yLLnfF.js} +2 -2
  85. package/dist/peculiar/{p-CpTwQbPC.js.map → p-t-yLLnfF.js.map} +1 -1
  86. package/dist/peculiar/{p-vMACJe_C.system.js → p-uFLk5hDd.system.js} +8 -8
  87. package/dist/peculiar/{p-vMACJe_C.system.js.map → p-uFLk5hDd.system.js.map} +1 -1
  88. package/dist/peculiar/peculiar.esm.js +1 -1
  89. package/dist/types/constants/oids.d.ts +15 -3
  90. package/hydrate/index.js +17 -4
  91. package/hydrate/index.mjs +17 -4
  92. package/package.json +2 -2
  93. package/dist/cjs/certification_request-Bipg1Az7.js.map +0 -1
  94. package/dist/esm/certification_request-BTbyumBe.js.map +0 -1
  95. package/dist/esm-es5/certification_request-BTbyumBe.js.map +0 -1
  96. package/dist/peculiar/p-B0CjUC4o.system.js.map +0 -1
  97. package/dist/peculiar/p-BTbyumBe.js.map +0 -1
  98. package/dist/peculiar/p-wgYkE8CV.system.js.map +0 -1
  99. /package/dist/peculiar/{p-80fc5538.entry.js.map → p-0e8ab957.entry.js.map} +0 -0
  100. /package/dist/peculiar/{p-e7266b0a.entry.js.map → p-3e4062f6.entry.js.map} +0 -0
  101. /package/dist/peculiar/{p-092074e8.system.entry.js.map → p-5608ba3e.system.entry.js.map} +0 -0
  102. /package/dist/peculiar/{p-ab220e36.system.entry.js.map → p-5b829829.system.entry.js.map} +0 -0
  103. /package/dist/peculiar/{p-73a75d1e.system.entry.js.map → p-63aa01ad.system.entry.js.map} +0 -0
  104. /package/dist/peculiar/{p-c2a805b3.entry.js.map → p-69b461b4.entry.js.map} +0 -0
  105. /package/dist/peculiar/{p-85667993.entry.js.map → p-7a3bf94e.entry.js.map} +0 -0
  106. /package/dist/peculiar/{p-1b3855ec.system.entry.js.map → p-bafc3336.system.entry.js.map} +0 -0
@@ -2,11 +2,11 @@
2
2
  * © Peculiar Ventures https://peculiarventures.com/ - MIT License
3
3
  */
4
4
  import { h, r as registerInstance, H as Host } from './index-DDDrq3In.js';
5
- import { _ as OIDs, Y as l10n, a5 as Name$1, u as ActivityDescription, W as WebGDPR, I as InsuranceValue, T as TypeRelationship, V as ValuationRanking, U as UnstructuredName, t as ChallengePassword, b as buildExports, Z as dateShort, a6 as CRLReason, a7 as InvalidityDate, a8 as CertificateIssuer } from './certification_request-BTbyumBe.js';
6
- import { X as X509AttributeCertificate, a as X509Crl } from './x509_crl-DRjoh8Yp.js';
7
- import { d as getStringByOID, R as RowValue, e as camelCaseToWords, f as TableRowTable, G as GeneralNamePart, h as RowTitle, B as BasicInformation, a as Signature, T as Thumbprints, g as getIPAddressLink, b as getDNSNameLink, c as getLEILink, E as Extensions, M as Miscellaneous, I as IssuerName, S as SubjectName, P as PublicKey } from './miscellaneous-CGtCg3Q9.js';
5
+ import { _ as OIDs, Y as l10n, a5 as Name$1, u as ActivityDescription, W as WebGDPR, I as InsuranceValue, T as TypeRelationship, V as ValuationRanking, U as UnstructuredName, t as ChallengePassword, b as buildExports, Z as dateShort, a6 as CRLReason, a7 as InvalidityDate, a8 as CertificateIssuer } from './certification_request-Wtz6WM17.js';
6
+ import { X as X509AttributeCertificate, a as X509Crl } from './x509_crl-CeW7yzP9.js';
7
+ import { d as getStringByOID, R as RowValue, e as camelCaseToWords, f as TableRowTable, G as GeneralNamePart, h as RowTitle, B as BasicInformation, a as Signature, T as Thumbprints, g as getIPAddressLink, b as getDNSNameLink, c as getLEILink, E as Extensions, M as Miscellaneous, I as IssuerName, S as SubjectName, P as PublicKey } from './miscellaneous-CsGuJ6zr.js';
8
8
  import { T as Typography } from './button-Djn8UI82.js';
9
- import { P as Pkcs10CertificateRequest } from './pkcs10_certificate_request-CrA_WcgY.js';
9
+ import { P as Pkcs10CertificateRequest } from './pkcs10_certificate_request-Cn7_Z7a1.js';
10
10
  import './link-BfDk078v.js';
11
11
  import './download-Cqfc-Sxf.js';
12
12
 
@@ -3,10 +3,10 @@
3
3
  */
4
4
  import { r as registerInstance, c as createEvent, h, H as Host } from './index-DDDrq3In.js';
5
5
  import { a as readAsBinaryString } from './read_file-F2F0McJX.js';
6
- import { P as PemConverter, b as buildExports, $ as SignedData, a0 as EncapsulatedContent, a1 as OctetString, a2 as CertificateSet, a3 as CertificateChoices, e as AsnConvert, C as Certificate, a4 as ContentInfo, D as Download } from './certification_request-BTbyumBe.js';
7
- import { X as X509Certificate } from './x509_certificate-DX7sKoAD.js';
8
- import { X as X509AttributeCertificate, a as X509Crl } from './x509_crl-DRjoh8Yp.js';
9
- import { P as Pkcs10CertificateRequest } from './pkcs10_certificate_request-CrA_WcgY.js';
6
+ import { P as PemConverter, b as buildExports, $ as SignedData, a0 as EncapsulatedContent, a1 as OctetString, a2 as CertificateSet, a3 as CertificateChoices, e as AsnConvert, C as Certificate, a4 as ContentInfo, D as Download } from './certification_request-Wtz6WM17.js';
7
+ import { X as X509Certificate } from './x509_certificate-ObET7_Te.js';
8
+ import { X as X509AttributeCertificate, a as X509Crl } from './x509_crl-CeW7yzP9.js';
9
+ import { P as Pkcs10CertificateRequest } from './pkcs10_certificate_request-Cn7_Z7a1.js';
10
10
  import { T as Typography, B as Button } from './button-Djn8UI82.js';
11
11
 
12
12
  const id_data = "1.2.840.113549.1.7.1";
@@ -2,9 +2,9 @@
2
2
  * © Peculiar Ventures https://peculiarventures.com/ - MIT License
3
3
  */
4
4
  import { r as registerInstance, h, H as Host } from './index-DDDrq3In.js';
5
- import { X as X509Certificate } from './x509_certificate-DX7sKoAD.js';
6
- import './certification_request-BTbyumBe.js';
7
- import { B as BasicInformation, S as SubjectName, I as IssuerName, P as PublicKey, a as Signature, T as Thumbprints, E as Extensions, g as getIPAddressLink, b as getDNSNameLink, c as getLEILink, M as Miscellaneous } from './miscellaneous-CGtCg3Q9.js';
5
+ import { X as X509Certificate } from './x509_certificate-ObET7_Te.js';
6
+ import './certification_request-Wtz6WM17.js';
7
+ import { B as BasicInformation, S as SubjectName, I as IssuerName, P as PublicKey, a as Signature, T as Thumbprints, E as Extensions, g as getIPAddressLink, b as getDNSNameLink, c as getLEILink, M as Miscellaneous } from './miscellaneous-CsGuJ6zr.js';
8
8
  import { T as Typography } from './button-Djn8UI82.js';
9
9
  import './link-BfDk078v.js';
10
10
  import './download-Cqfc-Sxf.js';
@@ -2,8 +2,8 @@
2
2
  * © Peculiar Ventures https://peculiarventures.com/ - MIT License
3
3
  */
4
4
  import { h, r as registerInstance, c as createEvent, H as Host } from './index-DDDrq3In.js';
5
- import { X as X509Certificate } from './x509_certificate-DX7sKoAD.js';
6
- import { Y as l10n, Z as dateShort, _ as OIDs } from './certification_request-BTbyumBe.js';
5
+ import { X as X509Certificate } from './x509_certificate-ObET7_Te.js';
6
+ import { Y as l10n, Z as dateShort, _ as OIDs } from './certification_request-Wtz6WM17.js';
7
7
  import { T as Typography, B as Button } from './button-Djn8UI82.js';
8
8
  import { D as DetailsIcon, L as LinkIcon, C as CrossIcon } from './cross-DdCuR1F2.js';
9
9
  import { D as DownloadIcon } from './download-Cqfc-Sxf.js';
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * © Peculiar Ventures https://peculiarventures.com/ - MIT License
3
3
  */
4
- import { A as AsnData, q as Attribute$1, r as AsnParser, s as ExtensionRequest, U as UnstructuredName, t as ChallengePassword, V as ValuationRanking, I as InsuranceValue, W as WebGDPR, u as ActivityDescription, T as TypeRelationship, v as DomainNameTechnicalOperator, w as DomainNameOwner, x as DomainNameLegalRepresentative, y as DomainNameBeneficiary, b as buildExports, z as id_pkcs9_at_extensionRequest, B as id_pkcs9_at_unstructuredName, F as id_pkcs9_at_challengePassword, G as id_ValuationRanking, H as id_InsuranceValue, J as id_WebGDPR, K as id_ActivityDescription, L as id_TypeRelationship, M as id_DomainNameTechnicalOperator, O as id_DomainNameOwner, Q as id_DomainNameLegalRepresentative, S as id_DomainNameBeneficiary, c as certificateRawToBuffer, X as CertificationRequest, P as PemConverter, N as Name, i as id_ecPublicKey, e as AsnConvert, f as ECParameters, g as id_rsaEncryption, R as RSAPublicKey, n as getCertificateThumbprint, E as Extension, D as Download } from './certification_request-BTbyumBe.js';
4
+ import { A as AsnData, q as Attribute$1, r as AsnParser, s as ExtensionRequest, U as UnstructuredName, t as ChallengePassword, V as ValuationRanking, I as InsuranceValue, W as WebGDPR, u as ActivityDescription, T as TypeRelationship, v as DomainNameTechnicalOperator, w as DomainNameOwner, x as DomainNameLegalRepresentative, y as DomainNameBeneficiary, b as buildExports, z as id_pkcs9_at_extensionRequest, B as id_pkcs9_at_unstructuredName, F as id_pkcs9_at_challengePassword, G as id_ValuationRanking, H as id_InsuranceValue, J as id_WebGDPR, K as id_ActivityDescription, L as id_TypeRelationship, M as id_DomainNameTechnicalOperator, O as id_DomainNameOwner, Q as id_DomainNameLegalRepresentative, S as id_DomainNameBeneficiary, c as certificateRawToBuffer, X as CertificationRequest, P as PemConverter, N as Name, i as id_ecPublicKey, e as AsnConvert, f as ECParameters, g as id_rsaEncryption, R as RSAPublicKey, n as getCertificateThumbprint, E as Extension, D as Download } from './certification_request-Wtz6WM17.js';
5
5
 
6
6
  /**
7
7
  * @license
@@ -142,6 +142,6 @@ class Pkcs10CertificateRequest extends AsnData {
142
142
  }
143
143
 
144
144
  export { Attribute as A, Pkcs10CertificateRequest as P };
145
- //# sourceMappingURL=pkcs10_certificate_request-CrA_WcgY.js.map
145
+ //# sourceMappingURL=pkcs10_certificate_request-Cn7_Z7a1.js.map
146
146
 
147
- //# sourceMappingURL=pkcs10_certificate_request-CrA_WcgY.js.map
147
+ //# sourceMappingURL=pkcs10_certificate_request-Cn7_Z7a1.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pkcs10_certificate_request-CrA_WcgY.js","sources":["src/crypto/attribute.ts","src/crypto/pkcs10_certificate_request.ts"],"sourcesContent":["/**\n * @license\n * Copyright (c) Peculiar Ventures, LLC.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Convert } from 'pvtsutils';\nimport { AsnParser } from '@peculiar/asn1-schema';\nimport { Attribute as AsnAttribute } from '@peculiar/asn1-x509';\nimport {\n id_DomainNameBeneficiary,\n DomainNameBeneficiary,\n\n id_DomainNameLegalRepresentative,\n DomainNameLegalRepresentative,\n\n id_DomainNameOwner,\n DomainNameOwner,\n\n id_DomainNameTechnicalOperator,\n DomainNameTechnicalOperator,\n\n id_TypeRelationship,\n TypeRelationship,\n\n id_ActivityDescription,\n ActivityDescription,\n\n id_WebGDPR,\n WebGDPR,\n\n id_InsuranceValue,\n InsuranceValue,\n\n id_ValuationRanking,\n ValuationRanking,\n} from '@peculiar/asn1-ntqwac';\nimport {\n id_pkcs9_at_extensionRequest,\n ExtensionRequest,\n\n id_pkcs9_at_challengePassword,\n ChallengePassword,\n\n id_pkcs9_at_unstructuredName,\n UnstructuredName,\n} from '@peculiar/asn1-pkcs9';\n\nimport { AsnData } from './asn_data';\n\nconst attributesParsers = {\n [id_DomainNameBeneficiary]: DomainNameBeneficiary,\n [id_DomainNameLegalRepresentative]: DomainNameLegalRepresentative,\n [id_DomainNameOwner]: DomainNameOwner,\n [id_DomainNameTechnicalOperator]: DomainNameTechnicalOperator,\n [id_TypeRelationship]: TypeRelationship,\n [id_ActivityDescription]: ActivityDescription,\n [id_WebGDPR]: WebGDPR,\n [id_InsuranceValue]: InsuranceValue,\n [id_ValuationRanking]: ValuationRanking,\n [id_pkcs9_at_challengePassword]: ChallengePassword,\n [id_pkcs9_at_unstructuredName]: UnstructuredName,\n [id_pkcs9_at_extensionRequest]: ExtensionRequest,\n};\n\ntype TAttributeKeys = keyof typeof attributesParsers;\nexport type TAttributeValue = InstanceType<typeof attributesParsers[TAttributeKeys]> | string;\n\nexport class Attribute<T extends TAttributeValue> extends AsnData<AsnAttribute> {\n public readonly value: T;\n\n private getAsnExtnValue() {\n return this.asn.values[0];\n }\n\n constructor(raw: BufferSource) {\n super(raw, AsnAttribute);\n\n const asnExtnValue = this.getAsnExtnValue();\n\n try {\n const target = attributesParsers[this.asn.type];\n\n if (target) {\n this.value = AsnParser.parse<T>(asnExtnValue, target);\n } else {\n console.warn(`Didn't detect parser for \"${this.asn.type}\" attribute.`);\n\n this.value = Convert.ToHex(asnExtnValue) as T;\n }\n } catch (error) {\n console.error(`Error parse \"${this.asn.type}\" attribute:`, error.message);\n\n this.value = Convert.ToHex(asnExtnValue) as T;\n }\n }\n}\n","/**\n * @license\n * Copyright (c) Peculiar Ventures, LLC.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { AsnConvert } from '@peculiar/asn1-schema';\nimport { ECParameters, id_ecPublicKey } from '@peculiar/asn1-ecc';\nimport { id_rsaEncryption, RSAPublicKey } from '@peculiar/asn1-rsa';\nimport { CertificationRequest } from '@peculiar/asn1-csr';\nimport {\n id_pkcs9_at_extensionRequest,\n ExtensionRequest,\n} from '@peculiar/asn1-pkcs9';\nimport { Convert } from 'pvtsutils';\n\nimport { Download } from '../utils';\n\nimport { AsnData } from './asn_data';\nimport { Name, INameJSON } from './name';\nimport { Attribute, TAttributeValue } from './attribute';\nimport { Extension, TExtensionValue } from './extension';\nimport { PemConverter } from './pem_converter';\nimport {\n certificateRawToBuffer,\n getCertificateThumbprint,\n} from './utils';\n\ninterface ISignature {\n algorithm: string;\n value: BufferSource;\n}\n\ninterface IPublicKey {\n algorithm: string;\n value: BufferSource;\n params?: ECParameters | RSAPublicKey;\n}\n\nexport class Pkcs10CertificateRequest extends AsnData<CertificationRequest> {\n public readonly subject: INameJSON[];\n\n public readonly version: number;\n\n public attributes: Attribute<TAttributeValue>[];\n\n public extensions: Extension<TExtensionValue>[];\n\n public thumbprints: Record<string, string> = {};\n\n public readonly type = 'PKCS#10 Certificate Request';\n\n public readonly tag = PemConverter.CertificateRequestTag;\n\n constructor(raw: string) {\n super(certificateRawToBuffer(raw), CertificationRequest);\n\n const { certificationRequestInfo } = this.asn;\n\n this.subject = new Name(certificationRequestInfo.subject).toJSON();\n this.version = certificationRequestInfo.version;\n }\n\n public get publicKey(): IPublicKey {\n const { subjectPublicKey, algorithm } = this.asn.certificationRequestInfo.subjectPKInfo;\n let params;\n\n if (algorithm.algorithm === id_ecPublicKey && algorithm.parameters) {\n params = AsnConvert.parse(algorithm.parameters, ECParameters);\n }\n\n if (algorithm.algorithm === id_rsaEncryption) {\n params = AsnConvert.parse(subjectPublicKey, RSAPublicKey);\n }\n\n const spki = AsnConvert.serialize(this.asn.certificationRequestInfo.subjectPKInfo);\n\n return {\n params,\n value: spki,\n algorithm: algorithm.algorithm,\n };\n }\n\n public get signature(): ISignature {\n const { signature, signatureAlgorithm } = this.asn;\n\n return {\n value: signature,\n algorithm: signatureAlgorithm.algorithm,\n };\n }\n\n public get commonName(): string {\n if (!this.subject) {\n return '';\n }\n\n for (let i = 0; i < this.subject.length; i += 1) {\n const name = this.subject[i];\n\n if (name.shortName === 'CN' || name.shortName === 'E' || name.shortName === 'O') {\n return name.value;\n }\n }\n\n return '';\n }\n\n public async getThumbprint(\n algorithm: string = 'SHA-1',\n ): Promise<void> {\n try {\n const thumbprint = await getCertificateThumbprint(algorithm, this.raw);\n\n if (thumbprint) {\n this.thumbprints[algorithm] = Convert.ToHex(thumbprint);\n }\n } catch (error) {\n console.error('Error thumbprint get:', error);\n }\n }\n\n public parseAttributes() {\n const { certificationRequestInfo } = this.asn;\n\n if (certificationRequestInfo.attributes) {\n this.attributes = certificationRequestInfo.attributes\n .map((e) => new Attribute(AsnConvert.serialize(e)));\n\n const extensionRequestAttribute = this.attributes.find(\n (attribute) => attribute.asn.type === id_pkcs9_at_extensionRequest,\n ) as Attribute<ExtensionRequest>;\n\n if (extensionRequestAttribute) {\n this.extensions = extensionRequestAttribute.value\n .map((e) => new Extension(AsnConvert.serialize(e)));\n }\n }\n }\n\n public toString(format: 'pem' | 'base64' | 'base64url' = 'pem'): string {\n switch (format) {\n case 'pem':\n return PemConverter.encode(this.raw, this.tag);\n case 'base64url':\n return Convert.ToBase64Url(this.raw);\n default:\n return Convert.ToBase64(this.raw);\n }\n }\n\n public downloadAsPEM(name?: string) {\n Download.csr.asPEM(\n this.toString('pem'),\n name || this.commonName,\n );\n }\n\n public downloadAsDER(name?: string) {\n Download.csr.asDER(\n this.raw,\n name || this.commonName,\n );\n }\n}\n"],"names":["AsnAttribute","Convert"],"mappings":";;;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AACxC,iBAAA,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAErD,MAAM,yBAAyB,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CACpD,CAAC,SAAS,KAAK,SAAS,CAAC,GAAG,CAAC,IAAI,KAAK,4BAA4B,CACpC;YAEhC,IAAI,yBAAyB,EAAE;AAC7B,gBAAA,IAAI,CAAC,UAAU,GAAG,yBAAyB,CAAC;AACzC,qBAAA,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;;;;IAKpD,QAAQ,CAAC,SAAyC,KAAK,EAAA;QAC5D,QAAQ,MAAM;AACZ,YAAA,KAAK,KAAK;AACR,gBAAA,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AAChD,YAAA,KAAK,WAAW;gBACd,OAAOA,oBAAO,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;AACtC,YAAA;gBACE,OAAOA,oBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;;;AAIhC,IAAA,aAAa,CAAC,IAAa,EAAA;AAChC,QAAA,QAAQ,CAAC,GAAG,CAAC,KAAK,CAChB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EACpB,IAAI,IAAI,IAAI,CAAC,UAAU,CACxB;;AAGI,IAAA,aAAa,CAAC,IAAa,EAAA;AAChC,QAAA,QAAQ,CAAC,GAAG,CAAC,KAAK,CAChB,IAAI,CAAC,GAAG,EACR,IAAI,IAAI,IAAI,CAAC,UAAU,CACxB;;AAEJ;;;;"}
1
+ {"version":3,"file":"pkcs10_certificate_request-Cn7_Z7a1.js","sources":["src/crypto/attribute.ts","src/crypto/pkcs10_certificate_request.ts"],"sourcesContent":["/**\n * @license\n * Copyright (c) Peculiar Ventures, LLC.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Convert } from 'pvtsutils';\nimport { AsnParser } from '@peculiar/asn1-schema';\nimport { Attribute as AsnAttribute } from '@peculiar/asn1-x509';\nimport {\n id_DomainNameBeneficiary,\n DomainNameBeneficiary,\n\n id_DomainNameLegalRepresentative,\n DomainNameLegalRepresentative,\n\n id_DomainNameOwner,\n DomainNameOwner,\n\n id_DomainNameTechnicalOperator,\n DomainNameTechnicalOperator,\n\n id_TypeRelationship,\n TypeRelationship,\n\n id_ActivityDescription,\n ActivityDescription,\n\n id_WebGDPR,\n WebGDPR,\n\n id_InsuranceValue,\n InsuranceValue,\n\n id_ValuationRanking,\n ValuationRanking,\n} from '@peculiar/asn1-ntqwac';\nimport {\n id_pkcs9_at_extensionRequest,\n ExtensionRequest,\n\n id_pkcs9_at_challengePassword,\n ChallengePassword,\n\n id_pkcs9_at_unstructuredName,\n UnstructuredName,\n} from '@peculiar/asn1-pkcs9';\n\nimport { AsnData } from './asn_data';\n\nconst attributesParsers = {\n [id_DomainNameBeneficiary]: DomainNameBeneficiary,\n [id_DomainNameLegalRepresentative]: DomainNameLegalRepresentative,\n [id_DomainNameOwner]: DomainNameOwner,\n [id_DomainNameTechnicalOperator]: DomainNameTechnicalOperator,\n [id_TypeRelationship]: TypeRelationship,\n [id_ActivityDescription]: ActivityDescription,\n [id_WebGDPR]: WebGDPR,\n [id_InsuranceValue]: InsuranceValue,\n [id_ValuationRanking]: ValuationRanking,\n [id_pkcs9_at_challengePassword]: ChallengePassword,\n [id_pkcs9_at_unstructuredName]: UnstructuredName,\n [id_pkcs9_at_extensionRequest]: ExtensionRequest,\n};\n\ntype TAttributeKeys = keyof typeof attributesParsers;\nexport type TAttributeValue = InstanceType<typeof attributesParsers[TAttributeKeys]> | string;\n\nexport class Attribute<T extends TAttributeValue> extends AsnData<AsnAttribute> {\n public readonly value: T;\n\n private getAsnExtnValue() {\n return this.asn.values[0];\n }\n\n constructor(raw: BufferSource) {\n super(raw, AsnAttribute);\n\n const asnExtnValue = this.getAsnExtnValue();\n\n try {\n const target = attributesParsers[this.asn.type];\n\n if (target) {\n this.value = AsnParser.parse<T>(asnExtnValue, target);\n } else {\n console.warn(`Didn't detect parser for \"${this.asn.type}\" attribute.`);\n\n this.value = Convert.ToHex(asnExtnValue) as T;\n }\n } catch (error) {\n console.error(`Error parse \"${this.asn.type}\" attribute:`, error.message);\n\n this.value = Convert.ToHex(asnExtnValue) as T;\n }\n }\n}\n","/**\n * @license\n * Copyright (c) Peculiar Ventures, LLC.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { AsnConvert } from '@peculiar/asn1-schema';\nimport { ECParameters, id_ecPublicKey } from '@peculiar/asn1-ecc';\nimport { id_rsaEncryption, RSAPublicKey } from '@peculiar/asn1-rsa';\nimport { CertificationRequest } from '@peculiar/asn1-csr';\nimport {\n id_pkcs9_at_extensionRequest,\n ExtensionRequest,\n} from '@peculiar/asn1-pkcs9';\nimport { Convert } from 'pvtsutils';\n\nimport { Download } from '../utils';\n\nimport { AsnData } from './asn_data';\nimport { Name, INameJSON } from './name';\nimport { Attribute, TAttributeValue } from './attribute';\nimport { Extension, TExtensionValue } from './extension';\nimport { PemConverter } from './pem_converter';\nimport {\n certificateRawToBuffer,\n getCertificateThumbprint,\n} from './utils';\n\ninterface ISignature {\n algorithm: string;\n value: BufferSource;\n}\n\ninterface IPublicKey {\n algorithm: string;\n value: BufferSource;\n params?: ECParameters | RSAPublicKey;\n}\n\nexport class Pkcs10CertificateRequest extends AsnData<CertificationRequest> {\n public readonly subject: INameJSON[];\n\n public readonly version: number;\n\n public attributes: Attribute<TAttributeValue>[];\n\n public extensions: Extension<TExtensionValue>[];\n\n public thumbprints: Record<string, string> = {};\n\n public readonly type = 'PKCS#10 Certificate Request';\n\n public readonly tag = PemConverter.CertificateRequestTag;\n\n constructor(raw: string) {\n super(certificateRawToBuffer(raw), CertificationRequest);\n\n const { certificationRequestInfo } = this.asn;\n\n this.subject = new Name(certificationRequestInfo.subject).toJSON();\n this.version = certificationRequestInfo.version;\n }\n\n public get publicKey(): IPublicKey {\n const { subjectPublicKey, algorithm } = this.asn.certificationRequestInfo.subjectPKInfo;\n let params;\n\n if (algorithm.algorithm === id_ecPublicKey && algorithm.parameters) {\n params = AsnConvert.parse(algorithm.parameters, ECParameters);\n }\n\n if (algorithm.algorithm === id_rsaEncryption) {\n params = AsnConvert.parse(subjectPublicKey, RSAPublicKey);\n }\n\n const spki = AsnConvert.serialize(this.asn.certificationRequestInfo.subjectPKInfo);\n\n return {\n params,\n value: spki,\n algorithm: algorithm.algorithm,\n };\n }\n\n public get signature(): ISignature {\n const { signature, signatureAlgorithm } = this.asn;\n\n return {\n value: signature,\n algorithm: signatureAlgorithm.algorithm,\n };\n }\n\n public get commonName(): string {\n if (!this.subject) {\n return '';\n }\n\n for (let i = 0; i < this.subject.length; i += 1) {\n const name = this.subject[i];\n\n if (name.shortName === 'CN' || name.shortName === 'E' || name.shortName === 'O') {\n return name.value;\n }\n }\n\n return '';\n }\n\n public async getThumbprint(\n algorithm: string = 'SHA-1',\n ): Promise<void> {\n try {\n const thumbprint = await getCertificateThumbprint(algorithm, this.raw);\n\n if (thumbprint) {\n this.thumbprints[algorithm] = Convert.ToHex(thumbprint);\n }\n } catch (error) {\n console.error('Error thumbprint get:', error);\n }\n }\n\n public parseAttributes() {\n const { certificationRequestInfo } = this.asn;\n\n if (certificationRequestInfo.attributes) {\n this.attributes = certificationRequestInfo.attributes\n .map((e) => new Attribute(AsnConvert.serialize(e)));\n\n const extensionRequestAttribute = this.attributes.find(\n (attribute) => attribute.asn.type === id_pkcs9_at_extensionRequest,\n ) as Attribute<ExtensionRequest>;\n\n if (extensionRequestAttribute) {\n this.extensions = extensionRequestAttribute.value\n .map((e) => new Extension(AsnConvert.serialize(e)));\n }\n }\n }\n\n public toString(format: 'pem' | 'base64' | 'base64url' = 'pem'): string {\n switch (format) {\n case 'pem':\n return PemConverter.encode(this.raw, this.tag);\n case 'base64url':\n return Convert.ToBase64Url(this.raw);\n default:\n return Convert.ToBase64(this.raw);\n }\n }\n\n public downloadAsPEM(name?: string) {\n Download.csr.asPEM(\n this.toString('pem'),\n name || this.commonName,\n );\n }\n\n public downloadAsDER(name?: string) {\n Download.csr.asDER(\n this.raw,\n name || this.commonName,\n );\n }\n}\n"],"names":["AsnAttribute","Convert"],"mappings":";;;;;AAAA;;;;;;AAMG;AA8CH,MAAM,iBAAiB,GAAG;IACxB,CAAC,wBAAwB,GAAG,qBAAqB;IACjD,CAAC,gCAAgC,GAAG,6BAA6B;IACjE,CAAC,kBAAkB,GAAG,eAAe;IACrC,CAAC,8BAA8B,GAAG,2BAA2B;IAC7D,CAAC,mBAAmB,GAAG,gBAAgB;IACvC,CAAC,sBAAsB,GAAG,mBAAmB;IAC7C,CAAC,UAAU,GAAG,OAAO;IACrB,CAAC,iBAAiB,GAAG,cAAc;IACnC,CAAC,mBAAmB,GAAG,gBAAgB;IACvC,CAAC,6BAA6B,GAAG,iBAAiB;IAClD,CAAC,4BAA4B,GAAG,gBAAgB;IAChD,CAAC,4BAA4B,GAAG,gBAAgB;CACjD;AAKK,MAAO,SAAqC,SAAQ,OAAqB,CAAA;IAGrE,eAAe,GAAA;QACrB,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;;AAG3B,IAAA,WAAA,CAAY,GAAiB,EAAA;AAC3B,QAAA,KAAK,CAAC,GAAG,EAAEA,WAAY,CAAC;AAExB,QAAA,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE;AAE3C,QAAA,IAAI;YACF,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;YAE/C,IAAI,MAAM,EAAE;gBACV,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAI,YAAY,EAAE,MAAM,CAAC;;iBAChD;gBACL,OAA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GI,IAAA,aAAa,CAAC,IAAa,EAAA;AAChC,QAAA,QAAQ,CAAC,GAAG,CAAC,KAAK,CAChB,IAAI,CAAC,GAAG,EACR,IAAI,IAAI,IAAI,CAAC,UAAU,CACxB;;AAEJ;;;;"}
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * © Peculiar Ventures https://peculiarventures.com/ - MIT License
3
3
  */
4
- import { A as AsnData, c as certificateRawToBuffer, C as Certificate, P as PemConverter, b as buildExports, N as Name, a as dateDiff, E as Extension, e as AsnConvert, i as id_ecPublicKey, f as ECParameters, g as id_rsaEncryption, R as RSAPublicKey, h as id_composite_key, j as CompositePublicKey, k as id_alg_composite, l as CompositeSignatureValue, m as CompositeParams, n as getCertificateThumbprint, D as Download } from './certification_request-BTbyumBe.js';
4
+ import { A as AsnData, c as certificateRawToBuffer, C as Certificate, P as PemConverter, b as buildExports, N as Name, a as dateDiff, E as Extension, e as AsnConvert, i as id_ecPublicKey, f as ECParameters, g as id_rsaEncryption, R as RSAPublicKey, h as id_composite_key, j as CompositePublicKey, k as id_alg_composite, l as CompositeSignatureValue, m as CompositeParams, n as getCertificateThumbprint, D as Download } from './certification_request-Wtz6WM17.js';
5
5
 
6
6
  /**
7
7
  * @license
@@ -155,6 +155,6 @@ class X509Certificate extends AsnData {
155
155
  }
156
156
 
157
157
  export { X509Certificate as X };
158
- //# sourceMappingURL=x509_certificate-DX7sKoAD.js.map
158
+ //# sourceMappingURL=x509_certificate-ObET7_Te.js.map
159
159
 
160
- //# sourceMappingURL=x509_certificate-DX7sKoAD.js.map
160
+ //# sourceMappingURL=x509_certificate-ObET7_Te.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"x509_certificate-DX7sKoAD.js","sources":["src/crypto/x509_certificate.ts"],"sourcesContent":["/**\n * @license\n * Copyright (c) Peculiar Ventures, LLC.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { AsnConvert } from '@peculiar/asn1-schema';\nimport { ECParameters, id_ecPublicKey } from '@peculiar/asn1-ecc';\nimport { id_rsaEncryption, RSAPublicKey } from '@peculiar/asn1-rsa';\nimport {\n id_composite_key,\n id_alg_composite,\n CompositePublicKey,\n CompositeSignatureValue,\n CompositeParams,\n} from '@peculiar/asn1-x509-post-quantum';\nimport { Certificate, SubjectPublicKeyInfo } from '@peculiar/asn1-x509';\nimport { Convert } from 'pvtsutils';\n\nimport { dateDiff, Download } from '../utils';\n\nimport { Name, INameJSON } from './name';\nimport { Extension, TExtensionValue } from './extension';\nimport { AsnData } from './asn_data';\nimport { PemConverter } from './pem_converter';\nimport {\n certificateRawToBuffer,\n getCertificateThumbprint,\n} from './utils';\n\nexport interface ISignature {\n algorithm: string;\n value: BufferSource;\n params?: {\n algorithm: string;\n value: BufferSource;\n }[];\n}\n\nexport interface IPublicKey {\n algorithm: string;\n value: BufferSource;\n params?: ECParameters | RSAPublicKey | IPublicKey[];\n}\n\nexport class X509Certificate extends AsnData<Certificate> {\n public readonly serialNumber: string;\n\n public readonly subject: INameJSON[];\n\n public readonly issuer: INameJSON[];\n\n public readonly notBefore: Date;\n\n public readonly notAfter: Date;\n\n public readonly validity: string;\n\n public extensions: Extension<TExtensionValue>[];\n\n public readonly version: number;\n\n public thumbprints: Record<string, string> = {};\n\n public readonly type = 'X.509 Certificate';\n\n public readonly tag = PemConverter.CertificateTag;\n\n constructor(raw: string) {\n super(certificateRawToBuffer(raw), Certificate);\n\n const { tbsCertificate } = this.asn;\n\n this.serialNumber = Convert.ToHex(tbsCertificate.serialNumber);\n this.subject = new Name(tbsCertificate.subject).toJSON();\n this.issuer = new Name(tbsCertificate.issuer).toJSON();\n this.version = tbsCertificate.version + 1;\n\n const notBefore = tbsCertificate.validity.notBefore.utcTime\n || tbsCertificate.validity.notBefore.generalTime;\n\n if (!notBefore) {\n throw new Error(\"Cannot get 'notBefore' value\");\n }\n\n this.notBefore = notBefore;\n\n const notAfter = tbsCertificate.validity.notAfter.utcTime\n || tbsCertificate.validity.notAfter.generalTime;\n\n if (!notAfter) {\n throw new Error(\"Cannot get 'notAfter' value\");\n }\n\n this.notAfter = notAfter;\n this.validity = dateDiff(this.notBefore, this.notAfter);\n }\n\n public parseExtensions() {\n const { tbsCertificate } = this.asn;\n\n if (tbsCertificate.extensions) {\n this.extensions = tbsCertificate.extensions\n .map((e) => new Extension(AsnConvert.serialize(e)));\n }\n }\n\n private getPublicKeyInfo(publicKeyInfo: SubjectPublicKeyInfo) {\n const { subjectPublicKey, algorithm } = publicKeyInfo;\n let params;\n\n if (algorithm.algorithm === id_ecPublicKey && algorithm.parameters) {\n params = AsnConvert.parse(algorithm.parameters, ECParameters);\n }\n\n if (algorithm.algorithm === id_rsaEncryption) {\n params = AsnConvert.parse(subjectPublicKey, RSAPublicKey);\n }\n\n if (algorithm.algorithm === id_composite_key) {\n params = AsnConvert.parse(subjectPublicKey, CompositePublicKey);\n\n params = params.map((param) => this.getPublicKeyInfo(param));\n }\n\n const spki = AsnConvert.serialize(publicKeyInfo);\n\n return {\n params,\n value: spki,\n algorithm: algorithm.algorithm,\n };\n }\n\n public get publicKey(): IPublicKey {\n return this.getPublicKeyInfo(this.asn.tbsCertificate.subjectPublicKeyInfo);\n }\n\n public get signature(): ISignature {\n const { signatureValue, signatureAlgorithm } = this.asn;\n let params;\n\n if (signatureAlgorithm.algorithm === id_alg_composite) {\n const compositeSignatureValues = AsnConvert.parse(signatureValue, CompositeSignatureValue);\n const compositeParams = AsnConvert.parse(signatureAlgorithm.parameters, CompositeParams);\n\n params = compositeParams.map((param, index) => ({\n ...param,\n value: compositeSignatureValues[index],\n }));\n }\n\n return {\n params,\n value: signatureValue,\n algorithm: signatureAlgorithm.algorithm,\n };\n }\n\n public async getThumbprint(\n algorithm: string = 'SHA-1',\n ): Promise<void> {\n try {\n const thumbprint = await getCertificateThumbprint(algorithm, this.raw);\n\n if (thumbprint) {\n this.thumbprints[algorithm] = Convert.ToHex(thumbprint);\n }\n } catch (error) {\n console.error('Error thumbprint get:', error);\n }\n }\n\n public get commonName(): string {\n if (!this.subject) {\n return '';\n }\n\n for (let i = 0; i < this.subject.length; i += 1) {\n const name = this.subject[i];\n\n if (name.shortName === 'CN' || name.shortName === 'E' || name.shortName === 'O') {\n return name.value;\n }\n }\n\n return '';\n }\n\n public get issuerCommonName(): string {\n if (!this.issuer) {\n return '';\n }\n\n for (let i = 0; i < this.issuer.length; i += 1) {\n const name = this.issuer[i];\n\n if (name.shortName === 'CN') {\n return name.value;\n }\n\n if (name.shortName === 'E') {\n return name.value;\n }\n }\n\n return '';\n }\n\n public get isRoot(): boolean {\n return JSON.stringify(this.issuer) === JSON.stringify(this.subject);\n }\n\n public subjectToString() {\n if (!this.subject) {\n return '';\n }\n\n return this.subject\n .map((name) => (\n `${name.shortName}=${name.value}`\n ))\n .join(', ');\n }\n\n public issuerToString() {\n if (!this.issuer) {\n return '';\n }\n\n return this.issuer\n .map((name) => (\n `${name.shortName}=${name.value}`\n ))\n .join(', ');\n }\n\n public toString(format: 'pem' | 'base64' | 'base64url' = 'pem'): string {\n switch (format) {\n case 'pem':\n return PemConverter.encode(this.raw, this.tag);\n case 'base64url':\n return Convert.ToBase64Url(this.raw);\n default:\n return Convert.ToBase64(this.raw);\n }\n }\n\n public downloadAsPEM(name?: string) {\n Download.cert.asPEM(\n this.toString('pem'),\n name || this.commonName,\n );\n }\n\n public downloadAsDER(name?: string) {\n Download.cert.asDER(\n this.raw,\n name || this.commonName,\n );\n }\n}\n"],"names":["Convert"],"mappings":";;;;;AAAA;;;;;;AAMG;AAyCG,MAAO,eAAgB,SAAQ,OAAoB,CAAA;AAuBvD,IAAA,WAAA,CAAY,GAAW,EAAA;QACrB,KAAK,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC;QAP1C,IAAW,CAAA,WAAA,GAA2B,EAAE;QAE/B,IAAI,CAAA,IAAA,GAAG,mBAAmB;AAE1B,QAAA,IAAA,CAAA,GAAG,GAAG,YAAY,CAAC,cAAc;AAK/C,QAAA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AAA;QAC5D,QAAQ,MAAM;AACZ,YAAA,KAAK,KAAK;AACR,gBAAA,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AAChD,YAAA,KAAK,WAAW;gBACd,OAAOA,oBAAO,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;AACtC,YAAA;gBACE,OAAOA,oBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;;;AAIhC,IAAA,aAAa,CAAC,IAAa,EAAA;AAChC,QAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,CACjB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EACpB,IAAI,IAAI,IAAI,CAAC,UAAU,CACxB;;AAGI,IAAA,aAAa,CAAC,IAAa,EAAA;AAChC,QAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,CACjB,IAAI,CAAC,GAAG,EACR,IAAI,IAAI,IAAI,CAAC,UAAU,CACxB;;AAEJ;;;;"}
1
+ {"version":3,"file":"x509_certificate-ObET7_Te.js","sources":["src/crypto/x509_certificate.ts"],"sourcesContent":["/**\n * @license\n * Copyright (c) Peculiar Ventures, LLC.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { AsnConvert } from '@peculiar/asn1-schema';\nimport { ECParameters, id_ecPublicKey } from '@peculiar/asn1-ecc';\nimport { id_rsaEncryption, RSAPublicKey } from '@peculiar/asn1-rsa';\nimport {\n id_composite_key,\n id_alg_composite,\n CompositePublicKey,\n CompositeSignatureValue,\n CompositeParams,\n} from '@peculiar/asn1-x509-post-quantum';\nimport { Certificate, SubjectPublicKeyInfo } from '@peculiar/asn1-x509';\nimport { Convert } from 'pvtsutils';\n\nimport { dateDiff, Download } from '../utils';\n\nimport { Name, INameJSON } from './name';\nimport { Extension, TExtensionValue } from './extension';\nimport { AsnData } from './asn_data';\nimport { PemConverter } from './pem_converter';\nimport {\n certificateRawToBuffer,\n getCertificateThumbprint,\n} from './utils';\n\nexport interface ISignature {\n algorithm: string;\n value: BufferSource;\n params?: {\n algorithm: string;\n value: BufferSource;\n }[];\n}\n\nexport interface IPublicKey {\n algorithm: string;\n value: BufferSource;\n params?: ECParameters | RSAPublicKey | IPublicKey[];\n}\n\nexport class X509Certificate extends AsnData<Certificate> {\n public readonly serialNumber: string;\n\n public readonly subject: INameJSON[];\n\n public readonly issuer: INameJSON[];\n\n public readonly notBefore: Date;\n\n public readonly notAfter: Date;\n\n public readonly validity: string;\n\n public extensions: Extension<TExtensionValue>[];\n\n public readonly version: number;\n\n public thumbprints: Record<string, string> = {};\n\n public readonly type = 'X.509 Certificate';\n\n public readonly tag = PemConverter.CertificateTag;\n\n constructor(raw: string) {\n super(certificateRawToBuffer(raw), Certificate);\n\n const { tbsCertificate } = this.asn;\n\n this.serialNumber = Convert.ToHex(tbsCertificate.serialNumber);\n this.subject = new Name(tbsCertificate.subject).toJSON();\n this.issuer = new Name(tbsCertificate.issuer).toJSON();\n this.version = tbsCertificate.version + 1;\n\n const notBefore = tbsCertificate.validity.notBefore.utcTime\n || tbsCertificate.validity.notBefore.generalTime;\n\n if (!notBefore) {\n throw new Error(\"Cannot get 'notBefore' value\");\n }\n\n this.notBefore = notBefore;\n\n const notAfter = tbsCertificate.validity.notAfter.utcTime\n || tbsCertificate.validity.notAfter.generalTime;\n\n if (!notAfter) {\n throw new Error(\"Cannot get 'notAfter' value\");\n }\n\n this.notAfter = notAfter;\n this.validity = dateDiff(this.notBefore, this.notAfter);\n }\n\n public parseExtensions() {\n const { tbsCertificate } = this.asn;\n\n if (tbsCertificate.extensions) {\n this.extensions = tbsCertificate.extensions\n .map((e) => new Extension(AsnConvert.serialize(e)));\n }\n }\n\n private getPublicKeyInfo(publicKeyInfo: SubjectPublicKeyInfo) {\n const { subjectPublicKey, algorithm } = publicKeyInfo;\n let params;\n\n if (algorithm.algorithm === id_ecPublicKey && algorithm.parameters) {\n params = AsnConvert.parse(algorithm.parameters, ECParameters);\n }\n\n if (algorithm.algorithm === id_rsaEncryption) {\n params = AsnConvert.parse(subjectPublicKey, RSAPublicKey);\n }\n\n if (algorithm.algorithm === id_composite_key) {\n params = AsnConvert.parse(subjectPublicKey, CompositePublicKey);\n\n params = params.map((param) => this.getPublicKeyInfo(param));\n }\n\n const spki = AsnConvert.serialize(publicKeyInfo);\n\n return {\n params,\n value: spki,\n algorithm: algorithm.algorithm,\n };\n }\n\n public get publicKey(): IPublicKey {\n return this.getPublicKeyInfo(this.asn.tbsCertificate.subjectPublicKeyInfo);\n }\n\n public get signature(): ISignature {\n const { signatureValue, signatureAlgorithm } = this.asn;\n let params;\n\n if (signatureAlgorithm.algorithm === id_alg_composite) {\n const compositeSignatureValues = AsnConvert.parse(signatureValue, CompositeSignatureValue);\n const compositeParams = AsnConvert.parse(signatureAlgorithm.parameters, CompositeParams);\n\n params = compositeParams.map((param, index) => ({\n ...param,\n value: compositeSignatureValues[index],\n }));\n }\n\n return {\n params,\n value: signatureValue,\n algorithm: signatureAlgorithm.algorithm,\n };\n }\n\n public async getThumbprint(\n algorithm: string = 'SHA-1',\n ): Promise<void> {\n try {\n const thumbprint = await getCertificateThumbprint(algorithm, this.raw);\n\n if (thumbprint) {\n this.thumbprints[algorithm] = Convert.ToHex(thumbprint);\n }\n } catch (error) {\n console.error('Error thumbprint get:', error);\n }\n }\n\n public get commonName(): string {\n if (!this.subject) {\n return '';\n }\n\n for (let i = 0; i < this.subject.length; i += 1) {\n const name = this.subject[i];\n\n if (name.shortName === 'CN' || name.shortName === 'E' || name.shortName === 'O') {\n return name.value;\n }\n }\n\n return '';\n }\n\n public get issuerCommonName(): string {\n if (!this.issuer) {\n return '';\n }\n\n for (let i = 0; i < this.issuer.length; i += 1) {\n const name = this.issuer[i];\n\n if (name.shortName === 'CN') {\n return name.value;\n }\n\n if (name.shortName === 'E') {\n return name.value;\n }\n }\n\n return '';\n }\n\n public get isRoot(): boolean {\n return JSON.stringify(this.issuer) === JSON.stringify(this.subject);\n }\n\n public subjectToString() {\n if (!this.subject) {\n return '';\n }\n\n return this.subject\n .map((name) => (\n `${name.shortName}=${name.value}`\n ))\n .join(', ');\n }\n\n public issuerToString() {\n if (!this.issuer) {\n return '';\n }\n\n return this.issuer\n .map((name) => (\n `${name.shortName}=${name.value}`\n ))\n .join(', ');\n }\n\n public toString(format: 'pem' | 'base64' | 'base64url' = 'pem'): string {\n switch (format) {\n case 'pem':\n return PemConverter.encode(this.raw, this.tag);\n case 'base64url':\n return Convert.ToBase64Url(this.raw);\n default:\n return Convert.ToBase64(this.raw);\n }\n }\n\n public downloadAsPEM(name?: string) {\n Download.cert.asPEM(\n this.toString('pem'),\n name || this.commonName,\n );\n }\n\n public downloadAsDER(name?: string) {\n Download.cert.asDER(\n this.raw,\n name || this.commonName,\n );\n }\n}\n"],"names":["Convert"],"mappings":";;;;;AAAA;;;;;;AAMG;AAyCG,MAAO,eAAgB,SAAQ,OAAoB,CAAA;AAuBvD,IAAA,WAAA,CAAY,GAAW,EAAA;QACrB,KAAK,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC;QAP1C,IAAW,CAAA,WAAA,GAA2B,EAAE;QAE/B,IAAI,CAAA,IAAA,GAAG,mBAAmB;AAE1B,QAAA,IAAA,CAAA,GAAG,GAAG,YAAY,CAAC,cAAc;AAK/C,QAAA,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,GAAG;QAEnC,IAAI,CAAC,YAAY,GAAGA,oBAAO,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC;AAC9D,QAAA,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE;AACxD,QAAA,IAAI,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE;QACtD,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,OAAO,GAAG,CAAC;QAEz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,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EACpB,IAAI,IAAI,IAAI,CAAC,UAAU,CACxB;;AAGI,IAAA,aAAa,CAAC,IAAa,EAAA;AAChC,QAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,CACjB,IAAI,CAAC,GAAG,EACR,IAAI,IAAI,IAAI,CAAC,UAAU,CACxB;;AAEJ;;;;"}
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  * © Peculiar Ventures https://peculiarventures.com/ - MIT License
3
3
  */
4
- import { A as AsnData, c as certificateRawToBuffer, o as AttributeCertificate, P as PemConverter, b as buildExports, a as dateDiff, E as Extension, e as AsnConvert, n as getCertificateThumbprint, D as Download, p as CertificateList, N as Name } from './certification_request-BTbyumBe.js';
5
- import { A as Attribute } from './pkcs10_certificate_request-CrA_WcgY.js';
4
+ import { A as AsnData, c as certificateRawToBuffer, o as AttributeCertificate, P as PemConverter, b as buildExports, a as dateDiff, E as Extension, e as AsnConvert, n as getCertificateThumbprint, D as Download, p as CertificateList, N as Name } from './certification_request-Wtz6WM17.js';
5
+ import { A as Attribute } from './pkcs10_certificate_request-Cn7_Z7a1.js';
6
6
 
7
7
  /**
8
8
  * @license
@@ -172,6 +172,6 @@ class X509Crl extends AsnData {
172
172
  }
173
173
 
174
174
  export { X509AttributeCertificate as X, X509Crl as a };
175
- //# sourceMappingURL=x509_crl-DRjoh8Yp.js.map
175
+ //# sourceMappingURL=x509_crl-CeW7yzP9.js.map
176
176
 
177
- //# sourceMappingURL=x509_crl-DRjoh8Yp.js.map
177
+ //# sourceMappingURL=x509_crl-CeW7yzP9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"x509_crl-DRjoh8Yp.js","sources":["src/crypto/x509_attribute_certificate.ts","src/crypto/x509_crl.ts"],"sourcesContent":["/**\n * @license\n * Copyright (c) Peculiar Ventures, LLC.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { AsnConvert } from '@peculiar/asn1-schema';\nimport type { GeneralName } from '@peculiar/asn1-x509';\nimport { AttributeCertificate, Holder } from '@peculiar/asn1-x509-attr';\nimport { Convert } from 'pvtsutils';\n\nimport { dateDiff, Download } from '../utils';\n\nimport { AsnData } from './asn_data';\nimport { Extension, TExtensionValue } from './extension';\nimport { Attribute, TAttributeValue } from './attribute';\nimport { PemConverter } from './pem_converter';\nimport {\n certificateRawToBuffer,\n getCertificateThumbprint,\n} from './utils';\n\ninterface ISignature {\n algorithm: string;\n value: BufferSource;\n}\n\nexport class X509AttributeCertificate extends AsnData<AttributeCertificate> {\n public readonly serialNumber: string;\n\n public readonly version: number;\n\n public readonly notBefore: Date;\n\n public readonly notAfter: Date;\n\n public readonly validity: string;\n\n public extensions: Extension<TExtensionValue>[];\n\n public attributes: Attribute<TAttributeValue>[];\n\n public thumbprints: Record<string, string> = {};\n\n public readonly issuer: GeneralName[];\n\n public holder: Holder;\n\n public readonly type = 'X.509 Attribute Certificate';\n\n public readonly tag = PemConverter.AttributeCertificateTag;\n\n constructor(raw: string) {\n super(certificateRawToBuffer(raw), AttributeCertificate);\n\n const { acinfo } = this.asn;\n\n this.serialNumber = Convert.ToHex(acinfo.serialNumber);\n this.version = acinfo.version;\n\n const notBefore = acinfo.attrCertValidityPeriod.notBeforeTime;\n\n if (!notBefore) {\n throw new Error(\"Cannot get 'notBefore' value\");\n }\n\n this.notBefore = notBefore;\n\n const notAfter = acinfo.attrCertValidityPeriod.notAfterTime;\n\n if (!notAfter) {\n throw new Error(\"Cannot get 'notAfter' value\");\n }\n\n this.notAfter = notAfter;\n this.validity = dateDiff(this.notBefore, this.notAfter);\n this.issuer = acinfo.issuer.v1Form || acinfo.issuer.v2Form?.issuerName;\n this.holder = acinfo.holder;\n }\n\n public get signature(): ISignature {\n const { signatureValue, signatureAlgorithm } = this.asn;\n\n return {\n value: signatureValue,\n algorithm: signatureAlgorithm.algorithm,\n };\n }\n\n public parseExtensions() {\n const { acinfo } = this.asn;\n\n if (acinfo.extensions) {\n this.extensions = acinfo.extensions\n .map((e) => new Extension(AsnConvert.serialize(e)));\n }\n }\n\n public parseAttributes() {\n const { acinfo } = this.asn;\n\n if (acinfo.attributes) {\n this.attributes = acinfo.attributes\n .map((e) => new Attribute(AsnConvert.serialize(e)));\n }\n }\n\n public async getThumbprint(\n algorithm: string = 'SHA-1',\n ): Promise<void> {\n try {\n const thumbprint = await getCertificateThumbprint(algorithm, this.raw);\n\n if (thumbprint) {\n this.thumbprints[algorithm] = Convert.ToHex(thumbprint);\n }\n } catch (error) {\n console.error('Error thumbprint get:', error);\n }\n }\n\n public get commonName(): string {\n return `attribute-certificate-${this.thumbprints['SHA-1']}`;\n }\n\n public toString(format: 'pem' | 'base64' | 'base64url' = 'pem'): string {\n switch (format) {\n case 'pem':\n return PemConverter.encode(this.raw, this.tag);\n case 'base64url':\n return Convert.ToBase64Url(this.raw);\n default:\n return Convert.ToBase64(this.raw);\n }\n }\n\n public downloadAsPEM(name?: string) {\n Download.attrCert.asPEM(\n this.toString('pem'),\n name || this.commonName,\n );\n }\n\n public downloadAsDER(name?: string) {\n Download.attrCert.asDER(\n this.raw,\n name || this.commonName,\n );\n }\n}\n","/**\n * @license\n * Copyright (c) Peculiar Ventures, LLC.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { AsnConvert } from '@peculiar/asn1-schema';\nimport { CertificateList, Time } from '@peculiar/asn1-x509';\nimport { Convert } from 'pvtsutils';\n\nimport { Download } from '../utils';\n\nimport { Extension, TExtensionValue } from './extension';\nimport { AsnData } from './asn_data';\nimport { Name, INameJSON } from './name';\nimport { PemConverter } from './pem_converter';\nimport {\n certificateRawToBuffer,\n getCertificateThumbprint,\n} from './utils';\n\ninterface ISignature {\n algorithm: string;\n value: BufferSource;\n}\n\nexport interface IRevokedCertificate {\n userCertificate: ArrayBuffer;\n revocationDate: Time;\n crlEntryExtensions?: Extension<TExtensionValue>[];\n}\n\nexport class X509Crl extends AsnData<CertificateList> {\n public readonly issuer: INameJSON[];\n\n public readonly version: number;\n\n public readonly lastUpdate: Date;\n\n public readonly nextUpdate: Date;\n\n public extensions: Extension<TExtensionValue>[];\n\n public revokedCertificates: IRevokedCertificate[];\n\n public thumbprints: Record<string, string> = {};\n\n public readonly type = 'X.509 Certificate Revocation List';\n\n public readonly tag = PemConverter.CrlTag;\n\n constructor(raw: string) {\n super(certificateRawToBuffer(raw), CertificateList);\n\n const { tbsCertList } = this.asn;\n\n this.issuer = new Name(tbsCertList.issuer).toJSON();\n this.version = tbsCertList.version + 1;\n this.lastUpdate = tbsCertList.thisUpdate.getTime();\n this.nextUpdate = tbsCertList.nextUpdate.getTime();\n\n this.revokedCertificates = (tbsCertList.revokedCertificates || [])\n .map((revokedCertificate) => ({\n revocationDate: revokedCertificate.revocationDate,\n userCertificate: revokedCertificate.userCertificate,\n crlEntryExtensions: revokedCertificate.crlEntryExtensions\n ?.map((e) => new Extension(AsnConvert.serialize(e))),\n }));\n }\n\n public async getThumbprint(\n algorithm: string = 'SHA-1',\n ): Promise<void> {\n try {\n const thumbprint = await getCertificateThumbprint(algorithm, this.raw);\n\n if (thumbprint) {\n this.thumbprints[algorithm] = Convert.ToHex(thumbprint);\n }\n } catch (error) {\n console.error('Error thumbprint get:', error);\n }\n }\n\n public get signature(): ISignature {\n const { signature, signatureAlgorithm } = this.asn;\n\n return {\n value: signature,\n algorithm: signatureAlgorithm.algorithm,\n };\n }\n\n public get commonName(): string {\n if (!this.issuer) {\n return '';\n }\n\n for (let i = 0; i < this.issuer.length; i += 1) {\n const name = this.issuer[i];\n\n if (name.shortName === 'CN' || name.shortName === 'E' || name.shortName === 'O') {\n return name.value;\n }\n }\n\n return '';\n }\n\n public parseExtensions() {\n const { tbsCertList } = this.asn;\n\n if (tbsCertList.crlExtensions) {\n this.extensions = tbsCertList.crlExtensions\n .map((e) => new Extension(AsnConvert.serialize(e)));\n }\n }\n\n public toString(format: 'pem' | 'base64' | 'base64url' = 'pem'): string {\n switch (format) {\n case 'pem':\n return PemConverter.encode(this.raw, this.tag);\n case 'base64url':\n return Convert.ToBase64Url(this.raw);\n default:\n return Convert.ToBase64(this.raw);\n }\n }\n\n public downloadAsPEM(name?: string) {\n Download.crl.asPEM(\n this.toString('pem'),\n name || this.commonName,\n );\n }\n\n public downloadAsDER(name?: string) {\n Download.crl.asDER(\n this.raw,\n name || this.commonName,\n );\n }\n}\n"],"names":["Convert"],"mappings":";;;;;;AAAA;;;;;;AAMG;AAuBG,MAAO,wBAAyB,SAAQ,OAA6B,CAAA;AAyBzE,IAAA,WAAA,CAAY,GAAW,EAAA;;QACrB,KAAK,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,oBAAoB,CAAC;QAXnD,IAAW,CAAA,WAAA,GAA2B,EAAE;QAM/B,IAAI,CAAA,IAAA,GAAG,6BAA6B;AAEpC,QAAA,IAAA,CAAA,GAAG,GAAG,YAAY,CAAC,uBAAuB;AAKxD,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG;QAE3B,IAAI,CAAC,YAAY,GAAGA,oBAAO,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;AACtD,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO;AAE7B,QAAA,MAAM,SAAS,GAAG,MAAM,CAAC,sBAAsB,CAAC,aAAa;QAE7D,IAAI,CAAC,SAAS,EAAE;AACd,YAAA,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC;;AAGjD,QAAA,IAAI,CAAC,SAAS,GAAG,SAAS;AAE1B,QAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,sBAAsB,CAAC,YAAY;QAE3D,IAAI,CAAC,QAAQ,EAAE;AACb,YAAA,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC;;AAGhD,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;AACxB,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,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aAAa,CAAC,IAAa,EAAA;AAChC,QAAA,QAAQ,CAAC,GAAG,CAAC,KAAK,CAChB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EACpB,IAAI,IAAI,IAAI,CAAC,UAAU,CACxB;;AAGI,IAAA,aAAa,CAAC,IAAa,EAAA;AAChC,QAAA,QAAQ,CAAC,GAAG,CAAC,KAAK,CAChB,IAAI,CAAC,GAAG,EACR,IAAI,IAAI,IAAI,CAAC,UAAU,CACxB;;AAEJ;;;;"}
1
+ {"version":3,"file":"x509_crl-CeW7yzP9.js","sources":["src/crypto/x509_attribute_certificate.ts","src/crypto/x509_crl.ts"],"sourcesContent":["/**\n * @license\n * Copyright (c) Peculiar Ventures, LLC.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { AsnConvert } from '@peculiar/asn1-schema';\nimport type { GeneralName } from '@peculiar/asn1-x509';\nimport { AttributeCertificate, Holder } from '@peculiar/asn1-x509-attr';\nimport { Convert } from 'pvtsutils';\n\nimport { dateDiff, Download } from '../utils';\n\nimport { AsnData } from './asn_data';\nimport { Extension, TExtensionValue } from './extension';\nimport { Attribute, TAttributeValue } from './attribute';\nimport { PemConverter } from './pem_converter';\nimport {\n certificateRawToBuffer,\n getCertificateThumbprint,\n} from './utils';\n\ninterface ISignature {\n algorithm: string;\n value: BufferSource;\n}\n\nexport class X509AttributeCertificate extends AsnData<AttributeCertificate> {\n public readonly serialNumber: string;\n\n public readonly version: number;\n\n public readonly notBefore: Date;\n\n public readonly notAfter: Date;\n\n public readonly validity: string;\n\n public extensions: Extension<TExtensionValue>[];\n\n public attributes: Attribute<TAttributeValue>[];\n\n public thumbprints: Record<string, string> = {};\n\n public readonly issuer: GeneralName[];\n\n public holder: Holder;\n\n public readonly type = 'X.509 Attribute Certificate';\n\n public readonly tag = PemConverter.AttributeCertificateTag;\n\n constructor(raw: string) {\n super(certificateRawToBuffer(raw), AttributeCertificate);\n\n const { acinfo } = this.asn;\n\n this.serialNumber = Convert.ToHex(acinfo.serialNumber);\n this.version = acinfo.version;\n\n const notBefore = acinfo.attrCertValidityPeriod.notBeforeTime;\n\n if (!notBefore) {\n throw new Error(\"Cannot get 'notBefore' value\");\n }\n\n this.notBefore = notBefore;\n\n const notAfter = acinfo.attrCertValidityPeriod.notAfterTime;\n\n if (!notAfter) {\n throw new Error(\"Cannot get 'notAfter' value\");\n }\n\n this.notAfter = notAfter;\n this.validity = dateDiff(this.notBefore, this.notAfter);\n this.issuer = acinfo.issuer.v1Form || acinfo.issuer.v2Form?.issuerName;\n this.holder = acinfo.holder;\n }\n\n public get signature(): ISignature {\n const { signatureValue, signatureAlgorithm } = this.asn;\n\n return {\n value: signatureValue,\n algorithm: signatureAlgorithm.algorithm,\n };\n }\n\n public parseExtensions() {\n const { acinfo } = this.asn;\n\n if (acinfo.extensions) {\n this.extensions = acinfo.extensions\n .map((e) => new Extension(AsnConvert.serialize(e)));\n }\n }\n\n public parseAttributes() {\n const { acinfo } = this.asn;\n\n if (acinfo.attributes) {\n this.attributes = acinfo.attributes\n .map((e) => new Attribute(AsnConvert.serialize(e)));\n }\n }\n\n public async getThumbprint(\n algorithm: string = 'SHA-1',\n ): Promise<void> {\n try {\n const thumbprint = await getCertificateThumbprint(algorithm, this.raw);\n\n if (thumbprint) {\n this.thumbprints[algorithm] = Convert.ToHex(thumbprint);\n }\n } catch (error) {\n console.error('Error thumbprint get:', error);\n }\n }\n\n public get commonName(): string {\n return `attribute-certificate-${this.thumbprints['SHA-1']}`;\n }\n\n public toString(format: 'pem' | 'base64' | 'base64url' = 'pem'): string {\n switch (format) {\n case 'pem':\n return PemConverter.encode(this.raw, this.tag);\n case 'base64url':\n return Convert.ToBase64Url(this.raw);\n default:\n return Convert.ToBase64(this.raw);\n }\n }\n\n public downloadAsPEM(name?: string) {\n Download.attrCert.asPEM(\n this.toString('pem'),\n name || this.commonName,\n );\n }\n\n public downloadAsDER(name?: string) {\n Download.attrCert.asDER(\n this.raw,\n name || this.commonName,\n );\n }\n}\n","/**\n * @license\n * Copyright (c) Peculiar Ventures, LLC.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { AsnConvert } from '@peculiar/asn1-schema';\nimport { CertificateList, Time } from '@peculiar/asn1-x509';\nimport { Convert } from 'pvtsutils';\n\nimport { Download } from '../utils';\n\nimport { Extension, TExtensionValue } from './extension';\nimport { AsnData } from './asn_data';\nimport { Name, INameJSON } from './name';\nimport { PemConverter } from './pem_converter';\nimport {\n certificateRawToBuffer,\n getCertificateThumbprint,\n} from './utils';\n\ninterface ISignature {\n algorithm: string;\n value: BufferSource;\n}\n\nexport interface IRevokedCertificate {\n userCertificate: ArrayBuffer;\n revocationDate: Time;\n crlEntryExtensions?: Extension<TExtensionValue>[];\n}\n\nexport class X509Crl extends AsnData<CertificateList> {\n public readonly issuer: INameJSON[];\n\n public readonly version: number;\n\n public readonly lastUpdate: Date;\n\n public readonly nextUpdate: Date;\n\n public extensions: Extension<TExtensionValue>[];\n\n public revokedCertificates: IRevokedCertificate[];\n\n public thumbprints: Record<string, string> = {};\n\n public readonly type = 'X.509 Certificate Revocation List';\n\n public readonly tag = PemConverter.CrlTag;\n\n constructor(raw: string) {\n super(certificateRawToBuffer(raw), CertificateList);\n\n const { tbsCertList } = this.asn;\n\n this.issuer = new Name(tbsCertList.issuer).toJSON();\n this.version = tbsCertList.version + 1;\n this.lastUpdate = tbsCertList.thisUpdate.getTime();\n this.nextUpdate = tbsCertList.nextUpdate.getTime();\n\n this.revokedCertificates = (tbsCertList.revokedCertificates || [])\n .map((revokedCertificate) => ({\n revocationDate: revokedCertificate.revocationDate,\n userCertificate: revokedCertificate.userCertificate,\n crlEntryExtensions: revokedCertificate.crlEntryExtensions\n ?.map((e) => new Extension(AsnConvert.serialize(e))),\n }));\n }\n\n public async getThumbprint(\n algorithm: string = 'SHA-1',\n ): Promise<void> {\n try {\n const thumbprint = await getCertificateThumbprint(algorithm, this.raw);\n\n if (thumbprint) {\n this.thumbprints[algorithm] = Convert.ToHex(thumbprint);\n }\n } catch (error) {\n console.error('Error thumbprint get:', error);\n }\n }\n\n public get signature(): ISignature {\n const { signature, signatureAlgorithm } = this.asn;\n\n return {\n value: signature,\n algorithm: signatureAlgorithm.algorithm,\n };\n }\n\n public get commonName(): string {\n if (!this.issuer) {\n return '';\n }\n\n for (let i = 0; i < this.issuer.length; i += 1) {\n const name = this.issuer[i];\n\n if (name.shortName === 'CN' || name.shortName === 'E' || name.shortName === 'O') {\n return name.value;\n }\n }\n\n return '';\n }\n\n public parseExtensions() {\n const { tbsCertList } = this.asn;\n\n if (tbsCertList.crlExtensions) {\n this.extensions = tbsCertList.crlExtensions\n .map((e) => new Extension(AsnConvert.serialize(e)));\n }\n }\n\n public toString(format: 'pem' | 'base64' | 'base64url' = 'pem'): string {\n switch (format) {\n case 'pem':\n return PemConverter.encode(this.raw, this.tag);\n case 'base64url':\n return Convert.ToBase64Url(this.raw);\n default:\n return Convert.ToBase64(this.raw);\n }\n }\n\n public downloadAsPEM(name?: string) {\n Download.crl.asPEM(\n this.toString('pem'),\n name || this.commonName,\n );\n }\n\n public downloadAsDER(name?: string) {\n Download.crl.asDER(\n this.raw,\n name || this.commonName,\n );\n }\n}\n"],"names":["Convert"],"mappings":";;;;;;AAAA;;;;;;AAMG;AAuBG,MAAO,wBAAyB,SAAQ,OAA6B,CAAA;AAyBzE,IAAA,WAAA,CAAY,GAAW,EAAA;;QACrB,KAAK,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,oBAAoB,CAAC;QAXnD,IAAW,CAAA,WAAA,GAA2B,EAAE;QAM/B,IAAI,CAAA,IAAA,GAAG,6BAA6B;AAEpC,QAAA,IAAA,CAAA,GAAG,GAAG,YAAY,CAAC,uBAAuB;AAKxD,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG;QAE3B,IAAI,CAAC,YAAY,GAAGA,oBAAO,CAAC,KAAK,CAAC,MAAM,CAA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