@peculiar/certificates-viewer 4.0.2 → 4.1.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 (152) hide show
  1. package/README.md +1 -1
  2. package/components/attribute-certificate-viewer.js +7 -7
  3. package/components/attribute-certificate-viewer.js.map +1 -1
  4. package/components/certificate-viewer.js +5 -5
  5. package/components/certificate-viewer.js.map +1 -1
  6. package/components/crl-viewer.js +6 -6
  7. package/components/crl-viewer.js.map +1 -1
  8. package/components/csr-viewer.js +4 -4
  9. package/components/csr-viewer.js.map +1 -1
  10. package/components/download.js +374 -374
  11. package/components/download.js.map +1 -1
  12. package/components/index2.js +2 -2
  13. package/components/index2.js.map +1 -1
  14. package/components/miscellaneous.js +647 -217
  15. package/components/miscellaneous.js.map +1 -1
  16. package/components/subject_name.js +2 -2
  17. package/components/subject_name.js.map +1 -1
  18. package/dist/cjs/{certification_request-c0cafa72.js → certification_request-bf416170.js} +553 -214
  19. package/dist/cjs/certification_request-bf416170.js.map +1 -0
  20. package/dist/cjs/{crl-b4322166.js → crl-d9591b95.js} +14 -14
  21. package/dist/cjs/{crl-b4322166.js.map → crl-d9591b95.js.map} +1 -1
  22. package/dist/cjs/{download-972dda8a.js → download-0fa5b33c.js} +377 -377
  23. package/dist/cjs/download-0fa5b33c.js.map +1 -0
  24. package/dist/cjs/index.cjs.js +1 -1
  25. package/dist/cjs/{miscellaneous-e43aaae5.js → miscellaneous-6e800553.js} +109 -15
  26. package/dist/cjs/miscellaneous-6e800553.js.map +1 -0
  27. package/dist/cjs/peculiar-attribute-certificate-viewer_3.cjs.entry.js +8 -8
  28. package/dist/cjs/peculiar-attribute-certificate-viewer_3.cjs.entry.js.map +1 -1
  29. package/dist/cjs/peculiar-certificate-decoder.cjs.entry.js +4 -4
  30. package/dist/cjs/peculiar-certificate-viewer.cjs.entry.js +4 -4
  31. package/dist/cjs/peculiar-certificates-viewer.cjs.entry.js +3 -3
  32. package/dist/cjs/{x509_certificate-989b1435.js → x509_certificate-53feebd3.js} +7 -7
  33. package/dist/cjs/{x509_certificate-989b1435.js.map → x509_certificate-53feebd3.js.map} +1 -1
  34. package/dist/collection/components/certificate-details-parts/extensions/index.js +5 -0
  35. package/dist/collection/components/certificate-details-parts/extensions/index.js.map +1 -1
  36. package/dist/collection/components/certificate-details-parts/extensions/key_description_extension.js +80 -0
  37. package/dist/collection/components/certificate-details-parts/extensions/key_description_extension.js.map +1 -0
  38. package/dist/collection/constants/oids.js +1 -0
  39. package/dist/collection/constants/oids.js.map +1 -1
  40. package/dist/collection/crypto/extension.js +4 -0
  41. package/dist/collection/crypto/extension.js.map +1 -1
  42. package/dist/collection/utils/camel_case_to_words.js +15 -0
  43. package/dist/collection/utils/camel_case_to_words.js.map +1 -0
  44. package/dist/collection/utils/index.js +1 -0
  45. package/dist/collection/utils/index.js.map +1 -1
  46. package/dist/esm/{certification_request-5cadde9f.js → certification_request-c9dc8e9c.js} +545 -209
  47. package/dist/esm/certification_request-c9dc8e9c.js.map +1 -0
  48. package/dist/esm/{crl-11670c3e.js → crl-70e85374.js} +14 -14
  49. package/dist/esm/{crl-11670c3e.js.map → crl-70e85374.js.map} +1 -1
  50. package/dist/esm/{download-57c5bf8f.js → download-aacb6eff.js} +375 -375
  51. package/dist/esm/download-aacb6eff.js.map +1 -0
  52. package/dist/esm/index.js +1 -1
  53. package/dist/esm/{miscellaneous-7793a310.js → miscellaneous-0763f98e.js} +109 -15
  54. package/dist/esm/miscellaneous-0763f98e.js.map +1 -0
  55. package/dist/esm/peculiar-attribute-certificate-viewer_3.entry.js +8 -8
  56. package/dist/esm/peculiar-attribute-certificate-viewer_3.entry.js.map +1 -1
  57. package/dist/esm/peculiar-certificate-decoder.entry.js +4 -4
  58. package/dist/esm/peculiar-certificate-viewer.entry.js +4 -4
  59. package/dist/esm/peculiar-certificates-viewer.entry.js +3 -3
  60. package/dist/esm/{x509_certificate-dfae6999.js → x509_certificate-8cf268d1.js} +7 -7
  61. package/dist/esm/{x509_certificate-dfae6999.js.map → x509_certificate-8cf268d1.js.map} +1 -1
  62. package/dist/esm-es5/certification_request-c9dc8e9c.js +97 -0
  63. package/dist/esm-es5/certification_request-c9dc8e9c.js.map +1 -0
  64. package/dist/esm-es5/{crl-11670c3e.js → crl-70e85374.js} +6 -6
  65. package/dist/esm-es5/{crl-11670c3e.js.map → crl-70e85374.js.map} +1 -1
  66. package/dist/esm-es5/download-aacb6eff.js +43 -0
  67. package/dist/esm-es5/download-aacb6eff.js.map +1 -0
  68. package/dist/esm-es5/index.js +1 -1
  69. package/dist/esm-es5/{miscellaneous-7793a310.js → miscellaneous-0763f98e.js} +63 -49
  70. package/dist/esm-es5/miscellaneous-0763f98e.js.map +1 -0
  71. package/dist/esm-es5/peculiar-attribute-certificate-viewer_3.entry.js +3 -3
  72. package/dist/esm-es5/peculiar-attribute-certificate-viewer_3.entry.js.map +1 -1
  73. package/dist/esm-es5/peculiar-certificate-decoder.entry.js +1 -1
  74. package/dist/esm-es5/peculiar-certificate-viewer.entry.js +1 -1
  75. package/dist/esm-es5/peculiar-certificates-viewer.entry.js +1 -1
  76. package/dist/esm-es5/x509_certificate-8cf268d1.js +12 -0
  77. package/dist/esm-es5/{x509_certificate-dfae6999.js.map → x509_certificate-8cf268d1.js.map} +1 -1
  78. package/dist/peculiar/index.esm.js +1 -1
  79. package/dist/peculiar/{p-7f9fef87.entry.js → p-025b3cfb.entry.js} +2 -2
  80. package/dist/peculiar/{p-441109db.system.entry.js → p-0bd7c6bc.system.entry.js} +2 -2
  81. package/dist/peculiar/p-10d2d400.system.js +34 -0
  82. package/dist/peculiar/{p-6667fe6e.system.js.map → p-10d2d400.system.js.map} +1 -1
  83. package/dist/peculiar/p-14f281b0.system.js +43 -0
  84. package/dist/peculiar/p-14f281b0.system.js.map +1 -0
  85. package/dist/peculiar/p-15cb92b5.system.js +97 -0
  86. package/dist/peculiar/p-15cb92b5.system.js.map +1 -0
  87. package/dist/peculiar/p-1ef997ee.js +97 -0
  88. package/dist/peculiar/p-1ef997ee.js.map +1 -0
  89. package/dist/peculiar/{p-e39de121.system.entry.js → p-24050d82.system.entry.js} +2 -2
  90. package/dist/peculiar/{p-bcc86979.entry.js → p-2f48fe70.entry.js} +2 -2
  91. package/dist/peculiar/{p-c362dc5e.system.js → p-31b60224.system.js} +65 -51
  92. package/dist/peculiar/p-31b60224.system.js.map +1 -0
  93. package/dist/peculiar/{p-0b475f2a.system.entry.js → p-4ab9673f.system.entry.js} +4 -4
  94. package/dist/peculiar/{p-0b475f2a.system.entry.js.map → p-4ab9673f.system.entry.js.map} +1 -1
  95. package/dist/peculiar/p-542412ae.js +33 -0
  96. package/dist/peculiar/{p-43eb3721.js.map → p-542412ae.js.map} +1 -1
  97. package/dist/peculiar/p-59e5ac12.js +43 -0
  98. package/dist/peculiar/p-59e5ac12.js.map +1 -0
  99. package/dist/peculiar/{p-1844b807.system.entry.js → p-5e49b881.system.entry.js} +2 -2
  100. package/dist/peculiar/p-72f53d81.js +12 -0
  101. package/dist/peculiar/{p-6e79b9c8.js.map → p-72f53d81.js.map} +1 -1
  102. package/dist/peculiar/p-80832207.system.js +1 -1
  103. package/dist/peculiar/{p-673336cf.entry.js → p-9c91dd68.entry.js} +5 -5
  104. package/dist/peculiar/{p-673336cf.entry.js.map → p-9c91dd68.entry.js.map} +1 -1
  105. package/dist/peculiar/{p-1de0381c.system.js → p-a3eeb94b.system.js} +2 -2
  106. package/dist/peculiar/p-ca02a823.js +362 -0
  107. package/dist/peculiar/p-ca02a823.js.map +1 -0
  108. package/dist/peculiar/p-cfca7dae.system.js +13 -0
  109. package/dist/peculiar/{p-31586b23.system.js.map → p-cfca7dae.system.js.map} +1 -1
  110. package/dist/peculiar/{p-882e1281.entry.js → p-e5b18cd1.entry.js} +2 -2
  111. package/dist/peculiar/peculiar.esm.js +1 -1
  112. package/dist/types/components/certificate-details-parts/extensions/key_description_extension.d.ts +15 -0
  113. package/dist/types/constants/oids.d.ts +1 -0
  114. package/dist/types/crypto/extension.d.ts +2 -1
  115. package/dist/types/utils/camel_case_to_words.d.ts +8 -0
  116. package/dist/types/utils/index.d.ts +1 -0
  117. package/hydrate/index.js +1039 -609
  118. package/package.json +22 -21
  119. package/dist/cjs/certification_request-c0cafa72.js.map +0 -1
  120. package/dist/cjs/download-972dda8a.js.map +0 -1
  121. package/dist/cjs/miscellaneous-e43aaae5.js.map +0 -1
  122. package/dist/esm/certification_request-5cadde9f.js.map +0 -1
  123. package/dist/esm/download-57c5bf8f.js.map +0 -1
  124. package/dist/esm/miscellaneous-7793a310.js.map +0 -1
  125. package/dist/esm-es5/certification_request-5cadde9f.js +0 -97
  126. package/dist/esm-es5/certification_request-5cadde9f.js.map +0 -1
  127. package/dist/esm-es5/download-57c5bf8f.js +0 -19
  128. package/dist/esm-es5/download-57c5bf8f.js.map +0 -1
  129. package/dist/esm-es5/miscellaneous-7793a310.js.map +0 -1
  130. package/dist/esm-es5/x509_certificate-dfae6999.js +0 -12
  131. package/dist/peculiar/p-31586b23.system.js +0 -13
  132. package/dist/peculiar/p-43eb3721.js +0 -33
  133. package/dist/peculiar/p-6667fe6e.system.js +0 -34
  134. package/dist/peculiar/p-6e79b9c8.js +0 -12
  135. package/dist/peculiar/p-74c241e7.js +0 -97
  136. package/dist/peculiar/p-74c241e7.js.map +0 -1
  137. package/dist/peculiar/p-a053c132.js +0 -19
  138. package/dist/peculiar/p-a053c132.js.map +0 -1
  139. package/dist/peculiar/p-a6e2e335.js +0 -348
  140. package/dist/peculiar/p-a6e2e335.js.map +0 -1
  141. package/dist/peculiar/p-ae9189f6.system.js +0 -19
  142. package/dist/peculiar/p-ae9189f6.system.js.map +0 -1
  143. package/dist/peculiar/p-c0a298fd.system.js +0 -97
  144. package/dist/peculiar/p-c0a298fd.system.js.map +0 -1
  145. package/dist/peculiar/p-c362dc5e.system.js.map +0 -1
  146. /package/dist/peculiar/{p-7f9fef87.entry.js.map → p-025b3cfb.entry.js.map} +0 -0
  147. /package/dist/peculiar/{p-441109db.system.entry.js.map → p-0bd7c6bc.system.entry.js.map} +0 -0
  148. /package/dist/peculiar/{p-e39de121.system.entry.js.map → p-24050d82.system.entry.js.map} +0 -0
  149. /package/dist/peculiar/{p-bcc86979.entry.js.map → p-2f48fe70.entry.js.map} +0 -0
  150. /package/dist/peculiar/{p-1844b807.system.entry.js.map → p-5e49b881.system.entry.js.map} +0 -0
  151. /package/dist/peculiar/{p-1de0381c.system.js.map → p-a3eeb94b.system.js.map} +0 -0
  152. /package/dist/peculiar/{p-882e1281.entry.js.map → p-e5b18cd1.entry.js.map} +0 -0
