Compare commits

...
28 Commits
Author SHA1 Message Date
Chris Tran 66cd2fe815 refactor: localize crop-image component
Add vue-i18n integration to crop-image.vue and replace hardcoded UI text with t() translation calls. Import useI18n and use t() for button labels, form labels, hints (with interpolation for zoom), and action text. Convert aspect ratio and export width option arrays into computed properties so they can use translated labels. These changes prepare the component for localization without changing functionality.
2026-06-06 15:14:05 -07:00
Chris Tran d9ad48daa5 feat: add crop-image 'texts' translations to locales
Add 'texts' translation entries for the crop-image tool across multiple locales (ar, da, de, el, en, es, fr, ga, it, ko, nl, no, pl, pt, ru, tr, uk, vi, zh). Adds UI strings such as drag/drop hints, flip/reset/fit controls, aspect ratio and custom ratio labels, background color, zoom/rotate, rule-of-thirds grid, export settings (format, quality, width), ratio presets and width options. Also fixes a small typo in the Turkish description (và → ve).
2026-06-06 15:12:54 -07:00
Chris Tran 6a95f93df2 feat: add 'crop-image' translations to locales
Add localization entries for a new 'crop-image' tool across multiple locale YAML files (ar, da, de, el, en, es, fr, ga, it, ko, nl, no, pl, pt, ru, tr, uk, vi, zh). Each file adds title and description strings for cropping, resizing, and rotating images with custom background colors.
2026-06-06 15:08:35 -07:00
Chris Tran 7e152bc831 fix(crop-image): fix crop coordinate misalignment on small viewports
Resolves an issue where exporting cropped images on small/mobile screens resulted in a different crop than shown in the preview.

