@peculiar/certificates-viewer 3.2.1 → 3.3.1

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 (108) hide show
  1. package/dist/cjs/{certification_request-cde57123.js → certification_request-50ce61b3.js} +643 -235
  2. package/dist/cjs/crl-0c15e04a.js +312 -0
  3. package/dist/cjs/{index-ff818d4d.js → download-a97f4cb2.js} +106 -2
  4. package/dist/cjs/index.cjs.js +1 -3
  5. package/dist/cjs/l10n-4eaa5263.js +167 -0
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/cjs/{peculiar-attribute-certificate-viewer_2.cjs.entry.js → peculiar-attribute-certificate-viewer_3.cjs.entry.js} +123 -21
  8. package/dist/cjs/peculiar-certificate-decoder.cjs.entry.js +25 -15
  9. package/dist/cjs/peculiar-certificate-summary_3.cjs.entry.js +2 -2
  10. package/dist/cjs/peculiar-certificate-viewer.cjs.entry.js +6 -25
  11. package/dist/cjs/peculiar-certificates-viewer.cjs.entry.js +6 -8
  12. package/dist/cjs/peculiar.cjs.js +1 -1
  13. package/dist/cjs/{public_key-2f5bd471.js → public_key-2b73778a.js} +80 -40
  14. package/dist/cjs/{x509_certificate-51a97033.js → x509_certificate-c94ce29e.js} +13 -7
  15. package/dist/collection/collection-manifest.json +1 -0
  16. package/dist/collection/components/certificate-decoder/certificate-decoder.js +19 -6
  17. package/dist/collection/components/certificate-viewer/attributes/type_relationship_attribute.js +2 -1
  18. package/dist/collection/components/certificate-viewer/basic_information.js +3 -1
  19. package/dist/collection/components/certificate-viewer/extensions/basic_constraints_extension.js +2 -1
  20. package/dist/collection/components/certificate-viewer/extensions/basic_extension.js +2 -1
  21. package/dist/collection/components/certificate-viewer/extensions/crl_number_extension.js +19 -0
  22. package/dist/collection/components/certificate-viewer/extensions/index.js +9 -1
  23. package/dist/collection/components/certificate-viewer/extensions/issuing_distribution_point_extension.js +27 -0
  24. package/dist/collection/components/certificate-viewer/extensions/timestamp_extension.js +2 -1
  25. package/dist/collection/components/certificate-viewer/miscellaneous.js +2 -20
  26. package/dist/collection/components/certificates-viewer/certificates-viewer.js +2 -3
  27. package/dist/collection/components/crl-viewer/crl-viewer.js +234 -0
  28. package/dist/collection/components/crl-viewer/revoked_certificates.js +27 -0
  29. package/dist/collection/crypto/crl.js +82 -0
  30. package/dist/collection/crypto/csr.js +7 -0
  31. package/dist/collection/crypto/extension.js +10 -1
  32. package/dist/collection/crypto/index.js +1 -0
  33. package/dist/collection/crypto/utils.js +5 -4
  34. package/dist/collection/crypto/x509_attribute_certificate.js +7 -1
  35. package/dist/collection/crypto/x509_certificate.js +7 -1
  36. package/dist/collection/locales/en.json +12 -1
  37. package/dist/collection/utils/download.js +18 -2
  38. package/dist/collection/utils/index.js +1 -0
  39. package/dist/collection/utils/validator.js +2 -0
  40. package/dist/esm/{certification_request-c0674647.js → certification_request-5b5c2fa2.js} +577 -172
  41. package/dist/esm/crl-10d4db54.js +308 -0
  42. package/dist/esm/{index-0ba131b0.js → download-67ac9120.js} +102 -2
  43. package/dist/esm/index.js +1 -3
  44. package/dist/esm/l10n-116c79fa.js +163 -0
  45. package/dist/esm/loader.js +1 -1
  46. package/dist/esm/{peculiar-attribute-certificate-viewer_2.entry.js → peculiar-attribute-certificate-viewer_3.entry.js} +113 -12
  47. package/dist/esm/peculiar-certificate-decoder.entry.js +21 -11
  48. package/dist/esm/peculiar-certificate-summary_3.entry.js +2 -2
  49. package/dist/esm/peculiar-certificate-viewer.entry.js +6 -25
  50. package/dist/esm/peculiar-certificates-viewer.entry.js +6 -8
  51. package/dist/esm/peculiar.js +1 -1
  52. package/dist/esm/{public_key-38c9ddc8.js → public_key-c1e6801e.js} +67 -28
  53. package/dist/esm/{x509_certificate-12f6d344.js → x509_certificate-61126913.js} +9 -3
  54. package/dist/peculiar/index.esm.js +1 -1
  55. package/dist/peculiar/locales/en.json +12 -1
  56. package/dist/peculiar/p-10aa0b03.entry.js +11 -0
  57. package/dist/peculiar/{p-17c4da7b.js → p-309fdd02.js} +2 -2
  58. package/dist/peculiar/p-318a1e9f.entry.js +4 -0
  59. package/dist/peculiar/p-53aac672.js +63 -0
  60. package/dist/peculiar/p-5a898f51.js +32 -0
  61. package/dist/peculiar/{p-38635919.entry.js → p-652f77d0.entry.js} +1 -1
  62. package/dist/peculiar/p-7ef69178.entry.js +4 -0
  63. package/dist/peculiar/{p-464e0943.js → p-bbf0fd6c.js} +9 -9
  64. package/dist/peculiar/p-cff9655c.js +18 -0
  65. package/dist/peculiar/p-ed58acd0.js +12 -0
  66. package/dist/peculiar/p-ff867be1.entry.js +26 -0
  67. package/dist/peculiar/peculiar.esm.js +1 -1
  68. package/dist/types/components/certificate-decoder/certificate-decoder.d.ts +3 -3
  69. package/dist/types/components/certificate-viewer/basic_information.d.ts +2 -0
  70. package/dist/types/components/certificate-viewer/extensions/crl_number_extension.d.ts +15 -0
  71. package/dist/types/components/certificate-viewer/extensions/issuing_distribution_point_extension.d.ts +15 -0
  72. package/dist/types/components/certificate-viewer/miscellaneous.d.ts +2 -2
  73. package/dist/types/components/certificate-viewer/row.d.ts +1 -1
  74. package/dist/types/components/crl-viewer/crl-viewer.d.ts +59 -0
  75. package/dist/types/components/crl-viewer/revoked_certificates.d.ts +14 -0
  76. package/dist/types/components.d.ts +66 -0
  77. package/dist/types/crypto/crl.d.ts +28 -0
  78. package/dist/types/crypto/csr.d.ts +2 -0
  79. package/dist/types/crypto/extension.d.ts +2 -2
  80. package/dist/types/crypto/index.d.ts +1 -0
  81. package/dist/types/crypto/x509_attribute_certificate.d.ts +2 -0
  82. package/dist/types/crypto/x509_certificate.d.ts +2 -0
  83. package/dist/types/utils/download.d.ts +10 -2
  84. package/dist/types/utils/index.d.ts +1 -0
  85. package/dist/types/utils/l10n.d.ts +11 -0
  86. package/dist/types/utils/validator.d.ts +1 -0
  87. package/package.json +19 -19
  88. package/dist/cjs/_commonjsHelpers-cb1f949a.js +0 -23
  89. package/dist/cjs/csr-78378ed0.js +0 -150
  90. package/dist/cjs/download-6724f3a7.js +0 -79
  91. package/dist/cjs/l10n-a048a686.js +0 -145
  92. package/dist/cjs/x509_attribute_certificate-cc325b70.js +0 -87
  93. package/dist/esm/_commonjsHelpers-bfbd2ad8.js +0 -20
  94. package/dist/esm/csr-c1b6a176.js +0 -147
  95. package/dist/esm/download-735fb2eb.js +0 -76
  96. package/dist/esm/l10n-ac28fa92.js +0 -141
  97. package/dist/esm/x509_attribute_certificate-a6d4aa15.js +0 -85
  98. package/dist/peculiar/p-006865d7.js +0 -4
  99. package/dist/peculiar/p-3f8d1008.entry.js +0 -4
  100. package/dist/peculiar/p-42da7f97.js +0 -11
  101. package/dist/peculiar/p-4f4c1d30.js +0 -12
  102. package/dist/peculiar/p-6011646e.entry.js +0 -11
  103. package/dist/peculiar/p-6bfd077c.entry.js +0 -18
  104. package/dist/peculiar/p-6c510523.js +0 -18
  105. package/dist/peculiar/p-986cc770.entry.js +0 -11
  106. package/dist/peculiar/p-b765873e.js +0 -78
  107. package/dist/peculiar/p-d0b55fbb.js +0 -4
  108. package/dist/peculiar/p-d7a13cb4.js +0 -18
