jclyo1 commited on
Commit
727f25a
·
1 Parent(s): 4e1488c
Files changed (3) hide show
  1. static/index.html +4 -20
  2. static/script.js +51 -24
  3. static/style.css +15 -1
static/index.html CHANGED
@@ -56,7 +56,7 @@
56
  }
57
  }
58
  ]
59
- */
60
  </script>
61
 
62
 
@@ -103,6 +103,9 @@
103
  </nav>
104
  <div class="verification" id="verification-output"></div>
105
  <div class="certificate" id="certificate-output">
 
 
 
106
  <div class="details">
107
  <strong>Basic info</strong>
108
  <div>
@@ -179,24 +182,5 @@
179
  </div>
180
  </section>
181
  </body>
182
- <script>
183
- /*
184
- function setCertificate(ind) {
185
- const certificate = certificates[ind].transformed;
186
-
187
- console.log("certificate", certificate);
188
- document.querySelector('.details .commonName').innerHTML = certificate.commonName;
189
- document.querySelector('.details .organizationUnit').innerHTML = certificate.organizationUnit;
190
- document.querySelector('.details .organization').innerHTML = certificate.organization;
191
- document.querySelector('.details .country').innerHTML = certificate.country;
192
- document.querySelector('.details .issued').innerHTML = certificate.issued;
193
- document.querySelector('.details .expired').innerHTML = certificate.expired;
194
- document.querySelector('.details .serialNumber').innerHTML = certificate.serialNumber;
195
- document.querySelector('.details .modulus').innerHTML = certificate.modulus;
196
-
197
- }
198
 
199
- setCertificate(0);
200
- */
201
- </script>
202
  </html>
 
56
  }
57
  }
58
  ]
59
+ */
60
  </script>
61
 
62
 
 
103
  </nav>
104
  <div class="verification" id="verification-output"></div>
105
  <div class="certificate" id="certificate-output">
106
+ <ul id="certificate-list">
107
+
108
+ </ul>
109
  <div class="details">
110
  <strong>Basic info</strong>
111
  <div>
 
182
  </div>
183
  </section>
184
  </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
 
 
 
 
186
  </html>
static/script.js CHANGED
@@ -13,6 +13,7 @@ const verificationDetails = document.querySelector(".verification-details");
13
  const parameters = document.querySelector(".parameters");
14
  const modelParam = document.querySelector(".parameters .model");
15
  const promptParam = document.querySelector(".parameters .prompt");
 
16
  var certificates = [];
17
 
