Merge branch 'chore/all-my-stuffs' into improve-unicode-search-performance

This commit is contained in:
sharevb authored and GitHub committed 2025-05-18 22:50:32 +02:00
commit 6743523b50
3 files changed
+10464 -13183

No files matched your search

+10418 -13165
View File
File diff suppressed because it is too large. Load diff
@@ -18,6 +18,22 @@ import * as openpgp from 'openpgp';
import * as forge from 'node-forge';
import { type LabelValue, getCSRLabelValues, getCertificateLabelValues, getFingerprintLabelValues, getPGPPrivateKeyLabelValuesAsync, getPGPPublicKeyLabelValuesAsync, getPrivateKeyLabelValues, getPublicKeyLabelValues, getSignatureLabelValues } from './certificate-key-parser.infos';
export async function getKeysOrCertificatesInfosAsync(keyOrCertificateValue: string | Buffer, passphrase: string) {
const parts = keyOrCertificateValue.toString().trim().split(/(-----BEGIN [^-]+-----\n)/).filter(s => s !== '');
if (!parts.length) {
return [await getKeyOrCertificateInfosAsync(keyOrCertificateValue, passphrase)];
}
const parsedPEMs: Array<{
values: LabelValue[]
certificateX509DER?: undefined | string
}> = [];
for (let i = 0; i < parts.length; i += 2) {
const pemPart = parts[i] + parts[i + 1];
parsedPEMs.push(await getKeyOrCertificateInfosAsync(pemPart, passphrase));
}
return parsedPEMs;
}
export async function getKeyOrCertificateInfosAsync(keyOrCertificateValue: string | Buffer, passphrase: string) {
try {
const canParse = (value: string | Buffer, parseFunction: (value: string | Buffer) => any) => {
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { Buffer } from 'node:buffer';
import { getKeyOrCertificateInfosAsync } from './certificate-key-parser.service';
import { getKeysOrCertificatesInfosAsync } from './certificate-key-parser.service';
import { type LabelValue } from './certificate-key-parser.infos';
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
@@ -37,7 +37,7 @@ function downloadX509DERFile() {
}
}
const parsedSections = computedAsync<LabelValue[]>(async () => {
const parsedSections = computedAsync<LabelValue[][]>(async () => {
const inputContent = inputKeyOrCertificate.value;
const file = fileInput.value;
let inputKeyOrCertificateValue: string | Buffer = '';
@@ -47,9 +47,15 @@ const parsedSections = computedAsync<LabelValue[]>(async () => {
else if (inputType.value === 'content' && inputContent) {
inputKeyOrCertificateValue = inputContent;
}
const { values, certificateX509DER: certPEM } = await getKeyOrCertificateInfosAsync(inputKeyOrCertificateValue, passphrase.value);
certificateX509DER.value = certPEM || '';
return values;
const parsed = await getKeysOrCertificatesInfosAsync(inputKeyOrCertificateValue, passphrase.value);
if (parsed.length === 1) {
const { values, certificateX509DER: certPEM } = parsed[0];
certificateX509DER.value = certPEM || '';
return [values];
}
else {
return parsed.map(p => p.values);
}
});
</script>
@@ -96,20 +102,26 @@ const parsedSections = computedAsync<LabelValue[]>(async () => {
<n-divider />
<input-copyable
v-for="{ label, value, multiline } of parsedSections"
:key="label"
:label="label"
:data-test-id="label"
label-position="left"
label-width="100px"
label-align="right"
<c-card
v-for="(part, partIndex) of parsedSections"
:key="partIndex"
mb-2
>
<input-copyable
v-for="{ label, value, multiline } of part"
:key="label"
:label="label"
:data-test-id="label"
label-position="left"
label-width="100px"
label-align="right"
autosize mb-2
:multiline="multiline"
:value="value"
placeholder="Not Set"
/>
autosize mb-2
:multiline="multiline"
:value="value"
placeholder="Not Set"
/>
</c-card>
<div v-if="certificateX509DER !== ''" flex justify-center>
<c-button @click="downloadX509DERFile()">