@@ -0,0 +1,234 @@
1
+ /*!
2
+ * © Peculiar Ventures https://peculiarventures.com/ - MIT License
3
+ */
4
+ /**
5
+ * @license
6
+ * Copyright (c) Peculiar Ventures, LLC.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */
11
+ import { Component, Host, h, Prop, State, Watch, } from '@stencil/core';
12
+ import { CRL } from '../../crypto';
13
+ import { getDNSNameLink, getIPAddressLink, getLEILink } from '../../utils/third_party_links';
14
+ import { Signature } from '../certificate-viewer/signature';
15
+ import { IssuerName } from '../certificate-viewer/issuer_name';
16
+ import { Thumbprints } from '../certificate-viewer/thumbprints';
17
+ import { Extensions } from '../certificate-viewer/extensions';
18
+ import { Miscellaneous } from '../certificate-viewer/miscellaneous';
19
+ import { BasicInformation } from '../certificate-viewer/basic_information';
20
+ import { RevokedCertificates } from './revoked_certificates';
21
+ export class CrlViewer {
22
+ constructor() {
23
+ this.isDecodeInProcess = true;
24
+ this.getAuthKeyIdParentLink = (value) => {
25
+ var _a;
26
+ return (_a = this.authKeyIdParentLink) === null || _a === void 0 ? void 0 : _a.replace('{{authKeyId}}', value);
27
+ };
28
+ this.getAuthKeyIdSiblingsLink = (value) => {
29
+ var _a;
30
+ return (_a = this.authKeyIdSiblingsLink) === null || _a === void 0 ? void 0 : _a.replace('{{authKeyId}}', value);
31
+ };
32
+ }
33
+ componentWillLoad() {
34
+ this.decodeCertificate(this.certificate);
35
+ }
36
+ async decodeCertificate(certificate) {
37
+ this.isDecodeInProcess = true;
38
+ try {
39
+ if (certificate instanceof CRL) {
40
+ this.certificateDecoded = certificate;
41
+ }
42
+ else if (typeof certificate === 'string') {
43
+ this.certificateDecoded = new CRL(certificate);
44
+ }
45
+ else {
46
+ return;
47
+ }
48
+ this.certificateDecoded.parseExtensions();
49
+ await this.certificateDecoded.getThumbprint('SHA-1');
50
+ await this.certificateDecoded.getThumbprint('SHA-256');
51
+ }
52
+ catch (error) {
53
+ this.certificateDecodeError = error;
54
+ console.error('Error certificate parse:', error);
55
+ }
56
+ this.isDecodeInProcess = false;
57
+ }
58
+ getIssuerDnLink() {
59
+ return this.issuerDnLink;
60
+ }
61
+ /**
62
+ * Rerun decodeCertificate if previuos value not equal current value
63
+ */
64
+ watchCertificateAndDecode(newValue, oldValue) {
65
+ if (typeof newValue === 'string' && typeof oldValue === 'string') {
66
+ if (newValue !== oldValue) {
67
+ this.decodeCertificate(newValue);
68
+ }
69
+ return;
70
+ }
71
+ if (newValue instanceof CRL
72
+ && oldValue instanceof CRL) {
73
+ if (newValue.commonName !== oldValue.commonName) {
74
+ this.decodeCertificate(newValue);
75
+ }
76
+ }
77
+ }
78
+ // eslint-disable-next-line class-methods-use-this
79
+ renderErrorState() {
80
+ return (h("div", { class: "status_wrapper" },
81
+ h("peculiar-typography", { type: "b1", class: "interaction_text" }, "There was an error decoding this certificate revocation list.")));
82
+ }
83
+ // eslint-disable-next-line class-methods-use-this
84
+ renderEmptyState() {
85
+ return (h("div", { class: "status_wrapper" },
86
+ h("peculiar-typography", { type: "b1", class: "interaction_text" }, "There is no certificate revocation list available.")));
87
+ }
88
+ render() {
89
+ if (this.certificateDecodeError) {
90
+ return this.renderErrorState();
91
+ }
92
+ if (!this.certificateDecoded) {
93
+ return this.renderEmptyState();
94
+ }
95
+ return (h(Host, { "data-view": this.view },
96
+ h("table", null,
97
+ h(BasicInformation, Object.assign({}, this.certificateDecoded)),
98
+ h(IssuerName, { name: this.certificateDecoded.issuer, issuerDnLink: this.getIssuerDnLink() }),
99
+ h(Signature, { signature: this.certificateDecoded.signature }),
100
+ h(Thumbprints, { thumbprints: this.certificateDecoded.thumbprints }),
101
+ h(Extensions, { extensions: this.certificateDecoded.extensions, getLEILink: getLEILink, getDNSNameLink: getDNSNameLink, getIPAddressLink: getIPAddressLink, getAuthKeyIdParentLink: this.getAuthKeyIdParentLink, getAuthKeyIdSiblingsLink: this.getAuthKeyIdSiblingsLink }),
102
+ this.certificateDecoded.asn.tbsCertList.revokedCertificates && (h(RevokedCertificates, { certificates: this.certificateDecoded.asn.tbsCertList.revokedCertificates })),
103
+ this.download && (h(Miscellaneous, { certificate: this.certificateDecoded })))));
104
+ }
105
+ static get is() { return "peculiar-crl-viewer"; }
106
+ static get encapsulation() { return "shadow"; }
107
+ static get originalStyleUrls() { return {
108
+ "$": ["../certificate-viewer/certificate-viewer.scss"]
109
+ }; }
110
+ static get styleUrls() { return {
111
+ "$": ["../certificate-viewer/certificate-viewer.css"]
112
+ }; }
113
+ static get properties() { return {
114
+ "certificate": {
115
+ "type": "string",
116
+ "mutable": false,
117
+ "complexType": {
118
+ "original": "CrlProp",
119
+ "resolved": "CRL | string",
120
+ "references": {
121
+ "CrlProp": {
122
+ "location": "local"
123
+ }
124
+ }
125
+ },
126
+ "required": false,
127
+ "optional": false,
128
+ "docs": {
129
+ "tags": [],
130
+ "text": "The certificate value for decode and show details. Use PEM or DER."
131
+ },
132
+ "attribute": "certificate",
133
+ "reflect": true
134
+ },
135
+ "download": {
136
+ "type": "boolean",
137
+ "mutable": false,
138
+ "complexType": {
139
+ "original": "boolean",
140
+ "resolved": "boolean",
141
+ "references": {}
142
+ },
143
+ "required": false,
144
+ "optional": true,
145
+ "docs": {
146
+ "tags": [],
147
+ "text": "If `true` - component will show split-button to download certificate as PEM or DER."
148
+ },
149
+ "attribute": "download",
150
+ "reflect": false
151
+ },
152
+ "authKeyIdParentLink": {
153
+ "type": "string",
154
+ "mutable": false,
155
+ "complexType": {
156
+ "original": "string",
157
+ "resolved": "string",
158
+ "references": {}
159
+ },
160
+ "required": false,
161
+ "optional": true,
162
+ "docs": {
163
+ "tags": [{
164
+ "name": "example",
165
+ "text": " https://censys.io/certificates?q=parsed.extensions.subject_key_id:%20{{authKeyId}}"
166
+ }],
167
+ "text": "Authority Key Identifier extension parent link.\n<br />\n**NOTE**: `{{authKeyId}}` will be replaced to value from the extension."
168
+ },
169
+ "attribute": "auth-key-id-parent-link",
170
+ "reflect": true
171
+ },
172
+ "authKeyIdSiblingsLink": {
173
+ "type": "string",
174
+ "mutable": false,
175
+ "complexType": {
176
+ "original": "string",
177
+ "resolved": "string",
178
+ "references": {}
179
+ },
180
+ "required": false,
181
+ "optional": true,
182
+ "docs": {
183
+ "tags": [{
184
+ "name": "example",
185
+ "text": " https://censys.io/certificates?q=parsed.extensions.authority_key_id:%20{{authKeyId}}"
186
+ }],
187
+ "text": "Authority Key Identifier extension siblings link.\n<br />\n**NOTE**: `{{authKeyId}}` will be replaced to value from the extension."
188
+ },
189
+ "attribute": "auth-key-id-siblings-link",
190
+ "reflect": true
191
+ },
192
+ "issuerDnLink": {
193
+ "type": "string",
194
+ "mutable": false,
195
+ "complexType": {
196
+ "original": "string",
197
+ "resolved": "string",
198
+ "references": {}
199
+ },
200
+ "required": false,
201
+ "optional": true,
202
+ "docs": {
203
+ "tags": [],
204
+ "text": "Issuer DN link.\n**NOTE**: HTML component attribute must be `issuer-dn-link`."
205
+ },
206
+ "attribute": "issuer-dn-link",
207
+ "reflect": true
208
+ },
209
+ "view": {
210
+ "type": "string",
211
+ "mutable": false,
212
+ "complexType": {
213
+ "original": "'mobile'",
214
+ "resolved": "\"mobile\"",
215
+ "references": {}
216
+ },
217
+ "required": false,
218
+ "optional": true,
219
+ "docs": {
220
+ "tags": [],
221
+ "text": "Choose view type instead @media."
222
+ },
223
+ "attribute": "view",
224
+ "reflect": true
225
+ }
226
+ }; }
227
+ static get states() { return {
228
+ "isDecodeInProcess": {}
229
+ }; }
230
+ static get watchers() { return [{
231
+ "propName": "certificate",
232
+ "methodName": "watchCertificateAndDecode"
233
+ }]; }
234
+ }
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * © Peculiar Ventures https://peculiarventures.com/ - MIT License
3
+ */
4
+ /**
5
+ * @license
6
+ * Copyright (c) Peculiar Ventures, LLC.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */
11
+ import { h } from '@stencil/core';
12
+ import { Convert } from 'pvtsutils';
13
+ import { dateShort, l10n } from '../../utils';
14
+ import { RowTitle, RowValue } from '../certificate-viewer/row';
15
+ export const RevokedCertificates = (props) => {
16
+ const { certificates, } = props;
17
+ return [
18
+ h(RowTitle, { value: l10n.getString('revokedCertificates') }),
19
+ certificates.map((certificate) => ([
20
+ h(RowValue, { name: l10n.getString('serialNumber'), value: Convert.ToHex(certificate.userCertificate), monospace: true }),
21
+ h(RowValue, { name: l10n.getString('revocation'), value: dateShort(certificate.revocationDate.getTime()) }),
22
+ h("tr", null,
23
+ h("td", { colSpan: 2, class: "divider" },
24
+ h("span", { class: "bg_fill" }))),
25
+ ])),
26
+ ];
27
+ };
@@ -0,0 +1,82 @@
1
+ /*!
2
+ * © Peculiar Ventures https://peculiarventures.com/ - MIT License
3
+ */
4
+ /**
5
+ * @license
6
+ * Copyright (c) Peculiar Ventures, LLC.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */
11
+ import { AsnConvert } from '@peculiar/asn1-schema';
12
+ import { CertificateList } from '@peculiar/asn1-x509';
13
+ import { Convert } from 'pvtsutils';
14
+ import { Download } from '../utils';
15
+ import { Extension } from './extension';
16
+ import { AsnData } from './asn_data';
17
+ import { Name } from './name';
18
+ import { certificateRawToBuffer, hexFormat, base64Format, getCertificateThumbprint, } from './utils';
19
+ export class CRL extends AsnData {
20
+ constructor(raw) {
21
+ super(certificateRawToBuffer(raw), CertificateList);
22
+ this.thumbprints = {};
23
+ this.type = 'X.509 Certificate Revocation List';
24
+ const { tbsCertList } = this.asn;
25
+ this.issuer = new Name(tbsCertList.issuer).toJSON();
26
+ this.version = tbsCertList.version + 1;
27
+ this.lastUpdate = tbsCertList.thisUpdate.getTime();
28
+ this.nextUpdate = tbsCertList.nextUpdate.getTime();
29
+ }
30
+ async getThumbprint(algorithm = 'SHA-1') {
31
+ try {
32
+ const thumbprint = await getCertificateThumbprint(algorithm, this.raw);
33
+ if (thumbprint) {
34
+ this.thumbprints[algorithm['name'] || algorithm] = Convert.ToHex(thumbprint);
35
+ }
36
+ }
37
+ catch (error) {
38
+ console.error('Error thumbprint get:', error);
39
+ }
40
+ }
41
+ get signature() {
42
+ const { signature, signatureAlgorithm } = this.asn;
43
+ return {
44
+ value: signature,
45
+ algorithm: signatureAlgorithm.algorithm,
46
+ };
47
+ }
48
+ get commonName() {
49
+ if (!this.issuer) {
50
+ return '';
51
+ }
52
+ for (let i = 0; i < this.issuer.length; i += 1) {
53
+ const name = this.issuer[i];
54
+ if (name.shortName === 'CN' || name.shortName === 'E' || name.shortName === 'O') {
55
+ return name.value;
56
+ }
57
+ }
58
+ return '';
59
+ }
60
+ parseExtensions() {
61
+ const { tbsCertList } = this.asn;
62
+ if (tbsCertList.crlExtensions) {
63
+ this.extensions = tbsCertList.crlExtensions
64
+ .map((e) => new Extension(AsnConvert.serialize(e)));
65
+ }
66
+ }
67
+ exportAsBase64() {
68
+ return Convert.ToBase64(this.raw);
69
+ }
70
+ exportAsHexFormatted() {
71
+ return hexFormat(Convert.ToHex(this.raw));
72
+ }
73
+ exportAsPemFormatted() {
74
+ return `-----BEGIN X509 CRL-----\n${base64Format(this.exportAsBase64())}\n-----END X509 CRL-----`;
75
+ }
76
+ downloadAsPEM(name) {
77
+ Download.crl.asPEM(this.exportAsPemFormatted(), name || this.commonName);
78
+ }
79
+ downloadAsDER(name) {
80
+ Download.crl.asDER(this.exportAsHexFormatted(), name || this.commonName);
81
+ }
82
+ }
@@ -13,6 +13,7 @@ import { ECParameters, id_ecPublicKey } from '@peculiar/asn1-ecc';
13
13
  import { id_rsaEncryption, RSAPublicKey } from '@peculiar/asn1-rsa';
