mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-08-20 13:47:46 +02:00
V2 remove cert (#4239)
# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details.
This commit is contained in:
parent
f1cb8ce5b3
commit
d74c3f4598
@ -1268,7 +1268,18 @@
|
|||||||
"title": "Remove Certificate Signature",
|
"title": "Remove Certificate Signature",
|
||||||
"header": "Remove the digital certificate from the PDF",
|
"header": "Remove the digital certificate from the PDF",
|
||||||
"selectPDF": "Select a PDF file:",
|
"selectPDF": "Select a PDF file:",
|
||||||
"submit": "Remove Signature"
|
"submit": "Remove Signature",
|
||||||
|
"description": "This tool will remove digital certificate signatures from your PDF document.",
|
||||||
|
"filenamePrefix": "unsigned",
|
||||||
|
"files": {
|
||||||
|
"placeholder": "Select a PDF file in the main view to get started"
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"failed": "An error occurred whilst removing certificate signatures."
|
||||||
|
},
|
||||||
|
"results": {
|
||||||
|
"title": "Certificate Removal Results"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"pageLayout": {
|
"pageLayout": {
|
||||||
"tags": "merge,composite,single-view,organize",
|
"tags": "merge,composite,single-view,organize",
|
||||||
|
@ -995,7 +995,18 @@
|
|||||||
"title": "Remove Certificate Signature",
|
"title": "Remove Certificate Signature",
|
||||||
"header": "Remove the digital certificate from the PDF",
|
"header": "Remove the digital certificate from the PDF",
|
||||||
"selectPDF": "Select a PDF file:",
|
"selectPDF": "Select a PDF file:",
|
||||||
"submit": "Remove Signature"
|
"submit": "Remove Signature",
|
||||||
|
"description": "This tool will remove digital certificate signatures from your PDF document.",
|
||||||
|
"filenamePrefix": "unsigned",
|
||||||
|
"files": {
|
||||||
|
"placeholder": "Select a PDF file in the main view to get started"
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"failed": "An error occurred while removing certificate signatures."
|
||||||
|
},
|
||||||
|
"results": {
|
||||||
|
"title": "Certificate Removal Results"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"pageLayout": {
|
"pageLayout": {
|
||||||
"tags": "merge,composite,single-view,organize",
|
"tags": "merge,composite,single-view,organize",
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { RemoveCertificateSignParameters } from '../../../hooks/tools/removeCertificateSign/useRemoveCertificateSignParameters';
|
||||||
|
|
||||||
|
interface RemoveCertificateSignSettingsProps {
|
||||||
|
parameters: RemoveCertificateSignParameters;
|
||||||
|
onParameterChange: <K extends keyof RemoveCertificateSignParameters>(parameter: K, value: RemoveCertificateSignParameters[K]) => void;
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const RemoveCertificateSignSettings: React.FC<RemoveCertificateSignSettingsProps> = ({
|
||||||
|
parameters,
|
||||||
|
onParameterChange, // Unused - kept for interface consistency and future extensibility
|
||||||
|
disabled = false
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="remove-certificate-sign-settings">
|
||||||
|
<p className="text-muted">
|
||||||
|
{t('removeCertSign.description', 'This tool will remove digital certificate signatures from your PDF document.')}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default RemoveCertificateSignSettings;
|
@ -11,6 +11,7 @@ import RemovePassword from '../tools/RemovePassword';
|
|||||||
import { SubcategoryId, ToolCategory, ToolRegistry } from './toolsTaxonomy';
|
import { SubcategoryId, ToolCategory, ToolRegistry } from './toolsTaxonomy';
|
||||||
import AddWatermark from '../tools/AddWatermark';
|
import AddWatermark from '../tools/AddWatermark';
|
||||||
import Repair from '../tools/Repair';
|
import Repair from '../tools/Repair';
|
||||||
|
import RemoveCertificateSign from '../tools/RemoveCertificateSign';
|
||||||
|
|
||||||
// Hook to get the translated tool registry
|
// Hook to get the translated tool registry
|
||||||
export function useFlatToolRegistry(): ToolRegistry {
|
export function useFlatToolRegistry(): ToolRegistry {
|
||||||
@ -323,11 +324,13 @@ export function useFlatToolRegistry(): ToolRegistry {
|
|||||||
"remove-certificate-sign": {
|
"remove-certificate-sign": {
|
||||||
icon: <span className="material-symbols-rounded">remove_moderator</span>,
|
icon: <span className="material-symbols-rounded">remove_moderator</span>,
|
||||||
name: t("home.removeCertSign.title", "Remove Certificate Signatures"),
|
name: t("home.removeCertSign.title", "Remove Certificate Signatures"),
|
||||||
component: null,
|
component: RemoveCertificateSign,
|
||||||
view: "security",
|
view: "security",
|
||||||
description: t("home.removeCertSign.desc", "Remove digital signatures from PDF documents"),
|
description: t("home.removeCertSign.desc", "Remove digital signatures from PDF documents"),
|
||||||
category: ToolCategory.STANDARD_TOOLS,
|
category: ToolCategory.STANDARD_TOOLS,
|
||||||
subcategory: SubcategoryId.REMOVAL
|
subcategory: SubcategoryId.REMOVAL,
|
||||||
|
maxFiles: -1,
|
||||||
|
endpoints: ["remove-certificate-sign"]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useToolOperation } from '../shared/useToolOperation';
|
||||||
|
import { createStandardErrorHandler } from '../../../utils/toolErrorHandler';
|
||||||
|
import { RemoveCertificateSignParameters } from './useRemoveCertificateSignParameters';
|
||||||
|
|
||||||
|
export const useRemoveCertificateSignOperation = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const buildFormData = (parameters: RemoveCertificateSignParameters, file: File): FormData => {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("fileInput", file);
|
||||||
|
return formData;
|
||||||
|
};
|
||||||
|
|
||||||
|
return useToolOperation<RemoveCertificateSignParameters>({
|
||||||
|
operationType: 'removeCertificateSign',
|
||||||
|
endpoint: '/api/v1/security/remove-cert-sign',
|
||||||
|
buildFormData,
|
||||||
|
filePrefix: t('removeCertSign.filenamePrefix', 'unsigned') + '_',
|
||||||
|
multiFileEndpoint: false,
|
||||||
|
getErrorMessage: createStandardErrorHandler(t('removeCertSign.error.failed', 'An error occurred while removing certificate signatures.'))
|
||||||
|
});
|
||||||
|
};
|
@ -0,0 +1,19 @@
|
|||||||
|
import { BaseParameters } from '../../../types/parameters';
|
||||||
|
import { useBaseParameters, BaseParametersHook } from '../shared/useBaseParameters';
|
||||||
|
|
||||||
|
export interface RemoveCertificateSignParameters extends BaseParameters {
|
||||||
|
// Extends BaseParameters - ready for future parameter additions if needed
|
||||||
|
}
|
||||||
|
|
||||||
|
export const defaultParameters: RemoveCertificateSignParameters = {
|
||||||
|
// No parameters needed
|
||||||
|
};
|
||||||
|
|
||||||
|
export type RemoveCertificateSignParametersHook = BaseParametersHook<RemoveCertificateSignParameters>;
|
||||||
|
|
||||||
|
export const useRemoveCertificateSignParameters = (): RemoveCertificateSignParametersHook => {
|
||||||
|
return useBaseParameters({
|
||||||
|
defaultParameters,
|
||||||
|
endpointName: 'remove-certificate-sign',
|
||||||
|
});
|
||||||
|
};
|
80
frontend/src/tools/RemoveCertificateSign.tsx
Normal file
80
frontend/src/tools/RemoveCertificateSign.tsx
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import React, { useEffect } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useEndpointEnabled } from "../hooks/useEndpointConfig";
|
||||||
|
import { useFileContext } from "../contexts/FileContext";
|
||||||
|
import { useToolFileSelection } from "../contexts/FileSelectionContext";
|
||||||
|
|
||||||
|
import { createToolFlow } from "../components/tools/shared/createToolFlow";
|
||||||
|
|
||||||
|
import { useRemoveCertificateSignParameters } from "../hooks/tools/removeCertificateSign/useRemoveCertificateSignParameters";
|
||||||
|
import { useRemoveCertificateSignOperation } from "../hooks/tools/removeCertificateSign/useRemoveCertificateSignOperation";
|
||||||
|
import { BaseToolProps } from "../types/tool";
|
||||||
|
|
||||||
|
const RemoveCertificateSign = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { setCurrentMode } = useFileContext();
|
||||||
|
const { selectedFiles } = useToolFileSelection();
|
||||||
|
|
||||||
|
const removeCertificateSignParams = useRemoveCertificateSignParameters();
|
||||||
|
const removeCertificateSignOperation = useRemoveCertificateSignOperation();
|
||||||
|
|
||||||
|
// Endpoint validation
|
||||||
|
const { enabled: endpointEnabled, loading: endpointLoading } = useEndpointEnabled(removeCertificateSignParams.getEndpointName());
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
removeCertificateSignOperation.resetResults();
|
||||||
|
onPreviewFile?.(null);
|
||||||
|
}, [removeCertificateSignParams.parameters]);
|
||||||
|
|
||||||
|
const handleRemoveSignature = async () => {
|
||||||
|
try {
|
||||||
|
await removeCertificateSignOperation.executeOperation(removeCertificateSignParams.parameters, selectedFiles);
|
||||||
|
if (removeCertificateSignOperation.files && onComplete) {
|
||||||
|
onComplete(removeCertificateSignOperation.files);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (onError) {
|
||||||
|
onError(error instanceof Error ? error.message : t("removeCertSign.error.failed", "Remove certificate signature operation failed"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleThumbnailClick = (file: File) => {
|
||||||
|
onPreviewFile?.(file);
|
||||||
|
sessionStorage.setItem("previousMode", "removeCertificateSign");
|
||||||
|
setCurrentMode("viewer");
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSettingsReset = () => {
|
||||||
|
removeCertificateSignOperation.resetResults();
|
||||||
|
onPreviewFile?.(null);
|
||||||
|
setCurrentMode("removeCertificateSign");
|
||||||
|
};
|
||||||
|
|
||||||
|
const hasFiles = selectedFiles.length > 0;
|
||||||
|
const hasResults = removeCertificateSignOperation.files.length > 0 || removeCertificateSignOperation.downloadUrl !== null;
|
||||||
|
|
||||||
|
return createToolFlow({
|
||||||
|
files: {
|
||||||
|
selectedFiles,
|
||||||
|
isCollapsed: hasFiles || hasResults,
|
||||||
|
placeholder: t("removeCertSign.files.placeholder", "Select a PDF file in the main view to get started"),
|
||||||
|
},
|
||||||
|
steps: [],
|
||||||
|
executeButton: {
|
||||||
|
text: t("removeCertSign.submit", "Remove Signature"),
|
||||||
|
isVisible: !hasResults,
|
||||||
|
loadingText: t("loading"),
|
||||||
|
onClick: handleRemoveSignature,
|
||||||
|
disabled: !removeCertificateSignParams.validateParameters() || !hasFiles || !endpointEnabled,
|
||||||
|
},
|
||||||
|
review: {
|
||||||
|
isVisible: hasResults,
|
||||||
|
operation: removeCertificateSignOperation,
|
||||||
|
title: t("removeCertSign.results.title", "Certificate Removal Results"),
|
||||||
|
onFileClick: handleThumbnailClick,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default RemoveCertificateSign;
|
@ -19,7 +19,8 @@ export type ModeType =
|
|||||||
| 'changePermissions'
|
| 'changePermissions'
|
||||||
| 'watermark'
|
| 'watermark'
|
||||||
| 'removePassword'
|
| 'removePassword'
|
||||||
| 'repair';
|
| 'repair'
|
||||||
|
| 'removeCertificateSign';
|
||||||
|
|
||||||
export type ViewType = 'viewer' | 'pageEditor' | 'fileEditor';
|
export type ViewType = 'viewer' | 'pageEditor' | 'fileEditor';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user