@@ -49,379 +49,379 @@ function downloadFromBuffer(value, name, extension, mime = 'application/octet-st
49
49
  });
50
50
  }
51
51
 
52
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
52
+ /*!
53
+ * MIT License
54
+ *
55
+ * Copyright (c) 2017-2022 Peculiar Ventures, LLC
56
+ *
57
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
58
+ * of this software and associated documentation files (the "Software"), to deal
59
+ * in the Software without restriction, including without limitation the rights
60
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
61
+ * copies of the Software, and to permit persons to whom the Software is
62
+ * furnished to do so, subject to the following conditions:
63
+ *
64
+ * The above copyright notice and this permission notice shall be included in all
65
+ * copies or substantial portions of the Software.
66
+ *
67
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
68
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
69
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
70
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
71
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
72
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
73
+ * SOFTWARE.
74
+ *
75
+ */
53
76
 
54
- function createCommonjsModule(fn, basedir, module) {
55
- return module = {
56
- path: basedir,
57
- exports: {},
58
- require: function (path, base) {
59
- return commonjsRequire();
60
- }
61
- }, fn(module, module.exports), module.exports;
77
+ const ARRAY_BUFFER_NAME = "[object ArrayBuffer]";
78
+ class BufferSourceConverter {
79
+ static isArrayBuffer(data) {
80
+ return Object.prototype.toString.call(data) === ARRAY_BUFFER_NAME;
81
+ }
82
+ static toArrayBuffer(data) {
83
+ if (this.isArrayBuffer(data)) {
84
+ return data;
85
+ }
86
+ if (data.byteLength === data.buffer.byteLength) {
87
+ return data.buffer;
88
+ }
89
+ if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
90
+ return data.buffer;
91
+ }
92
+ return this.toUint8Array(data.buffer)
93
+ .slice(data.byteOffset, data.byteOffset + data.byteLength)
94
+ .buffer;
95
+ }
96
+ static toUint8Array(data) {
97
+ return this.toView(data, Uint8Array);
98
+ }
99
+ static toView(data, type) {
100
+ if (data.constructor === type) {
101
+ return data;
102
+ }
103
+ if (this.isArrayBuffer(data)) {
104
+ return new type(data);
105
+ }
106
+ if (this.isArrayBufferView(data)) {
107
+ return new type(data.buffer, data.byteOffset, data.byteLength);
108
+ }
109
+ throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
110
+ }
111
+ static isBufferSource(data) {
112
+ return this.isArrayBufferView(data)
113
+ || this.isArrayBuffer(data);
114
+ }
115
+ static isArrayBufferView(data) {
116
+ return ArrayBuffer.isView(data)
117
+ || (data && this.isArrayBuffer(data.buffer));
118
+ }
119
+ static isEqual(a, b) {
120
+ const aView = BufferSourceConverter.toUint8Array(a);
121
+ const bView = BufferSourceConverter.toUint8Array(b);
122
+ if (aView.length !== bView.byteLength) {
123
+ return false;
124
+ }
125
+ for (let i = 0; i < aView.length; i++) {
126
+ if (aView[i] !== bView[i]) {
127
+ return false;
128
+ }
129
+ }
130
+ return true;
131
+ }
132
+ static concat(...args) {
133
+ let buffers;
134
+ if (Array.isArray(args[0]) && !(args[1] instanceof Function)) {
135
+ buffers = args[0];
136
+ }
137
+ else if (Array.isArray(args[0]) && args[1] instanceof Function) {
138
+ buffers = args[0];
139
+ }
140
+ else {
141
+ if (args[args.length - 1] instanceof Function) {
142
+ buffers = args.slice(0, args.length - 1);
143
+ }
144
+ else {
145
+ buffers = args;
146
+ }
147
+ }
148
+ let size = 0;
149
+ for (const buffer of buffers) {
150
+ size += buffer.byteLength;
151
+ }
152
+ const res = new Uint8Array(size);
153
+ let offset = 0;
154
+ for (const buffer of buffers) {
155
+ const view = this.toUint8Array(buffer);
156
+ res.set(view, offset);
157
+ offset += view.length;
158
+ }
159
+ if (args[args.length - 1] instanceof Function) {
160
+ return this.toView(res, args[args.length - 1]);
161
+ }
162
+ return res.buffer;
163
+ }
62
164
  }