14
14
  import { CertificationRequest } from '@peculiar/asn1-csr';
15
15
  import { Convert } from 'pvtsutils';
16
+ import { Download } from '../utils';
16
17
  import { AsnData } from './asn_data';
17
18
  import { Name } from './name';
18
19
  import { Attribute } from './attribute';
@@ -88,4 +89,10 @@ export class CSR extends AsnData {
88
89
  exportAsPemFormatted() {
89
90
  return `-----BEGIN CERTIFICATE REQUEST-----\n${base64Format(this.exportAsBase64())}\n-----END CERTIFICATE REQUEST-----`;
90
91
  }
92
+ downloadAsPEM(name) {
93
+ Download.csr.asPEM(this.exportAsPemFormatted(), name || this.commonName);
94
+ }
95
+ downloadAsDER(name) {
96
+ Download.csr.asDER(this.exportAsHexFormatted(), name || this.commonName);
97
+ }
91
98
  }
@@ -9,7 +9,7 @@
9
9
  * LICENSE file in the root directory of this source tree.
10
10
  */
11
11
  import { Convert } from 'pvtsutils';
12
- import { Extension as AsnExtension, id_pe_authorityInfoAccess, AuthorityInfoAccessSyntax, id_ce_authorityKeyIdentifier, AuthorityKeyIdentifier, id_ce_basicConstraints, BasicConstraints, id_ce_certificateIssuer, CertificateIssuer, id_ce_certificatePolicies, CertificatePolicies, id_ce_cRLDistributionPoints, CRLDistributionPoints, id_ce_cRLReasons, CRLReason, id_ce_extKeyUsage, ExtendedKeyUsage, id_ce_inhibitAnyPolicy, InhibitAnyPolicy, id_ce_invalidityDate, InvalidityDate, id_ce_issuerAltName, IssueAlternativeName, id_ce_keyUsage, KeyUsage, id_ce_nameConstraints, NameConstraints, id_ce_policyConstraints, PolicyConstraints, id_ce_policyMappings, PolicyMappings, id_ce_subjectAltName, SubjectAlternativeName, id_ce_subjectDirectoryAttributes, SubjectDirectoryAttributes, id_ce_subjectKeyIdentifier, SubjectKeyIdentifier, id_ce_privateKeyUsagePeriod, PrivateKeyUsagePeriod, id_entrust_entrustVersInfo, EntrustVersionInfo, id_pe_subjectInfoAccess, SubjectInfoAccessSyntax, } from '@peculiar/asn1-x509';
12
+ import { Extension as AsnExtension, id_pe_authorityInfoAccess, AuthorityInfoAccessSyntax, id_ce_authorityKeyIdentifier, AuthorityKeyIdentifier, id_ce_basicConstraints, BasicConstraints, id_ce_certificateIssuer, CertificateIssuer, id_ce_certificatePolicies, CertificatePolicies, id_ce_cRLDistributionPoints, CRLDistributionPoints, id_ce_issuingDistributionPoint, IssuingDistributionPoint, id_ce_cRLReasons, CRLReason, id_ce_extKeyUsage, ExtendedKeyUsage, id_ce_inhibitAnyPolicy, InhibitAnyPolicy, id_ce_invalidityDate, InvalidityDate, id_ce_issuerAltName, IssueAlternativeName, id_ce_keyUsage, KeyUsage, id_ce_nameConstraints, NameConstraints, id_ce_policyConstraints, PolicyConstraints, id_ce_policyMappings, PolicyMappings, id_ce_subjectAltName, SubjectAlternativeName, id_ce_subjectDirectoryAttributes, SubjectDirectoryAttributes, id_ce_subjectKeyIdentifier, SubjectKeyIdentifier, id_ce_privateKeyUsagePeriod, PrivateKeyUsagePeriod, id_entrust_entrustVersInfo, EntrustVersionInfo, id_pe_subjectInfoAccess, SubjectInfoAccessSyntax, id_ce_cRLNumber, CRLNumber, id_ce_deltaCRLIndicator, BaseCRLNumber, } from '@peculiar/asn1-x509';
13
13
  import { id_pe_qcStatements, QCStatements, id_pe_biometricInfo, BiometricSyntax, } from '@peculiar/asn1-x509-qualified';