18
  [textGenInput, model].forEach((item) => {
@@ -121,20 +122,41 @@ function setCertificateOutput(manifestStore = null) {
121
  {
122
  der: certificate.der,
123
  name: certificate.subjectName,
124
- decoded: new x509.X509Certificate(certificate.der)
125
  },
126
  ...certificate.chain.map((certificate) => ({
127
  der: certificate.der,
128
- decoded: new x509.X509Certificate(certificate.der)
129
  })),
130
  ];
131
-
132
  certificates.forEach((certificate) => {
133
  certificate.transformed = transformCert(certificate.decoded);
134
  });
135
 
136
  console.log("certificates", certificates);
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  setCertificate(0);
139
  }
140
 
@@ -167,20 +189,22 @@ function transformCert(certificate) {
167
  notAfter: expired,
168
  notBefore: issued,
169
  serialNumber,
170
- publicKey: {algorithm: {name: algorithm, modulusLength: modulus}}
 
 
171
  } = certificate;
172
 
173
  const response = {
174
- commonName,
175
- organizationUnit,
176
- organization,
177
- country,
178
- issued,
179
- expired,
180
- serialNumber,
181
- algorithm,
182
- modulus
183
- }
184
 
185
  console.log("response", response);
186
  return response;
@@ -206,13 +230,16 @@ function setCertificate(ind) {
206
  const certificate = certificates[ind].transformed;
207
 
208
  console.log("certificate", certificate);
209
- document.querySelector('.details .commonName').innerHTML = certificate.commonName;
210
- document.querySelector('.details .organizationUnit').innerHTML = certificate.organizationUnit;
211
- document.querySelector('.details .organization').innerHTML = certificate.organization;
212
- document.querySelector('.details .country').innerHTML = certificate.country;
213
- document.querySelector('.details .issued').innerHTML = certificate.issued;
214
- document.querySelector('.details .expired').innerHTML = certificate.expired;
215
- document.querySelector('.details .serialNumber').innerHTML = certificate.serialNumber;
216
- document.querySelector('.details .modulus').innerHTML = certificate.modulus;
217
-
218
- }
 
 
 
 
13
  const parameters = document.querySelector(".parameters");
14
  const modelParam = document.querySelector(".parameters .model");
15
  const promptParam = document.querySelector(".parameters .prompt");
16
+ const certificateList = document.getElementById("certificate-list");
17
  var certificates = [];
18
 
19
  [textGenInput, model].forEach((item) => {
 
122
  {
123
  der: certificate.der,
124
  name: certificate.subjectName,
125
+ decoded: new x509.X509Certificate(certificate.der),
126
  },
127
  ...certificate.chain.map((certificate) => ({
128
  der: certificate.der,
129
+ decoded: new x509.X509Certificate(certificate.der),
130
  })),
131
  ];
132
+
133
  certificates.forEach((certificate) => {
134
  certificate.transformed = transformCert(certificate.decoded);
135
  });
136
 
137
  console.log("certificates", certificates);
138
 
139
+ certificateList.innerHTML = "";
140
+
141
+ certificates.forEach((certificate, index) => {
142
+ console.log("Add li..");
143
+ var li = document.createElement("li");
144
+ li.appendChild(document.createTextNode(certificate.transformed.commonName));
145
+
146
+ li.addEventListener("click", function (e) {
147
+ setCertificate(index);
148
+ const lis = document.querySelectorAll("#certificate-list li");
149
+
150
+ lis.forEach((element) => {
151
+ element.classList.remove("active");
152
+ });
153
+
154
+ this.classList.add("active");
155
+ });
156
+
157
+ certificateList.appendChild(li);
158
+ });
159
+
160
  setCertificate(0);
161
  }
162
 
 
189
  notAfter: expired,
190
  notBefore: issued,
191
  serialNumber,
192
+ publicKey: {
193
+ algorithm: { name: algorithm, modulusLength: modulus },
194
+ },
195
  } = certificate;
196
 
197
  const response = {
198
+ commonName,
199
+ organizationUnit,
200
+ organization,
201
+ country,
202
+ issued,
203
+ expired,
204
+ serialNumber,
205
+ algorithm,
206
+ modulus,
207
+ };
208
 
209
  console.log("response", response);
210
  return response;
 
230
  const certificate = certificates[ind].transformed;
231
 
232
  console.log("certificate", certificate);
233
+ document.querySelector(".details .commonName").innerHTML =
234
+ certificate.commonName;
235
+ document.querySelector(".details .organizationUnit").innerHTML =
236
+ certificate.organizationUnit;
237
+ document.querySelector(".details .organization").innerHTML =
238
+ certificate.organization;
239
+ document.querySelector(".details .country").innerHTML = certificate.country;
240
+ document.querySelector(".details .issued").innerHTML = certificate.issued;
241
+ document.querySelector(".details .expired").innerHTML = certificate.expired;
242
+ document.querySelector(".details .serialNumber").innerHTML =
243
+ certificate.serialNumber;
244
+ document.querySelector(".details .modulus").innerHTML = certificate.modulus;
245
+ }
static/style.css CHANGED
@@ -188,4 +188,18 @@ section.verification-details .certificate .details div label {
188
  width: 200px;
189
  font-size: 12px;
190
  font-weight: 400;
191
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  width: 200px;
189
  font-size: 12px;
190
  font-weight: 400;
191
+ }
192
+
193
+ #certificate-list {
194
+ padding: 0;
195
+ }
196
+
197
+ #certificate-list li {
198
+ border: 1px solid #d8dfe5;
199
+ list-style: none;
200
+ padding: .5rem;
201
+ }
202
+
203
+ #certificate-list li.active {
204
+ background: #f7f9fa;
205
+ }