- Added reactive viewport scaling tracking using `@vueuse/core` `useElementSize`.
- Wrapped the cropper viewport in a container that scales down via CSS `transform: scale()` to maintain aspect ratios and layout without shrinking coordinates.
- Scaled pointer dragging deltas (`dx`, `dy`) by the scale factor to preserve movement tracking accuracy.
- Cleaned up related ESLint warnings/errors and unused imports in the `crop-image` files."
2026-06-06 15:06:08 -07:00
Chris Tran b688eb27d0 Add crop-image sizing utilities and tests
Introduce getViewportDimensions and getBaseDimensions utility functions (src/tools/crop-image/crop-image.service.ts) to centralize viewport/base sizing logic and handle missing natural dimensions. Refactor crop-image.vue to consume these utilities for computed viewport and base dimensions. Add unit tests covering landscape/portrait calculations and cover scaling (src/tools/crop-image/crop-image.service.test.ts) and expand the e2e spec to upload a 1x1 PNG and assert presence of the cropper, sliders and control buttons (src/tools/crop-image/crop-image.e2e.spec.ts). Improves testability and keeps sizing logic consistent across the component.
2026-06-06 14:24:25 -07:00
Chris Tran a455ee0a8f Add crop-image tool
Introduce a new Crop Image tool: adds an interactive Vue cropper component (src/tools/crop-image/crop-image.vue) with drag/drop upload, viewport cropping, zoom, rotation, horizontal/vertical flip, aspect-ratio presets/custom ratio, rule-of-thirds grid, background color, and export options (PNG/JPEG/WebP, quality and width modes). Also adds tool registration (src/tools/crop-image/index.ts), a placeholder service (crop-image.service.ts), a Vitest unit test (crop-image.service.test.ts) and a Playwright e2e spec stub (crop-image.e2e.spec.ts).
2026-06-06 14:21:41 -07:00
ShareVB 102bb9926e fix(Data Storage Units Converter): fix b/iB/B conversion
Fix #398
2026-05-28 09:33:36 +02:00
ShareVB dfb92f2441 fix(Speed Converter): wrong m/h is in fact mi/h (miles)
Fix #399
2026-05-28 09:10:11 +02:00
ShareVB fb8a1eb5b1 fix(Amortization Calculator): exclude historical currencies
Fix #396
2026-05-24 23:02:41 +02:00
Shaquille_Oatmeal c5a93af9cc docs: enhance Docker cheat sheet (#397)
- Fix --no-cache flag and dockerd command
- Remove escaped underscores from placeholders
- Add Volumes, Networks, Compose, and Cleanup sections
- Add common flags reference table
2026-05-22 17:08:39 +02:00
ShareVB 3b7ddb4b8f fix: optimize Home loading
Fix part of #330
2026-05-17 16:17:04 +02:00
ShareVB d5f4dcb91c fixup! fix: node-forge patch for EcDSA 2026-05-16 16:14:22 +02:00
ShareVB 1a664fe096 feat(new tool): HTTPS Tester
Add HTTPS test tools (certificate, HSTS, 302 rewrite)

Fix #345
2026-05-16 15:53:44 +02:00
ShareVB 5fd2bb66f3 feat(new tool): Powershell Memo
Fix #1793
2026-05-16 15:47:55 +02:00
ShareVB 4100059b3a feat(new tool): DNS Propagation Tester
Fix #346
2026-05-16 15:47:55 +02:00
ShareVB d8787317a4 feat(new tool): DNS Tester
DNS Queries, Reverse DNS Queries, DNSSec test, AXFR test and Whois queries
2026-05-16 15:47:55 +02:00
ShareVB 23ede48549 feat(x509 Certificate Generator): add options for RSA bits 2026-05-11 13:59:16 +02:00
ShareVB 6cc1ad7e98 fix: node-forge patch for EcDSA
Fix #1792
2026-05-11 13:47:00 +02:00
ShareVB 7e9cf35c28 fix(Geo Coordinates Converter): fix marker display
Fix #392
2026-05-11 12:42:28 +02:00
Brian Baidalandsharevb 89975dc505 feat(new tool): Random Line Picker (#393)
Adds a new Random Line Picker tool to pick one or more random lines from user-provided text. It's a handy utility for quickly selecting random items (winners, samples, shuffled lists) inside the app.

Co-authored-by: sharevb <sharevb@gmail.com>
2026-05-11 00:28:20 +02:00
ShareVB f0e35b09ee feat(Geo Coordinates Converter): add DMS/Decimal/UTM and a interactive map
Fix #392
2026-05-11 00:11:03 +02:00
ShareVB 905de13a84 fix: remove HTTP Headers security as this broke many tools 2026-05-10 23:38:06 +02:00
ShareVB efd0b2513a i18n: translate remaining 2026-05-03 22:19:13 +02:00
ShareVB 4103bd7e6e i18n: extract more strings 2026-05-03 21:59:05 +02:00
ShareVB 92bf2b5bd7 fix(Pdf Signature Checker): not supported certificate 2026-05-03 21:48:30 +02:00
ShareVB 04c2575ab6 feat(UUID Generator): Case and hyphen options
Fix #373
2026-05-03 20:54:00 +02:00
hakimilgandShareVB b05e70d6d8 feat(new tool): JSON to .env converter (#349)
Converts a flat JSON object into a .env file. Keys are upper-cased,
values are safely quoted when they contain whitespace, quotes, or env
special characters (#, $, `, \). Nested objects and arrays are
JSON-stringified and always quoted; null/undefined become "".

Follows the existing FormatTransformer pattern used by the other
json-to-* converters, including i18n via useI18n and the built-in
.env download button.

Co-authored-by: ShareVB <sharevb@gmail.com>
2026-05-03 19:21:46 +02:00
ShareVB f7f82a57d6 chore: update dependencies 2026-05-03 19:20:25 +02:00
70 changed files with 48076 additions and 27392 deletions

No files matched your search

+1
View File
@@ -9,6 +9,7 @@ RUN apk add --update python3 make g++\
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
COPY patches patches
RUN npm install -g pnpm && pnpm i --ignore-scripts --frozen-lockfile
COPY . .
ARG BASE_URL
+2302 -1443
View File
File diff suppressed because it is too large. Load diff
+2395 -1500
View File
File diff suppressed because it is too large. Load diff
+2695 -1699
View File
File diff suppressed because it is too large. Load diff
+2742 -1751
View File
File diff suppressed because it is too large. Load diff
+1900 -1623
View File
File diff suppressed because it is too large. Load diff
+2654 -1679
View File
File diff suppressed because it is too large. Load diff
+882 -113
View File
File diff suppressed because it is too large. Load diff
+2572 -1625
View File
File diff suppressed because it is too large. Load diff
+2591 -1643
View File
File diff suppressed because it is too large. Load diff
+2015 -1246
View File
File diff suppressed because it is too large. Load diff
+2544 -1599
View File
File diff suppressed because it is too large. Load diff
+2398 -1501
View File
File diff suppressed because it is too large. Load diff
+2467 -1554
View File
File diff suppressed because it is too large. Load diff
+2544 -1604
View File
File diff suppressed because it is too large. Load diff
+2536 -1585
View File
File diff suppressed because it is too large. Load diff
+2536 -1602
View File
File diff suppressed because it is too large. Load diff
+2473 -1558
View File
File diff suppressed because it is too large. Load diff
+2485 -1574
View File
File diff suppressed because it is too large. Load diff
+866 -119
View File
File diff suppressed because it is too large. Load diff
+7 -7
View File
@@ -5,13 +5,13 @@ server {
root /usr/share/nginx/html;
index index.html;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header Referrer-Policy strict-origin-when-cross-origin;
add_header X-Permitted-Cross-Domain-Policies none;
add_header Cross-Origin-Resource-Policy same-site;
add_header Cross-Origin-Opener-Policy same-origin;
add_header Cross-Origin-Embedder-Policy require-corp;
#add_header X-Frame-Options SAMEORIGIN;
#add_header X-Content-Type-Options nosniff;
#add_header Referrer-Policy strict-origin-when-cross-origin;
#add_header X-Permitted-Cross-Domain-Policies none;
#add_header Cross-Origin-Resource-Policy same-site;
#add_header Cross-Origin-Opener-Policy same-origin;
#add_header Cross-Origin-Embedder-Policy require-corp;
#add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' http: https: blob:; style-src 'self' 'unsafe-inline' https: http:; img-src 'self' data: blob: https: http:; connect-src data: blob: https: http:; font-src 'self' https: http:; object-src 'none'; base-uri 'self'; form-action 'self';";
include /etc/nginx/mime.types;
+7 -2
View File
@@ -238,6 +238,7 @@
"jwt-decode": "^4.0.0",
"korean-unpacker": "^1.0.3",
"langs": "^2.0.0",
"leaflet": "^1.9.4",
"libmime": "^5.3.8",
"libphonenumber-js": "^1.12.33",
"lodash": "^4.18.1",
@@ -395,6 +396,7 @@
"@types/js-beautify": "^1.14.3",
"@types/jsdom": "^21.1.7",
"@types/jsonpath": "^0.2.4",
"@types/leaflet": "^1.9.21",
"@types/libmime": "^5.0.3",
"@types/lodash": "^4.17.20",
"@types/lodash.defaultsdeep": "^4.6.9",
@@ -446,10 +448,10 @@
"unplugin-vue-components": "^0.25.0",
"unplugin-vue-markdown": "^29.1.0",
"vite": "^4.4.9",
"vite-plugin-node-polyfills": "^0.23.0",
"vite-plugin-node-polyfills": "^0.26.0",
"vite-plugin-pwa": "^1.1.0",
"vite-plugin-splash-screen": "^0.2.0",
"vite-plugin-wasm": "^3.4.1",
"vite-plugin-wasm": "^3.6.0",
"vite-svg-loader": "^4.0.0",
"vitest": "^0.34.6",
"vue-i18n-extract": "^2.0.7",
@@ -460,6 +462,9 @@
"overrides": {
"@vueuse/shared": "13.9.0",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
},
"patchedDependencies": {
"node-forge@1.4.0": "patches/node-forge@1.4.0.patch"
}
},
"scarfSettings": {
+765
View File
@@ -0,0 +1,765 @@
diff --git a/lib/asn1-validator.js b/lib/asn1-validator.js
index 2be328501e93e5f0e38245b6ee797bfc426dfcaa..4deb9f17e77b9c1a602fc6e034012b4c1ccf7e52 100644
--- a/lib/asn1-validator.js
+++ b/lib/asn1-validator.js
@@ -17,7 +17,6 @@ exports.privateKeyValidator = {
name: 'PrivateKeyInfo.version',
tagClass: asn1.Class.UNIVERSAL,
type: asn1.Type.INTEGER,
- constructed: false,
capture: 'privateKeyVersion'
}, {
// privateKeyAlgorithm
@@ -29,7 +28,6 @@ exports.privateKeyValidator = {
name: 'AlgorithmIdentifier.algorithm',
tagClass: asn1.Class.UNIVERSAL,
type: asn1.Type.OID,
- constructed: false,
capture: 'privateKeyOid'
}]
}, {
@@ -37,12 +35,11 @@ exports.privateKeyValidator = {
name: 'PrivateKeyInfo',
tagClass: asn1.Class.UNIVERSAL,
type: asn1.Type.OCTETSTRING,
- constructed: false,
capture: 'privateKey'
}]
};
-exports.publicKeyValidator = {
+exports.publicKeyInfoValidator = {
name: 'SubjectPublicKeyInfo',
tagClass: asn1.Class.UNIVERSAL,
type: asn1.Type.SEQUENCE,
@@ -54,38 +51,24 @@ exports.publicKeyValidator = {
type: asn1.Type.SEQUENCE,
constructed: true,
value: [{
- name: 'AlgorithmIdentifier.algorithm',
- tagClass: asn1.Class.UNIVERSAL,
- type: asn1.Type.OID,
- constructed: false,
- capture: 'publicKeyOid'
- }]
- },
- // capture group for ed25519PublicKey
- {
- tagClass: asn1.Class.UNIVERSAL,
- type: asn1.Type.BITSTRING,
- constructed: false,
- composed: true,
- captureBitStringValue: 'ed25519PublicKey'
- }
- // FIXME: this is capture group for rsaPublicKey, use it in this API or
- // discard?
- /* {
+ name: 'AlgorithmIdentifier.algorithm',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ capture: 'publicKeyOid'
+ },
+ {
+ name: 'AlgorithmIdentifier.parameters',
+ tagClass: asn1.Class.UNIVERSAL,
+ optional: true,
+ captureAsn1: 'parameters',
+ }]
+ }, {
// subjectPublicKey
name: 'SubjectPublicKeyInfo.subjectPublicKey',
tagClass: asn1.Class.UNIVERSAL,
type: asn1.Type.BITSTRING,
constructed: false,
- value: [{
- // RSAPublicKey
- name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey',
- tagClass: asn1.Class.UNIVERSAL,
- type: asn1.Type.SEQUENCE,
- constructed: true,
- optional: true,
- captureAsn1: 'rsaPublicKey'
- }]
- } */
- ]
+ captureAsn1: 'subjectPublicKey', // used by RSA
+ captureBitStringValue: 'subjectPublicKeyRaw', // used by ECDSA and ED25519
+ }]
};
diff --git a/lib/ecdsa.js b/lib/ecdsa.js
new file mode 100644
index 0000000000000000000000000000000000000000..6373401341a319edcd5360d3002cab2de4b81942
--- /dev/null
+++ b/lib/ecdsa.js
@@ -0,0 +1,390 @@
+/**
+ * JavaScript implementation of ECDSA.
+ *
+ * Copyright (c) 2021 HAMANO Tsukasa <hamano@osstech.co.jp>
+ *
+ * This implementation is based on the elliptic
+ *
+ * https://github.com/indutny/elliptic/
+ */
+var forge = require('./forge');
+require('./asn1');
+require('./jsbn');
+require('./random');
+require('./sha512');
+var util = require('./util');
+var elliptic = require('elliptic');
+var asn1Validator = require('./asn1-validator');
+var publicKeyInfoValidator = asn1Validator.publicKeyInfoValidator;
+var privateKeyValidator = asn1Validator.privateKeyValidator;
+var asn1 = forge.asn1;
+
+if(typeof BigInteger === 'undefined') {
+ var BigInteger = forge.jsbn.BigInteger;
+}
+
+var ByteBuffer = util.ByteBuffer;
+var NativeBuffer = typeof Buffer === 'undefined' ? Uint8Array : Buffer;
+
+forge.pki = forge.pki || {};
+module.exports = forge.pki.ecdsa = forge.ecdsa = forge.ecdsa || {};
+var ecdsa = forge.ecdsa;
+
+ecdsa.constants = {};
+
+/*
+ * Supported namedCurve listed here:
+ * https://github.com/indutny/elliptic/blob/master/lib/elliptic/curves.js
+ */
+ecdsa.supportedCueves = [
+ 'p192', // secp192r1, prime192v1
+ 'p256', // secp256r1, prime256v1
+ 'p224', // secp224r1,
+ 'p384', // secp384r1
+ 'p521', // secp521r1
+ 'secp256k1',// secp256k1
+];
+
+/*
+ * RCF5915: Elliptic Curve Private Key Format
+ * https://datatracker.ietf.org/doc/html/rfc5915
+ *
+ * ECPrivateKey ::= SEQUENCE {
+ * version INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1),
+ * privateKey OCTET STRING,
+ * parameters [0] ECParameters {{ NamedCurve }} OPTIONAL,
+ * publicKey [1] BIT STRING OPTIONAL
+ * }
+ */
+var ecPrivateKeyValidator = {
+ name: 'ECPrivateKey',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'ECPrivateKey.version',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ capture: 'version',
+ }, {
+ name: 'ECPrivateKey.privateKey',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ capture: 'privateKey',
+ }, {
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 0x0,
+ optional: true,
+ value: [{
+ name: 'ECPrivateKey.parameters',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ captureAsn1: 'parameters',
+ }],
+ }, {
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
+ type: 0x1,
+ optional: true,
+ value: [{
+ name: 'ECPrivateKey.publicKey',
+ type: asn1.Type.BITSTRING,
+ captureAsn1: 'publicKey',
+ }],
+ }]
+};
+
+var ecSpecifiedCurveValidator = {
+ name: 'SpecifiedCurve',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'SpecifiedCurveVersion',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ capture: 'version',
+ }, {
+ name: 'SpecifiedCurve.FieldID',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'SpecifiedCurve.FieldID.fieldType',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OID,
+ capture: 'fieldType',
+ }, {
+ name: 'SpecifiedCurve.FieldID.prime',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ capture: 'p',
+ }]
+ }, {
+ name: 'SpecifiedCurve.Curve',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.SEQUENCE,
+ constructed: true,
+ value: [{
+ name: 'SpecifiedCurve.Curve.a',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ capture: 'a',
+ }, {
+ name: 'SpecifiedCurve.Curve.b',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ capture: 'b',
+ }]
+ }, {
+ name: 'SpecifiedCurve.Generator',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.OCTETSTRING,
+ capture: 'g',
+ }, {
+ name: 'SpecifiedCurve.Order',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ capture: 'n',
+ }, {
+ name: 'SpecifiedCurve.Confactor',
+ tagClass: asn1.Class.UNIVERSAL,
+ type: asn1.Type.INTEGER,
+ capture: 'c',
+ optional: true
+ }]
+};
+
+ecdsa.generateKeyPair = function(options) {
+ options = options || {};
+ var curveName = options.name || 'p256';
+ var seed = options.seed;
+ var errors = [];
+
+ if (!(ecdsa.supportedCueves.includes(curveName))) {
+ var error = new Error('unsupported curveName: ' + curveName);
+ error.errors = errors;
+ throw error;
+ }
+ var curve = elliptic.curves[curveName];
+ var ec = new elliptic.ec(curve);
+ ec.curveName = curveName;
+ var kp = ec.genKeyPair({
+ entropy: seed,
+ });
+ var privateKey = kp.getPrivate();
+ var publicKey = kp.getPublic();
+ return {
+ publicKey: new ecdsa.ECPublicKey(kp.ec, publicKey),
+ privateKey: new ecdsa.ECPrivateKey(kp.ec, privateKey)
+ };
+};
+
+/**
+ * Converts a ECPrivateKey to an ASN.1 representation.
+ *
+ * @param key the ECPrivateKey.
+ *
+ * @return the ASN.1 representation of an ECPrivateKey.
+ */
+ecdsa.privateKeyToAsn1 = function(key, options) {
+ return key.toAsn1(options);
+};
+
+var ECPublicKey = function(ec, publicKey) {
+ this._ec = ec;
+ this._publicKey = publicKey;
+};
+
+ecdsa.ECPublicKey = ECPublicKey;
+
+/**
+ * Converts a public key from a RFC8410 ASN.1 encoding.
+ *
+ * @param obj - The asn1 representation of a public key.
+ *
+ * @return {ECPublicKey} - ECPublicKey object.
+ */
+ECPublicKey.fromAsn1 = function(obj) {
+ var capture = {};
+ var errors = [];
+ if(!forge.asn1.validate(obj, publicKeyInfoValidator, capture, errors)) {
+ var error = new Error('Cannot read PublicKeyInfo ASN.1 object.');
+ error.errors = errors;
+ throw error;
+ }
+ var publicKey = capture.subjectPublicKeyRaw;
+ var params = capture.parameters;
+ var curve;
+ var curveName;
+ if(params && params.type === forge.asn1.Type.OID) {
+ var oid = forge.asn1.derToOid(params.value);
+ curveName = forge.oids[oid];
+ if(!ecdsa.supportedCueves.includes(curveName)) {
+ var error = new Error('Unsupported curveName: ' + curveName);
+ error.errors = errors;
+ throw error;
+ }
+ curve = elliptic.curves[curveName];
+ } else if(params && params.type === forge.asn1.Type.SEQUENCE) {
+ var capture = {};
+ if(!forge.asn1.validate(params, ecSpecifiedCurveValidator, capture, errors)) {
+ var error = new Error('Cannot read specified curve ASN.1 object.');
+ error.errors = errors;
+ throw error;
+ }
+ var options = {
+ p: util.bytesToHex(capture.p),
+ a: util.bytesToHex(capture.a),
+ b: util.bytesToHex(capture.b),
+ n: util.bytesToHex(capture.n),
+ };
+ var _curve = new elliptic.curve.short(options);
+ var g = _curve.decodePoint(util.bytesToHex(capture.g), 'hex');
+ curve = {
+ curve: _curve,
+ n: _curve.n,
+ g: g
+ };
+ } else {
+ var error = new Error('no ECParameters');
+ error.errors = errors;
+ throw error;
+ }
+ var ec = new elliptic.ec({curve: curve});
+ ec.curveName = curveName;
+ var kp = ec.keyFromPublic(publicKey);
+ return new ECPublicKey(ec, kp.getPublic());
+};
+
+ECPublicKey.prototype.verify = function(msg, signature) {
+ var hexMsg = util.bytesToHex(msg);
+ var hexSignature = util.bytesToHex(signature);
+ return this._ec.verify(hexMsg, hexSignature, this._publicKey, 'hex');
+};
+
+ECPublicKey.prototype.toString = function() {
+ return this._publicKey.encode('hex');
+};
+
+ECPublicKey.prototype.getBytes = function() {
+ return String.fromCharCode.apply(null, this._publicKey.encode());
+};
+
+ECPublicKey.prototype.toAsn1 = function(options) {
+ var curveOID = forge.oids[this._ec.curveName];
+ if (!curveOID) {
+ var error = new Error('unsupported namedCurve or specifiedCurve.');
+ error.errors = errors;
+ throw error;
+ }
+
+ var obj = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
+ var aid = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(forge.oids['ecPublicKey']).getBytes()),
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(curveOID).getBytes())]);
+ obj.value.push(aid);
+ obj.value.push(
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,
+ "\0" + this.getBytes()));
+ return obj;
+};
+
+ECPublicKey.prototype.toDer = function() {
+ return asn1.toDer(this.toAsn1()).getBytes();
+};
+
+ECPublicKey.prototype.toPem = function() {
+ return '-----BEGIN PUBLIC KEY-----\n' +
+ util.encode64(this.toDer(), 64) +
+ '\n-----END PUBLIC KEY-----\n';
+};
+
+
+var ECPrivateKey = function(ec, privateKey) {
+ this._ec = ec;
+ this._privateKey = privateKey;
+};
+ecdsa.ECPrivateKey = ECPrivateKey;
+
+/**
+ * Converts a private key from a RFC5915 ASN.1 Object.
+ *
+ * @param obj - The asn1 representation of a private key.
+ *
+ * @returns {Object} obj - The ASN.1 key object.
+ * @returns {ECPrivateKey} ECPrivateKey object.
+ */
+ECPrivateKey.fromAsn1 = function(obj) {
+ var capture = {};
+ var errors = [];
+ var valid = forge.asn1.validate(obj, ecPrivateKeyValidator, capture, errors);
+ if(!valid) {
+ var error = new Error('Invalid ECPrivateKey object.');
+ error.errors = errors;
+ throw error;
+ }
+ var params;
+ if (!capture.parameters) {
+ var error = new Error('no ECPrivateKey.parameters.');
+ error.errors = errors;
+ throw error;
+ }
+ var oid = asn1.derToOid(capture.parameters.value)
+ var curveName = forge.oids[oid];
+ if (!ecdsa.supportedCueves.includes(curveName)) {
+ var error = new Error('unsupported curveName: ' + curveName);
+ error.errors = errors;
+ throw error;
+ }
+ curve = elliptic.curves[curveName];
+ var ec = new elliptic.ec({curve: curve});
+ ec.curveName = curveName;
+ var kp = ec.keyFromPrivate(util.bytesToHex(capture.privateKey));
+ return new ECPrivateKey(ec, kp.getPrivate());
+};
+
+ECPrivateKey.prototype.sign = function(msg) {
+ var hexMsg = util.bytesToHex(msg);
+ var signature = this._ec.sign(hexMsg, this._privateKey);
+ return String.fromCharCode.apply(null, signature.toDER());
+};
+
+ECPrivateKey.prototype.toString = function() {
+ return this._privateKey.toString('hex');
+};
+
+ECPrivateKey.prototype.getBytes = function() {
+ return String.fromCharCode.apply(null, this._privateKey.toArray());
+};
+
+ECPrivateKey.prototype.toAsn1 = function(options) {
+ var curveOID = forge.oids[this._ec.curveName];
+ if (!curveOID) {
+ var error = new Error('unsupported namedCurve');
+ error.errors = errors;
+ throw error;
+ }
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
+ asn1.create(asn1.Class.UNIVERSAL,
+ asn1.Type.INTEGER, false,
+ asn1.integerToDer(1).getBytes()),
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
+ this.getBytes()),
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0x0, true, [
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
+ asn1.oidToDer(curveOID).getBytes())
+ ]),
+ ]);
+};
+
+ECPrivateKey.prototype.toDer = function(options) {
+ return asn1.toDer(this.toAsn1(options)).getBytes();
+};
+
+ECPrivateKey.prototype.toPem = function(options) {
+ return '-----BEGIN EC PRIVATE KEY-----\n' +
+ util.encode64(this.toDer(options), 64) +
+ '\n-----END EC PRIVATE KEY-----\n';
+};
diff --git a/lib/ed25519.js b/lib/ed25519.js
index 87eb7097aff14b2a26103c10ce6777a672e0a0e8..31c48254c6112625a581945029f541269e74b46e 100644
--- a/lib/ed25519.js
+++ b/lib/ed25519.js
@@ -114,7 +114,7 @@ ed25519.publicKeyFromAsn1 = function(obj) {
// get SubjectPublicKeyInfo
var capture = {};
var errors = [];
- var valid = forge.asn1.validate(obj, publicKeyValidator, capture, errors);
+ var valid = forge.asn1.validate(obj, publicKeyInfoValidator, capture, errors);
if(!valid) {
var error = new Error('Invalid Key.');
error.errors = errors;
@@ -126,7 +126,7 @@ ed25519.publicKeyFromAsn1 = function(obj) {
throw new Error('Invalid OID "' + oid + '"; OID must be "' +
ed25519Oid + '".');
}
- var publicKeyBytes = capture.ed25519PublicKey;
+ var publicKeyBytes = capture.ed25519PublicKeyRaw;
if(publicKeyBytes.length !== ed25519.constants.PUBLIC_KEY_BYTE_LENGTH) {
throw new Error('Key length is invalid.');
}
diff --git a/lib/oids.js b/lib/oids.js
index 817ed1be2001cf1640df2b59cc4822cb01877cce..6ead3acf140269037eba6e1e0bd047fccc95167b 100644
--- a/lib/oids.js
+++ b/lib/oids.js
@@ -39,6 +39,18 @@ _IN('1.3.101.112', 'EdDSA25519');
_IN('1.2.840.10040.4.3', 'dsa-with-sha1');
+_IN('1.2.840.10045.2.1', 'ecPublicKey');
+_IN('1.2.840.10045.4.3.2', 'ecdsa-with-SHA256');
+_IN('1.2.840.10045.4.3.3', 'ecdsa-with-SHA384');
+_IN('1.2.840.10045.4.3.4', 'ecdsa-with-SHA512');
+
+_IN('1.2.840.10045.3.1.1', 'p192');
+_IN('1.2.840.10045.3.1.7', 'p256');
+_IN('1.3.132.0.33', 'p224');
+_IN('1.3.132.0.34', 'p384');
+_IN('1.3.132.0.35', 'p521');
+_IN('1.3.132.0.10', 'secp256k1');
+
_IN('1.3.14.3.2.7', 'desCBC');
_IN('1.3.14.3.2.26', 'sha1');
@@ -60,6 +72,7 @@ _IN('1.2.840.113549.1.7.3', 'envelopedData');
_IN('1.2.840.113549.1.7.4', 'signedAndEnvelopedData');
_IN('1.2.840.113549.1.7.5', 'digestedData');
_IN('1.2.840.113549.1.7.6', 'encryptedData');
+_IN('2.23.136.1.1.1', 'mrtdSignatureData');
// pkcs#9 oids
_IN('1.2.840.113549.1.9.1', 'emailAddress');
diff --git a/lib/pkcs7.js b/lib/pkcs7.js
index 3a5d845c5d6d62ac9fc6195ee6ef4155ecc0619c..5a773bcce033d69ebdc73d8586c0c2258eb9419b 100644
--- a/lib/pkcs7.js
+++ b/lib/pkcs7.js
@@ -1167,7 +1167,7 @@ function _fromAsn1(msg, obj, validator) {
// Check contentType, so far we only support (raw) Data.
var contentType = asn1.derToOid(capture.contentType);
- if(contentType !== forge.pki.oids.data) {
+ if(![forge.pki.oids.data, forge.pki.oids.mrtdSignatureData].includes(contentType)) {
throw new Error('Unsupported PKCS#7 message. ' +
'Only wrapped ContentType Data supported.');
}
diff --git a/lib/rsa.js b/lib/rsa.js
index a4264822b4dcd6dca44ca3e59e410c982eed7183..8cab56a1b776e808f550ded9ef14395fa6304da1 100644
--- a/lib/rsa.js
+++ b/lib/rsa.js
@@ -70,6 +70,10 @@ require('./prime');
require('./random');
require('./util');
+var asn1Validator = require('./asn1-validator');
+var publicKeyInfoValidator = asn1Validator.publicKeyInfoValidator;
+var ecdsa = require('./ecdsa');
+
if(typeof BigInteger === 'undefined') {
var BigInteger = forge.jsbn.BigInteger;
}
@@ -226,44 +230,6 @@ var rsaPublicKeyValidator = {
}]
};
-// validator for an SubjectPublicKeyInfo structure
-// Note: Currently only works with an RSA public key
-var publicKeyValidator = forge.pki.rsa.publicKeyValidator = {
- name: 'SubjectPublicKeyInfo',
- tagClass: asn1.Class.UNIVERSAL,
- type: asn1.Type.SEQUENCE,
- constructed: true,
- captureAsn1: 'subjectPublicKeyInfo',
- value: [{
- name: 'SubjectPublicKeyInfo.AlgorithmIdentifier',
- tagClass: asn1.Class.UNIVERSAL,
- type: asn1.Type.SEQUENCE,
- constructed: true,
- value: [{
- name: 'AlgorithmIdentifier.algorithm',
- tagClass: asn1.Class.UNIVERSAL,
- type: asn1.Type.OID,
- constructed: false,
- capture: 'publicKeyOid'
- }]
- }, {
- // subjectPublicKey
- name: 'SubjectPublicKeyInfo.subjectPublicKey',
- tagClass: asn1.Class.UNIVERSAL,
- type: asn1.Type.BITSTRING,
- constructed: false,
- value: [{
- // RSAPublicKey
- name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey',
- tagClass: asn1.Class.UNIVERSAL,
- type: asn1.Type.SEQUENCE,
- constructed: true,
- optional: true,
- captureAsn1: 'rsaPublicKey'
- }]
- }]
-};
-
// validator for a DigestInfo structure
var digestInfoValidator = {
name: 'DigestInfo',
@@ -1465,36 +1431,29 @@ pki.privateKeyToAsn1 = pki.privateKeyToRSAPrivateKey = function(key) {
};
/**
- * Converts a public key from an ASN.1 SubjectPublicKeyInfo or RSAPublicKey.
+ * Converts a RSA public key from an ASN.1 SubjectPublicKeyInfo.
*
- * @param obj the asn1 representation of a SubjectPublicKeyInfo or RSAPublicKey.
+ * @param obj the asn1 representation of a SubjectPublicKeyInfo.
*
* @return the public key.
*/
-pki.publicKeyFromAsn1 = function(obj) {
- // get SubjectPublicKeyInfo
+pki.rsa.publicKeyFromAsn1 = function(obj) {
+ //var subjectPublicKey = obj.value[1].value[0];
var capture = {};
var errors = [];
- if(asn1.validate(obj, publicKeyValidator, capture, errors)) {
- // get oid
- var oid = asn1.derToOid(capture.publicKeyOid);
- if(oid !== pki.oids.rsaEncryption) {
- var error = new Error('Cannot read public key. Unknown OID.');
- error.oid = oid;
- throw error;
- }
- obj = capture.rsaPublicKey;
+ if(!asn1.validate(obj, publicKeyInfoValidator, capture, errors)) {
+ var error = new Error('Cannot read public key. ' +
+ 'ASN.1 object does not contain an PublicKeyInfo.');
+ error.errors = errors;
+ throw error;
}
-
- // get RSA params
- errors = [];
+ obj = capture.subjectPublicKey.value[0];
if(!asn1.validate(obj, rsaPublicKeyValidator, capture, errors)) {
var error = new Error('Cannot read public key. ' +
- 'ASN.1 object does not contain an RSAPublicKey.');
+ 'ASN.1 object does not contain an RSAPublicKey.');
error.errors = errors;
throw error;
}
-
// FIXME: inefficient, get a BigInteger that uses byte strings
var n = forge.util.createBuffer(capture.publicKeyModulus).toHex();
var e = forge.util.createBuffer(capture.publicKeyExponent).toHex();
@@ -1503,6 +1462,31 @@ pki.publicKeyFromAsn1 = function(obj) {
return pki.setRsaPublicKey(
new BigInteger(n, 16),
new BigInteger(e, 16));
+}
+
+/**
+ * Converts a public key from an ASN.1 SubjectPublicKeyInfo or RSAPublicKey.
+ *
+ * @param obj the asn1 representation of a SubjectPublicKeyInfo or RSAPublicKey.
+ *
+ * @return the public key.
+ */
+pki.publicKeyFromAsn1 = function(obj) {
+ // get SubjectPublicKeyInfo
+ var capture = {};
+ var errors = [];
+ // get oid
+ var oid = asn1.derToOid(obj.value[0].value[0].value);
+ switch (oid) {
+ case pki.oids.rsaEncryption:
+ return pki.rsa.publicKeyFromAsn1(obj);
+ case pki.oids.ecPublicKey:
+ return ecdsa.ECPublicKey.fromAsn1(obj);
+ default:
+ var error = new Error('Cannot read public key. Unknown OID.');
+ error.oid = oid;
+ throw error;
+ }
};
/**
diff --git a/lib/x509.js b/lib/x509.js
index b4a4f6d7a4c57bea6d986a733f360a299bd15f5f..ce83d6dec9140d7df79c0e61bfc754df44f907a8 100644
--- a/lib/x509.js
+++ b/lib/x509.js
@@ -144,8 +144,8 @@ _shortNames['E'] = oids['emailAddress'];
_shortNames['emailAddress'] = 'E';
// validator for an SubjectPublicKeyInfo structure
-// Note: Currently only works with an RSA public key
-var publicKeyValidator = forge.pki.rsa.publicKeyValidator;
+var asn1Validator = require('./asn1-validator');
+var publicKeyInfoValidator = asn1Validator.publicKeyInfoValidator;
// validator for an X.509v3 certificate
var x509CertificateValidator = {
@@ -252,7 +252,7 @@ var x509CertificateValidator = {
captureAsn1: 'certSubject'
},
// SubjectPublicKeyInfo
- publicKeyValidator,
+ publicKeyInfoValidator,
{
// issuerUniqueID (optional)
name: 'Certificate.TBSCertificate.issuerUniqueID',
@@ -427,7 +427,7 @@ var certificationRequestInfoValidator = {
captureAsn1: 'certificationRequestInfoSubject'
},
// SubjectPublicKeyInfo
- publicKeyValidator,
+ publicKeyInfoValidator,
{
name: 'CertificationRequestInfo.attributes',
tagClass: asn1.Class.CONTEXT_SPECIFIC,
@@ -706,13 +706,15 @@ var _createSignatureDigest = function(options) {
case 'md5WithRSAEncryption':
return forge.md.md5.create();
case 'sha256WithRSAEncryption':
+ case 'RSASSA-PSS':
+ case 'ecdsa-with-SHA256':
return forge.md.sha256.create();
case 'sha384WithRSAEncryption':
+ case 'ecdsa-with-SHA384':
return forge.md.sha384.create();
case 'sha512WithRSAEncryption':
+ case 'ecdsa-with-SHA512':
return forge.md.sha512.create();
- case 'RSASSA-PSS':
- return forge.md.sha256.create();
default:
var error = new Error(
'Could not compute ' + options.type + ' digest. ' +
@@ -1312,8 +1314,8 @@ pki.certificateFromAsn1 = function(obj, computeHash) {
// get oid
var oid = asn1.derToOid(capture.publicKeyOid);
- if(oid !== pki.oids.rsaEncryption) {
- throw new Error('Cannot read public key. OID is not RSA.');
+ if(![pki.oids.rsaEncryption, pki.oids.ecPublicKey].includes(oid)) {
+ throw new Error('Cannot read public key. publicKeyOid: ' + oid);
}
// create certificate
diff --git a/package.json b/package.json
index a78076c0f5020f48af7d9bf0b88ef39883374d08..b4d0074930f08c206c6071167cf43e2db0fc477e 100644
--- a/package.json
+++ b/package.json
@@ -119,5 +119,8 @@
"buffer": false,
"crypto": false,
"process": false
+ },
+ "dependencies": {
+ "elliptic": "^6.5.4"
}
}
+43 -20
View File
@@ -8,6 +8,11 @@ overrides:
'@vueuse/shared': 13.9.0
xlsx: https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz
patchedDependencies:
node-forge@1.4.0:
hash: be4w4shpo4tldv77tcysxrioha
path: patches/node-forge@1.4.0.patch
importers:
.:
@@ -600,6 +605,9 @@ importers:
langs:
specifier: ^2.0.0
version: 2.0.0
leaflet:
specifier: ^1.9.4
version: 1.9.4
libmime:
specifier: ^5.3.8
version: 5.3.8
@@ -719,7 +727,7 @@ importers:
version: 1.0.23
node-forge:
specifier: ^1.4.0
version: 1.4.0
version: 1.4.0(patch_hash=be4w4shpo4tldv77tcysxrioha)
openai-chat-tokens:
specifier: ^0.2.8
version: 0.2.8
@@ -1066,6 +1074,9 @@ importers:
'@types/jsonpath':
specifier: ^0.2.4
version: 0.2.4
'@types/leaflet':
specifier: ^1.9.21
version: 1.9.21
'@types/libmime':
specifier: ^5.0.3
version: 5.0.3
@@ -1220,8 +1231,8 @@ importers:
specifier: ^4.4.9
version: 4.4.9(@types/node@24.10.1)(less@4.2.2)(lightningcss@1.30.1)(sass@1.83.4)(terser@5.39.0)
vite-plugin-node-polyfills:
specifier: ^0.23.0
version: 0.23.0(rollup@2.79.2)(vite@4.4.9(@types/node@24.10.1)(less@4.2.2)(lightningcss@1.30.1)(sass@1.83.4)(terser@5.39.0))
specifier: ^0.26.0
version: 0.26.0(rollup@2.79.2)(vite@4.4.9(@types/node@24.10.1)(less@4.2.2)(lightningcss@1.30.1)(sass@1.83.4)(terser@5.39.0))
vite-plugin-pwa:
specifier: ^1.1.0
version: 1.1.0(vite@4.4.9(@types/node@24.10.1)(less@4.2.2)(lightningcss@1.30.1)(sass@1.83.4)(terser@5.39.0))(workbox-build@7.3.0)(workbox-window@7.3.0)
@@ -1229,8 +1240,8 @@ importers:
specifier: ^0.2.0
version: 0.2.0
vite-plugin-wasm:
specifier: ^3.4.1
version: 3.4.1(vite@4.4.9(@types/node@24.10.1)(less@4.2.2)(lightningcss@1.30.1)(sass@1.83.4)(terser@5.39.0))
specifier: ^3.6.0
version: 3.6.0(vite@4.4.9(@types/node@24.10.1)(less@4.2.2)(lightningcss@1.30.1)(sass@1.83.4)(terser@5.39.0))
vite-svg-loader:
specifier: ^4.0.0
version: 4.0.0
@@ -4284,6 +4295,9 @@ packages:
'@types/katex@0.16.5':
resolution: {integrity: sha512-DD2Y3xMlTQvAnN6d8803xdgnOeYZ+HwMglb7/9YCf49J9RkJL53azf9qKa40MkEYhqVwxZ1GS2+VlShnz4Z1Bw==}
'@types/leaflet@1.9.21':
resolution: {integrity: sha512-TbAd9DaPGSnzp6QvtYngntMZgcRk+igFELwR2N99XZn7RXUdKgsXMR+28bUO0rPsWp8MIu/f47luLIQuSLYv/w==}
'@types/libmime@5.0.3':
resolution: {integrity: sha512-fJ4ISAOqnWpnojw5+Ya1Fu1lPWf3PTK9E8KwJoUnJvtTXYepuFwzE4EI4lMhbAshCVu8jLdQrWLjBZyEcFgADQ==}
@@ -8360,6 +8374,9 @@ packages:
resolution: {integrity: sha512-DpMa59o5uGUWWjruMp71e6knmwKU3jRBBn1kjuLWN9EeIOxNeSAwvHf03WIl8g/ZMR2oSQC9ej3yeLBwdDc/pg==}
engines: {node: '>=10.13.0'}
leaflet@1.9.4:
resolution: {integrity: sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==}
less@4.2.2:
resolution: {integrity: sha512-tkuLHQlvWUTeQ3doAqnHbNn8T6WX1KA8yvbKG9x4VtKtIjHsVKQZCH11zRgAfbDAXC2UNIg/K9BYAAcEzUIrNg==}
engines: {node: '>=6'}
@@ -9081,8 +9098,8 @@ packages:
node-rsa@1.1.1:
resolution: {integrity: sha512-Jd4cvbJMryN21r5HgxQOpMEqv+ooke/korixNNK3mGqfGJmy0M77WDDzo/05969+OkMy3XW1UuZsSmW9KQm7Fw==}
node-stdlib-browser@1.3.0:
resolution: {integrity: sha512-g/koYzOr9Fb1Jc+tHUHlFd5gODjGn48tHexUK8q6iqOVriEgSnd3/1T7myBYc+0KBVze/7F7n65ec9rW6OD7xw==}
node-stdlib-browser@1.3.1:
resolution: {integrity: sha512-X75ZN8DCLftGM5iKwoYLA3rjnrAEs97MkzvSd4q2746Tgpg8b8XWiBGiBG4ZpgcAqBgtgPHTiAc8ZMCvZuikDw==}
engines: {node: '>=10'}
nodemailer@6.9.16:
@@ -11278,10 +11295,10 @@ packages:
engines: {node: '>=v14.18.0'}
hasBin: true
vite-plugin-node-polyfills@0.23.0:
resolution: {integrity: sha512-4n+Ys+2bKHQohPBKigFlndwWQ5fFKwaGY6muNDMTb0fSQLyBzS+jjUNRZG9sKF0S/Go4ApG6LFnUGopjkILg3w==}
vite-plugin-node-polyfills@0.26.0:
resolution: {integrity: sha512-BAe5YzJf368XGev02hDvioidx4uVH8dqEJlG73bjQSxM26/AQnGcKFomq9n3vGq5yqpSHKN4h1XQNxx9l98mBg==}
peerDependencies:
vite: ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0
vite: ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0
vite-plugin-pwa@1.1.0:
resolution: {integrity: sha512-VsSpdubPzXhHWVINcSx6uHRMpOHVHQcHsef1QgkOlEoaIDAlssFEW88LBq1a59BuokAhsh2kUDJbaX1bZv4Bjw==}
@@ -11298,10 +11315,10 @@ packages:
vite-plugin-splash-screen@0.2.0:
resolution: {integrity: sha512-PCUiVq8wjx7dHMa9vOqnB+bewKp60VFbhPJJjQOA8UdwmPdf9ChBGuxh+sku4szrnJFsriB0gIDAURAmOqBcUQ==}
vite-plugin-wasm@3.4.1:
resolution: {integrity: sha512-ja3nSo2UCkVeitltJGkS3pfQHAanHv/DqGatdI39ja6McgABlpsZ5hVgl6wuR8Qx5etY3T5qgDQhOWzc5RReZA==}
vite-plugin-wasm@3.6.0:
resolution: {integrity: sha512-mL/QPziiIA4RAA6DkaZZzOstdwbW5jO4Vz7Zenj0wieKWBlNvIvX5L5ljum9lcUX0ShNfBgCNLKTjNkRVVqcsw==}
peerDependencies:
vite: ^2 || ^3 || ^4 || ^5 || ^6
vite: ^2 || ^3 || ^4 || ^5 || ^6 || ^7 || ^8
vite-svg-loader@4.0.0:
resolution: {integrity: sha512-0MMf1yzzSYlV4MGePsLVAOqXsbF5IVxbn4EEzqRnWxTQl8BJg/cfwIzfQNmNQxZp5XXwd4kyRKF1LytuHZTnqA==}
@@ -15482,6 +15499,10 @@ snapshots:
'@types/katex@0.16.5': {}
'@types/leaflet@1.9.21':
dependencies:
'@types/geojson': 7946.0.16
'@types/libmime@5.0.3':
dependencies:
'@types/node': 24.10.1
@@ -19848,7 +19869,7 @@ snapshots:
jks-js@1.1.4:
dependencies:
node-forge: 1.4.0
node-forge: 1.4.0(patch_hash=be4w4shpo4tldv77tcysxrioha)
node-int64: 0.4.0
node-rsa: 1.1.1
@@ -20102,6 +20123,8 @@ snapshots:
lead@4.0.0: {}
leaflet@1.9.4: {}
less@4.2.2:
dependencies:
copy-anything: 2.0.6
@@ -20871,7 +20894,7 @@ snapshots:
fetch-blob: 3.2.0
formdata-polyfill: 4.0.10
node-forge@1.4.0: {}
node-forge@1.4.0(patch_hash=be4w4shpo4tldv77tcysxrioha): {}
node-gyp-build-optional-packages@5.2.2:
dependencies:
@@ -20890,7 +20913,7 @@ snapshots:
dependencies:
asn1: 0.2.6
node-stdlib-browser@1.3.0:
node-stdlib-browser@1.3.1:
dependencies:
assert: 2.1.0
browser-resolve: 2.0.0
@@ -21298,7 +21321,7 @@ snapshots:
dependencies:
base64-js: 1.5.1
ieee754: 1.2.1
node-forge: 1.4.0
node-forge: 1.4.0(patch_hash=be4w4shpo4tldv77tcysxrioha)
pdfjs-dist@4.10.38:
optionalDependencies:
@@ -23460,10 +23483,10 @@ snapshots:
- supports-color
- terser
vite-plugin-node-polyfills@0.23.0(rollup@2.79.2)(vite@4.4.9(@types/node@24.10.1)(less@4.2.2)(lightningcss@1.30.1)(sass@1.83.4)(terser@5.39.0)):
vite-plugin-node-polyfills@0.26.0(rollup@2.79.2)(vite@4.4.9(@types/node@24.10.1)(less@4.2.2)(lightningcss@1.30.1)(sass@1.83.4)(terser@5.39.0)):
dependencies:
'@rollup/plugin-inject': 5.0.5(rollup@2.79.2)
node-stdlib-browser: 1.3.0
node-stdlib-browser: 1.3.1
vite: 4.4.9(@types/node@24.10.1)(less@4.2.2)(lightningcss@1.30.1)(sass@1.83.4)(terser@5.39.0)
transitivePeerDependencies:
- rollup
@@ -23481,7 +23504,7 @@ snapshots:
vite-plugin-splash-screen@0.2.0: {}
vite-plugin-wasm@3.4.1(vite@4.4.9(@types/node@24.10.1)(less@4.2.2)(lightningcss@1.30.1)(sass@1.83.4)(terser@5.39.0)):
vite-plugin-wasm@3.6.0(vite@4.4.9(@types/node@24.10.1)(less@4.2.2)(lightningcss@1.30.1)(sass@1.83.4)(terser@5.39.0)):
dependencies:
vite: 4.4.9(@types/node@24.10.1)(less@4.2.2)(lightningcss@1.30.1)(sass@1.83.4)(terser@5.39.0)
-1
View File
@@ -182,7 +182,6 @@ const themeVars = useThemeVars();
:collapsed-icon-size="22"
:options="tools"
:indent="8"
:default-expand-all="true"
/>
</div>
</div>
+10 -3
View File
@@ -92,13 +92,20 @@ function update(key: string) {
.value();
}
else {
const converter = unitsconverter[converterType.value](value).from(key);
const mapUnit = (unit: string) => {
// npm units-converter uses wrong symbol for miles per hour, so we need to fix it
if (converterType.value === 'speed' && unit === 'mi/h') {
return 'm/h';
}
return unit;
};
const converter = unitsconverter[converterType.value](value).from(mapUnit(key));
_.chain(units)
.omit(key)
.omit(mapUnit(key))
.forEach(({ unit }) => {
try {
units[unit].ref = converter.to(unit).value;
units[unit].ref = converter.to(mapUnit(unit)).value;
}
catch (e: any) {
units[unit].ref = 0;
+49
View File
@@ -0,0 +1,49 @@
<script setup lang="ts">
import VueMarkdown from 'vue-markdown-render';
import { useTheme } from '../ui/c-link/c-link.theme';
const linkTheme = useTheme();
const homeCustomMarkdown = ref('');
const base = import.meta.env.BASE_URL ?? '/';
const res = await fetch(`${base}home.custom.md`);
if (res.ok) {
homeCustomMarkdown.value = await res.text();
}
</script>
<template>
<div v-if="homeCustomMarkdown" class="home-custom-md">
<VueMarkdown :source="homeCustomMarkdown" />
</div>
</template>
<style scoped lang="less">
::v-deep(.home-custom-md) a {
line-height: inherit;
font-family: inherit;
font-size: inherit;
border: none;
cursor: pointer;
text-decoration: none;
font-weight: 400;
color: v-bind('linkTheme.default.textColor');
border-radius: 4px;
transition: color cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
outline-offset: 1px;
&:hover {
color: v-bind('linkTheme.default.hover.textColor');
}
&:active {
color: v-bind('linkTheme.default.textColor');
}
&:focus {
color: v-bind('linkTheme.default.outline.color');
}
}
</style>
+4 -49
View File
@@ -3,16 +3,11 @@ import { IconDragDrop, IconHeart } from '@tabler/icons-vue';
import { useHead } from '@vueuse/head';
import { computed, nextTick, onMounted, onUnmounted, ref } from 'vue';
import Draggable from 'vuedraggable';
import VueMarkdown from 'vue-markdown-render';
import ColoredCard from '../components/ColoredCard.vue';
import ToolCard from '../components/ToolCard.vue';
import HomeCustom from './Home.custom.vue';
import { useToolStore } from '@/tools/tools.store';
import { config } from '@/config';
import { useTheme } from '../ui/c-link/c-link.theme';
const base = import.meta.env.BASE_URL ?? '/';
const homeCustomMarkdown = ref('');
const { t } = useI18n();
@@ -55,9 +50,6 @@ useHead({
});
const favoriteTools = computed(() => toolStore.favoriteTools);
const linkTheme = useTheme();
const isOrderingFavorites = ref(false);
window.addEventListener('contextmenu', (e) => {
@@ -121,16 +113,6 @@ onMounted(() => {
);
loadingObserver.observe(loadingIndicator);
}
fetch(`${base}home.custom.md`).then((r) => {
if (r.ok) {
r.text().then((t) => {
if (t) {
homeCustomMarkdown.value = t;
}
});
}
});
});
});
@@ -193,9 +175,9 @@ onUnmounted(() => {
</div>
</div>
<div v-if="homeCustomMarkdown" class="home-custom-md">
<VueMarkdown :source="homeCustomMarkdown" />
</div>
<Suspense>
<HomeCustom />
</Suspense>
<h3 class="mb-5px mt-25px font-500 text-neutral-400">
{{ $t('home.categories.allTools') }}
@@ -249,31 +231,4 @@ onUnmounted(() => {
transform: scale(1.0);
}
}
::v-deep(.home-custom-md) a {
line-height: inherit;
font-family: inherit;
font-size: inherit;
border: none;
cursor: pointer;
text-decoration: none;
font-weight: 400;
color: v-bind('linkTheme.default.textColor');
border-radius: 4px;
transition: color cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
outline-offset: 1px;
&:hover {
color: v-bind('linkTheme.default.hover.textColor');
}
&:active {
color: v-bind('linkTheme.default.textColor');
}
&:focus {
color: v-bind('linkTheme.default.outline.color');
}
}
</style>
@@ -11,11 +11,26 @@ const amortizationCalculator = ref(new StandardAmortizationCalculator());
const currencyDisplayNames = computed(() => new Intl.DisplayNames(locale.value, { type: 'currency' }));
const historicalCodes = ['AFA', 'FIM', 'ALK', 'ADP', 'ESP', 'FRF', 'AOK', 'AON', 'AOR', 'ARA', 'ARP', 'ARY',
'RUR', 'ATS', 'AYM', 'AZM', 'RUR', 'BYB', 'BYR', 'RUR', 'BEC', 'BEF', 'BEL', 'BOP', 'BAD', 'BRB', 'BRC',
'BRE', 'BRN', 'BRR', 'BGJ', 'BGK', 'BGL', 'BGN', 'BUK', 'HRD', 'HRK', 'HRK', 'CUC', 'ANG', 'CYP', 'CSJ',
'CSK', 'ECS', 'ECV', 'GQE', 'EEK', 'XEU', 'FIM', 'FRF', 'FRF', 'FRF', 'GEK', 'RUR', 'DDM', 'DEM', 'GHC',
'GHP', 'GRD', 'FRF', 'GNE', 'GNS', 'GWE', 'GWP', 'ITL', 'ISJ', 'IEP', 'ILP', 'ILR', 'ITL', 'RUR', 'RUR',
'LAJ', 'LVL', 'LVR', 'LSM', 'ZAL', 'LTL', 'LTT', 'LUC', 'LUF', 'LUL', 'MGF', 'MWK', 'MVQ', 'MLF', 'MTL',
'MTP', 'FRF', 'MRO', 'FRF', 'MXP', 'RUR', 'FRF', 'MZE', 'MZM', 'NLG', 'ANG', 'NIC', 'PEH', 'PEI', 'PEN',
'PES', 'PLZ', 'PTE', 'FRF', 'ROK', 'ROL', 'RON', 'RUR', 'FRF', 'FRF', 'FRF', 'ITL', 'STD', 'CSD', 'EUR',
'SLL', 'ANG', 'SKK', 'SIT', 'ZAL', 'SDG', 'RHD', 'ESA', 'ESB', 'ESP', 'SDD', 'SDP', 'SRG', 'SZL', 'CHC',
'RUR', 'TJR', 'IDR', 'TPE', 'TRL', 'TRY', 'RUR', 'TMM', 'UGS', 'UGW', 'UAK', 'SUR', 'USS', 'UYN', 'UYP',
'RUR', 'VEB', 'VEF', 'VEF', 'VEF', 'VNC', 'YDD', 'YUD', 'YUM', 'YUN', 'ZRN', 'ZRZ', 'ZMK', 'ZWC', 'ZWD',
'ZWD', 'ZWN', 'ZWR', 'ZWL', 'XFO', 'XRE', 'XFU'];
const supportedCurrencies = ref(
Intl.supportedValuesOf('currency').map(value => ({
value,
label: currencyDisplayNames.value.of(value),
})),
Intl.supportedValuesOf('currency')
.filter(value => !historicalCodes.includes(value))
.map(value => ({
value,
label: currencyDisplayNames.value.of(value),
})),
);
const selectedCurrency = useQueryParamOrStorage({
@@ -141,7 +141,7 @@ async function onUpload(file: File) {
<n-space justify="center" mb-1>
<n-checkbox v-model:checked="includeDataUri">
Include data: URI prefix
{{ $t('tools.base64-file-converter.texts.include-data-uri-prefix') }}
</n-checkbox>
</n-space>
@@ -0,0 +1,55 @@
import { Buffer } from 'node:buffer';
import { expect, test } from '@playwright/test';
test.describe('Tool - Crop image', () => {
test.beforeEach(async ({ page }) => {
page.on('console', (msg) => {
// eslint-disable-next-line no-console
console.log(`[BROWSER CONSOLE] ${msg.type()}: ${msg.text()}`);
});
page.on('pageerror', (err) => {
// eslint-disable-next-line no-console
console.log(`[BROWSER ERROR] ${err.message}`);
});
await page.goto('/crop-image');
});
test('Has correct title', async ({ page }) => {
await expect(page).toHaveTitle('Crop image - IT Tools');
});
test('Upload an image and interact with crop controls', async ({ page }) => {
// Check that we start in upload mode
const fileInput = page.locator('input[type="file"]');
await expect(fileInput).toBeAttached();
// 1x1 transparent PNG buffer
const pixelPng = Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==',
'base64',
);
// Upload the file
await fileInput.setInputFiles({
name: 'test.png',
mimeType: 'image/png',
buffer: pixelPng,
});
// Interactive cropper grid should now be visible
const viewportBox = page.locator('.viewport-box');
await expect(viewportBox).toBeVisible();
// Check sliders exist for zooming and rotation
const sliders = page.locator('.n-slider');
await expect(sliders).toHaveCount(2);
// Export button should be visible
const exportButton = page.getByRole('button', { name: /Export & Download Cropped Image/i });
await expect(exportButton).toBeVisible();
// Change image button should be visible
const changeImageButton = page.getByRole('button', { name: /Change Image/i });
await expect(changeImageButton).toBeVisible();
});
});
@@ -0,0 +1,47 @@
import { describe, expect, it } from 'vitest';
import { getBaseDimensions, getViewportDimensions } from './crop-image.service';
describe('crop-image service utilities', () => {
describe('getViewportDimensions', () => {
it('calculates landscape/square ratios correctly', () => {
// 1:1 ratio
const sq = getViewportDimensions(1, 400, 400);
expect(sq).toEqual({ width: 400, height: 400 });
// 2:1 ratio (landscape)
const ls = getViewportDimensions(2, 400, 400);
expect(ls).toEqual({ width: 400, height: 200 });
});
it('calculates portrait ratios correctly', () => {
// 1:2 ratio (portrait)
const pt = getViewportDimensions(0.5, 400, 400);
expect(pt).toEqual({ width: 200, height: 400 });
});
});
describe('getBaseDimensions', () => {
it('returns viewport dimensions when natural dimensions are zero or missing', () => {
const fallback = getBaseDimensions(300, 200, 0, 0);
expect(fallback).toEqual({ width: 300, height: 200 });
});
it('calculates cover dimensions for landscape image in portrait viewport', () => {
// Image: 800x600 (4:3 landscape, ratio 1.33)
// Viewport: 300x400 (3:4 portrait, ratio 0.75)
// Image should fit to height (400) and scale width to 400 * 1.3333 = 533.33
const cover = getBaseDimensions(300, 400, 800, 600);
expect(cover.height).toBe(400);
expect(cover.width).toBeCloseTo(533.33, 1);
});
it('calculates cover dimensions for portrait image in landscape viewport', () => {
// Image: 600x800 (3:4 portrait, ratio 0.75)
// Viewport: 400x300 (4:3 landscape, ratio 1.33)
// Image should fit to width (400) and scale height to 400 / 0.75 = 533.33
const cover = getBaseDimensions(400, 300, 600, 800);
expect(cover.width).toBe(400);
expect(cover.height).toBeCloseTo(533.33, 1);
});
});
});
@@ -0,0 +1,52 @@
/**
* Calculates viewport dimensions bounded by max width and height.
*/
export function getViewportDimensions(
ratio: number,
maxWidth: number = 450,
maxHeight: number = 450,
): { width: number; height: number } {
if (ratio >= 1) {
return {
width: maxWidth,
height: maxWidth / ratio,
};
}
else {
return {
width: maxHeight * ratio,
height: maxHeight,
};
}
}
/**
* Calculates base dimensions of the image when fit to cover the viewport.
*/
export function getBaseDimensions(
vW: number,
vH: number,
naturalWidth: number,
naturalHeight: number,
): { width: number; height: number } {
if (!naturalWidth || !naturalHeight) {
return { width: vW, height: vH };
}
const vRatio = vW / vH;
const iRatio = naturalWidth / naturalHeight;
if (iRatio > vRatio) {
// Landscape relative to viewport
return {
width: vH * iRatio,
height: vH,
};
}
else {
// Portrait relative to viewport
return {
width: vW,
height: vW / iRatio,
};
}
}
+608
View File
@@ -0,0 +1,608 @@
<script setup lang="ts">
import { computed, nextTick, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useElementSize } from '@vueuse/core';
import {
Download,
FlipHorizontal,
FlipVertical,
Focus,
Maximize,
Refresh,
Rotate,
RotateClockwise,
} from '@vicons/tabler';
import { getBaseDimensions, getViewportDimensions } from './crop-image.service';
const { t } = useI18n();
// Image references
const imageSrc = ref<string | null>(null);
const fileName = ref<string>('image');
const fileType = ref<string>('image/png');
// Image dimensions and position
const imgNaturalWidth = ref(0);
const imgNaturalHeight = ref(0);
const zoom = ref(1.0);
const rotation = ref(0); // in degrees
const offsetX = ref(0);
const offsetY = ref(0);
const flipH = ref(false);
const flipV = ref(false);
// Background and UI settings
const backgroundColor = ref('#00000000'); // hex or rgba/hsla
const aspectRatio = ref<string>('1'); // presets: '1', '1.777777778' (16:9), '0.5625' (9:16), '1.333333333' (4:3), '1.5' (3:2), 'original', 'free'
const customRatioWidth = ref(4);
const customRatioHeight = ref(3);
const showGrid = ref(true);
// Export settings
const exportFormat = ref<'png' | 'jpeg' | 'webp'>('png');
const exportQuality = ref(0.9);
const exportWidthMode = ref<'original' | 'viewport' | 'custom'>('original');
const customExportWidth = ref(1024);
// Dragging state
const isDragging = ref(false);
let startPointerX = 0;
let startPointerY = 0;
let startOffsetX = 0;
let startOffsetY = 0;
// Presets for aspect ratios
const aspectRatioOptions = computed(() => [
{ label: t('tools.crop-image.texts.ratio-square'), value: '1' },
{ label: t('tools.crop-image.texts.ratio-widescreen'), value: '1.777777778' },
{ label: t('tools.crop-image.texts.ratio-portrait'), value: '0.5625' },
{ label: t('tools.crop-image.texts.ratio-standard'), value: '1.333333333' },
{ label: t('tools.crop-image.texts.ratio-photo'), value: '1.5' },
{ label: t('tools.crop-image.texts.ratio-original'), value: 'original' },
{ label: t('tools.crop-image.texts.ratio-custom'), value: 'free' },
]);
const exportFormatOptions = [
{ label: 'PNG', value: 'png' },
{ label: 'JPEG', value: 'jpeg' },
{ label: 'WebP', value: 'webp' },
];
const exportWidthOptions = computed(() => [
{ label: t('tools.crop-image.texts.width-original'), value: 'original' },
{ label: t('tools.crop-image.texts.width-viewport'), value: 'viewport' },
{ label: t('tools.crop-image.texts.width-custom'), value: 'custom' },
]);
// Computed aspect ratio value
const currentRatio = computed(() => {
if (aspectRatio.value === 'original') {
if (imgNaturalWidth.value && imgNaturalHeight.value) {
return imgNaturalWidth.value / imgNaturalHeight.value;
}
return 1;
}
if (aspectRatio.value === 'free') {
const w = customRatioWidth.value || 1;
const h = customRatioHeight.value || 1;
return w / h;
}
return Number.parseFloat(aspectRatio.value);
});
// Viewport width and height (max bounded inside 450x450 box)
const maxViewportWidth = 450;
const maxViewportHeight = 450;
const viewportDimensions = computed(() => {
return getViewportDimensions(currentRatio.value, maxViewportWidth, maxViewportHeight);
});
// Container ref and scale calculations for small viewports
const containerRef = ref<HTMLElement | null>(null);
const { width: containerWidth } = useElementSize(containerRef);
const scale = computed(() => {
if (!containerWidth.value || !viewportDimensions.value.width) {
return 1;
}
const maxWidth = Math.max(0, containerWidth.value - 8);
return Math.min(1, maxWidth / viewportDimensions.value.width);
});
// Image base dimensions when fitting cover
const baseDimensions = computed(() => {
return getBaseDimensions(
viewportDimensions.value.width,
viewportDimensions.value.height,
imgNaturalWidth.value,
imgNaturalHeight.value,
);
});
// Reset image to center with cover scale
function resetPosition() {
zoom.value = 1.0;
rotation.value = 0;
flipH.value = false;
flipV.value = false;
const vW = viewportDimensions.value.width;
const vH = viewportDimensions.value.height;
const bW = baseDimensions.value.width;
offsetX.value = (vW - bW) / 2;
offsetY.value = (vH - baseDimensions.value.height) / 2;
}
// Fit image entirely inside viewport
function fitToViewport() {
if (!imgNaturalWidth.value || !imgNaturalHeight.value) {
return;
}
rotation.value = 0;
flipH.value = false;
flipV.value = false;
const vW = viewportDimensions.value.width;
const vH = viewportDimensions.value.height;
const iRatio = imgNaturalWidth.value / imgNaturalHeight.value;
const vRatio = vW / vH;
let bW = 0;
if (iRatio > vRatio) {
// Fit width
bW = vW;
}
else {
// Fit height
bW = vH * iRatio;
}
zoom.value = bW / baseDimensions.value.width;
offsetX.value = (vW - baseDimensions.value.width * zoom.value) / 2;
offsetY.value = (vH - baseDimensions.value.height * zoom.value) / 2;
}
// Reset when image changes or viewport ratio changes
watch([imageSrc, aspectRatio], () => {
nextTick(() => {
resetPosition();
});
});
// Drag and drop image upload
function onUpload(file: File) {
if (!file) {
return;
}
fileName.value = file.name;
fileType.value = file.type;
const reader = new FileReader();
reader.onload = (e) => {
if (e.target?.result) {
const img = new Image();
img.onload = () => {
imgNaturalWidth.value = img.naturalWidth;
imgNaturalHeight.value = img.naturalHeight;
imageSrc.value = e.target!.result as string;
};
img.src = e.target.result as string;
}
};
reader.readAsDataURL(file);
}
// Handle mouse/touch drag events
function handlePointerDown(e: MouseEvent | TouchEvent) {
if (!imageSrc.value) {
return;
}
e.preventDefault();
isDragging.value = true;
const clientX = 'touches' in e ? e.touches[0].clientX : e.clientX;
const clientY = 'touches' in e ? e.touches[0].clientY : e.clientY;
startPointerX = clientX;
startPointerY = clientY;
startOffsetX = offsetX.value;
startOffsetY = offsetY.value;
window.addEventListener('mousemove', handlePointerMove);
window.addEventListener('mouseup', handlePointerUp);
window.addEventListener('touchmove', handlePointerMove, { passive: false });
window.addEventListener('touchend', handlePointerUp);
}
function handlePointerMove(e: MouseEvent | TouchEvent) {
if (!isDragging.value) {
return;
}
const clientX = 'touches' in e ? e.touches[0].clientX : e.clientX;
const clientY = 'touches' in e ? e.touches[0].clientY : e.clientY;
const dx = (clientX - startPointerX) / scale.value;
const dy = (clientY - startPointerY) / scale.value;
offsetX.value = startOffsetX + dx;
offsetY.value = startOffsetY + dy;
}
function handlePointerUp() {
isDragging.value = false;
window.removeEventListener('mousemove', handlePointerMove);
window.removeEventListener('mouseup', handlePointerUp);
window.removeEventListener('touchmove', handlePointerMove);
window.removeEventListener('touchend', handlePointerUp);
}
// Mouse wheel zoom
function handleWheel(e: WheelEvent) {
if (!imageSrc.value) {
return;
}
e.preventDefault();
const zoomStep = 0.05;
let newZoom = zoom.value;
if (e.deltaY < 0) {
newZoom = Math.min(zoom.value + zoomStep, 10.0);
}
else {
newZoom = Math.max(zoom.value - zoomStep, 0.05);
}
zoom.value = newZoom;
}
// Draw to Canvas & Trigger Download
function exportImage() {
if (!imageSrc.value) {
return;
}
const img = new Image();
img.onload = () => {
const vW = viewportDimensions.value.width;
const vH = viewportDimensions.value.height;
let canvasWidth = vW;
let canvasHeight = vH;
if (exportWidthMode.value === 'original') {
const bW = baseDimensions.value.width;
const scaleFactor = imgNaturalWidth.value / bW;
canvasWidth = vW * scaleFactor;
canvasHeight = vH * scaleFactor;
}
else if (exportWidthMode.value === 'custom') {
canvasWidth = customExportWidth.value;
canvasHeight = customExportWidth.value / currentRatio.value;
}
const canvas = document.createElement('canvas');
canvas.width = canvasWidth;
canvas.height = canvasHeight;
const ctx = canvas.getContext('2d');
if (!ctx) {
return;
}
// Background color
if (backgroundColor.value !== '#00000000') {
ctx.fillStyle = backgroundColor.value;
ctx.fillRect(0, 0, canvasWidth, canvasHeight);
}
else {
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
}
// Replicate CSS: transform-origin center center on an element of size (bW x bH)
// CSS computes: T(origin) · translate(ox, oy) · rotate(r) · scale(sx, sy) · T(-origin)
// We scale from viewport coordinates to canvas coordinates first.
const scaleFactor = canvasWidth / vW;
const bW = baseDimensions.value.width;
const bH = baseDimensions.value.height;
const ox = offsetX.value;
const oy = offsetY.value;
const r = rotation.value * Math.PI / 180;
const sx = zoom.value * (flipH.value ? -1 : 1);
const sy = zoom.value * (flipV.value ? -1 : 1);
ctx.save();
ctx.scale(scaleFactor, scaleFactor); // viewport → canvas coords
ctx.translate(bW / 2, bH / 2); // T(origin)
ctx.translate(ox, oy); // CSS translate
ctx.rotate(r); // CSS rotate
ctx.scale(sx, sy); // CSS scale (includes flip)
ctx.translate(-bW / 2, -bH / 2); // T(-origin)
ctx.drawImage(img, 0, 0, bW, bH); // draw at element's natural position
ctx.restore();
// Trigger Download
const mime = exportFormat.value === 'jpeg' ? 'image/jpeg' : exportFormat.value === 'webp' ? 'image/webp' : 'image/png';
const extension = exportFormat.value;
const dataUrl = canvas.toDataURL(mime, exportQuality.value);
const link = document.createElement('a');
link.href = dataUrl;
let baseName = fileName.value || 'image';
if (baseName.includes('.')) {
baseName = baseName.substring(0, baseName.lastIndexOf('.'));
}
link.download = `${baseName}_cropped.${extension}`;
link.click();
};
img.src = imageSrc.value;
}
</script>
<template>
<div>
<!-- Drop Zone Mode -->
<c-card v-if="!imageSrc">
<div flex flex-col items-center justify-center gap-6 py-12>
<c-file-upload
accept="image/*"
:title="t('tools.crop-image.texts.drag-drop')"
w-full
@file-upload="onUpload"
/>
</div>
</c-card>
<!-- Interactive Cropper Mode -->
<n-grid v-else cols="1 900:12" x-gap="24" y-gap="24">
<!-- Left Column: Viewport & Canvas transformations -->
<n-gi span="1 900:5">
<c-card>
<div w-full flex flex-col items-center>
<div ref="containerRef" w-full flex items-center justify-center>
<div
class="viewport-box-wrapper"
:style="{
width: `${viewportDimensions.width * scale}px`,
height: `${viewportDimensions.height * scale}px`,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}"
>
<div
class="viewport-box relative cursor-move select-none overflow-hidden border-2 border-gray-300 rounded-lg shadow-lg transition-all duration-200 dark:border-gray-600"
:style="{
width: `${viewportDimensions.width}px`,
height: `${viewportDimensions.height}px`,
transform: `scale(${scale})`,
transformOrigin: 'center center',
flexShrink: 0,
backgroundColor,
}"
@mousedown="handlePointerDown"
@touchstart="handlePointerDown"
@wheel="handleWheel"
>
<!-- Transparent checkerboard background -->
<div
v-if="backgroundColor === '#00000000' || backgroundColor.includes('rgba(') && backgroundColor.endsWith(', 0)')"
class="checkerboard-bg pointer-events-none absolute inset-0"
/>
<!-- The transformable image -->
<img
:src="imageSrc"
class="pointer-events-none absolute"
:style="{
width: `${baseDimensions.width}px`,
height: `${baseDimensions.height}px`,
transform: `translate(${offsetX}px, ${offsetY}px) rotate(${rotation}deg) scale(${zoom * (flipH ? -1 : 1)}, ${zoom * (flipV ? -1 : 1)})`,
transformOrigin: 'center center',
}"
>
<!-- 3x3 rule of thirds grid overlay -->
<div
v-if="showGrid"
class="grid-overlay pointer-events-none absolute inset-0 grid grid-cols-3 grid-rows-3 border border-white/20"
>
<div class="border-b border-r border-white/20 border-dashed" />
<div class="border-b border-r border-white/20 border-dashed" />
<div class="border-b border-white/20 border-dashed" />
<div class="border-b border-r border-white/20 border-dashed" />
<div class="border-b border-r border-white/20 border-dashed" />
<div class="border-b border-white/20 border-dashed" />
<div class="border-r border-white/20 border-dashed" />
<div class="border-r border-white/20 border-dashed" />
<div />
</div>
</div>
</div>
</div>
<!-- Viewport Hint -->
<div mt-3 text-center text-xs text-gray-400>
{{ t('tools.crop-image.texts.drag-hint', { zoom: Math.round(zoom * 100) }) }}
</div>
<!-- Quick Action Transform Buttons -->
<div mt-5 flex flex-wrap justify-center gap-2>
<c-button size="small" @click="rotation -= 90">
<n-icon :component="Rotate" class="mr-1" />
-90°
</c-button>
<c-button size="small" @click="rotation += 90">
<n-icon :component="RotateClockwise" class="mr-1" />
+90°
</c-button>
<c-button size="small" @click="flipH = !flipH">
<n-icon :component="FlipHorizontal" class="mr-1" />
{{ t('tools.crop-image.texts.flip-h') }}
</c-button>
<c-button size="small" @click="flipV = !flipV">
<n-icon :component="FlipVertical" class="mr-1" />
{{ t('tools.crop-image.texts.flip-v') }}
</c-button>
<c-button size="small" @click="resetPosition">
<n-icon :component="Focus" class="mr-1" />
{{ t('tools.crop-image.texts.reset') }}
</c-button>
<c-button size="small" @click="fitToViewport">
<n-icon :component="Maximize" class="mr-1" />
{{ t('tools.crop-image.texts.fit') }}
</c-button>
</div>
</div>
</c-card>
</n-gi>
<!-- Right Column: Settings, Customizer and Download actions -->
<n-gi span="1 900:7">
<c-card>
<div flex flex-col gap-6>
<!-- Header actions -->
<div flex items-center justify-between border-b border-gray-200 pb-4 dark:border-gray-700>
<div text-lg font-bold class="max-w-220px truncate">
{{ fileName }}
</div>
<c-button type="warning" size="small" @click="imageSrc = null">
<n-icon :component="Refresh" class="mr-1" />
{{ t('tools.crop-image.texts.change-image') }}
</c-button>
</div>
<n-form label-placement="left" label-width="140" label-align="right">
<!-- Aspect Ratio Presets -->
<n-form-item :label="t('tools.crop-image.texts.aspect-ratio')">
<c-select
v-model:value="aspectRatio"
:options="aspectRatioOptions"
w-full
/>
</n-form-item>
<!-- Custom Aspect Ratio Inputs -->
<n-form-item v-if="aspectRatio === 'free'" :label="t('tools.crop-image.texts.custom-ratio')">
<div w-full flex items-center gap-3>
<n-input-number v-model:value="customRatioWidth" :min="1" placeholder="W" class="flex-1" />
<span font-bold text-gray-400>:</span>
<n-input-number v-model:value="customRatioHeight" :min="1" placeholder="H" class="flex-1" />
</div>
</n-form-item>
<!-- Background Color Picker -->
<n-form-item :label="t('tools.crop-image.texts.background-color')">
<div w-full flex items-center gap-4>
<n-color-picker v-model:value="backgroundColor" :modes="['hex', 'rgba']" class="flex-1" />
<c-button size="small" @click="backgroundColor = '#00000000'">
{{ t('tools.crop-image.texts.transparent') }}
</c-button>
</div>
</n-form-item>
<!-- Interactive Zoom Slider -->
<n-form-item :label="t('tools.crop-image.texts.zoom-image')">
<div w-full flex items-center gap-4>
<n-slider v-model:value="zoom" :min="0.1" :max="5" :step="0.01" class="flex-1" />
<span w-50px text-right font-mono>{{ Math.round(zoom * 100) }}%</span>
</div>
</n-form-item>
<!-- Interactive Rotation Slider -->
<n-form-item :label="t('tools.crop-image.texts.rotate-image')">
<div w-full flex items-center gap-4>
<n-slider v-model:value="rotation" :min="-180" :max="180" :step="1" class="flex-1" />
<span w-50px text-right font-mono>{{ rotation }}°</span>
</div>
</n-form-item>
<!-- Toggle Grid lines -->
<n-form-item :label="t('tools.crop-image.texts.rule-of-thirds-grid')">
<n-switch v-model:value="showGrid" />
</n-form-item>
</n-form>
<n-divider class="my-2" />
<div text-md mb-2 font-bold>
{{ t('tools.crop-image.texts.export-settings') }}
</div>
<n-form label-placement="left" label-width="140" label-align="right">
<!-- Export Format select -->
<n-form-item :label="t('tools.crop-image.texts.export-format')">
<c-select
v-model:value="exportFormat"
:options="exportFormatOptions"
w-full
/>
</n-form-item>
<!-- Quality slider for lossy formats -->
<n-form-item v-if="exportFormat === 'jpeg' || exportFormat === 'webp'" :label="t('tools.crop-image.texts.image-quality')">
<div w-full flex items-center gap-4>
<n-slider v-model:value="exportQuality" :min="0.1" :max="1" :step="0.05" class="flex-1" />
<span w-50px text-right font-mono>{{ Math.round(exportQuality * 100) }}%</span>
</div>
</n-form-item>
<!-- Export width options -->
<n-form-item :label="t('tools.crop-image.texts.export-width')">
<c-select
v-model:value="exportWidthMode"
:options="exportWidthOptions"
w-full
/>
</n-form-item>
<!-- Custom Export Width Input -->
<n-form-item v-if="exportWidthMode === 'custom'" :label="t('tools.crop-image.texts.custom-width')">
<n-input-number v-model:value="customExportWidth" :min="10" :max="10000" w-full />
</n-form-item>
</n-form>
<!-- Big Download/Cropped Image Button -->
<c-button type="primary" size="large" class="mt-4 w-full" @click="exportImage">
<n-icon :component="Download" class="mr-2 text-lg" />
{{ t('tools.crop-image.texts.export-download-image') }}
</c-button>
</div>
</c-card>
</n-gi>
</n-grid>
</div>
</template>
<style lang="less" scoped>
.viewport-box {
background-color: #f3f4f6;
}
.checkerboard-bg {
background-image:
linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
background-size: 16px 16px;
background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
:deep(.dark) &, .dark & {
background-image:
linear-gradient(45deg, #374151 25%, transparent 25%),
linear-gradient(-45deg, #374151 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, #374151 75%),
linear-gradient(-45deg, transparent 75%, #374151 75%);
}
}
.grid-overlay {
& > div {
box-sizing: border-box;
}
}
</style>
+14
View File
@@ -0,0 +1,14 @@
import { Crop } from '@vicons/tabler';
import { defineTool } from '../tool';
import { translate } from '@/plugins/i18n.plugin';
export const tool = defineTool({
name: translate('tools.crop-image.title'),
path: '/crop-image',
description: translate('tools.crop-image.description'),
keywords: ['crop', 'image', 'resize', 'canvas'],
component: () => import('./crop-image.vue'),
icon: Crop,
createdAt: new Date('2026-06-06'),
category: 'Images',
});
@@ -29,6 +29,13 @@ describe('data-storage-unit-converter', () => {
expect(convertStorageAndRateUnitsDisplay({ value: 1, fromUnit: 'Mb', toUnit: 'KB', precision: 0 })).toBe('125');
expect(convertStorageAndRateUnitsDisplay({ value: 125, fromUnit: 'KB', toUnit: 'Mb', precision: 0 })).toBe('1');
expect(convertStorageAndRateUnitsDisplay({ value: 8, fromUnit: 'b', toUnit: 'B' })).toBe('1.000');
expect(convertStorageAndRateUnitsDisplay({ value: 1, fromUnit: 'B', toUnit: 'b' })).toBe('8.000');
expect(convertStorageAndRateUnitsDisplay({ value: 8000, fromUnit: 'b', toUnit: 'KB' })).toBe('1.000');
expect(convertStorageAndRateUnitsDisplay({ value: 1000, fromUnit: 'iB', toUnit: 'b' })).toBe('8000.000');
expect(convertStorageAndRateUnitsDisplay({ value: 1, fromUnit: 'KiB', toUnit: 'b' })).toBe('8192.000');
expect(convertStorageAndRateUnitsDisplay({ value: 1, fromUnit: 'KB', toUnit: 'iB' })).toBe('1000.000');
expect(convertStorageAndRateUnitsDisplay({ value: 1, fromUnit: 'MiB', toUnit: 'Kb' })).toBe('8388.608');
expect(convertStorageAndRateUnitsDisplay({ value: 8388.608, fromUnit: 'Kb', toUnit: 'MiB', precision: 0 })).toBe('1');
});
@@ -32,11 +32,11 @@ export function convertStorageAndRateUnits(
];
const fromIndex = units.indexOf(fromUnit);
const fromFactor = fromIndex / 9 > 1 ? 1000 : 1024;
const fromDivisor = fromIndex / 9 > 2 ? 8 : 1;
const fromFactor = fromIndex / 9 >= 1 ? 1000 : 1024;
const fromDivisor = fromIndex / 9 >= 2 ? 8 : 1;
const toIndex = units.indexOf(toUnit);
const toFactor = toIndex / 9 > 1 ? 1000 : 1024;
const toDivisor = toIndex / 9 > 2 ? 8 : 1;
const toFactor = toIndex / 9 >= 1 ? 1000 : 1024;
const toDivisor = toIndex / 9 >= 2 ? 8 : 1;
const fromBase = (fromFactor ** (fromIndex % 9)) / fromDivisor;
const toBase = (toFactor ** (toIndex % 9)) / toDivisor;
@@ -0,0 +1,306 @@
<script setup lang="ts">
import { useITStorage, useQueryParamOrStorage } from '@/composable/queryParams';
import { Base64 } from 'js-base64';
const serverHost = useITStorage('dns-prop:url', 'http://localhost:8000');
const serverAuth = useITStorage('dns-prop:auth', '');
const loading = ref(false);
async function api(path: string, params: Record<string, string | number | boolean> = {}) {
const pathParams = new URLSearchParams();
Object.entries(params).forEach(([k, v]) => pathParams.append(k, v?.toString() || ''));
const url = `${serverHost.value}${path}?${pathParams.toString()}`;
const response = await fetch(url,
serverAuth.value
? {
method: 'GET',
headers: { Authorization: `Basic ${Base64.encode(serverAuth.value)}` },
}
: undefined);
if (!response.ok) {
const text = await response.text();
throw new Error(text || 'Server error');
}
return await response.json();
}
const builtinResolvers = [
{ name: 'Google', ip: '8.8.8.8' },
{ name: 'Google', ip: '8.8.4.4' },
{ name: 'Cloudflare', ip: '1.1.1.1' },
{ name: 'Cloudflare', ip: '1.0.0.1' },
{ name: 'Quad9', ip: '9.9.9.9' },
{ name: 'Quad9', ip: '149.112.112.112' },
{ name: 'OpenDNS', ip: '208.67.222.222' },
{ name: 'OpenDNS', ip: '208.67.220.220' },
{ name: 'CleanBrowsing', ip: '185.228.168.9' },
{ name: 'CleanBrowsing', ip: '185.228.169.9' },
// Europe
{ name: 'DNS.Watch', ip: '84.200.69.80' },
{ name: 'DNS.Watch', ip: '84.200.70.40' },
{ name: 'FreeDNS', ip: '37.235.1.174' },
{ name: 'FreeDNS', ip: '37.235.1.177' },
{ name: 'FDN France', ip: '80.67.169.12' },
{ name: 'FDN France', ip: '80.67.169.40' },
{ name: 'Neustar EU', ip: '156.154.70.1' },
{ name: 'Neustar EU', ip: '156.154.71.1' },
// North America
{ name: 'Level3', ip: '209.244.0.3' },
{ name: 'Level3', ip: '209.244.0.4' },
{ name: 'Comodo', ip: '8.26.56.26' },
{ name: 'Comodo', ip: '8.20.247.20' },
{ name: 'CenturyLink', ip: '205.171.3.65' },
{ name: 'CenturyLink', ip: '205.171.2.65' },
// Asia-Pacific
{ name: 'DNSPod', ip: '119.29.29.29' },
{ name: 'AliDNS', ip: '223.5.5.5' },
{ name: 'AliDNS', ip: '223.6.6.6' },
{ name: 'Yandex', ip: '77.88.8.8' },
{ name: 'Yandex', ip: '77.88.8.1' },
{ name: 'Naver Korea', ip: '125.209.222.141' },
{ name: 'Naver Korea', ip: '125.209.249.1' },
// South America
{ name: 'GigaDNS Brazil', ip: '189.38.95.95' },
{ name: 'GigaDNS Brazil', ip: '189.38.95.96' },
// Africa
{ name: 'OpenDNS Africa', ip: '196.3.132.153' },
{ name: 'OpenDNS Africa', ip: '196.3.132.154' },
];
interface Resolver {
ip: string
name: string
}
const customResolvers = useITStorage<Resolver[]>('dns-prop:cust', []);
const resolvers = computed(() => [
...builtinResolvers,
...customResolvers.value,
]);
const propDomain = useQueryParamOrStorage({ name: 'domain', storageName: 'dns-prop:d', defaultValue: '' });
const propType = useQueryParamOrStorage({ name: 'type', storageName: 'dns-prop:t', defaultValue: 'A' });
const selectedResolvers = ref<string[]>([]);
interface DNSQueryResult {
ok: boolean
domain: string
record_type: string
answers?: string[] | null
error?: string | null
}
type Result = Record<string, { status: 'checking' | 'success' | 'error'; result?: DNSQueryResult }>;
const propResults = reactive<Result>({});
// -------------------- Custom DNS Resolvers --------------------
const newResolverName = ref('');
const newResolverIp = ref('');
function addCustomResolver() {
if (!newResolverName.value || !newResolverIp.value) {
return;
}
customResolvers.value.push({
name: newResolverName.value,
ip: newResolverIp.value,
});
newResolverName.value = '';
newResolverIp.value = '';
}
function removeCustomResolver(ip: string) {
customResolvers.value = customResolvers.value.filter(r => r.ip !== ip);
}
async function runPropagation() {
Object.assign(propResults, {});
for (const ip of selectedResolvers.value) {
propResults[ip] = {
status: 'checking',
};
}
loading.value = true;
const allPromises: Promise<void>[] = [];
for (const ip of selectedResolvers.value) {
allPromises.push((async () => {
try {
const dnsResult = await api('/dns-query', {
domain: propDomain.value,
record_type: propType.value,
resolver_ip: ip,
});
propResults[ip] = {
status: dnsResult.ok ? 'success' : 'error',
result: dnsResult,
};
}
catch (err: any) {
propResults[ip] = {
status: 'error',
result: {
ok: false,
domain: propDomain.value,
record_type: propType.value,
error: err.toString(),
},
};
}
})());
}
Promise.all(allPromises).then(() => {
loading.value = false;
});
}
</script>
<template>
<div>
<details mb-2>
<summary>Network Utilities Service Configuration (self hosted)</summary>
<n-card>
<NFormItem label="Network Utilities Service Url:" label-placement="top">
<NInput v-model:value="serverHost" placeholder="http://localhost:3000" />
</NFormItem>
<NFormItem label="Basic Authentication:" label-placement="left" label-width="auto">
<NInput v-model:value="serverAuth" placeholder="username:password" />
</NFormItem>
<n-p>
You must self host Network Utilities Service. See:
<c-link href="https://github.com/sharevb/network-utils-ws#running-in-docker" target="_blank">
Network Utilities Service docker install
</c-link>
</n-p>
</n-card>
</details>
<n-tabs type="line" animated>
<n-tab-pane name="propagation" tab="DNS Propagation">
<n-form>
<c-input-text v-model:value="propDomain" label="Domain:" label-position="left" placeholder="example.com" mb-1 />
<c-select
v-model:value="propType" label="Record Type:"
mb-1
label-position="left"
:options="['A', 'AAAA', 'CNAME', 'MX', 'NS', 'TXT', 'SRV', 'SOA', 'CAA', 'DS', 'DNSKEY'].map(x => ({ label: x, value: x }))"
/>
<n-card title="Resolvers to Check" mb-2>
<n-space justify="center" mb-1 gap-1>
<n-button size="tiny" @click="selectedResolvers = resolvers.map(r => r.ip)">
Select All
</n-button>
<n-button size="tiny" @click="selectedResolvers = []">
Deselect All
</n-button>
</n-space>
<n-checkbox-group v-model:value="selectedResolvers">
<n-space wrap>
<n-checkbox
v-for="r in resolvers"
:key="r.ip"
:value="r.ip"
>
{{ r.name }} <em>({{ r.ip }})</em>
</n-checkbox>
</n-space>
</n-checkbox-group>
</n-card>
<n-space justify="center" mb-1>
<n-button type="primary" :disabled="!propDomain || !propType || !selectedResolvers.length || loading" :loading="loading" @click="runPropagation">
Check Propagation
</n-button>
</n-space>
</n-form>
<n-card v-if="Object.keys(propResults).length" title="Results">
<table>
<thead>
<tr>
<th>Resolver</th>
<th>Resolver IP</th>
<th>Status</th>
<th>Answers</th>
</tr>
</thead>
<tbody>
<tr v-for="(res, ip) in propResults" :key="ip">
<td>{{ resolvers.find(r => r.ip === ip)?.name || ip }}</td>
<td>{{ ip }}</td>
<td>
<n-tag :type="res.status === 'success' ? 'success' : res.status === 'error' ? 'error' : 'default'">
{{ res.status }}
</n-tag>
</td>
<td>
<div v-if="res.result?.error" style="color: red;">
{{ res.result.error }}
</div>
<div v-else-if="res.status === 'checking'">
Checking...
</div>
<ul v-else-if="res.result?.answers">
<li v-for="(a, idx) in res.result.answers" :key="idx">
{{ a }}
</li>
</ul>
<div v-else>
No answers
</div>
</td>
</tr>
</tbody>
</table>
</n-card>
</n-tab-pane>
<n-tab-pane name="custom-resolvers" tab="Custom Resolvers">
<n-card title="Add Custom Resolver">
<c-input-text v-model:value="newResolverName" label="Resolver Name:" label-width="120px" label-position="left" placeholder="Resolver name (e.g. My DNS)" mb-1 />
<c-input-text v-model:value="newResolverIp" label="Resolver IP:" label-width="120px" label-position="left" placeholder="Resolver IP (e.g. 10.0.0.1)" mb-1 />
<n-space justify="center" mb-1>
<n-button type="primary" @click="addCustomResolver">
Add Resolver
</n-button>
</n-space>
</n-card>
<n-card v-if="customResolvers.length" title="Your Custom Resolvers">
<div
v-for="r in customResolvers"
:key="r.ip"
>
<div style="display:flex; justify-content:space-between; align-items:center;">
<div>{{ r.name }} — {{ r.ip }}</div>
<n-button type="error" size="tiny" @click="removeCustomResolver(r.ip)">
Remove
</n-button>
</div>
</div>
</n-card>
<n-card v-else>
No custom resolvers added yet.
</n-card>
</n-tab-pane>
</n-tabs>
</div>
</template>
+14
View File
@@ -0,0 +1,14 @@
import { World } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'DNS Propagation Tester',
path: '/dns-propagation-tester',
description: 'A simple tool for testing DNS propagation across different servers.',
keywords: ['dns', 'propagation', 'tester'],
component: () => import('./dns-propagation-tester.vue'),
icon: World,
createdAt: new Date('2026-05-11'),
category: 'Forensic',
externAccessDescription: 'This tool calls your Self Host Network Utilities Service to perform DNS queries.',
});
+478
View File
@@ -0,0 +1,478 @@
<script setup lang="ts">
import { useITStorage } from '@/composable/queryParams';
import { Base64 } from 'js-base64';
const serverHost = useITStorage('https-tester:url', 'http://localhost:8000');
const serverAuth = useITStorage('https-tester:auth', '');
const loading = ref(false);
const error = ref<string | null>(null);
async function api(path: string, params: Record<string, string | number | boolean> = {}) {
error.value = null;
loading.value = true;
try {
const pathParams = new URLSearchParams();
Object.entries(params).forEach(([k, v]) => pathParams.append(k, v?.toString() || ''));
const url = `${serverHost.value}${path}?${pathParams.toString()}`;
const response = await fetch(url,
serverAuth.value
? {
method: 'GET',
headers: { Authorization: `Basic ${Base64.encode(serverAuth.value)}` },
}
: undefined);
if (!response.ok) {
const text = await response.text();
throw new Error(text || 'Server error');
}
return await response.json();
}
catch (err: any) {
error.value = err.toString();
}
finally {
loading.value = false;
}
}
type AnyDict = Record<string, any>;
interface DNSQueryResult {
ok: boolean
domain: string
record_type: string
answers?: string[] | null
error?: string | null
}
interface WhoisResult {
ok: boolean
domain: string
raw?: string | null
parsed?: AnyDict | null
error?: string | null
}
interface DNSSECResult {
ok: boolean
domain: string
validated: boolean
dnskey?: string | null
rrsig?: string | null
error?: string | null
}
interface ReverseDNSResult {
ok: boolean
ip: string
ptr?: string | null
error?: string | null
}
interface AXFRResult {
ok: boolean
domain: string
soa?: string | null
axfr_allowed: boolean
records?: string[] | null
error?: string | null
}
function prettyJSON(value: unknown): string {
try {
return JSON.stringify(value, null, 2);
}
catch {
return String(value);
}
}
const dnsTypes = [
{ value: 'A', label: 'A — IPv4 address' },
{ value: 'AAAA', label: 'AAAA — IPv6 address' },
{ value: 'AFSDB', label: 'AFSDB — AFS database location' },
{ value: 'APL', label: 'APL — Address prefix list' },
{ value: 'CAA', label: 'CAA — Certificate Authority Authorization' },
{ value: 'CDNSKEY', label: 'CDNSKEY — Child DNSKEY' },
{ value: 'CDS', label: 'CDS — Child DS' },
{ value: 'CERT', label: 'CERT — Certificate storage' },
{ value: 'CNAME', label: 'CNAME — Canonical name' },
{ value: 'CSYNC', label: 'CSYNC — Child-to-parent sync' },
{ value: 'DHCID', label: 'DHCID — DHCP identifier' },
{ value: 'DLV', label: 'DLV — DNSSEC Lookaside Validation (obsolete)' },
{ value: 'DNAME', label: 'DNAME — Non-terminal rename' },
{ value: 'DNSKEY', label: 'DNSKEY — DNSSEC public key' },
{ value: 'DS', label: 'DS — Delegation signer' },
{ value: 'EUI48', label: 'EUI48 — MAC address (48-bit)' },
{ value: 'EUI64', label: 'EUI64 — MAC address (64-bit)' },
{ value: 'HINFO', label: 'HINFO — Host information' },
{ value: 'HIP', label: 'HIP — Host identity protocol' },
{ value: 'HTTPS', label: 'HTTPS — HTTPS service binding' },
{ value: 'IPSECKEY', label: 'IPSECKEY — IPsec key' },
{ value: 'KEY', label: 'KEY — Security key (obsolete)' },
{ value: 'KX', label: 'KX — Key exchanger' },
{ value: 'LOC', label: 'LOC — Geographic location' },
{ value: 'MX', label: 'MX — Mail exchanger' },
{ value: 'NAPTR', label: 'NAPTR — Regex-based rewrite' },
{ value: 'NS', label: 'NS — Name server' },
{ value: 'NSEC', label: 'NSEC — DNSSEC denial of existence' },
{ value: 'NSEC3', label: 'NSEC3 — Hashed denial of existence' },
{ value: 'NSEC3PARAM', label: 'NSEC3PARAM — NSEC3 parameters' },
{ value: 'OPENPGPKEY', label: 'OPENPGPKEY — OpenPGP public key' },
{ value: 'PTR', label: 'PTR — Reverse lookup pointer' },
{ value: 'RRSIG', label: 'RRSIG — DNSSEC signature' },
{ value: 'RP', label: 'RP — Responsible person' },
{ value: 'SIG', label: 'SIG — Signature (obsolete)' },
{ value: 'SMIMEA', label: 'SMIMEA — S/MIME cert association' },
{ value: 'SOA', label: 'SOA — Start of authority' },
{ value: 'SPF', label: 'SPF — Sender Policy Framework (deprecated)' },
{ value: 'SRV', label: 'SRV — Service locator' },
{ value: 'SSHFP', label: 'SSHFP — SSH public key fingerprint' },
{ value: 'SVCB', label: 'SVCB — Service binding' },
{ value: 'TA', label: 'TA — Trust anchor (experimental)' },
{ value: 'TKEY', label: 'TKEY — Secret key agreement' },
{ value: 'TLSA', label: 'TLSA — DANE TLS association' },
{ value: 'TSIG', label: 'TSIG — Transaction signature' },
{ value: 'TXT', label: 'TXT — Text record' },
{ value: 'URI', label: 'URI — URI template' },
{ value: 'ZONEMD', label: 'ZONEMD — Zone message digest' },
];
const resolverIP = ref('');
const dnsDomain = ref('');
const dnsType = ref('A');
const dnsResult = ref<DNSQueryResult | null>(null);
const whoisDomain = ref('');
const whoisResult = ref<WhoisResult | null>(null);
const dnssecDomain = ref('');
const dnssecResult = ref<DNSSECResult | null>(null);
const reverseIp = ref('');
const reverseResult = ref<ReverseDNSResult | null>(null);
const axfrDomain = ref('');
const axfrResult = ref<AXFRResult | null>(null);
async function runDns() {
dnsResult.value = await api('/dns-query', {
domain: dnsDomain.value,
record_type: dnsType.value,
resolver_ip: resolverIP.value,
});
}
async function runWhois() {
whoisResult.value = await api('/whois', { domain: whoisDomain.value });
}
async function runDnssec() {
dnssecResult.value = await api('/dnssec', {
domain: dnssecDomain.value,
resolver_ip: resolverIP.value,
});
}
async function runReverse() {
reverseResult.value = await api('/reverse-dns', {
ip: reverseIp.value,
resolver_ip: resolverIP.value,
});
}
async function runAxfr() {
axfrResult.value = await api('/soa-axfr', {
domain: axfrDomain.value,
resolver_ip: resolverIP.value,
});
}
const labelProps = {
'label-position': 'left',
'label-width': '150px',
};
</script>
<template>
<div style="min-height: 80vh;">
<details mb-2>
<summary>Network Utilities Service Configuration (self hosted)</summary>
<n-card>
<NFormItem label="Network Utilities Service Url:" label-placement="top">
<NInput v-model:value="serverHost" placeholder="http://localhost:3000" />
</NFormItem>
<NFormItem label="Basic Authentication:" label-placement="left" label-width="auto">
<NInput v-model:value="serverAuth" placeholder="username:password" />
</NFormItem>
<n-p>
You must self host Network Utilities Service. See:
<c-link href="https://github.com/sharevb/network-utils-ws#running-in-docker" target="_blank">
Network Utilities Service docker install
</c-link>
</n-p>
</n-card>
</details>
<NFormItem label="Target DNS Resolver IP:" label-placement="left">
<NInput v-model:value="resolverIP" placeholder="8.8.8.8 or leave empty for default /etc/resolv.conf DNS configuration" />
</NFormItem>
<n-tabs type="line" animated>
<!-- DNS QUERY -->
<n-tab-pane name="dns" tab="DNS Query" style="min-height: 80vh;">
<c-input-text v-model:value="dnsDomain" label="Domain:" v-bind="labelProps" placeholder="example.com" mb-1 />
<c-select
v-model:value="dnsType"
label="DNS Record type:"
v-bind="labelProps"
:options="dnsTypes"
mb-1
/>
<div mb-2 flex justify-center>
<n-button :loading="loading" @click="runDns">
Query DNS
</n-button>
</div>
<n-card v-if="dnsResult" title="Result">
<n-space justify="center" mb-1>
<n-tag :type="dnsResult.ok ? 'success' : 'error'" size="small">
{{ dnsResult.ok ? 'OK' : 'FAILED' }}
</n-tag>
</n-space>
<input-copyable label="Domain" v-bind="labelProps" :value="dnsResult.domain" mb-1 />
<input-copyable label="Record type" v-bind="labelProps" :value="dnsResult.record_type" mb-1 />
<n-card v-if="dnsResult.answers" title="Answers" mb-1>
<textarea-copyable
v-if="dnsResult.answers"
:value="dnsResult.answers.join('\n')"
mb-1
/>
</n-card>
<n-alert
v-if="dnsResult.error"
type="error"
:bordered="false"
show-icon
>
{{ dnsResult.error }}
</n-alert>
</n-card>
<c-alert v-if="error">
{{ error }}
</c-alert>
</n-tab-pane>
<!-- WHOIS -->
<n-tab-pane name="whois" tab="WHOIS">
<c-input-text v-model:value="whoisDomain" label="Domain:" v-bind="labelProps" placeholder="example.com" mb-1 />
<div mb-2 flex justify-center>
<n-button type="primary" :loading="loading" @click="runWhois">
Lookup WHOIS
</n-button>
</div>
<n-card v-if="whoisResult" title="Result">
<n-space justify="center" mb-1>
<n-tag :type="whoisResult.ok ? 'success' : 'error'" size="small" mb-1>
{{ whoisResult.ok ? 'OK' : 'FAILED' }}
</n-tag>
</n-space>
<input-copyable label="Domain" v-bind="labelProps" :value="whoisResult.domain" mb-1 />
<textarea-copyable
v-if="whoisResult.raw"
label="Raw WHOIS"
:value="whoisResult.raw"
mb-1
/>
<textarea-copyable
v-if="whoisResult.parsed"
label="Parsed"
:value="prettyJSON(whoisResult.parsed)"
language="json"
mb-1
/>
<n-alert
v-if="whoisResult.error"
type="error"
:bordered="false"
show-icon
>
{{ whoisResult.error }}
</n-alert>
</n-card>
<c-alert v-if="error">
{{ error }}
</c-alert>
</n-tab-pane>
<!-- DNSSEC -->
<n-tab-pane name="dnssec" tab="DNSSEC Validation">
<c-input-text v-model:value="dnssecDomain" label="Domain:" v-bind="labelProps" placeholder="example.com" mb-1 />
<div mb-2 flex justify-center>
<n-button type="primary" :loading="loading" @click="runDnssec">
Validate DNSSEC
</n-button>
</div>
<n-card v-if="dnssecResult" title="Result">
<n-space justify="center" mb-1>
<n-tag :type="dnssecResult.ok ? 'success' : 'error'" size="small" mb-1>
{{ dnssecResult.ok ? 'OK' : 'FAILED' }}
</n-tag>
</n-space>
<input-copyable label="Domain" v-bind="labelProps" :value="dnssecResult.domain" mb-1 />
<input-copyable
label="Validated"
v-bind="labelProps"
:value="dnssecResult.validated ? 'Yes' : 'No'"
mb-1
/>
<input-copyable
v-if="dnssecResult.dnskey"
label="DNSKEY"
v-bind="labelProps"
:value="dnssecResult.dnskey"
mb-1
/>
<input-copyable
v-if="dnssecResult.rrsig"
label="RRSIG"
v-bind="labelProps"
:value="dnssecResult.rrsig"
mb-1
/>
<n-alert
v-if="dnssecResult.error"
type="error"
:bordered="false"
show-icon
>
{{ dnssecResult.error }}
</n-alert>
</n-card>
<c-alert v-if="error">
{{ error }}
</c-alert>
</n-tab-pane>
<!-- REVERSE DNS -->
<n-tab-pane name="reverse" tab="Reverse DNS (PTR)">
<c-input-text v-model:value="reverseIp" label="IP Address:" v-bind="labelProps" placeholder="8.8.8.8" mb-1 />
<div mb-2 flex justify-center>
<n-button type="primary" :loading="loading" @click="runReverse">
Reverse Lookup
</n-button>
</div>
<n-card v-if="reverseResult" title="Result">
<n-space justify="center" mb-1>
<n-tag :type="reverseResult.ok ? 'success' : 'error'" size="small" mb-1>
{{ reverseResult.ok ? 'OK' : 'FAILED' }}
</n-tag>
</n-space>
<input-copyable label="IP" v-bind="labelProps" :value="reverseResult.ip" mb-1 />
<input-copyable
v-if="reverseResult.ptr"
label="PTR"
v-bind="labelProps"
:value="reverseResult.ptr"
mb-1
/>
<n-alert
v-if="reverseResult.error"
type="error"
:bordered="false"
show-icon
>
{{ reverseResult.error }}
</n-alert>
</n-card>
<c-alert v-if="error">
{{ error }}
</c-alert>
</n-tab-pane>
<!-- SOA + AXFR -->
<n-tab-pane name="axfr" tab="SOA + AXFR Test">
<c-input-text v-model:value="axfrDomain" label="Domain:" v-bind="labelProps" placeholder="example.com" mb-1 />
<div mb-2 flex justify-center>
<n-button type="primary" :loading="loading" @click="runAxfr">
Run SOA + AXFR
</n-button>
</div>
<n-card v-if="axfrResult" title="Result">
<n-space justify="center" mb-1>
<n-tag :type="axfrResult.ok ? 'success' : 'error'" size="small" mb-1>
{{ axfrResult.ok ? 'OK' : 'FAILED' }}
</n-tag>
</n-space>
<input-copyable label="Domain" v-bind="labelProps" :value="axfrResult.domain" mb-1 />
<textarea-copyable
v-if="axfrResult.soa"
label="SOA"
:value="axfrResult.soa"
mb-1
/>
<input-copyable
label="AXFR allowed"
v-bind="labelProps"
:value="axfrResult.axfr_allowed ? 'Yes' : 'No'"
mb-1
/>
<textarea-copyable
v-if="axfrResult.records"
label="Records"
:value="axfrResult.records.join('\n')"
mb-1
/>
<n-alert
v-if="axfrResult.error"
type="error"
:bordered="false"
show-icon
>
{{ axfrResult.error }}
</n-alert>
</n-card>
<c-alert v-if="error">
{{ error }}
</c-alert>
</n-tab-pane>
</n-tabs>
</div>
</template>
+14
View File
@@ -0,0 +1,14 @@
import { World } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'DNS Tester',
path: '/dns-tester',
description: 'A simple tool for testing DNS resolution, whois queries, and other DNS-related tasks.',
keywords: ['dns', 'tester', 'resolution', 'whois', 'lookup', 'query', 'axfr', 'zone', 'dnssec'],
component: () => import('./dns-tester.vue'),
icon: World,
createdAt: new Date('2026-05-11'),
category: 'Forensic',
externAccessDescription: 'This tool calls your Self Host Network Utilities Service to perform DNS/Whois queries and related tasks.',
});
+432 -113
View File
@@ -1,163 +1,482 @@
Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allows you to run many containers simultaneously on a given host. Containers are lightweight and contain everything needed to run the application, so you do not need to rely on what is currently installed on the host. You can easily share containers while you work, and be sure that everyone you share with gets the same container that works in the same way.
## INSTALLATION
## Installation & Resources
## GENERAL COMMANDS
- Docker Desktop (Mac, Linux, Windows): https://docs.docker.com/desktop
- Example projects using Docker: https://github.com/docker/awesome-compose
- Official documentation: https://docs.docker.com
Docker Desktop is available for Mac, Linux and Windows https://docs.docker.com/desktop
View example projects that use Docker
https://github.com/docker/awesome-compose
Check out our docs for information on using Docker https://docs.docker.com
## IMAGES
Docker images are a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.
Build an Image from a Dockerfile
## General Commands
Start the Docker daemon:
```bash
docker build -t <image_name> .
dockerd
```
Build an Image from a Dockerfile without the cache
```bash
docker build -t <image\_name> . -no-cache
```
List local images
```bash
docker images
```
Delete an Image
```bash
docker rmi <image\_name>
```
Remove all unused images
```bash
docker image prune
```
## DOCKER HUB
Docker Hub is a service provided by Docker for finding and sharing container images with your team. Learn more and find images at https://hub.docker.com
Login into Docker
```bash
docker login -u <username>
```
Publish an image to Docker Hub
```bash
docker push <username>/<image\_name>
```
Search Hub for an image
```bash
docker search <image\_name>
```
Pull an image from a Docker Hub
```bash
docker pull <image\_name>
```
Start the docker daemon
```bash
docker -d
```
Get help with Docker. Can also use -help on all subcommands
Get help with Docker (works on all subcommands, e.g. `docker run --help`):
```bash
docker --help
```
Display system-wide information
Display system-wide information:
```bash
docker info
```
## CONTAINERS
A container is a runtime instance of a docker image. A container will always run the same, regardless of the infrastructure. Containers isolate software from its environment and ensure that it works uniformly despite differences for instance between development and staging.
Create and run a container from an image, with a custom name:
Show Docker version (client and server):
```bash
docker run --name <container\_name> <image\_name>
docker version
```
Run a container with and publish a container's port(s) to the host.
## Images
Docker images are a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings.
Build an image from a Dockerfile in the current directory:
```bash
docker run -p <host\_port>:<container\_port> <image\_name>
docker build -t <image_name> .
```
Run a container in the background
Build an image without using the cache:
```bash
docker run -d <image\_name>
docker build -t <image_name> . --no-cache
```
Start or stop an existing container:
Build with a specific tag (e.g. `myapp:v1.2`):
```bash
docker start|stop <container\_name> (or <container-id>)
docker build -t <image_name>:<tag> .
```
Remove a stopped container:
List local images:
```bash
docker rm <container\_name>
docker images
```
Open a shell inside a running container:
Tag an image for pushing to a registry:
```bash
docker exec -it <container\_name> sh
docker tag <image> <username>/<image>:<tag>
```
Fetch and follow the logs of a container:
Delete an image:
```bash
docker logs -f <container\_name>
docker rmi <image_name>
```
To inspect a running container:
Remove dangling (unused) images:
```bash
docker inspect <container\_name> (or <container\_id>)
docker image prune
```
To list currently running containers:
Remove all unused images, not just dangling:
```bash
docker image prune -a
```
Show the layers of an image:
```bash
docker history <image_name>
```
## Docker Hub
Docker Hub is a service for finding and sharing container images. Learn more at https://hub.docker.com
Log in to Docker Hub:
```bash
docker login -u <username>
```
Log out:
```bash
docker logout
```
Search Docker Hub for an image:
```bash
docker search <image_name>
```
Pull an image from Docker Hub:
```bash
docker pull <image_name>
```
Pull a specific tagged version:
```bash
docker pull <image_name>:<tag>
```
Publish an image to Docker Hub:
```bash
docker push <username>/<image_name>
```
## Containers
A container is a runtime instance of a Docker image. A container will always run the same, regardless of the infrastructure. Containers isolate software from its environment and ensure it works uniformly across development, staging, and production.
### Running containers
Create and run a container from an image:
```bash
docker run <image_name>
```
Run with a custom name:
```bash
docker run --name <container_name> <image_name>
```
Run in the background (detached):
```bash
docker run -d <image_name>
```
Run interactively with a shell:
```bash
docker run -it <image_name> bash
```
Auto-remove the container when it exits:
```bash
docker run --rm <image_name>
```
Publish a container's port to the host:
```bash
docker run -p <host_port>:<container_port> <image_name>
```
Set an environment variable:
```bash
docker run -e KEY=value <image_name>
```
Load environment variables from a file:
```bash
docker run --env-file ./env.list <image_name>
```
Mount a named volume:
```bash
docker run -v <volume_name>:/path/in/container <image_name>
```
Bind-mount the current directory:
```bash
docker run -v $(pwd):/app <image_name>
```
Set a restart policy (options: `no`, `on-failure`, `always`, `unless-stopped`):
```bash
docker run --restart unless-stopped <image_name>
```
Attach to a specific network:
```bash
docker run --network <network_name> <image_name>
```
### Managing containers
List currently running containers:
```bash
docker ps
```
List all docker containers (running and stopped):
List all containers (running and stopped):
```bash
docker ps --all
docker ps -a
```
View resource usage stats
Start a stopped container:
```bash
docker container stats
```
docker start <container_name>
```
Stop a running container:
```bash
docker stop <container_name>
```
Restart a container:
```bash
docker restart <container_name>
```
Remove a stopped container:
```bash
docker rm <container_name>
```
Force-remove a running container:
```bash
docker rm -f <container_name>
```
Remove all stopped containers:
```bash
docker container prune
```
Rename a container:
```bash
docker rename <old_name> <new_name>
```
### Inspecting and interacting
Open a shell inside a running container:
```bash
docker exec -it <container_name> bash
```
Use `sh` for minimal images (e.g. alpine) that don't ship bash:
```bash
docker exec -it <container_name> sh
```
Fetch logs:
```bash
docker logs <container_name>
```
Follow logs (like `tail -f`):
```bash
docker logs -f <container_name>
```
Show only the last 100 lines:
```bash
docker logs --tail 100 <container_name>
```
Show low-level container details (JSON):
```bash
docker inspect <container_name>
```
Live resource usage stats for all containers:
```bash
docker stats
```
Show running processes inside a container:
```bash
docker top <container_name>
```
Copy a file out of a container:
```bash
docker cp <container_name>:/path/in/container ./
```
Copy a file into a container:
```bash
docker cp ./local_file <container_name>:/path/
```
Show filesystem changes since container start:
```bash
docker diff <container_name>
```
## Volumes
Volumes persist data outside the container's writable layer, so data survives container removal.
Create a named volume:
```bash
docker volume create <volume_name>
```
List volumes:
```bash
docker volume ls
```
Show details about a volume:
```bash
docker volume inspect <volume_name>
```
Remove a volume:
```bash
docker volume rm <volume_name>
```
Remove all unused volumes:
```bash
docker volume prune
```
Attach a named volume to a container (managed by Docker):
```bash
docker run -v <volume_name>:/data <image_name>
```
Bind-mount a host path into a container:
```bash
docker run -v $(pwd):/app <image_name>
```
Equivalent bind mount using the `--mount` syntax:
```bash
docker run --mount type=bind,src=$(pwd),dst=/app <image_name>
```
## Networks
Containers on the same network can reach each other by container name.
List networks:
```bash
docker network ls
```
Create a network:
```bash
docker network create <network_name>
```
Show network details:
```bash
docker network inspect <network_name>
```
Attach a running container to a network:
```bash
docker network connect <network_name> <container_name>
```
Detach a container from a network:
```bash
docker network disconnect <network_name> <container_name>
```
Remove a network:
```bash
docker network rm <network_name>
```
Remove all unused networks:
```bash
docker network prune
```
## Docker Compose
Compose runs multi-container apps from a single `compose.yaml` (or `docker-compose.yml`) file.
Start all services (foreground):
```bash
docker compose up
```
Start all services (detached):
```bash
docker compose up -d
```
Rebuild images before starting:
```bash
docker compose up --build
```
Stop and remove containers and networks:
```bash
docker compose down
```
Also remove named volumes:
```bash
docker compose down -v
```
List services in the project:
```bash
docker compose ps
```
Follow logs for all services:
```bash
docker compose logs -f
```
Follow logs for one service:
```bash
docker compose logs -f <service>
```
Build (or rebuild) services:
```bash
docker compose build
```
Pull service images:
```bash
docker compose pull
```
Open a shell in a running service:
```bash
docker compose exec <service> bash
```
Run a one-off command in a new container:
```bash
docker compose run --rm <service> <command>
```
Restart a single service:
```bash
docker compose restart <service>
```
Validate and view the resolved compose file:
```bash
docker compose config
```
## System & Cleanup
Disk usage adds up fast. These commands reclaim space.
Show disk usage (images, containers, volumes, build cache):
```bash
docker system df
```
Remove stopped containers, dangling images, and unused networks:
```bash
docker system prune
```
Also remove all unused images (not just dangling):
```bash
docker system prune -a
```
Also remove unused volumes (destructive — double-check before running):
```bash
docker system prune -a --volumes
```
Clean the build cache:
```bash
docker builder prune
```
## Quick Reference: Common Flags
| Flag | Meaning |
|------|---------|
| `-d` | Detached (run in background) |
| `-it` | Interactive + TTY (for shells) |
| `--rm` | Remove container when it exits |
| `-p host:container` | Publish a port |
| `-v src:dst` | Mount volume or bind mount |
| `-e KEY=value` | Environment variable |
| `--name` | Assign a container name |
| `--network` | Attach to a network |
| `--restart` | Restart policy (`no`, `on-failure`, `always`, `unless-stopped`) |
@@ -5,12 +5,34 @@ import { flatten } from 'flatten-anything';
import { convertFrom } from './geo-coordinates-converter.service';
import { objectArrayToData } from '@/utils/objectarray.export';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
import proj4 from 'proj4';
import L from 'leaflet';
import 'leaflet/dist/leaflet.css';
import markerIconUrl from 'leaflet/dist/images/marker-icon.png';
import markerIconRetinaUrl from 'leaflet/dist/images/marker-icon-2x.png';
import markerShadowUrl from 'leaflet/dist/images/marker-shadow.png';
L.Icon.Default.prototype.options.iconUrl = markerIconUrl;
L.Icon.Default.prototype.options.iconRetinaUrl = markerIconRetinaUrl;
L.Icon.Default.prototype.options.shadowUrl = markerShadowUrl;
L.Icon.Default.imagePath = '';
const { t } = useI18n();
const decimal = reactive({
lat: 48.8566,
lng: 2.3522,
latDir: 'N',
lngDir: 'E',
});
const sourceSystem = useQueryParamOrStorage({ name: 'type', storageName: 'geo-coord-conv:t', defaultValue: 'BD09' });
const inputLatitude = useQueryParam({ tool: 'geo-coord-conv', name: 'lat', defaultValue: 39.915 });
const inputLongitude = useQueryParam({ tool: 'geo-coord-conv', name: 'lng', defaultValue: 116.404 });
const inputLatitude = useQueryParam({ tool: 'geo-coord-conv', name: 'lat', defaultValue: 48.8566 });
watch(inputLatitude, v => decimal.lat = v);
const inputLongitude = useQueryParam({ tool: 'geo-coord-conv', name: 'lng', defaultValue: 2.3522 });
watch(inputLongitude, v => decimal.lng = v);
const inputCSV = ref('');
const batchRows = ref<string[][]>([]);
const resultsData = ref<Record<string, { lat: number; lng: number }>[]>([]);
@@ -24,7 +46,7 @@ const resultsDisplay = computed(() => {
output.push({
system,
decimal: `${x.toFixed(6)}, ${y.toFixed(6)}`,
dms: `${toDMS(x)}, ${toDMS(y)}`,
dms: `${toDMSString(x)}, ${toDMSString(y)}`,
});
}
return output;
@@ -78,92 +100,315 @@ function downloadCsv() {
URL.revokeObjectURL(url);
}
function toDMS(deg: number) {
function toDMSString(deg: number) {
const d = Math.floor(deg);
const m = Math.floor((deg - d) * 60);
const s = (((deg - d) * 60 - m) * 60).toFixed(2);
return `${d}°${m}′${s}″`;
}
// -----------------------------
// CONSTANTS
// -----------------------------
const latDirOptions = [
{ label: 'N', value: 'N' },
{ label: 'S', value: 'S' },
];
const lngDirOptions = [
{ label: 'E', value: 'E' },
{ label: 'W', value: 'W' },
];
const hemisphereOptions = [
{ label: t('tools.geo-coordinates-converter.texts.north'), value: 'N' },
{ label: t('tools.geo-coordinates-converter.texts.south'), value: 'S' },
];
const degree = reactive({
lat: { d: 48, m: 51, s: 23.76 },
lng: { d: 2, m: 21, s: 7.92 },
latDir: 'N',
lngDir: 'E',
});
const utm = reactive({
zone: 31,
hemisphere: 'N',
easting: 448251,
northing: 5411932,
});
const mapRef = ref<HTMLElement | null>(null);
watch(mapRef, () => initMap());
let map: L.Map;
let marker: L.Marker;
// -----------------------------
// HELPERS
// -----------------------------
function applyDir(value: number, dir: string) {
return dir === 'S' || dir === 'W' ? -Math.abs(value) : Math.abs(value);
}
function dmsToDecimal(d: number, m: number, s: number, dir: string) {
const val = d + m / 60 + s / 3600;
return applyDir(val, dir);
}
function decimalToDms(value: number) {
const abs = Math.abs(value);
const d = Math.floor(abs);
const minFloat = (abs - d) * 60;
const m = Math.floor(minFloat);
const s = (minFloat - m) * 60;
return { d, m, s };
}
function getUtmProjection(zone: number, hemisphere: string) {
return `+proj=utm +zone=${zone} ${hemisphere === 'S' ? '+south' : ''} +datum=WGS84 +units=m +no_defs`;
}
// -----------------------------
// UPDATE HANDLERS
// -----------------------------
function onDecimalChange() {
const lat = applyDir(decimal.lat, decimal.latDir);
const lng = applyDir(decimal.lng, decimal.lngDir);
inputLatitude.value = lat;
inputLongitude.value = lng;
// Update DMS
const dLat = decimalToDms(lat);
const dLng = decimalToDms(lng);
degree.lat = dLat;
degree.lng = dLng;
degree.latDir = lat >= 0 ? 'N' : 'S';
degree.lngDir = lng >= 0 ? 'E' : 'W';
// Update UTM
const zone = Math.floor((lng + 180) / 6) + 1;
const proj = getUtmProjection(zone, lat >= 0 ? 'N' : 'S');
const [easting, northing] = proj4('EPSG:4326', proj, [lng, lat]);
utm.zone = zone;
utm.hemisphere = lat >= 0 ? 'N' : 'S';
utm.easting = Math.round(easting);
utm.northing = Math.round(northing);
updateMarker();
}
function onDegreeChange() {
decimal.lat = dmsToDecimal(degree.lat.d, degree.lat.m, degree.lat.s, degree.latDir);
decimal.lng = dmsToDecimal(degree.lng.d, degree.lng.m, degree.lng.s, degree.lngDir);
decimal.latDir = degree.latDir;
decimal.lngDir = degree.lngDir;
onDecimalChange();
}
function onUtmChange() {
const proj = getUtmProjection(utm.zone, utm.hemisphere);
const [lng, lat] = proj4(proj, 'EPSG:4326', [utm.easting, utm.northing]);
decimal.lat = Number.parseFloat(lat.toFixed(6));
decimal.lng = Number.parseFloat(lng.toFixed(6));
decimal.latDir = lat >= 0 ? 'N' : 'S';
decimal.lngDir = lng >= 0 ? 'E' : 'W';
onDecimalChange();
}
function initMap() {
try {
if (!mapRef.value) {
return;
}
map = L.map(mapRef.value).setView([decimal.lat, decimal.lng], 13);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
referrerPolicy: 'strict-origin-when-cross-origin',
}).addTo(map);
marker = L.marker([decimal.lat, decimal.lng], { draggable: true }).addTo(map);
marker.on('dragend', () => {
const pos = marker.getLatLng();
decimal.lat = Number.parseFloat(pos.lat.toFixed(6));
decimal.lng = Number.parseFloat(pos.lng.toFixed(6));
decimal.latDir = pos.lat >= 0 ? 'N' : 'S';
decimal.lngDir = pos.lng >= 0 ? 'E' : 'W';
onDecimalChange();
});
map.on('click', (e: L.LeafletMouseEvent) => {
decimal.lat = Number.parseFloat(e.latlng.lat.toFixed(6));
decimal.lng = Number.parseFloat(e.latlng.lng.toFixed(6));
decimal.latDir = e.latlng.lat >= 0 ? 'N' : 'S';
decimal.lngDir = e.latlng.lng >= 0 ? 'E' : 'W';
onDecimalChange();
});
}
catch {}
}
onMounted(() => {
initMap();
});
function updateMarker() {
marker.setLatLng([decimal.lat, decimal.lng]);
map.setView([decimal.lat, decimal.lng]);
}
</script>
<template>
<div>
<n-radio-group v-model:value="sourceSystem" mb-2>
<n-space justify="center">
<n-radio value="WGS84">
{{ t('tools.geo-coordinates-converter.texts.tag-wgs84-wsg1984-epsg4326-global-standard') }}
</n-radio>
<n-radio value="GCJ02">
{{ t('tools.geo-coordinates-converter.texts.tag-gcj02-amap-gaode-qq-maps') }}
</n-radio>
<n-radio value="BD09">
{{ t('tools.geo-coordinates-converter.texts.tag-bd09-bd09ll-bmap-baidu-maps') }}
</n-radio>
<n-radio value="BD09MC">
{{ t('tools.geo-coordinates-converter.texts.tag-bd09mc-bd09meter-baidu-meter') }}
</n-radio>
<n-radio value="CGCS2000">
{{ t('tools.geo-coordinates-converter.texts.tag-cgcs2000-china-geodetic-system-2000') }}
</n-radio>
<n-radio value="WebMercator">
{{ t('tools.geo-coordinates-converter.texts.tag-webmercator-epsg3857-epsg900913') }}
</n-radio>
</n-space>
</n-radio-group>
<n-tabs type="card" mb-1>
<n-tab-pane name="single" :tab="t('tools.geo-coordinates-converter.text.single-lat-lng-converter')">
<n-space justify="center">
<n-form-item :label="t('tools.geo-coordinates-converter.texts.label-latitude')" label-placement="left">
<n-input-number-i18n v-model:value="inputLatitude" />
</n-form-item>
<n-form-item :label="t('tools.geo-coordinates-converter.texts.label-longitude')" label-placement="left">
<n-input-number-i18n v-model:value="inputLongitude" />
</n-form-item>
</n-space>
<n-space justify="center">
<n-button type="primary" @click="convertSingle">
{{ t('tools.geo-coordinates-converter.texts.tag-convert-single') }}
</n-button>
</n-space>
</n-tab-pane>
<n-tab-pane name="batch" :tab="t('tools.geo-coordinates-converter.text.batch-lat-lng-converter')">
<c-input-text
v-model:value="inputCSV"
:label="t('tools.geo-coordinates-converter.texts.label-csv-content-lng-lat')"
:placeholder="t('tools.geo-coordinates-converter.texts.placeholder-put-your-longitude-and-latitude-in-this-order-csv-to-convert')"
multiline
rows="5"
mb-2
/>
<n-tab-pane name="coords" :tab="t('tools.geo-coordinates-converter.texts.coordinates-notations')">
<n-card :title="t('tools.geo-coordinates-converter.texts.decimal-notation')" mb-2>
<n-form :model="decimal" label-placement="left" label-width="140">
<n-form-item :label="t('tools.geo-coordinates-converter.texts.latitude-decimal')">
<n-input-group gap-1>
<n-input-number v-model:value="decimal.lat" :precision="6" @update:value="onDecimalChange" />
<n-select v-model:value="decimal.latDir" :options="latDirOptions" style="width: 80px" @update:value="onDecimalChange" />
</n-input-group>
</n-form-item>
<n-space justify="center">
<n-button
type="primary"
@click="convertBatch"
>
{{ t('tools.geo-coordinates-converter.texts.tag-convert-batch') }}
</n-button>
</n-space>
<n-form-item :label="t('tools.geo-coordinates-converter.texts.longitude-decimal')">
<n-input-group gap-1>
<n-input-number v-model:value="decimal.lng" :precision="6" @update:value="onDecimalChange" />
<n-select v-model:value="decimal.lngDir" :options="lngDirOptions" style="width: 80px" @update:value="onDecimalChange" />
</n-input-group>
</n-form-item>
</n-form>
</n-card>
<n-card :title="t('tools.geo-coordinates-converter.texts.dms-notation')" mb-2>
<n-form :model="degree" label-placement="left" label-width="140">
<n-form-item :label="t('tools.geo-coordinates-converter.texts.latitude-dms')">
<n-input-group gap-1>
<n-input-number v-model:value="degree.lat.d" placeholder="°" @update:value="onDegreeChange" />
<n-input-number v-model:value="degree.lat.m" placeholder="′" @update:value="onDegreeChange" />
<n-input-number v-model:value="degree.lat.s" placeholder="″" @update:value="onDegreeChange" />
<n-select v-model:value="degree.latDir" :options="latDirOptions" style="width: 80px" @update:value="onDegreeChange" />
</n-input-group>
</n-form-item>
<n-form-item :label="t('tools.geo-coordinates-converter.texts.longitude-dms')">
<n-input-group gap-1>
<n-input-number v-model:value="degree.lng.d" placeholder="°" @update:value="onDegreeChange" />
<n-input-number v-model:value="degree.lng.m" placeholder="′" @update:value="onDegreeChange" />
<n-input-number v-model:value="degree.lng.s" placeholder="″" @update:value="onDegreeChange" />
<n-select v-model:value="degree.lngDir" :options="lngDirOptions" style="width: 80px" @update:value="onDegreeChange" />
</n-input-group>
</n-form-item>
</n-form>
</n-card>
<n-card :title="t('tools.geo-coordinates-converter.texts.utm-notation')" mb-2>
<n-form :model="utm" label-placement="left" label-width="140">
<n-form-item :label="t('tools.geo-coordinates-converter.texts.utm-zone')">
<n-input-number v-model:value="utm.zone" @update:value="onUtmChange" />
</n-form-item>
<n-form-item :label="t('tools.geo-coordinates-converter.texts.hemisphere')">
<n-select v-model:value="utm.hemisphere" :options="hemisphereOptions" @update:value="onUtmChange" />
</n-form-item>
<n-form-item :label="t('tools.geo-coordinates-converter.texts.easting')">
<n-input-number v-model:value="utm.easting" @update:value="onUtmChange" />
</n-form-item>
<n-form-item :label="t('tools.geo-coordinates-converter.texts.northing')">
<n-input-number v-model:value="utm.northing" @update:value="onUtmChange" />
</n-form-item>
</n-form>
</n-card>
<div ref="mapRef" style="height: 400px; width: 100%; border-radius: 8px; overflow: hidden" />
</n-tab-pane>
<n-tab-pane name="proj" :tab="t('tools.geo-coordinates-converter.texts.decimal-projections')">
<n-radio-group v-model:value="sourceSystem" mb-2>
<n-space justify="center">
<n-radio value="WGS84">
{{ t('tools.geo-coordinates-converter.texts.tag-wgs84-wsg1984-epsg4326-global-standard') }}
</n-radio>
<n-radio value="GCJ02">
{{ t('tools.geo-coordinates-converter.texts.tag-gcj02-amap-gaode-qq-maps') }}
</n-radio>
<n-radio value="BD09">
{{ t('tools.geo-coordinates-converter.texts.tag-bd09-bd09ll-bmap-baidu-maps') }}
</n-radio>
<n-radio value="BD09MC">
{{ t('tools.geo-coordinates-converter.texts.tag-bd09mc-bd09meter-baidu-meter') }}
</n-radio>
<n-radio value="CGCS2000">
{{ t('tools.geo-coordinates-converter.texts.tag-cgcs2000-china-geodetic-system-2000') }}
</n-radio>
<n-radio value="WebMercator">
{{ t('tools.geo-coordinates-converter.texts.tag-webmercator-epsg3857-epsg900913') }}
</n-radio>
</n-space>
</n-radio-group>
<n-tabs type="card" mb-1>
<n-tab-pane name="single" :tab="t('tools.geo-coordinates-converter.text.single-lat-lng-converter')">
<n-space justify="center">
<n-form-item :label="t('tools.geo-coordinates-converter.texts.label-latitude')" label-placement="left">
<n-input-number-i18n v-model:value="inputLatitude" />
</n-form-item>
<n-form-item :label="t('tools.geo-coordinates-converter.texts.label-longitude')" label-placement="left">
<n-input-number-i18n v-model:value="inputLongitude" />
</n-form-item>
</n-space>
<n-space justify="center">
<n-button type="primary" @click="convertSingle">
{{ t('tools.geo-coordinates-converter.texts.tag-convert-single') }}
</n-button>
</n-space>
</n-tab-pane>
<n-tab-pane name="batch" :tab="t('tools.geo-coordinates-converter.text.batch-lat-lng-converter')">
<c-input-text
v-model:value="inputCSV"
:label="t('tools.geo-coordinates-converter.texts.label-csv-content-lng-lat')"
:placeholder="t('tools.geo-coordinates-converter.texts.placeholder-put-your-longitude-and-latitude-in-this-order-csv-to-convert')"
multiline
rows="5"
mb-2
/>
<n-space justify="center">
<n-button
type="primary"
@click="convertBatch"
>
{{ t('tools.geo-coordinates-converter.texts.tag-convert-batch') }}
</n-button>
</n-space>
</n-tab-pane>
</n-tabs>
<c-card v-if="resultsData?.length" :title="t('tools.geo-coordinates-converter.texts.title-conversion-results')" mb-2>
<n-data-table v-if="resultsDisplay?.length" :columns="columns" :data="resultsDisplay" bordered mb-2 />
<n-space justify="center">
<n-button
type="success"
:disabled="resultsData.length === 0"
@click="downloadCsv"
>
{{ $t('tools.geo-coordinates-converter.text.download-results-csv') }}
</n-button>
</n-space>
</c-card>
<n-alert type="info" :title="t('tools.geo-coordinates-converter.texts.title-notes')" mt-3>
{{ t('tools.geo-coordinates-converter.texts.tag-longitude-east-is-positive-west-is-negative') }}<br>{{ t('tools.geo-coordinates-converter.texts.tag-latitude-north-is-positive-south-is-negative') }}
</n-alert>
</n-tab-pane>
</n-tabs>
<c-card v-if="resultsData?.length" :title="t('tools.geo-coordinates-converter.texts.title-conversion-results')" mb-2>
<n-data-table v-if="resultsDisplay?.length" :columns="columns" :data="resultsDisplay" bordered mb-2 />
<n-space justify="center">
<n-button
type="success"
:disabled="resultsData.length === 0"
@click="downloadCsv"
>
{{ $t('tools.geo-coordinates-converter.text.download-results-csv') }}
</n-button>
</n-space>
</c-card>
<n-alert type="info" :title="t('tools.geo-coordinates-converter.texts.title-notes')" mt-3>
{{ t('tools.geo-coordinates-converter.texts.tag-longitude-east-is-positive-west-is-negative') }}<br>{{ t('tools.geo-coordinates-converter.texts.tag-latitude-north-is-positive-south-is-negative') }}
</n-alert>
</div>
</template>
@@ -11,4 +11,5 @@ export const tool = defineTool({
icon: IconWorldPin,
createdAt: new Date('2026-01-09'),
category: 'Converters',
externAccessDescription: 'This tool access OpenStreetMap to display the World map using the Leaflet library.',
});
+44 -42
View File
@@ -1,7 +1,10 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { useITStorage } from '@/composable/queryParams';
import { Base64 } from 'js-base64';
const { t } = useI18n();
const url = ref('');
const html = ref('');
const error = ref('');
@@ -26,12 +29,12 @@ const options = useITStorage('html-to-pdf:opts', {
});
const pdfFormats = [
{ label: 'A2', value: 'A2' },
{ label: 'A3', value: 'A3' },
{ label: 'A4', value: 'A4' },
{ label: 'A5', value: 'A5' },
{ label: 'Letter', value: 'Letter' },
{ label: 'Legal', value: 'Legal' },
{ label: t('tools.html-to-pdf.texts.label-a2'), value: 'A2' },
{ label: t('tools.html-to-pdf.texts.label-a3'), value: 'A3' },
{ label: t('tools.html-to-pdf.texts.label-a4'), value: 'A4' },
{ label: t('tools.html-to-pdf.texts.label-a5'), value: 'A5' },
{ label: t('tools.html-to-pdf.texts.label-letter'), value: 'Letter' },
{ label: t('tools.html-to-pdf.texts.label-legal'), value: 'Legal' },
];
function downloadURL(data: string, fileName: string) {
@@ -186,28 +189,27 @@ async function generateBatch() {
<template>
<div>
<details mb-2>
<summary>HTML to PDF Service Configuration (self hosted)</summary>
<summary>{{ t('tools.html-to-pdf.texts.tag-html-to-pdf-service-configuration-self-hosted') }}</summary>
<n-card>
<NFormItem label="HTML to PDF Service Url:" label-placement="top">
<NInput v-model:value="serverHost" placeholder="http://localhost:3000" />
<NFormItem :label="t('tools.html-to-pdf.texts.label-html-to-pdf-service-url')" label-placement="top">
<NInput v-model:value="serverHost" :placeholder="t('tools.html-to-pdf.texts.placeholder-http-localhost-3000')" />
</NFormItem>
<NFormItem label="Basic Authentication:" label-placement="left" label-width="auto">
<NInput v-model:value="serverAuth" placeholder="username:password" />
<NFormItem :label="t('tools.html-to-pdf.texts.label-basic-authentication')" label-placement="left" label-width="auto">
<NInput v-model:value="serverAuth" :placeholder="t('tools.html-to-pdf.texts.placeholder-username-password')" />
</NFormItem>
<n-p>
You must self host HTML to PDF Service. See:
<c-link href="https://github.com/sharevb/puppeteer-htmltopdf?tab=readme-ov-file#running-in-docker" target="_blank">
HTML to PDF Service install
{{ t('tools.html-to-pdf.texts.tag-you-must-self-host-html-to-pdf-service-see') }}<c-link href="https://github.com/sharevb/puppeteer-htmltopdf?tab=readme-ov-file#running-in-docker" target="_blank">
{{ t('tools.html-to-pdf.texts.tag-html-to-pdf-service-install') }}
</c-link>
</n-p>
</n-card>
</details>
<NTabs type="line">
<NTabPane name="url" tab="URL → PDF">
<NTabPane name="url" :tab="t('tools.html-to-pdf.texts.tab-url-pdf')">
<NForm label-placement="left">
<NFormItem label="URL:">
<NInput v-model:value="url" placeholder="https://example.com" />
<NFormItem :label="t('tools.html-to-pdf.texts.label-url')">
<NInput v-model:value="url" :placeholder="t('tools.html-to-pdf.texts.placeholder-https-example-com')" />
</NFormItem>
<n-space mb-2 justify="center">
@@ -217,7 +219,7 @@ async function generateBatch() {
:disabled="isRunning"
@click="generateFromUrl"
>
Generate PDF
{{ t('tools.html-to-pdf.texts.tag-generate-pdf') }}
</NButton>
</n-space>
@@ -227,9 +229,9 @@ async function generateBatch() {
</NForm>
</NTabPane>
<NTabPane name="html" tab="HTML → PDF">
<NTabPane name="html" :tab="t('tools.html-to-pdf.texts.tab-html-pdf')">
<NForm label-placement="top">
<NFormItem label="HTML Content:">
<NFormItem :label="t('tools.html-to-pdf.texts.label-html-content')">
<NInput
v-model:value="html"
type="textarea"
@@ -244,7 +246,7 @@ async function generateBatch() {
:disabled="isRunning"
@click="generateFromHtml"
>
Generate PDF
{{ t('tools.html-to-pdf.texts.tag-generate-pdf') }}
</NButton>
</n-space>
@@ -254,9 +256,9 @@ async function generateBatch() {
</NForm>
</NTabPane>
<NTabPane name="batch" tab="Batch URL → PDF">
<NTabPane name="batch" :tab="t('tools.html-to-pdf.texts.tab-batch-url-pdf')">
<NForm label-placement="top">
<NFormItem label="URLs (one per line):">
<NFormItem :label="t('tools.html-to-pdf.texts.label-urls-one-per-line')">
<NInput
v-model:value="batchUrls"
type="textarea"
@@ -271,7 +273,7 @@ async function generateBatch() {
:disabled="isBatchRunning"
@click="generateBatch"
>
Generate PDFs
{{ t('tools.html-to-pdf.texts.tag-generate-pdfs') }}
</NButton>
</n-space>
</NForm>
@@ -289,11 +291,11 @@ async function generateBatch() {
</div>
<!-- Results -->
<NCard v-if="batchResults.length > 0" title="Results">
<NCard v-if="batchResults.length > 0" :title="t('tools.html-to-pdf.texts.title-results')">
<n-table>
<thead>
<th>Url</th>
<th>Download</th>
<th>{{ t('tools.html-to-pdf.texts.tag-url') }}</th>
<th>{{ t('tools.html-to-pdf.texts.tag-download') }}</th>
</thead>
<tbody>
<tr
@@ -311,13 +313,13 @@ async function generateBatch() {
type="success"
@click="downloadBlob(item.pdfBlob!, `${urlToFilename(item.url)}.pdf`)"
>
Download PDF
{{ t('tools.html-to-pdf.texts.tag-download-pdf') }}
</NButton>
</template>
<template v-else>
<NButton size="small" type="error" disabled>
Failed
{{ t('tools.html-to-pdf.texts.tag-failed') }}
</NButton>
<div style="color: red; font-size: 12px">
{{ item.error }}
@@ -331,52 +333,52 @@ async function generateBatch() {
</NTabPane>
<!-- Custom PDF Options -->
<NTabPane name="custom-options" tab="Custom PDF Options">
<NTabPane name="custom-options" :tab="t('tools.html-to-pdf.texts.tab-custom-pdf-options')">
<NForm label-placement="left">
<NFormItem label="Format:">
<NFormItem :label="t('tools.html-to-pdf.texts.label-format')">
<NSelect
v-model:value="options.format"
:options="pdfFormats"
/>
</NFormItem>
<NFormItem label="Language:">
<NInput v-model:value="options.language" placeholder="en-US" />
<NFormItem :label="t('tools.html-to-pdf.texts.label-language')">
<NInput v-model:value="options.language" :placeholder="t('tools.html-to-pdf.texts.placeholder-en-us')" />
</NFormItem>
<n-space justify="center">
<NFormItem label="Landscape:">
<NFormItem :label="t('tools.html-to-pdf.texts.label-landscape')">
<NSwitch v-model:value="options.landscape" />
</NFormItem>
<NFormItem label="One Long Page:">
<NFormItem :label="t('tools.html-to-pdf.texts.label-one-long-page')">
<NSwitch v-model:value="options.onePage" />
</NFormItem>
<NFormItem label="Auto-Hide Cookie Banners:">
<NFormItem :label="t('tools.html-to-pdf.texts.label-auto-hide-cookie-banners')">
<NSwitch v-model:value="options.autoHideCookies" />
</NFormItem>
<NFormItem label="Print Background:">
<NFormItem :label="t('tools.html-to-pdf.texts.label-print-background')">
<NSwitch v-model:value="options.printBackground" />
</NFormItem>
</n-space>
<c-card title="Margins">
<c-card :title="t('tools.html-to-pdf.texts.title-margins')">
<NSpace justify="center">
<NFormItem label="Top (mm):" style="width: 200px">
<NFormItem :label="t('tools.html-to-pdf.texts.label-top-mm')" style="width: 200px">
<NInputNumber v-model:value="options.margin.top" />
</NFormItem>
<NFormItem label="Bottom (mm):" style="width: 200px">
<NFormItem :label="t('tools.html-to-pdf.texts.label-bottom-mm')" style="width: 200px">
<NInputNumber v-model:value="options.margin.bottom" />
</NFormItem>
<NFormItem label="Left (mm):" style="width: 200px">
<NFormItem :label="t('tools.html-to-pdf.texts.label-left-mm')" style="width: 200px">
<NInputNumber v-model:value="options.margin.left" />
</NFormItem>
<NFormItem label="Right (mm):" style="width: 200px">
<NFormItem :label="t('tools.html-to-pdf.texts.label-right-mm')" style="width: 200px">
<NInputNumber v-model:value="options.margin.right" />
</NFormItem>
</NSpace>
+4 -3
View File
@@ -1,14 +1,15 @@
import { translate as t } from '@/plugins/i18n.plugin';
import { Printer } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'HTML to PDF',
name: t('tools.html-to-pdf.title'),
path: '/html-to-pdf',
description: 'Generate PDF from HTML content or URL with format selection and auto hide cookie banners',
description: t('tools.html-to-pdf.description'),
keywords: ['html', 'url', 'pdf'],
component: () => import('./html-to-pdf.vue'),
icon: Printer,
createdAt: new Date('2026-04-07'),
category: 'PDF',
externAccessDescription: 'This tool sends URLs and HTML content to the *self hosted* Puppeteer webservice configured.',
externAccessDescription: t('tools.html-to-pdf.externalAccess'),
});
+366
View File
@@ -0,0 +1,366 @@
<script setup lang="ts">
import { useITStorage } from '@/composable/queryParams';
import { Base64 } from 'js-base64';
const serverHost = useITStorage('https-tester:url', 'http://localhost:8000');
const serverAuth = useITStorage('https-tester:auth', '');
const loading = ref(false);
const error = ref<string | null>(null);
async function api(path: string, params: Record<string, string | number | boolean> = {}) {
error.value = null;
loading.value = true;
try {
const pathParams = new URLSearchParams();
Object.entries(params).forEach(([k, v]) => pathParams.append(k, v?.toString() || ''));
const url = `${serverHost.value}${path}?${pathParams.toString()}`;
const response = await fetch(url,
serverAuth.value
? {
method: 'GET',
headers: { Authorization: `Basic ${Base64.encode(serverAuth.value)}` },
}
: undefined);
if (!response.ok) {
const text = await response.text();
throw new Error(text || 'Server error');
}
return await response.json();
}
catch (err: any) {
error.value = err.toString();
}
finally {
loading.value = false;
}
}
type AnyDict = Record<string, any>;
interface CertificateCheckResult {
ok: boolean
hostname: string
port: number
not_before?: string | null
not_after?: string | null
days_until_expiry?: number | null
subject?: AnyDict | null
issuer?: AnyDict | null
san?: any[] | null
error?: string | null
}
interface HSTSCheckResult {
ok: boolean
url: string
hsts_present: boolean
max_age?: number | null
include_subdomains: boolean
preload: boolean
raw_header?: string | null
error?: string | null
}
interface RedirectCheckResult {
ok: boolean
http_url: string
redirected: boolean
final_url?: string | null
status_code?: number | null
redirect_chain?: { status_code: number; url: string; headers: Record<string, string> }[] | null
error?: string | null
}
function prettyJSON(value: unknown): string {
try {
return JSON.stringify(value, null, 2);
}
catch {
return String(value);
}
}
function formatDate(value: string | null | undefined): string {
if (!value) {
return '';
}
const d = new Date(value);
return Number.isNaN(d.getTime()) ? value : d.toISOString();
}
const certHost = ref('');
const certPort = ref(443);
const certResult = ref<CertificateCheckResult | null>(null);
const hstsUrl = ref('');
const hstsResult = ref<HSTSCheckResult | null>(null);
const redirectDomain = ref('');
const redirectResult = ref<RedirectCheckResult | null>(null);
// -------------------- Actions --------------------
async function runCertificate() {
certResult.value = await api('/check-certificate', {
host: certHost.value,
port: certPort.value,
});
}
async function runHsts() {
hstsResult.value = await api('/check-hsts', { url: hstsUrl.value });
}
async function runRedirect() {
redirectResult.value = await api('/check-redirect', { domain: redirectDomain.value });
}
const labelProps = {
'label-position': 'left',
'label-width': '120px',
};
</script>
<template>
<div>
<details mb-2>
<summary>Network Utilities Service Configuration (self hosted)</summary>
<n-card>
<NFormItem label="Network Utilities Service Url:" label-placement="top">
<NInput v-model:value="serverHost" placeholder="http://localhost:3000" />
</NFormItem>
<NFormItem label="Basic Authentication:" label-placement="left" label-width="auto">
<NInput v-model:value="serverAuth" placeholder="username:password" />
</NFormItem>
<n-p>
You must self host Network Utilities Service. See:
<c-link href="https://github.com/sharevb/network-utils-ws#running-in-docker" target="_blank">
Network Utilities Service docker install
</c-link>
</n-p>
</n-card>
</details>
<n-tabs type="line" animated>
<n-tab-pane name="cert" tab="Certificate">
<c-input-text v-model:value="certHost" label="Host:" v-bind="labelProps" placeholder="example.com" mb-1 />
<c-input-text v-model:value="certPort" label="Port:" v-bind="labelProps" placeholder="443" mb-1 />
<div mb-2 flex justify-center>
<n-button type="primary" :loading="loading" @click="runCertificate">
Check Certificate
</n-button>
</div>
<n-card v-if="certResult" title="Result">
<n-space justify="center" mb-1>
<n-tag :type="certResult.ok ? 'success' : 'error'" size="small">
{{ certResult.ok ? 'OK' : 'FAILED' }}
</n-tag>
</n-space>
<input-copyable label="Hostname:" v-bind="labelProps" :value="certResult.hostname" mb-1 />
<input-copyable label="Port:" v-bind="labelProps" :value="certResult.port" mb-1 />
<input-copyable
label="Not before:"
v-bind="labelProps"
:value="formatDate(certResult.not_before)" mb-1
/>
<input-copyable
label="Not after:"
v-bind="labelProps"
:value="formatDate(certResult.not_after)" mb-1
/>
<input-copyable
label="Days until expiry:"
v-bind="labelProps"
:value="String(certResult.days_until_expiry)" mb-1
/>
<input-copyable
label="Subject:"
v-bind="labelProps"
:value="prettyJSON(certResult.subject)" mb-1
/>
<input-copyable
label="Issuer:"
v-bind="labelProps"
:value="prettyJSON(certResult.issuer)" mb-1
/>
<input-copyable
v-for="(san, index) in certResult.san"
:key="index"
label="Sub. Alt. Name:"
v-bind="labelProps"
:value="prettyJSON(san)" mb-1
/>
<n-alert
v-if="certResult.error"
type="error"
:bordered="false"
show-icon
>
{{ certResult.error }}
</n-alert>
</n-card>
<c-alert v-if="error">
{{ error }}
</c-alert>
</n-tab-pane>
<!-- HSTS -->
<n-tab-pane name="hsts" tab="HSTS">
<c-input-text v-model:value="hstsUrl" label="URL:" v-bind="labelProps" placeholder="https://example.com" mb-1 />
<div mb-2 flex justify-center>
<n-button type="primary" :loading="loading" @click="runHsts">
Check HSTS
</n-button>
</div>
<n-card v-if="hstsResult" title="Result">
<n-space justify="center" mb-1>
<n-tag :type="hstsResult.ok ? 'success' : 'error'" size="small" mb-1>
{{ hstsResult.ok ? 'OK' : 'FAILED' }}
</n-tag>
</n-space>
<input-copyable label="URL" v-bind="labelProps" :value="hstsResult.url" mb-1 />
<input-copyable
label="HSTS present"
v-bind="labelProps"
:value="hstsResult.hsts_present ? 'Yes' : 'No'"
mb-1
/>
<input-copyable
v-if="hstsResult.max_age"
label="Max-Age"
v-bind="labelProps"
:value="String(hstsResult.max_age)"
mb-1
/>
<input-copyable
label="Inc. subdomains"
v-bind="labelProps"
:value="hstsResult.include_subdomains ? 'Yes' : 'No'"
mb-1
/>
<input-copyable
label="Preload"
v-bind="labelProps"
:value="hstsResult.preload ? 'Yes' : 'No'"
mb-1
/>
<input-copyable
v-if="hstsResult.raw_header"
label="Raw header"
v-bind="labelProps"
:value="hstsResult.raw_header"
mb-1
/>
<n-alert
v-if="hstsResult.error"
type="error"
:bordered="false"
show-icon
>
{{ hstsResult.error }}
</n-alert>
</n-card>
<c-alert v-if="error">
{{ error }}
</c-alert>
</n-tab-pane>
<!-- REDIRECT -->
<n-tab-pane name="redirect" tab="HTTP → HTTPS Redirect">
<n-form>
<c-input-text v-model:value="redirectDomain" label="Domain:" v-bind="labelProps" placeholder="example.com" mb-1 />
<div mb-2 flex justify-center>
<n-button type="primary" :loading="loading" @click="runRedirect">
Check Redirect
</n-button>
</div>
</n-form>
<n-card v-if="redirectResult" title="Result">
<n-space justify="center" mb-1>
<n-tag :type="redirectResult.ok ? 'success' : 'error'" size="small" mb-1>
{{ redirectResult.ok ? 'OK' : 'FAILED' }}
</n-tag>
</n-space>
<input-copyable label="HTTP URL" v-bind="labelProps" :value="redirectResult.http_url" mb-1 />
<input-copyable
label="Redirected"
v-bind="labelProps"
:value="redirectResult.redirected ? 'Yes' : 'No'"
mb-1
/>
<input-copyable
label="Final URL"
v-bind="labelProps"
:value="redirectResult.final_url"
mb-1
/>
<input-copyable
label="Status code"
v-bind="labelProps"
:value="String(redirectResult.status_code)"
mb-1
/>
<input-copyable
v-if="redirectResult.redirect_chain"
label="Redirect chain:"
v-bind="labelProps"
:value="redirectResult.redirect_chain.map(r => r.url).join(' → ')"
mb-1
/>
<n-card title="Redirect chain details">
<textarea-copyable
v-if="redirectResult.redirect_chain"
label="Redirect chain"
:value="prettyJSON(redirectResult.redirect_chain)"
mb-1
/>
</n-card>
<n-alert
v-if="redirectResult.error"
type="error"
:bordered="false"
show-icon
>
{{ redirectResult.error }}
</n-alert>
</n-card>
<c-alert v-if="error">
{{ error }}
</c-alert>
</n-tab-pane>
</n-tabs>
</div>
</template>
+14
View File
@@ -0,0 +1,14 @@
import { ShieldCheck } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'HTTPS Tester',
path: '/https-tester',
description: 'Validate HTTPS certificate, HSTS and 302 redirection',
keywords: ['https', 'hsts', 'redirection', 'certificate', 'tester'],
component: () => import('./https-tester.vue'),
icon: ShieldCheck,
createdAt: new Date('2026-05-11'),
category: 'Forensic',
externAccessDescription: 'This tool calls your Self Host Network Utilities Service to perform HTTPS/HSTS related tasks.',
});
+15
View File
@@ -0,0 +1,15 @@
import { Braces } from '@vicons/tabler';
import { defineTool } from '../tool';
import { translate as t } from '@/plugins/i18n.plugin';
export const tool = defineTool({
name: t('tools.json-to-env.title'),
path: '/json-to-env',
description: t('tools.json-to-env.description'),
keywords: ['json', 'to', 'env', 'dotenv', 'convert', 'environment', 'variables'],
component: () => import('./json-to-env.vue'),
icon: Braces,
createdAt: new Date('2026-04-17'),
npmPackages: ['json5'],
category: 'JSON',
});
@@ -0,0 +1,27 @@
import { expect, test } from '@playwright/test';
test.describe('Tool - JSON to .env', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/json-to-env');
});
test('Has correct title', async ({ page }) => {
await expect(page).toHaveTitle('JSON to .env - IT Tools');
});
test('Provided JSON is converted to .env', async ({ page }) => {
await page.getByTestId('input').fill(`{
"ACCESS_KEY": "mySecretAccessKey",
"AMQP_DNS": "amqp://a:b@rabbit/po",
"APP_ENV": "prod"
}`);
const generated = await page.getByTestId('area-content').innerText();
expect(generated.trim()).toEqual(
`ACCESS_KEY=mySecretAccessKey
AMQP_DNS=amqp://a:b@rabbit/po
APP_ENV=prod`.trim(),
);
});
});
@@ -0,0 +1,82 @@
import { describe, expect, it } from 'vitest';
import { convertJsonToEnv } from './json-to-env.service';
describe('json-to-env service', () => {
describe('convertJsonToEnv', () => {
it('converts a flat JSON object to .env lines', () => {
const json = JSON.stringify({
ACCESS_KEY: 'mySecretAccessKey',
APP_ENV: 'prod',
});
expect(convertJsonToEnv({ json })).toMatchInlineSnapshot(`
"ACCESS_KEY=mySecretAccessKey
APP_ENV=prod"
`);
});
it('uppercases keys by default', () => {
expect(convertJsonToEnv({ json: '{"app_env": "prod"}' })).toBe('APP_ENV=prod');
});
it('keeps original case when uppercaseKeys is false', () => {
expect(convertJsonToEnv({ json: '{"appEnv": "prod"}', uppercaseKeys: false })).toBe('appEnv=prod');
});
it('quotes values that contain spaces', () => {
expect(convertJsonToEnv({ json: '{"greeting": "hello world"}' })).toBe('GREETING="hello world"');
});
it('quotes values that contain double quotes and escapes them', () => {
expect(convertJsonToEnv({ json: '{"q": "he said \\"hi\\""}' })).toBe('Q="he said \\"hi\\""');
});
it('quotes values that contain # so they are not read as comments', () => {
expect(convertJsonToEnv({ json: '{"color": "#ff0000"}' })).toBe('COLOR="#ff0000"');
});
it('quotes empty string values', () => {
expect(convertJsonToEnv({ json: '{"empty": ""}' })).toBe('EMPTY=""');
});
it('converts null and undefined to empty values', () => {
expect(convertJsonToEnv({ json: '{"a": null}' })).toBe('A=""');
});
it('stringifies numbers and booleans', () => {
expect(convertJsonToEnv({ json: '{"port": 8080, "debug": true}' })).toMatchInlineSnapshot(`
"PORT=8080
DEBUG=true"
`);
});
it('serializes nested objects and arrays as JSON strings', () => {
const result = convertJsonToEnv({ json: '{"list": [1, 2, 3], "obj": {"a": 1}}' });
expect(result).toMatchInlineSnapshot(`
"LIST=\\"[1,2,3]\\"
OBJ=\\"{\\\\\\"a\\\\\\":1}\\""
`);
});
it('escapes newlines in values', () => {
expect(convertJsonToEnv({ json: '{"multi": "line1\\nline2"}' })).toBe('MULTI="line1\\nline2"');
});
it('returns empty string on empty input', () => {
expect(convertJsonToEnv({ json: '' })).toBe('');
expect(convertJsonToEnv({ json: ' ' })).toBe('');
});
it('throws when JSON is an array', () => {
expect(() => convertJsonToEnv({ json: '[1, 2, 3]' })).toThrow();
});
it('throws when JSON is a primitive', () => {
expect(() => convertJsonToEnv({ json: '"just a string"' })).toThrow();
});
it('throws on invalid JSON', () => {
expect(() => convertJsonToEnv({ json: '{not json}' })).toThrow();
});
});
});
@@ -0,0 +1,49 @@
import JSON5 from 'json5';
export { convertJsonToEnv };
function serializeValue(value: unknown): { value: string; forceQuote: boolean } {
if (value === null || value === undefined) {
return { value: '', forceQuote: true };
}
if (typeof value === 'object') {
return { value: JSON.stringify(value), forceQuote: true };
}
return { value: String(value), forceQuote: false };
}
function formatEnvValue({ value, forceQuote }: { value: string; forceQuote: boolean }): string {
const needsQuoting = forceQuote || value === '' || /[\s"'#`$\\]/.test(value);
if (!needsQuoting) {
return value;
}
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n').replace(/\r/g, '\\r');
return `"${escaped}"`;
}
function convertJsonToEnv({ json, uppercaseKeys = true }: { json: string; uppercaseKeys?: boolean }): string {
const trimmed = json.trim();
if (trimmed === '') {
return '';
}
const parsed = JSON5.parse(trimmed);
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
throw new TypeError('JSON must be an object, not an array or primitive.');
}
return Object.entries(parsed)
.map(([key, value]) => {
const envKey = uppercaseKeys ? key.toUpperCase() : key;
const envValue = formatEnvValue(serializeValue(value));
return `${envKey}=${envValue}`;
})
.join('\n');
}
+46
View File
@@ -0,0 +1,46 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import JSON5 from 'json5';
import { convertJsonToEnv } from './json-to-env.service';
import type { UseValidationRule } from '@/composable/validation';
import { withDefaultOnError } from '@/utils/defaults';
const { t } = useI18n();
const defaultValue = '{\n "ACCESS_KEY": "mySecretAccessKey",\n "AMQP_DNS": "amqp://a:b@rabbit/po",\n "APP_ENV": "prod"\n}';
function transformer(value: string) {
return withDefaultOnError(() => {
if (value === '') {
return '';
}
return convertJsonToEnv({ json: value });
}, '');
}
const rules: UseValidationRule<string>[] = [
{
validator: (v: string) => {
if (v === '') {
return true;
}
const parsed = JSON5.parse(v);
return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed);
},
message: t('tools.json-to-env.texts.message-provided-json-is-not-a-valid-flat-object'),
},
];
</script>
<template>
<format-transformer
:input-label="t('tools.json-to-env.texts.input-label-your-json')"
:input-default="defaultValue"
:input-placeholder="t('tools.json-to-env.texts.input-placeholder-paste-your-json-here')"
:output-label="t('tools.json-to-env.texts.output-label-env-from-your-json')"
output-language="bash"
:input-validation-rules="rules"
:transformer="transformer"
download-file-name=".env"
/>
</template>
@@ -17,7 +17,7 @@ async function onVerifyClicked(uploadedFile: File) {
status.value = 'loading';
try {
const { signatures: parsedSignatures } = verifyPDF(fileBuffer);
signatures.value = parsedSignatures;
signatures.value = parsedSignatures || [];
status.value = 'parsed';
}
catch (e) {
+13
View File
@@ -0,0 +1,13 @@
import { Command } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Powershell Cheatsheet',
path: '/powershell-memo',
description: 'Powershell is a powerful scripting language and command-line shell designed for system administration and automation. It provides a wide range of cmdlets and features that allow users to manage and automate tasks on Windows systems efficiently.',
keywords: ['powershell', 'memo', 'cheatsheet', 'shell'],
component: () => import('./powershell-memo.vue'),
icon: Command,
createdAt: new Date('2026-05-11'),
category: 'Cheatsheets',
});
@@ -0,0 +1,220 @@
## Variables
| Syntax | Description |
|-------|-------------|
| `$var = "string"` | Assign variable |
| `[Type]$var="typedVar"` | Assign strong typed variable |
| `[ValidateRange(1,9)][int]$x=1` | Strong typed attribute‑controlled variable |
| `$a,$b,$c = 0` or `$a,$b = 'a','b'` | Assign multiple variables |
| `$a,$b = $b,$a` | Flip variables |
| *Scopes* | global, local, private, script |
| `$global:var = "var"` | Assign global scoped variable |
## Arrays
| Syntax | Description |
|--------|-------------|
| `"a","b","c"` | Array of strings |
| `@()` | Empty array |
| `1,(2,3),4` | Array within array |
| `,"hi"` | Array of one element |
| `$arr[5]` | Sixth element |
| `$arr[2..20]` | Elements 3–21 |
| `$arr[-1]` | Last element |
| `$arr[-3..-1]` | Last three elements |
| `$arr[1,4+6..9]` | Elements at positions 1,4,6–9 |
| `@(Get-Process)` | Force result to array |
| `$arr[($arr.length-1)..0]` | Reverse array |
| `$arr[1] += 200` | Add to existing item |
| `$b = $arr[0,1 + 3..6]` | New array from elements |
| `$z = $arrA + $arrB` | Combine arrays |
## Hash Tables (Associative Arrays)
| Syntax | Description |
|--------|-------------|
| `$hash = @{}` | Empty hash table |
| `@{foo=1; bar='value2'}` | Initialize hash |
| `[ordered]@{a=1; b=2; c=3}` | Ordered dictionary |
| `$hash.key1 = 1` | Assign value |
| `$hash.key1` | Get value |
| `$hash["key1"]` | Get value |
| `$hash.GetEnumerator \| sort Key` | Sort by key |
| `[pscustomobject]@{x=1;z="z"}` | Custom object |
## Strings
| Syntax | Description |
|--------|-------------|
| `"$var expand"` | Expand variables |
| `'$var no expand'` | No expansion |
| `@" ... "@` | Here‑string (double quotes allow expressions) |
## Comments & Escape Characters
| Syntax | Description |
|--------|-------------|
| `# Comment` | Comment |
| `<# comment #>` | Multiline comment |
| `"A '\"test`\""` | Escape `'` |
| `` `t `` | Tab |
| `` `n `` | New line |
| `` ` `` | Line continuation |
## Basics of Text & Files
| Command | Description |
|---------|-------------|
| `Get-Location` | Current directory |
| `Set-Location` | Change directory |
| `Get-Content` | Read file |
| `Add-Content` | Append |
| `Set-Content` | Overwrite |
| `Out-File` | Formatted output |
| `Out-Null` | Discard output |
| `Out-String` | Convert to string |
| `Copy-Item` | Copy |
| `Remove-Item` | Delete |
| `Move-Item` | Move |
| `Rename-Item` | Rename |
| `Set-Item` | Set file contents |
| `Clear-Item` | Clear file |
| `New-Item` | New file/dir |
## Flow Control
| Syntax | Description |
|--------|-------------|
| `If($x -eq 5){ } elseif($x -gt 5){ } else{ }` | If |
| `$x=1; while($x -lt 10){$x;$x++}` | While |
| `for($i=0; $i -lt 10; $i++){ $i }` | For |
| `foreach($file in dir C:\){$file.Name}` | Foreach |
| `1..10 \| foreach{$_}` | Foreach pipeline |
| `Switch -options (...) { Pattern { } Default { } }` | Switch |
## Operators
### Assignment, Logical, Comparison
| Syntax | Description |
|--------|-------------|
| `= += == *= /= %= ++ --` | Assignment |
| `-and -or -xor -not !` | Logical |
| `-eq -ne` | Equal / not equal |
| `-gt -ge` | Greater than / ≥ |
| `-lt -le` | Less than / ≤ |
| `-replace` | Replace text |
| `-match -notmatch` | Regex |
| `-like -notlike` | Wildcards |
| `-contains -notcontains` | Array contains |
| `-in -notin` | Reverse contains |
## Other Operators
| Syntax | Description |
|--------|-------------|
| `-split` | Split string |
| `-join` | Join strings |
| `..` | Range |
| `-is -isnot` | Type check |
| `-as` | Cast |
| `-f` | Format strings |
| `[type]` | Cast operator |
| `$( )` | Subexpression |
| `@()` | Array subexpression |
| `&` | Invocation |
## Objects
| Syntax | Description |
|--------|-------------|
| `(Get-Date).Date` | Date property |
| `Get-Date \| Get-Member` | List members |
| `[DateTime]::Now` | Static property |
| `"string".ToUpper()` | Method call |
| `[system.Net.Dns]::GetHostByAddress("127.0.0.1")` | Static method |
| `new-object -com excel.application` | Excel COM object |
## Filter, Sort, Group, Format
| Command | Description |
|---------|-------------|
| `dir C:\pub \| where LastWriteTime -gt (Get-Date).AddDays(-1)` | Files modified yesterday |
| `ps \| where { $_.path -like "C:\windows\system32*" -and $_.company -notlike "Microsoft*" }` | Filter processes |
| `ps Explorer \| select ProcessName -ExpandProperty Modules \| format-list` | Expand modules |
| `ps \| sort WorkingSet \| select -Last 5` | Top 5 memory |
| `"a","b","a" \| select -Unique` | Unique values |
| `Get-Service \| Group-Object Status` | Group by status |
| `dir \| Group-Object { $_.Length -gt 100KB }` | Group by size |
| `Get-Content pcs.txt \| Select-String "q-" \| sls "win7"` | Search text |
| `ps \| Format-Table Name,StartTime -AutoSize` | Format table |
| `ps \| Format-Table ProcessName, @{Label="Total Run Time"; Expression={(Get-Date)-$_.StartTime}}` | Custom column |
| `Get-EventLog -Log System \| select -First 5 \| ft -wrap` | First 5 events |
| `gi C:\Users \| fl *` | All properties |
| `"{0}``t{1}``n" -f $a,5` | Format operator |
## Common Commands
- `Get-EventLog`
- `Get-WinEvent`
- `Get-CimInstance`
- `Get-Date`
- `Start-Sleep`
- `Compare-Object`
- `Start-Job`
- `Get-Credential`
- `Test-Connection`
- `New-PSSession`
- `Test-Path`
- `Split-Path`
## Importing, Exporting, Converting
- `Export-Clixml`
- `Import-Clixml`
- `ConvertTo-Xml`
- `ConvertTo-Html`
- `Export-Csv`
- `Import-Csv`
- `ConvertTo-Csv`
- `ConvertFrom-Csv`
## Automatic Variables
| Variable | Description |
|----------|-------------|
| `$_` / `$PSItem` | Pipeline object |
| `$Args` | Script args |
| `$Error` | Errors |
| `$True` / `$False` | Boolean |
| `$null` | Null |
| `$profile` | Profile paths |
## PSDrives
| Drive | Description |
|-------|-------------|
| `Alias:` | Aliases |
| `Cert:` | Certificates |
| `Env:` | Environment variables |
| `Function:` | Functions |
| `HKLM:` | Registry (Local Machine) |
| `HKCU:` | Registry (Current User) |
| `Variable:` | Variables |
| `WSMan:` | WinRM |
| `AD:` | Active Directory |
| `Set-Location HKLM:` | Navigate registry |
| `gci variable:` | List variables |
## Regular Expressions
| Pattern | Meaning |
|---------|---------|
| `\w` | Word char `[a-zA-Z0-9]` |
| `\W` | Non‑word char |
| `\s` | Whitespace |
| `\S` | Non‑whitespace |
| `\d` / `\D` | Digit / non‑digit |
| `{n} {n,} {n,m}` | Quantifiers |
| More | Google .NET Regex |
@@ -0,0 +1,32 @@
<script setup lang="ts">
import { useThemeVars } from 'naive-ui';
import Memo from './powershell-memo.content.md';
const themeVars = useThemeVars();
</script>
<template>
<div>
<Memo />
</div>
</template>
<style lang="less" scoped>
::v-deep(pre) {
margin: 0;
padding: 15px 22px;
background-color: v-bind('themeVars.cardColor');
border-radius: 4px;
overflow: auto;
}
::v-deep(table) {
border-collapse: collapse;
}
::v-deep(table), ::v-deep(td), ::v-deep(th) {
border: 1px solid v-bind('themeVars.textColor1');
padding: 5px;
}
::v-deep(a) {
color: v-bind('themeVars.textColor1');
}
</style>
+14
View File
@@ -0,0 +1,14 @@
import { ArrowsShuffle } from '@vicons/tabler';
import { defineTool } from '../tool';
import { translate as t } from '@/plugins/i18n.plugin';
export const tool = defineTool({
name: t('tools.random-line-picker.title'),
path: '/random-line-picker',
description: t('tools.random-line-picker.description'),
keywords: ['text', 'random', 'line', 'picker', 'shuffle'],
component: () => import('./random-line-picker.vue'),
icon: ArrowsShuffle,
createdAt: new Date('2026-05-08'),
category: 'Text',
});
@@ -0,0 +1,27 @@
import { expect, test } from '@playwright/test';
test.describe('Tool - Random Line Picker', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/random-line-picker');
await expect(page.getByTestId('input')).toBeVisible();
await expect(page.getByTestId('count')).toBeVisible();
});
test('Has correct title', async ({ page }) => {
await expect(page).toHaveTitle('Random Line Picker - IT Tools');
});
test('Picks random lines without repeats', async ({ page }) => {
await page.getByTestId('input').fill('one\ntwo\nthree\nfour');
const countInput = page.getByTestId('count').locator('input');
await countInput.fill('2');
await countInput.press('Enter');
const picked = (await page.getByTestId('output').inputValue()).split('\n');
expect(picked.length).toBe(2);
expect(new Set(picked).size).toBe(2);
});
});
@@ -0,0 +1,73 @@
import { describe, expect, it } from 'vitest';
import { getLines, pickLines } from './random-line-picker.models';
import type { Config } from './random-line-picker.types';
describe('random-line-picker', () => {
describe('getLines', () => {
it('should split input into lines', () => {
const config: Config = { input: 'a\nb\nc', count: 1, repeat: false, prefix: false };
expect(getLines(config)).toEqual(['a', 'b', 'c']);
});
it('should return an empty array for empty input', () => {
const config: Config = { input: '', count: 1, repeat: false, prefix: false };
expect(getLines(config)).toEqual([]);
});
});
describe('pickLines', () => {
it('should return the correct number of lines', () => {
const config: Config = { input: 'a\nb\nc\nd\ne', count: 3, repeat: false, prefix: false };
const result = pickLines(config).split('\n');
expect(result).toHaveLength(3);
});
it('should not exceed the number of available lines when repeat is false', () => {
const config: Config = { input: 'a\nb\nc', count: 10, repeat: false, prefix: false };
const result = pickLines(config).split('\n');
expect(result).toHaveLength(3);
});
it('should allow picking more lines than available when repeat is true', () => {
const config: Config = { input: 'a\nb', count: 5, repeat: true, prefix: false };
const result = pickLines(config).split('\n');
expect(result).toHaveLength(5);
});
it('should only return lines from the input', () => {
const config: Config = { input: 'foo\nbar\nbaz', count: 3, repeat: false, prefix: false };
const result = pickLines(config).split('\n');
expect(result.every(line => ['foo', 'bar', 'baz'].includes(line))).toBe(true);
});
it('should not repeat lines when repeat is false', () => {
const config: Config = { input: 'a\nb\nc', count: 3, repeat: false, prefix: false };
const result = pickLines(config).split('\n');
expect(new Set(result).size).toBe(result.length);
});
it('should add numeric prefix when prefix is true', () => {
const config: Config = { input: 'a\nb\nc', count: 3, repeat: false, prefix: true };
const result = pickLines(config).split('\n');
expect(result[0]).toMatch(/^1\. /);
expect(result[1]).toMatch(/^2\. /);
expect(result[2]).toMatch(/^3\. /);
});
it('should not add prefix when prefix is false', () => {
const config: Config = { input: 'a\nb\nc', count: 3, repeat: false, prefix: false };
const result = pickLines(config).split('\n');
expect(result.every(line => !/^\d+\. /.test(line))).toBe(true);
});
it('should return an empty string for empty input', () => {
const config: Config = { input: '', count: 3, repeat: false, prefix: false };
expect(pickLines(config)).toBe('');
});
it('should return a single line when count is 1', () => {
const config: Config = { input: 'only', count: 1, repeat: false, prefix: false };
expect(pickLines(config)).toBe('only');
});
});
});
@@ -0,0 +1,24 @@
import type { Config } from './random-line-picker.types';
function getRandomInt(min: number, max: number) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
export function getLines(config: Config) {
return config.input ? config.input.split(/\n/) : [];
}
export function pickLines(config: Config) {
const lines = getLines(config);
const length = config.repeat ? config.count : Math.min(config.count, lines.length);
return Array.from({ length }, (_, i) => {
const index = getRandomInt(0, lines.length - 1);
const line = config.repeat ? lines[index] : lines.splice(index, 1)[0];
return line && config.prefix ? `${i + 1}. ${line}` : line;
}).join('\n');
}
@@ -0,0 +1,6 @@
export interface Config {
input: string
count: number
repeat: boolean
prefix: boolean
}
@@ -0,0 +1,75 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { computedRefreshable } from '@/composable/computedRefreshable';
import { useCopy } from '@/composable/copy';
import { useStorage } from '@vueuse/core';
import { getLines, pickLines } from './random-line-picker.models';
const { t } = useI18n();
const config = useStorage('random-line-picker:config', {
input: '',
count: 1,
repeat: false,
prefix: false,
});
const [pickedLines, refreshPickedLines] = computedRefreshable(() => pickLines(config.value));
const { copy } = useCopy({ source: pickedLines, text: t('tools.random-line-picker.texts.text-picked-lines-copied-to-clipboard') });
const maxCount = ref<number | undefined>(undefined);
watch([() => config.value.repeat, () => config.value.input], () => {
maxCount.value = config.value.repeat ? undefined : getLines(config.value).length;
if (!config.value.repeat && maxCount.value && config.value.count > maxCount.value) {
config.value.count = maxCount.value;
}
}, { immediate: true });
</script>
<template>
<div>
<c-card>
<c-input-text v-model:value="config.input" test-id="input" multiline :placeholder="t('tools.random-line-picker.texts.placeholder-put-your-text-here')" rows="10" />
<n-space mt-5>
<n-form-item :label="t('tools.random-line-picker.texts.label-number-of-lines-to-pick')" label-placement="left">
<n-input-number-i18n v-model:value="config.count" data-test-id="count" min="1" :max="maxCount" size="small" />
</n-form-item>
<n-form-item :label="t('tools.random-line-picker.texts.label-allow-repeated-lines')" label-placement="left">
<n-switch v-model:value="config.repeat" />
</n-form-item>
<n-form-item :label="t('tools.random-line-picker.texts.label-prefix-lines-with-line-number')" label-placement="left">
<n-switch v-model:value="config.prefix" />
</n-form-item>
</n-space>
</c-card>
<c-card mt-5>
<c-input-text
v-model:value="pickedLines"
test-id="output"
multiline
:placeholder="t('tools.random-line-picker.texts.placeholder-picked-lines')"
readonly
rows="3"
autosize
class="passphrase-display"
word-wrap
/>
<div mt-5 flex justify-center gap-3>
<c-button @click="copy()">
{{ t('tools.random-line-picker.texts.tag-copy') }}
</c-button>
<c-button @click="refreshPickedLines">
{{ t('tools.random-line-picker.texts.tag-refresh') }}
</c-button>
</div>
</c-card>
</div>
</template>
@@ -1,10 +1,11 @@
import { translate as t } from '@/plugins/i18n.plugin';
import { SunOff } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Shutdown Command Generator',
name: t('tools.shutdown-command-generator.title'),
path: '/shutdown-command-generator',
description: 'Generate shutdown command for various OS',
description: t('tools.shutdown-command-generator.description'),
keywords: ['shutdown', 'command'],
component: () => import('./shutdown-command-generator.vue'),
icon: SunOff,
@@ -1,4 +1,7 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
type Platform = 'windows' | 'linux' | 'macos';
type Mode = 'delay' | 'time';
@@ -22,14 +25,14 @@ const cancel = ref(false);
const hibernate = ref(false);
const platformOptions = [
{ label: 'Windows', value: 'windows' },
{ label: 'Linux', value: 'linux' },
{ label: 'macOS', value: 'macos' },
{ label: t('tools.shutdown-command-generator.texts.label-windows'), value: 'windows' },
{ label: t('tools.shutdown-command-generator.texts.label-linux'), value: 'linux' },
{ label: t('tools.shutdown-command-generator.texts.label-macos'), value: 'macos' },
];
const modeOptions = [
{ label: 'Delay', value: 'delay' },
{ label: 'Specific Time', value: 'time' },
{ label: t('tools.shutdown-command-generator.texts.label-delay'), value: 'delay' },
{ label: t('tools.shutdown-command-generator.texts.label-specific-time'), value: 'time' },
];
// --- Command Builders -------------------------------------------------------
@@ -167,7 +170,7 @@ const command = computed(() => {
<c-select
v-model:value="platform"
:options="platformOptions"
label="Platform:"
:label="t('tools.shutdown-command-generator.texts.label-platform')"
label-position="left"
mb-1
/>
@@ -185,27 +188,22 @@ const command = computed(() => {
</NSpace>
<NSpace v-if="mode === 'delay'" justify="center" mb-1>
<NFormItem label="Delay:" label-placement="left" mb-1>
<NFormItem :label="t('tools.shutdown-command-generator.texts.label-delay')" label-placement="left" mb-1>
<NInputNumber
v-model:value="delayHours"
:min="0"
/>
&nbsp;h&nbsp;
<NInputNumber
/>{{ t('tools.shutdown-command-generator.texts.tag-nbsp-h-nbsp') }}<NInputNumber
v-model:value="delayMinutes"
:min="0"
/>
&nbsp;m&nbsp;
<NInputNumber
/>{{ t('tools.shutdown-command-generator.texts.tag-nbsp-m-nbsp') }}<NInputNumber
v-model:value="delaySeconds"
:min="0"
/>
&nbsp;s
/>{{ t('tools.shutdown-command-generator.texts.tag-nbsp-s') }}
</NFormItem>
</NSpace>
<NSpace v-if="mode === 'time'" justify="center" mb-1>
<NFormItem label="Shutdown time:" label-placement="left">
<NFormItem :label="t('tools.shutdown-command-generator.texts.label-shutdown-time')" label-placement="left">
<NDatePicker
v-model:value="timeValue"
type="datetime"
@@ -214,14 +212,14 @@ const command = computed(() => {
</NSpace>
<NSpace justify="center" mb-1>
<NCheckbox v-model:checked="force" label="Force" />
<NCheckbox v-model:checked="reboot" label="Reboot" />
<NCheckbox v-model:checked="logoff" label="Logoff" />
<NCheckbox v-model:checked="cancel" label="Cancel" />
<NCheckbox v-model:checked="hibernate" label="Hibernate" />
<NCheckbox v-model:checked="force" :label="t('tools.shutdown-command-generator.texts.label-force')" />
<NCheckbox v-model:checked="reboot" :label="t('tools.shutdown-command-generator.texts.label-reboot')" />
<NCheckbox v-model:checked="logoff" :label="t('tools.shutdown-command-generator.texts.label-logoff')" />
<NCheckbox v-model:checked="cancel" :label="t('tools.shutdown-command-generator.texts.label-cancel')" />
<NCheckbox v-model:checked="hibernate" :label="t('tools.shutdown-command-generator.texts.label-hibernate')" />
</NSpace>
<c-card title="Generated command">
<c-card :title="t('tools.shutdown-command-generator.texts.title-generated-command')">
<textarea-copyable :value="command" language="bash" />
</c-card>
</div>
@@ -4,10 +4,10 @@ import UnitsConverter from '@/components/UnitsConverter.vue';
const supportedUnits = {
'm/s': 'meter per second',
'km/h': 'kilometer per hour',
'm/h': 'meter per hour',
'mi/h': 'miles per hour',
'knot': 'knot',
'ft/s': 'feet per second',
}; ;
};
</script>
<template>
+17 -13
View File
@@ -1,4 +1,8 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
const billAmount = ref<number>();
const tipPercentage = ref<number>(15);
const numberOfPeople = ref<number>(1);
@@ -35,33 +39,33 @@ const amountPerPersonFormatted = computed(() => formatCurrency(amountPerPerson.v
<template>
<div style="margin: 0 auto; max-width: 600px">
<c-card mb-3 title="Bill Details">
<c-card mb-3 :title="t('tools.tip-calculator.texts.title-bill-details')">
<n-form label-placement="left" label-width="150px" label-align="left">
<n-form-item label="Bill Amount:">
<n-input-number v-model:value="billAmount" :min="0" placeholder="Total Bill" />
<n-form-item :label="t('tools.tip-calculator.texts.label-bill-amount')">
<n-input-number v-model:value="billAmount" :min="0" :placeholder="t('tools.tip-calculator.texts.placeholder-total-bill')" />
</n-form-item>
<n-form-item label="Tip Percentage:">
<n-input-number v-model:value="tipPercentage" :min="0" placeholder="Tip %">
<n-form-item :label="t('tools.tip-calculator.texts.label-tip-percentage')">
<n-input-number v-model:value="tipPercentage" :min="0" :placeholder="t('tools.tip-calculator.texts.placeholder-tip')">
<template #suffix>
%
{{ t('tools.tip-calculator.texts.tag-') }}
</template>
</n-input-number>
</n-form-item>
<n-form-item label="Number of person:">
<n-input-number v-model:value="numberOfPeople" :min="1" placeholder="People" />
<n-form-item :label="t('tools.tip-calculator.texts.label-number-of-person')">
<n-input-number v-model:value="numberOfPeople" :min="1" :placeholder="t('tools.tip-calculator.texts.placeholder-people')" />
</n-form-item>
</n-form>
</c-card>
<c-card mb-3 title="Results">
<input-copyable label="Tip Amount:" :value="tipAmountFormatted" readonly label-position="left" label-width="150px" mb-1 />
<input-copyable label="Total Bill:" :value="totalAmountFormatted" readonly label-position="left" label-width="150px" mb-1 />
<input-copyable label="Amount Per Person:" :value="amountPerPersonFormatted" readonly label-position="left" label-width="150px" mb-1 />
<c-card mb-3 :title="t('tools.tip-calculator.texts.title-results')">
<input-copyable :label="t('tools.tip-calculator.texts.label-tip-amount')" :value="tipAmountFormatted" readonly label-position="left" label-width="150px" mb-1 />
<input-copyable :label="t('tools.tip-calculator.texts.label-total-bill')" :value="totalAmountFormatted" readonly label-position="left" label-width="150px" mb-1 />
<input-copyable :label="t('tools.tip-calculator.texts.label-amount-per-person')" :value="amountPerPersonFormatted" readonly label-position="left" label-width="150px" mb-1 />
</c-card>
<c-card title="Quick Tip %">
<c-card :title="t('tools.tip-calculator.texts.title-quick-tip')">
<n-space justify="center">
<n-button v-for="tip in [10, 15, 18, 20, 25]" :key="tip" size="small" @click="tipPercentage = tip">
{{ tip }}%
+19 -2
View File
@@ -13,6 +13,8 @@ const versions = ['NIL', 'v1', 'v3', 'v4', 'v5', 'v6', 'v7'] as const;
const version = useQueryParamOrStorage<typeof versions[number]>({ name: 'version', storageName: 'uuid-generator:version', defaultValue: 'v4' });
const count = useQueryParamOrStorage({ name: 'amount', storageName: 'uuid-generator:quantity', defaultValue: 1 });
const bare = useQueryParamOrStorage({ name: 'bare', storageName: 'uuid-generator:bare', defaultValue: false });
const upperCase = useQueryParamOrStorage({ name: 'upper', storageName: 'uuid-generator:upper', defaultValue: false });
const v35Args = ref({ namespace: '6ba7b811-9dad-11d1-80b4-00c04fd430c8', name: '' });
const validUuidRules = [
@@ -46,7 +48,13 @@ const generators = {
const [uuids, refreshUUIDs] = computedRefreshable(() => withDefaultOnError(() =>
Array.from({ length: count.value }, (_ignored, index) => {
const generator = generators[version.value] ?? generators.NIL;
return generator(index);
let uuid = generator(index);
if (bare.value) {
uuid = uuid.replace(/-/g, '');
}
return upperCase.value ? uuid.toUpperCase() : uuid.toLowerCase();
}).join('\n'), ''));
const { copy } = useCopy({ source: uuids, text: t('tools.uuid-generator.texts.text-uuids-copied-to-the-clipboard') });
@@ -61,7 +69,7 @@ const { copy } = useCopy({ source: uuids, text: t('tools.uuid-generator.texts.te
<n-input-number-i18n v-model:value="count" flex-1 :min="1" :max="50" :placeholder="t('tools.uuid-generator.texts.placeholder-uuid-quantity')" />
</div>
<div v-if="version === 'v3' || version === 'v5'">
<div v-if="version === 'v3' || version === 'v5'" mb-2>
<div>
<c-buttons-select
v-model:value="v35Args.namespace"
@@ -98,6 +106,15 @@ const { copy } = useCopy({ source: uuids, text: t('tools.uuid-generator.texts.te
/>
</div>
<n-space justify="center" mb-2>
<n-checkbox v-model:checked="upperCase">
{{ $t('tools.uuid-generator.texts.uppercase') }}
</n-checkbox>
<n-checkbox v-model:checked="bare">
{{ $t('tools.uuid-generator.texts.no-hyphen') }}
</n-checkbox>
</n-space>
<c-input-text
style="text-align: center; font-family: monospace"
:value="uuids"
@@ -5,6 +5,7 @@ import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { withDefaultOnErrorAsync } from '@/utils/defaults';
import { computedRefreshableAsync } from '@/composable/computedRefreshable';
import { useValidation } from '@/composable/validation';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
@@ -29,6 +30,17 @@ const country = ref('France');
const contactEmail = ref('');
const subjectAlternativeNames = ref('');
const emptyCSR = { certificatePem: '', privateKeyPem: '', publicKeyPem: '', fingerprint: '' };
const bits = useQueryParamOrStorage({ name: 'bits', storageName: 'cert-gen:b', defaultValue: 2048 });
const { attrs: bitsValidationAttrs } = useValidation({
source: bits,
rules: [
{
message: t('tools.csr-generator.texts.bits-should-be-256-less-than-bits-less-than-16384-and-be-a-multiple-of-8'),
validator: value => value >= 256 && value <= 16384 && value % 8 === 0,
},
],
});
const [certs, refreshCerts] = computedRefreshableAsync(
() => withDefaultOnErrorAsync(() => {
@@ -38,6 +50,7 @@ const [certs, refreshCerts] = computedRefreshableAsync(
return generateSSLCertificate({
password: password.value,
bits: bits.value,
commonName: commonName.value,
countryName: country.value,
city: city.value,
@@ -181,6 +194,12 @@ const [certs, refreshCerts] = computedRefreshableAsync(
</n-form-item>
</div>
<div>
<n-form-item :label="t('tools.x509-certificate-generator.texts.rsa-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>
</div>
<div flex justify-center>
<c-button @click="refreshCerts">
{{ t('tools.x509-certificate-generator.texts.tag-refresh-certificate') }}
+7 -6
View File
@@ -193,10 +193,11 @@ export default defineConfig({
},
},
},
server: {
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
},
},
// server: {
// headers: {
// 'Cross-Origin-Resource-Policy': 'same-site',
// 'Cross-Origin-Opener-Policy': 'same-origin',
// 'Cross-Origin-Embedder-Policy': 'require-corp',
// },
// },
});