63
165
 
64
- function commonjsRequire () {
65
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
166
+ const STRING_TYPE = "string";
167
+ const HEX_REGEX = /^[0-9a-f]+$/i;
168
+ const BASE64_REGEX = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
169
+ const BASE64URL_REGEX = /^[a-zA-Z0-9-_]+$/;
170
+ class Utf8Converter {
171
+ static fromString(text) {
172
+ const s = unescape(encodeURIComponent(text));
173
+ const uintArray = new Uint8Array(s.length);
174
+ for (let i = 0; i < s.length; i++) {
175
+ uintArray[i] = s.charCodeAt(i);
176
+ }
177
+ return uintArray.buffer;
178
+ }
179
+ static toString(buffer) {
180
+ const buf = BufferSourceConverter.toUint8Array(buffer);
181
+ let encodedString = "";
182
+ for (let i = 0; i < buf.length; i++) {
183
+ encodedString += String.fromCharCode(buf[i]);
184
+ }
185
+ const decodedString = decodeURIComponent(escape(encodedString));
186
+ return decodedString;
187
+ }
66
188
  }
67
-
68
- var build = createCommonjsModule(function (module, exports) {
69
-
70
- Object.defineProperty(exports, '__esModule', { value: true });
71
-
72
- const ARRAY_BUFFER_NAME = "[object ArrayBuffer]";
73
- class BufferSourceConverter {
74
- static isArrayBuffer(data) {
75
- return Object.prototype.toString.call(data) === ARRAY_BUFFER_NAME;
76
- }
77
- static toArrayBuffer(data) {
78
- if (this.isArrayBuffer(data)) {
79
- return data;
80
- }
81
- if (data.byteLength === data.buffer.byteLength) {
82
- return data.buffer;
83
- }
84
- return this.toUint8Array(data).slice().buffer;
85
- }
86
- static toUint8Array(data) {
87
- return this.toView(data, Uint8Array);
88
- }
89
- static toView(data, type) {
90
- if (data.constructor === type) {
91
- return data;
92
- }
93
- if (this.isArrayBuffer(data)) {
94
- return new type(data);
95
- }
96
- if (this.isArrayBufferView(data)) {
97
- return new type(data.buffer, data.byteOffset, data.byteLength);
98
- }
99
- throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
100
- }
101
- static isBufferSource(data) {
102
- return this.isArrayBufferView(data)
103
- || this.isArrayBuffer(data);
104
- }
105
- static isArrayBufferView(data) {
106
- return ArrayBuffer.isView(data)
107
- || (data && this.isArrayBuffer(data.buffer));
108
- }
109
- static isEqual(a, b) {
110
- const aView = BufferSourceConverter.toUint8Array(a);
111
- const bView = BufferSourceConverter.toUint8Array(b);
112
- if (aView.length !== bView.byteLength) {
113
- return false;
114
- }
115
- for (let i = 0; i < aView.length; i++) {
116
- if (aView[i] !== bView[i]) {
117
- return false;
118
- }
119
- }
120
- return true;
121
- }
122
- static concat(...args) {
123
- if (Array.isArray(args[0])) {
124
- const buffers = args[0];
125
- let size = 0;
126
- for (const buffer of buffers) {
127
- size += buffer.byteLength;
128
- }
129
- const res = new Uint8Array(size);
130
- let offset = 0;
131
- for (const buffer of buffers) {
132
- const view = this.toUint8Array(buffer);
133
- res.set(view, offset);
134
- offset += view.length;
135
- }
136
- if (args[1]) {
137
- return this.toView(res, args[1]);
138
- }
139
- return res.buffer;
140
- }
141
- else {
142
- return this.concat(args);
143
- }
144
- }
189
+ class Utf16Converter {
190
+ static toString(buffer, littleEndian = false) {
191
+ const arrayBuffer = BufferSourceConverter.toArrayBuffer(buffer);
192
+ const dataView = new DataView(arrayBuffer);
193
+ let res = "";
194
+ for (let i = 0; i < arrayBuffer.byteLength; i += 2) {
195
+ const code = dataView.getUint16(i, littleEndian);
196
+ res += String.fromCharCode(code);
197
+ }
198
+ return res;
199
+ }
200
+ static fromString(text, littleEndian = false) {
201
+ const res = new ArrayBuffer(text.length * 2);
202
+ const dataView = new DataView(res);
203
+ for (let i = 0; i < text.length; i++) {
204
+ dataView.setUint16(i * 2, text.charCodeAt(i), littleEndian);
205
+ }
206
+ return res;
207
+ }
208
+ }
209
+ class Convert {
210
+ static isHex(data) {
211
+ return typeof data === STRING_TYPE
212
+ && HEX_REGEX.test(data);
213
+ }
214
+ static isBase64(data) {
215
+ return typeof data === STRING_TYPE
216
+ && BASE64_REGEX.test(data);
217
+ }
218
+ static isBase64Url(data) {
219
+ return typeof data === STRING_TYPE
220
+ && BASE64URL_REGEX.test(data);
221
+ }
222
+ static ToString(buffer, enc = "utf8") {
223
+ const buf = BufferSourceConverter.toUint8Array(buffer);
224
+ switch (enc.toLowerCase()) {
225
+ case "utf8":
226
+ return this.ToUtf8String(buf);
227
+ case "binary":
228
+ return this.ToBinary(buf);
229
+ case "hex":
230
+ return this.ToHex(buf);
231
+ case "base64":
232
+ return this.ToBase64(buf);
233
+ case "base64url":
234
+ return this.ToBase64Url(buf);
235
+ case "utf16le":
236
+ return Utf16Converter.toString(buf, true);
237
+ case "utf16":
238
+ case "utf16be":
239
+ return Utf16Converter.toString(buf);
240
+ default:
241
+ throw new Error(`Unknown type of encoding '${enc}'`);
242
+ }
243
+ }
244
+ static FromString(str, enc = "utf8") {
245
+ if (!str) {
246
+ return new ArrayBuffer(0);
247
+ }
248
+ switch (enc.toLowerCase()) {
249
+ case "utf8":
250
+ return this.FromUtf8String(str);
251
+ case "binary":
252
+ return this.FromBinary(str);
253
+ case "hex":
254
+ return this.FromHex(str);
255
+ case "base64":
256
+ return this.FromBase64(str);
257
+ case "base64url":
258
+ return this.FromBase64Url(str);
259
+ case "utf16le":
260
+ return Utf16Converter.fromString(str, true);
261
+ case "utf16":
262
+ case "utf16be":
263
+ return Utf16Converter.fromString(str);
264
+ default:
265
+ throw new Error(`Unknown type of encoding '${enc}'`);
266
+ }
267
+ }
268
+ static ToBase64(buffer) {
269
+ const buf = BufferSourceConverter.toUint8Array(buffer);
270
+ if (typeof btoa !== "undefined") {
271
+ const binary = this.ToString(buf, "binary");
272
+ return btoa(binary);
273
+ }
274
+ else {
275
+ return Buffer.from(buf).toString("base64");
276
+ }
277
+ }
278
+ static FromBase64(base64) {
279
+ const formatted = this.formatString(base64);
280
+ if (!formatted) {
281
+ return new ArrayBuffer(0);
282
+ }
283
+ if (!Convert.isBase64(formatted)) {
284
+ throw new TypeError("Argument 'base64Text' is not Base64 encoded");
285
+ }
286
+ if (typeof atob !== "undefined") {
287
+ return this.FromBinary(atob(formatted));
288
+ }
289
+ else {
290
+ return new Uint8Array(Buffer.from(formatted, "base64")).buffer;
291
+ }
292
+ }
293
+ static FromBase64Url(base64url) {
294
+ const formatted = this.formatString(base64url);
295
+ if (!formatted) {
296
+ return new ArrayBuffer(0);
297
+ }
298
+ if (!Convert.isBase64Url(formatted)) {
299
+ throw new TypeError("Argument 'base64url' is not Base64Url encoded");
300
+ }
301
+ return this.FromBase64(this.Base64Padding(formatted.replace(/\-/g, "+").replace(/\_/g, "/")));
302
+ }
303
+ static ToBase64Url(data) {
304
+ return this.ToBase64(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/\=/g, "");
305
+ }
306
+ static FromUtf8String(text, encoding = Convert.DEFAULT_UTF8_ENCODING) {
307
+ switch (encoding) {
308
+ case "ascii":
309
+ return this.FromBinary(text);
310
+ case "utf8":
311
+ return Utf8Converter.fromString(text);
312
+ case "utf16":
313
+ case "utf16be":
314
+ return Utf16Converter.fromString(text);
315
+ case "utf16le":
316
+ case "usc2":
317
+ return Utf16Converter.fromString(text, true);
318
+ default:
319
+ throw new Error(`Unknown type of encoding '${encoding}'`);
320
+ }
321
+ }
322
+ static ToUtf8String(buffer, encoding = Convert.DEFAULT_UTF8_ENCODING) {
323
+ switch (encoding) {
324
+ case "ascii":
325
+ return this.ToBinary(buffer);
326
+ case "utf8":
327
+ return Utf8Converter.toString(buffer);
328
+ case "utf16":
329
+ case "utf16be":
330
+ return Utf16Converter.toString(buffer);
331
+ case "utf16le":
332
+ case "usc2":
333
+ return Utf16Converter.toString(buffer, true);
334
+ default:
335
+ throw new Error(`Unknown type of encoding '${encoding}'`);
336
+ }
337
+ }
338
+ static FromBinary(text) {
339
+ const stringLength = text.length;
340
+ const resultView = new Uint8Array(stringLength);
341
+ for (let i = 0; i < stringLength; i++) {
342
+ resultView[i] = text.charCodeAt(i);
343
+ }
344
+ return resultView.buffer;
345
+ }
346
+ static ToBinary(buffer) {
347
+ const buf = BufferSourceConverter.toUint8Array(buffer);
348
+ let res = "";
349
+ for (let i = 0; i < buf.length; i++) {
350
+ res += String.fromCharCode(buf[i]);
351
+ }
352
+ return res;
353
+ }
354
+ static ToHex(buffer) {
355
+ const buf = BufferSourceConverter.toUint8Array(buffer);
356
+ let result = "";
357
+ const len = buf.length;
358
+ for (let i = 0; i < len; i++) {
359
+ const byte = buf[i];
360
+ if (byte < 16) {
361
+ result += "0";
362
+ }
363
+ result += byte.toString(16);
364
+ }
365
+ return result;
366
+ }
367
+ static FromHex(hexString) {
368
+ let formatted = this.formatString(hexString);
369
+ if (!formatted) {
370
+ return new ArrayBuffer(0);
371
+ }
372
+ if (!Convert.isHex(formatted)) {
373
+ throw new TypeError("Argument 'hexString' is not HEX encoded");
374
+ }
375
+ if (formatted.length % 2) {
376
+ formatted = `0${formatted}`;
377
+ }
378
+ const res = new Uint8Array(formatted.length / 2);
379
+ for (let i = 0; i < formatted.length; i = i + 2) {
380
+ const c = formatted.slice(i, i + 2);
381
+ res[i / 2] = parseInt(c, 16);
382
+ }
383
+ return res.buffer;
384
+ }
385
+ static ToUtf16String(buffer, littleEndian = false) {
386
+ return Utf16Converter.toString(buffer, littleEndian);
387
+ }
388
+ static FromUtf16String(text, littleEndian = false) {
389
+ return Utf16Converter.fromString(text, littleEndian);
390
+ }
391
+ static Base64Padding(base64) {
392
+ const padCount = 4 - (base64.length % 4);
393
+ if (padCount < 4) {
394
+ for (let i = 0; i < padCount; i++) {
395
+ base64 += "=";
396
+ }
397
+ }
398
+ return base64;
399
+ }
400
+ static formatString(data) {
401
+ return (data === null || data === void 0 ? void 0 : data.replace(/[\n\r\t ]/g, "")) || "";
402
+ }
145
403
  }
146
-
147
- class Utf8Converter {
148
- static fromString(text) {
149
- const s = unescape(encodeURIComponent(text));
150
- const uintArray = new Uint8Array(s.length);
151
- for (let i = 0; i < s.length; i++) {
152
- uintArray[i] = s.charCodeAt(i);
153
- }
154
- return uintArray.buffer;
155
- }
156
- static toString(buffer) {
157
- const buf = BufferSourceConverter.toUint8Array(buffer);
158
- let encodedString = "";
159
- for (let i = 0; i < buf.length; i++) {
160
- encodedString += String.fromCharCode(buf[i]);
161
- }
162
- const decodedString = decodeURIComponent(escape(encodedString));
163
- return decodedString;
164
- }
165
- }
166
- class Utf16Converter {
167
- static toString(buffer, littleEndian = false) {
168
- const arrayBuffer = BufferSourceConverter.toArrayBuffer(buffer);
169
- const dataView = new DataView(arrayBuffer);
170
- let res = "";
171
- for (let i = 0; i < arrayBuffer.byteLength; i += 2) {
172
- const code = dataView.getUint16(i, littleEndian);
173
- res += String.fromCharCode(code);
174
- }
175
- return res;
176
- }
177
- static fromString(text, littleEndian = false) {
178
- const res = new ArrayBuffer(text.length * 2);
179
- const dataView = new DataView(res);
180
- for (let i = 0; i < text.length; i++) {
181
- dataView.setUint16(i * 2, text.charCodeAt(i), littleEndian);
182
- }
183
- return res;
184
- }
185
- }
186
- class Convert {
187
- static isHex(data) {
188
- return typeof data === "string"
189
- && /^[a-z0-9]+$/i.test(data);
190
- }
191
- static isBase64(data) {
192
- return typeof data === "string"
193
- && /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(data);
194
- }
195
- static isBase64Url(data) {
196
- return typeof data === "string"
197
- && /^[a-zA-Z0-9-_]+$/i.test(data);
198
- }
199
- static ToString(buffer, enc = "utf8") {
200
- const buf = BufferSourceConverter.toUint8Array(buffer);
201
- switch (enc.toLowerCase()) {
202
- case "utf8":
203
- return this.ToUtf8String(buf);
204
- case "binary":
205
- return this.ToBinary(buf);
206
- case "hex":
207
- return this.ToHex(buf);
208
- case "base64":
209
- return this.ToBase64(buf);
210
- case "base64url":
211
- return this.ToBase64Url(buf);
212
- case "utf16le":
213
- return Utf16Converter.toString(buf, true);
214
- case "utf16":
215
- case "utf16be":
216
- return Utf16Converter.toString(buf);
217
- default:
218
- throw new Error(`Unknown type of encoding '${enc}'`);
219
- }
220
- }
221
- static FromString(str, enc = "utf8") {
222
- if (!str) {
223
- return new ArrayBuffer(0);
224
- }
225
- switch (enc.toLowerCase()) {
226
- case "utf8":
227
- return this.FromUtf8String(str);
228
- case "binary":
229
- return this.FromBinary(str);
230
- case "hex":
231
- return this.FromHex(str);
232
- case "base64":
233
- return this.FromBase64(str);
234
- case "base64url":
235
- return this.FromBase64Url(str);
236
- case "utf16le":
237
- return Utf16Converter.fromString(str, true);
238
- case "utf16":
239
- case "utf16be":
240
- return Utf16Converter.fromString(str);
241
- default:
242
- throw new Error(`Unknown type of encoding '${enc}'`);
243
- }
244
- }
245
- static ToBase64(buffer) {
246
- const buf = BufferSourceConverter.toUint8Array(buffer);
247
- if (typeof btoa !== "undefined") {
248
- const binary = this.ToString(buf, "binary");
249
- return btoa(binary);
250
- }
251
- else {
252
- return Buffer.from(buf).toString("base64");
253
- }
254
- }
255
- static FromBase64(base64) {
256
- const formatted = this.formatString(base64);
257
- if (!formatted) {
258
- return new ArrayBuffer(0);
259
- }
260
- if (!Convert.isBase64(formatted)) {
261
- throw new TypeError("Argument 'base64Text' is not Base64 encoded");
262
- }
263
- if (typeof atob !== "undefined") {
264
- return this.FromBinary(atob(formatted));
265
- }
266
- else {
267
- return new Uint8Array(Buffer.from(formatted, "base64")).buffer;
268
- }
269
- }
270
- static FromBase64Url(base64url) {
271
- const formatted = this.formatString(base64url);
272
- if (!formatted) {
273
- return new ArrayBuffer(0);
274
- }
275
- if (!Convert.isBase64Url(formatted)) {
276
- throw new TypeError("Argument 'base64url' is not Base64Url encoded");
277
- }
278
- return this.FromBase64(this.Base64Padding(formatted.replace(/\-/g, "+").replace(/\_/g, "/")));
279
- }
280
- static ToBase64Url(data) {
281
- return this.ToBase64(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/\=/g, "");
282
- }
283
- static FromUtf8String(text, encoding = Convert.DEFAULT_UTF8_ENCODING) {
284
- switch (encoding) {
285
- case "ascii":
286
- return this.FromBinary(text);
287
- case "utf8":
288
- return Utf8Converter.fromString(text);
289
- case "utf16":
290
- case "utf16be":
291
- return Utf16Converter.fromString(text);
292
- case "utf16le":
293
- case "usc2":
294
- return Utf16Converter.fromString(text, true);
295
- default:
296
- throw new Error(`Unknown type of encoding '${encoding}'`);
297
- }
298
- }
299
- static ToUtf8String(buffer, encoding = Convert.DEFAULT_UTF8_ENCODING) {
300
- switch (encoding) {
301
- case "ascii":
302
- return this.ToBinary(buffer);
303
- case "utf8":
304
- return Utf8Converter.toString(buffer);
305
- case "utf16":
306
- case "utf16be":
307
- return Utf16Converter.toString(buffer);
308
- case "utf16le":
309
- case "usc2":
310
- return Utf16Converter.toString(buffer, true);
311
- default:
312
- throw new Error(`Unknown type of encoding '${encoding}'`);
313
- }
314
- }
315
- static FromBinary(text) {
316
- const stringLength = text.length;
317
- const resultView = new Uint8Array(stringLength);
318
- for (let i = 0; i < stringLength; i++) {
319
- resultView[i] = text.charCodeAt(i);
320
- }
321
- return resultView.buffer;
322
- }
323
- static ToBinary(buffer) {
324
- const buf = BufferSourceConverter.toUint8Array(buffer);
325
- let res = "";
326
- for (let i = 0; i < buf.length; i++) {
327
- res += String.fromCharCode(buf[i]);
328
- }
329
- return res;
330
- }
331
- static ToHex(buffer) {
332
- const buf = BufferSourceConverter.toUint8Array(buffer);
333
- const splitter = "";
334
- const res = [];
335
- const len = buf.length;
336
- for (let i = 0; i < len; i++) {
337
- const char = buf[i].toString(16).padStart(2, "0");
338
- res.push(char);
339
- }
340
- return res.join(splitter);
341
- }
342
- static FromHex(hexString) {
343
- let formatted = this.formatString(hexString);
344
- if (!formatted) {
345
- return new ArrayBuffer(0);
346
- }
347
- if (!Convert.isHex(formatted)) {
348
- throw new TypeError("Argument 'hexString' is not HEX encoded");
349
- }
350
- if (formatted.length % 2) {
351
- formatted = `0${formatted}`;
352
- }
353
- const res = new Uint8Array(formatted.length / 2);
354
- for (let i = 0; i < formatted.length; i = i + 2) {
355
- const c = formatted.slice(i, i + 2);
356
- res[i / 2] = parseInt(c, 16);
357
- }
358
- return res.buffer;
359
- }
360
- static ToUtf16String(buffer, littleEndian = false) {
361
- return Utf16Converter.toString(buffer, littleEndian);
362
- }
363
- static FromUtf16String(text, littleEndian = false) {
364
- return Utf16Converter.fromString(text, littleEndian);
365
- }
366
- static Base64Padding(base64) {
367
- const padCount = 4 - (base64.length % 4);
368
- if (padCount < 4) {
369
- for (let i = 0; i < padCount; i++) {
370
- base64 += "=";
371
- }
372
- }
373
- return base64;
374
- }
375
- static formatString(data) {
376
- return (data === null || data === void 0 ? void 0 : data.replace(/[\n\r\t ]/g, "")) || "";
377
- }
378
- }
379
404
  Convert.DEFAULT_UTF8_ENCODING = "utf8";
380
-
381
- function assign(target, ...sources) {
382
- const res = arguments[0];
383
- for (let i = 1; i < arguments.length; i++) {
384
- const obj = arguments[i];
385
- for (const prop in obj) {
386
- res[prop] = obj[prop];
387
- }
388
- }
389
- return res;
390
- }
391
- function combine(...buf) {
392
- const totalByteLength = buf.map((item) => item.byteLength).reduce((prev, cur) => prev + cur);
393
- const res = new Uint8Array(totalByteLength);
394
- let currentPos = 0;
395
- buf.map((item) => new Uint8Array(item)).forEach((arr) => {
396
- for (const item2 of arr) {
397
- res[currentPos++] = item2;
398
- }
399
- });
400
- return res.buffer;
401
- }
402
- function isEqual(bytes1, bytes2) {
403
- if (!(bytes1 && bytes2)) {
404
- return false;
405
- }
406
- if (bytes1.byteLength !== bytes2.byteLength) {
407
- return false;
408
- }
409
- const b1 = new Uint8Array(bytes1);
410
- const b2 = new Uint8Array(bytes2);
411
- for (let i = 0; i < bytes1.byteLength; i++) {
412
- if (b1[i] !== b2[i]) {
413
- return false;
414
- }
415
- }
416
- return true;
405
+ function isEqual(bytes1, bytes2) {
406
+ if (!(bytes1 && bytes2)) {
407
+ return false;
408
+ }
409
+ if (bytes1.byteLength !== bytes2.byteLength) {
410
+ return false;
411
+ }
412
+ const b1 = new Uint8Array(bytes1);
413
+ const b2 = new Uint8Array(bytes2);
414
+ for (let i = 0; i < bytes1.byteLength; i++) {
415
+ if (b1[i] !== b2[i]) {
416
+ return false;
417
+ }
418
+ }
419
+ return true;
417
420
  }
418
421
 
419
- exports.BufferSourceConverter = BufferSourceConverter;
420
- exports.Convert = Convert;
421
- exports.assign = assign;
422
- exports.combine = combine;
423
- exports.isEqual = isEqual;
424
- });
422
+ var BufferSourceConverter_1 = BufferSourceConverter;
423
+ var Convert_1 = Convert;
424
+ var isEqual_1 = isEqual;
425
425
 
426
426
  /**
427
427
  * @license
@@ -434,37 +434,37 @@ class Download {
434
434
  }
435
435
  Download.cert = {
436
436
  asPEM: (pem, name) => {
437
- downloadFromBuffer(build.Convert.FromString(pem), name, 'cer', 'application/pkix-cert');
437
+ downloadFromBuffer(Convert_1.FromString(pem), name, 'cer', 'application/pkix-cert');
438
438
  },
439
439
  asDER: (hex, name) => {
440
- downloadFromBuffer(build.Convert.FromString(hex), name, 'cer', 'application/pkix-cert');
440
+ downloadFromBuffer(Convert_1.FromString(hex), name, 'cer', 'application/pkix-cert');
441
441
  },
442
442
  };
443
443
  Download.attrCert = {
444
444
  asPEM: (pem, name) => {
445
- downloadFromBuffer(build.Convert.FromString(pem), name, 'cer', 'application/pkix-attr-cert');
445
+ downloadFromBuffer(Convert_1.FromString(pem), name, 'cer', 'application/pkix-attr-cert');
446
446
  },
447
447
  asDER: (hex, name) => {
448
- downloadFromBuffer(build.Convert.FromString(hex), name, 'cer', 'application/pkix-attr-cert');
448
+ downloadFromBuffer(Convert_1.FromString(hex), name, 'cer', 'application/pkix-attr-cert');
449
449
  },
450
450
  };
451
451
  Download.csr = {
452
452
  asPEM: (pem, name) => {
453
- downloadFromBuffer(build.Convert.FromString(pem), name, 'csr', 'application/pkcs10');
453
+ downloadFromBuffer(Convert_1.FromString(pem), name, 'csr', 'application/pkcs10');
454
454
  },
455
455
  asDER: (hex, name) => {
456
- downloadFromBuffer(build.Convert.FromString(hex), name, 'csr', 'application/pkcs10');
456
+ downloadFromBuffer(Convert_1.FromString(hex), name, 'csr', 'application/pkcs10');
457
457
  },
458
458
  };
459
459
  Download.crl = {
460
460
  asPEM: (pem, name) => {
461
- downloadFromBuffer(build.Convert.FromString(pem), name, 'crl', 'application/pkix-crl');
461
+ downloadFromBuffer(Convert_1.FromString(pem), name, 'crl', 'application/pkix-crl');
462
462
  },
463
463
  asDER: (hex, name) => {
464
- downloadFromBuffer(build.Convert.FromString(hex), name, 'crl', 'application/pkix-crl');
464
+ downloadFromBuffer(Convert_1.FromString(hex), name, 'crl', 'application/pkix-crl');
465
465
  },
466
466
  };
467
467
 
468
- export { Download as D, commonjsGlobal as a, build as b, createCommonjsModule as c, downloadFromBuffer as d };
468
+ export { BufferSourceConverter_1 as B, Convert_1 as C, Download as D, downloadFromBuffer as d, isEqual_1 as i };
469
469
 
470
- //# sourceMappingURL=download-57c5bf8f.js.map
470
+ //# sourceMappingURL=download-aacb6eff.js.map