mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
Merge branch 'feat/rsa-keygen-enhancements' into chore/all-my-stuffs
# Conflicts: # components.d.ts # package.json # vite.config.ts
This commit is contained in:
commit
dc478634c3
6 files changed
+120
-37
No files matched your search
+3
-1
@@ -2,6 +2,7 @@
|
||||
"name": "it-tools",
|
||||
"version": "2024.10.22-7ca5933",
|
||||
"packageManager": "pnpm@8.15.3",
|
||||
"version": "2023.11.2-7d94e11",
|
||||
"description": "Collection of handy online tools for developers, with great UX. ",
|
||||
"author": "Corentin Th <corentin.thomasset74+it-tools@gmail.com> (https://corentin.tech)",
|
||||
"license": "GNU GPLv3",
|
||||
@@ -307,6 +308,7 @@
|
||||
"vue-i18n": "^9.9.1",
|
||||
"vue-mathjax-next": "^0.0.6",
|
||||
"vue-markdown-render": "^2.2.1",
|
||||
"vue-i18n": "^9.2.2",
|
||||
"vue-router": "^4.1.6",
|
||||
"vue-shadow-dom": "^4.2.0",
|
||||
"vue-tsc": "^1.8.1",
|
||||
@@ -324,7 +326,7 @@
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^0.41.0",
|
||||
"@iconify-json/mdi": "^1.1.50",
|
||||
"@intlify/unplugin-vue-i18n": "^2.0.0",
|
||||
"@intlify/unplugin-vue-i18n": "^0.13.0",
|
||||
"@playwright/test": "^1.32.3",
|
||||
"@rushstack/eslint-patch": "^1.2.0",
|
||||
"@tsconfig/node18": "^18.2.0",
|
||||
|
||||
Generated
+6
-8
@@ -627,7 +627,7 @@ dependencies:
|
||||
specifier: ^0.1.1
|
||||
version: 0.1.1
|
||||
vue-i18n:
|
||||
specifier: ^9.9.1
|
||||
specifier: ^9.2.2
|
||||
version: 9.9.1(vue@3.3.4)
|
||||
vue-markdown-render:
|
||||
specifier: ^2.2.1
|
||||
@@ -683,8 +683,8 @@ devDependencies:
|
||||
specifier: ^1.1.50
|
||||
version: 1.1.50
|
||||
'@intlify/unplugin-vue-i18n':
|
||||
specifier: ^2.0.0
|
||||
version: 2.0.0(rollup@2.79.1)(vue-i18n@9.9.1)
|
||||
specifier: ^0.13.0
|
||||
version: 0.13.0(rollup@2.79.1)(vue-i18n@9.9.1)
|
||||
'@playwright/test':
|
||||
specifier: ^1.32.3
|
||||
version: 1.32.3
|
||||
@@ -3437,8 +3437,8 @@ packages:
|
||||
resolution: {integrity: sha512-b3Pta1nwkz5rGq434v0psHwEwHGy1pYCttfcM22IE//K9owbpkEvFptx9VcuRAxjQdrO2If249cmDDjBu5wMDA==}
|
||||
engines: {node: '>= 16'}
|
||||
|
||||
/@intlify/unplugin-vue-i18n@2.0.0(rollup@2.79.1)(vue-i18n@9.9.1):
|
||||
resolution: {integrity: sha512-1oKvm92L9l2od2H9wKx2ZvR4tzn7gUtd7bPLI7AWUmm7U9H1iEypndt5d985ypxGsEs0gToDaKTrytbBIJwwSg==}
|
||||
/@intlify/unplugin-vue-i18n@0.13.0(rollup@2.79.1)(vue-i18n@9.9.1):
|
||||
resolution: {integrity: sha512-Mm9NhcvbsSZ5FXXnCpL/XFCk1hPp809hxErNmnwqGp21JjYOKGp3wpQSrpvGk33ZrHZbhPqAu70IEVEAxVZ5+A==}
|
||||
engines: {node: '>= 14.16'}
|
||||
peerDependencies:
|
||||
petite-vue-i18n: '*'
|
||||
@@ -5682,7 +5682,7 @@ packages:
|
||||
/@types/lodash-es@4.17.10:
|
||||
resolution: {integrity: sha512-YJP+w/2khSBwbUSFdGsSqmDvmnN3cCKoPOL7Zjle6s30ZtemkkqhjVfFqGwPN7ASil5VyjE2GtyU/yqYY6mC0A==}
|
||||
dependencies:
|
||||
'@types/lodash': 4.14.200
|
||||
'@types/lodash': 4.14.192
|
||||
dev: false
|
||||
|
||||
/@types/lodash.defaultsdeep@4.6.9:
|
||||
@@ -5705,7 +5705,6 @@ packages:
|
||||
|
||||
/@types/lodash@4.14.192:
|
||||
resolution: {integrity: sha512-km+Vyn3BYm5ytMO13k9KTp27O75rbQ0NFw+U//g+PX7VZyjCioXaRFisqSIJRECljcTv73G3i6BpglNGHgUQ5A==}
|
||||
dev: true
|
||||
|
||||
/@types/lodash@4.14.200:
|
||||
resolution: {integrity: sha512-YI/M/4HRImtNf3pJgbF+W6FrXovqj+T+/HpENLTooK9PnkacBsDpeP3IpHab40CClUfhNmdM2WTNP2sa2dni5Q==}
|
||||
@@ -16747,7 +16746,6 @@ packages:
|
||||
|
||||
/yamljs@0.3.0:
|
||||
resolution: {integrity: sha512-C/FsVVhht4iPQYXOInoxUM/1ELSf9EsgKH34FofQOp6hwCPrW4vG4w5++TED3xRUo8gD7l0P1J1dLlDYzODsTQ==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
argparse: 1.0.10
|
||||
glob: 7.2.3
|
||||
|
||||
@@ -5,8 +5,8 @@ import { translate } from '@/plugins/i18n.plugin';
|
||||
export const tool = defineTool({
|
||||
name: translate('tools.rsa-key-pair-generator.title'),
|
||||
path: '/rsa-key-pair-generator',
|
||||
description: translate('tools.rsa-key-pair-generator.description'),
|
||||
keywords: ['rsa', 'key', 'pair', 'generator', 'public', 'private', 'secret', 'ssh', 'pem'],
|
||||
description: 'Generate new random RSA private and public keys (with or without passphrase).',
|
||||
keywords: ['rsa', 'key', 'pair', 'generator', 'public', 'private', 'secret', 'ssh', 'pem', 'passphrase', 'password'],
|
||||
component: () => import('./rsa-key-pair-generator.vue'),
|
||||
icon: Certificate,
|
||||
npmPackages: ['node-forge'],
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { pki } from 'node-forge';
|
||||
import workerScript from 'node-forge/dist/prime.worker.min?url';
|
||||
import sshpk from 'sshpk';
|
||||
|
||||
export { generateKeyPair };
|
||||
|
||||
@@ -16,11 +17,39 @@ function generateRawPairs({ bits = 2048 }) {
|
||||
);
|
||||
}
|
||||
|
||||
async function generateKeyPair(config: { bits?: number } = {}) {
|
||||
async function generateKeyPair(config: {
|
||||
bits?: number
|
||||
password?: string
|
||||
format?: sshpk.PrivateKeyFormatType
|
||||
comment?: string
|
||||
} = {}) {
|
||||
const { privateKey, publicKey } = await generateRawPairs(config);
|
||||
|
||||
const privateUnencryptedKeyPem = pki.privateKeyToPem(privateKey);
|
||||
|
||||
if (config?.format === 'pem') {
|
||||
return {
|
||||
publicKey: pki.publicKeyToPem(publicKey),
|
||||
privateKey: config?.password
|
||||
? pki.encryptRsaPrivateKey(privateKey, config?.password)
|
||||
: privateUnencryptedKeyPem,
|
||||
};
|
||||
}
|
||||
|
||||
const privKey = sshpk.parsePrivateKey(privateUnencryptedKeyPem);
|
||||
privKey.comment = config?.comment;
|
||||
const pubFormat = config.format ?? 'ssh';
|
||||
let privFormat = config.format ?? 'ssh';
|
||||
if (privFormat === 'ssh') {
|
||||
privFormat = 'ssh-private';
|
||||
}
|
||||
const pubKey = privKey.toPublic();
|
||||
return {
|
||||
publicKeyPem: pki.publicKeyToPem(publicKey),
|
||||
privateKeyPem: pki.privateKeyToPem(privateKey),
|
||||
publicKey: pubKey.toString(pubFormat),
|
||||
privateKey: config?.password
|
||||
? privKey.toString(privFormat,
|
||||
{ passphrase: config?.password, comment: config?.comment },
|
||||
)
|
||||
: privKey.toString(privFormat, { comment: config?.comment }),
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import type sshpk from 'sshpk';
|
||||
import { generateKeyPair } from './rsa-key-pair-generator.service';
|
||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||
import { withDefaultOnErrorAsync } from '@/utils/defaults';
|
||||
@@ -6,7 +7,21 @@ import { useValidation } from '@/composable/validation';
|
||||
import { computedRefreshableAsync } from '@/composable/computedRefreshable';
|
||||
|
||||
const bits = ref(2048);
|
||||
const emptyCerts = { publicKeyPem: '', privateKeyPem: '' };
|
||||
const comment = ref('');
|
||||
const password = ref('');
|
||||
const emptyCerts = { publicKey: '', privateKey: '' };
|
||||
|
||||
const format = useStorage('rsa-key-pair-generator:format', 'ssh');
|
||||
const formatOptions = [
|
||||
{ value: 'pem', label: 'PEM' },
|
||||
{ value: 'pkcs1', label: 'PKCS#1' },
|
||||
{ value: 'pkcs8', label: 'PKCS#8' },
|
||||
{ value: 'ssh', label: 'OpenSSH Standard' },
|
||||
{ value: 'openssh', label: 'OpenSSH New' },
|
||||
{ value: 'putty', label: 'PuTTY' },
|
||||
];
|
||||
|
||||
const supportsPassphrase = computed(() => format.value === 'pem' || format.value === 'ssh');
|
||||
|
||||
const { attrs: bitsValidationAttrs } = useValidation({
|
||||
source: bits,
|
||||
@@ -19,31 +34,67 @@ const { attrs: bitsValidationAttrs } = useValidation({
|
||||
});
|
||||
|
||||
const [certs, refreshCerts] = computedRefreshableAsync(
|
||||
() => withDefaultOnErrorAsync(() => generateKeyPair({ bits: bits.value }), emptyCerts),
|
||||
() => withDefaultOnErrorAsync(() => generateKeyPair({
|
||||
bits: bits.value,
|
||||
password: password.value,
|
||||
format: format.value as sshpk.PrivateKeyFormatType,
|
||||
comment: comment.value,
|
||||
}), emptyCerts),
|
||||
emptyCerts,
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="flex: 0 0 100%">
|
||||
<div item-style="flex: 1 1 0" style="max-width: 600px" mx-auto flex gap-3>
|
||||
<n-form-item label="Bits :" v-bind="bitsValidationAttrs as any" label-placement="left" label-width="100">
|
||||
<div>
|
||||
<n-space justify="space-between" mb-1>
|
||||
<c-select
|
||||
v-model:value="format"
|
||||
label-position="left"
|
||||
label="Format:"
|
||||
:options="formatOptions"
|
||||
placeholder="Select a key format"
|
||||
/>
|
||||
|
||||
<n-form-item label="Bits :" v-bind="bitsValidationAttrs as any" label-placement="left">
|
||||
<n-input-number v-model:value="bits" min="256" max="16384" step="8" />
|
||||
</n-form-item>
|
||||
</n-space>
|
||||
|
||||
<div v-if="supportsPassphrase" mb-1>
|
||||
<n-form-item label="Passphrase :" label-placement="left">
|
||||
<n-input
|
||||
v-model:value="password"
|
||||
type="password"
|
||||
show-password-on="mousedown"
|
||||
placeholder="Passphrase"
|
||||
/>
|
||||
</n-form-item>
|
||||
</div>
|
||||
|
||||
<div mb-1>
|
||||
<n-form-item label="Comment :" label-placement="left">
|
||||
<n-input
|
||||
v-model:value="comment"
|
||||
type="text"
|
||||
placeholder="Comment"
|
||||
/>
|
||||
</n-form-item>
|
||||
</div>
|
||||
|
||||
<n-space justify="center" mb-1>
|
||||
<c-button @click="refreshCerts">
|
||||
Refresh key-pair
|
||||
</c-button>
|
||||
</n-space>
|
||||
|
||||
<div>
|
||||
<h3>Public key</h3>
|
||||
<TextareaCopyable :value="certs.publicKey" :word-wrap="true" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3>Private key</h3>
|
||||
<TextareaCopyable :value="certs.privateKey" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3>Public key</h3>
|
||||
<TextareaCopyable :value="certs.publicKeyPem" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3>Private key</h3>
|
||||
<TextareaCopyable :value="certs.privateKeyPem" />
|
||||
</div>
|
||||
</template>
|
||||
+11
-8
@@ -1,8 +1,8 @@
|
||||
import { resolve } from 'node:path';
|
||||
import { URL, fileURLToPath } from 'node:url';
|
||||
import { resolve } from 'node:path';
|
||||
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
||||
|
||||
import VueI18n from '@intlify/unplugin-vue-i18n/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||||
import Unocss from 'unocss/vite';
|
||||
@@ -12,12 +12,19 @@ import Icons from 'unplugin-icons/vite';
|
||||
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers';
|
||||
import Components from 'unplugin-vue-components/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
import markdown from 'vite-plugin-vue-markdown';
|
||||
import svgLoader from 'vite-svg-loader';
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
import AutoImport from 'unplugin-auto-import/vite';
|
||||
import Components from 'unplugin-vue-components/vite';
|
||||
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers';
|
||||
import Unocss from 'unocss/vite';
|
||||
import { configDefaults } from 'vitest/config';
|
||||
import topLevelAwait from "vite-plugin-top-level-await";
|
||||
import Icons from 'unplugin-icons/vite';
|
||||
import IconsResolver from 'unplugin-icons/resolver';
|
||||
import VueI18n from '@intlify/unplugin-vue-i18n/vite';
|
||||
|
||||
const baseUrl = process.env.BASE_URL ?? '/';
|
||||
|
||||
@@ -26,13 +33,9 @@ export default defineConfig({
|
||||
plugins: [
|
||||
VueI18n({
|
||||
runtimeOnly: true,
|
||||
jitCompilation: true,
|
||||
compositionOnly: true,
|
||||
fullInstall: true,
|
||||
strictMessage: false,
|
||||
include: [
|
||||
resolve(__dirname, 'locales/**'),
|
||||
],
|
||||
include: [resolve(__dirname, 'locales/**')],
|
||||
}),
|
||||
AutoImport({
|
||||
imports: [
|
||||
|
||||
Reference in new issue
Block a user