14
14
  import { id_certificateTemplate, CertificateTemplate, id_enrollCertType, EnrollCertTypeChoice, id_caVersion, CaVersion, } from '@peculiar/asn1-x509-microsoft';
15
15
  import { id_netscapeComment, NetscapeComment, id_netscapeCertType, NetscapeCertType, } from '@peculiar/asn1-x509-netscape';
@@ -45,6 +45,9 @@ export class Extension extends AsnData {
45
45
  case '2.5.29.46':
46
46
  this.value = AsnParser.parse(asnExtnValue, CRLDistributionPoints);
47
47
  break;
48
+ case id_ce_issuingDistributionPoint:
49
+ this.value = AsnParser.parse(asnExtnValue, IssuingDistributionPoint);
50
+ break;
48
51
  case id_ce_cRLReasons:
49
52
  this.value = AsnParser.parse(asnExtnValue, CRLReason);
50
53
  break;
@@ -133,6 +136,12 @@ export class Extension extends AsnData {
133
136
  case id_pe_subjectInfoAccess:
134
137
  this.value = AsnParser.parse(asnExtnValue, SubjectInfoAccessSyntax);
135
138
  break;
139
+ case id_ce_cRLNumber:
140
+ this.value = AsnParser.parse(asnExtnValue, CRLNumber);
141
+ break;
142
+ case id_ce_deltaCRLIndicator:
143
+ this.value = AsnParser.parse(asnExtnValue, BaseCRLNumber);
144
+ break;
136
145
  default:
137
146
  console.warn(`Didn't detect parser for "${this.asn.extnID}" extension.`);
138
147
  this.value = Convert.ToHex(asnExtnValue);
@@ -4,3 +4,4 @@
4
4
  export * from './x509_certificate';
5
5
  export * from './x509_attribute_certificate';
6
6
  export * from './csr';
7
+ export * from './crl';
@@ -4,10 +4,11 @@
4
4
  import { Convert } from 'pvtsutils';
5
5
  import { validator } from '../utils';
6
6
  import { cryptoProvider } from './provider';
7
- export const base64Clarify = (base64) => (base64
8
- .replace(/.*base64,/, '')
9
- .replace(/-----.+-----/g, '')
10
- .replace(/[\s\r\n]/g, ''));
7
+ const base64Re = /-----BEGIN [^-]+-----([A-Za-z0-9+/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+/=\s]+)====/;
8
+ export const base64Clarify = (base64) => {
9
+ const execArray = base64Re.exec(base64);
10
+ return execArray ? (execArray[1] || execArray[2]) : base64;
11
+ };
11
12
  export const hexFormat = (hex) => (hex
12
13
  .replace(/(.{32})/g, '$1\n')
13
14
  .replace(/(.{4})/g, '$1 ')
@@ -11,7 +11,7 @@
11
11
  import { AsnConvert } from '@peculiar/asn1-schema';
12
12
  import { AttributeCertificate } from '@peculiar/asn1-x509-attr';
13
13
  import { Convert } from 'pvtsutils';
14
- import { dateDiff } from '../utils';
14
+ import { dateDiff, Download } from '../utils';
15
15
  import { AsnData } from './asn_data';
16
16
  import { Extension } from './extension';
17
17
  import { Attribute } from './attribute';
@@ -83,4 +83,10 @@ export class X509AttributeCertificate extends AsnData {
83
83
  get commonName() {
84
84
  return `attribute-certificate-${this.thumbprints['SHA-1']}`;
85
85
  }
86
+ downloadAsPEM(name) {
87
+ Download.attrCert.asPEM(this.exportAsPemFormatted(), name || this.commonName);
88
+ }
89
+ downloadAsDER(name) {
90
+ Download.attrCert.asDER(this.exportAsHexFormatted(), name || this.commonName);
91
+ }
86
92
  }
@@ -13,7 +13,7 @@ import { ECParameters, id_ecPublicKey } from '@peculiar/asn1-ecc';
13
13
  import { id_rsaEncryption, RSAPublicKey } from '@peculiar/asn1-rsa';
14
14
  import { Certificate } from '@peculiar/asn1-x509';
15
15
  import { Convert } from 'pvtsutils';
16
- import { dateDiff } from '../utils';
16
+ import { dateDiff, Download } from '../utils';
17
17
  import { Name } from './name';
18
18
  import { Extension } from './extension';
19
19
  import { AsnData } from './asn_data';
@@ -138,4 +138,10 @@ export class X509Certificate extends AsnData {
138
138
  .map((name) => (`${name.shortName}=${name.value}`))
139
139
  .join(', ');
140
140
  }
141
+ downloadAsPEM(name) {
142
+ Download.cert.asPEM(this.exportAsPemFormatted(), name || this.commonName);
143
+ }
144
+ downloadAsDER(name) {
145
+ Download.cert.asDER(this.exportAsHexFormatted(), name || this.commonName);
146
+ }
141
147
  }
@@ -14,6 +14,8 @@
14
14
  "validity": "Validity",
15
15
  "issued": "Issued",
16
16
  "expired": "Expired",
17
+ "lastUpdate": "Last Update",
18
+ "nextUpdate": "Next Update",
17
19
  "algorithm": "Algorithm",
18
20
  "namedCurve": "Named Curve",
19
21
  "exponent": "Exponent",
@@ -32,5 +34,14 @@
32
34
  "certificateDetails": "Certificate Details",
33
35
  "holder": "Holder",
34
36
  "digestInfo": "Digest Info",
35
- "type": "Type"
37
+ "type": "Type",
38
+ "revokedCertificates": "Revoked Certificates",
39
+ "revocation": "Revocation",
40
+ "yes": "Yes",
41
+ "no": "No",
42
+ "onlyUserCertificates": "Only User Certificates",
43
+ "onlyAttributeCertificates": "Only Attribute Certificates",
44
+ "onlyCACertificates": "Only CA Certificates",
45
+ "indirectCRL": "Indirect CRL",
46
+ "onlyReasons": "Only Reasons"
36
47
  }
@@ -12,7 +12,7 @@ import { Convert } from 'pvtsutils';
12
12
  import { downloadFromBuffer } from './download_from_buffer';
13
13
  export class Download {
14
14
  }
15
- Download.x509 = {
15
+ Download.cert = {
16
16
  asPEM: (pem, name) => {
17
17
  downloadFromBuffer(Convert.FromString(pem), name, 'cer', 'application/pkix-cert');
18
18
  },
@@ -20,7 +20,15 @@ Download.x509 = {
20
20
  downloadFromBuffer(Convert.FromString(hex), name, 'cer', 'application/pkix-cert');
21
21
  },
22
22
  };
23
- Download.pkcs10 = {
23
+ Download.attrCert = {
24
+ asPEM: (pem, name) => {
25
+ downloadFromBuffer(Convert.FromString(pem), name, 'cer', 'application/pkix-attr-cert');
26
+ },
27
+ asDER: (hex, name) => {
28
+ downloadFromBuffer(Convert.FromString(hex), name, 'cer', 'application/pkix-attr-cert');
29
+ },
30
+ };
31
+ Download.csr = {
24
32
  asPEM: (pem, name) => {
25
33
  downloadFromBuffer(Convert.FromString(pem), name, 'csr', 'application/pkcs10');
26
34
  },
@@ -28,3 +36,11 @@ Download.pkcs10 = {
28
36
  downloadFromBuffer(Convert.FromString(hex), name, 'csr', 'application/pkcs10');
29
37
  },
30
38
  };
39
+ Download.crl = {
40
+ asPEM: (pem, name) => {
41
+ downloadFromBuffer(Convert.FromString(pem), name, 'crl', 'application/pkix-crl');
42
+ },
43
+ asDER: (hex, name) => {
44
+ downloadFromBuffer(Convert.FromString(hex), name, 'crl', 'application/pkix-crl');
45
+ },
46
+ };
@@ -5,4 +5,5 @@ import * as validator from './validator';
5
5
  export * from './read_file';
6
6
  export * from './date_formatter';
7
7
  export * from './l10n';
8
+ export * from './download';
8
9
  export { validator, };
@@ -15,6 +15,8 @@ export const isPem = (value) => (/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----
15
15
  .test(value));
16
16
  export const isX509Pem = (value) => (/-----BEGIN CERTIFICATE-----([A-Za-z0-9+\/=\s]+)-----END CERTIFICATE-----/
17
17
  .test(value));
18
+ export const isX509CRLPem = (value) => (/-----BEGIN X509 CRL-----([A-Za-z0-9+\/=\s]+)-----END X509 CRL-----/
19
+ .test(value));
18
20
  export const isPkcs10Pem = (value) => (/-----BEGIN CERTIFICATE REQUEST-----([A-Za-z0-9+\/=\s]+)-----END CERTIFICATE REQUEST-----/
19
21
  .test(value));
20
22
  export const isX509AttributePem = (value) => (/-----BEGIN ATTRIBUTE CERTIFICATE-----([A-Za-z0-9+\/=\s]+)-----END ATTRIBUTE CERTIFICATE-----/