Add electronic signature

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-02-16 23:12:09 +01:00
parent e6f9d7aae2
commit c191d25e9a
58 changed files with 7557 additions and 292 deletions

View File

@@ -217,6 +217,7 @@ const (
subjectTrustCenterAccess = "Compliance Page Access Invitation - %s"
subjectTrustCenterDocumentAccessRejected = "Compliance Page Document Access Rejected - %s"
subjectMagicLink = "Connect to %s"
subjectElectronicSignatureCertificate = "Your signed %s - Certificate of Completion"
)
var (
@@ -238,6 +239,8 @@ var (
trustCenterDocumentAccessRejectedTextTemplate = texttemplate.Must(texttemplate.ParseFS(Templates, "dist/trust-center-document-access-rejected.txt.tmpl"))
magicLinkHTMLTemplate = htmltemplate.Must(htmltemplate.ParseFS(Templates, "dist/magic-link.html.tmpl"))
magicLinkTextTemplate = texttemplate.Must(texttemplate.ParseFS(Templates, "dist/magic-link.txt.tmpl"))
electronicSignatureCertificateHTMLTemplate = htmltemplate.Must(htmltemplate.ParseFS(Templates, "dist/electronic-signature-certificate.html.tmpl"))
electronicSignatureCertificateTextTemplate = texttemplate.Must(texttemplate.ParseFS(Templates, "dist/electronic-signature-certificate.txt.tmpl"))
)
func (p *Presenter) getCommonVariables(ctx context.Context) (*CommonVariables, error) {
@@ -460,6 +463,26 @@ func (p *Presenter) RenderMagicLink(ctx context.Context, magicLinkUrlPath string
return fmt.Sprintf(subjectMagicLink, organizationName), textBody, htmlBody, err
}
func (p *Presenter) RenderElectronicSignatureCertificate(ctx context.Context, signerName string, documentType string) (subject string, textBody string, htmlBody *string, err error) {
vars, err := p.getCommonVariables(ctx)
if err != nil {
return "", "", nil, fmt.Errorf("cannot get common variables: %w", err)
}
data := struct {
*CommonVariables
SignerName string
DocumentType string
}{
CommonVariables: vars,
SignerName: signerName,
DocumentType: documentType,
}
textBody, htmlBody, err = renderEmail(electronicSignatureCertificateTextTemplate, electronicSignatureCertificateHTMLTemplate, data)
return fmt.Sprintf(subjectElectronicSignatureCertificate, documentType), textBody, htmlBody, err
}
func renderEmail(textTemplate *texttemplate.Template, htmlTemplate *htmltemplate.Template, data any) (textBody string, htmlBody *string, err error) {
var textBuf bytes.Buffer
if err := textTemplate.Execute(&textBuf, data); err != nil {

View File

@@ -12,6 +12,7 @@ import Invitation from "../src/Invitation";
import PasswordReset from "../src/PasswordReset";
import TrustCenterAccess from "../src/TrustCenterAccess";
import TrustCenterDocumentAccessRejected from "../src/TrustCenterDocumentAccessRejected";
import ElectronicSignatureCertificate from "../src/ElectronicSignatureCertificate";
import MagicLink from "../src/MagicLink";
const __filename = fileURLToPath(import.meta.url);
@@ -59,6 +60,10 @@ const templates: TemplateConfig[] = [
name: "magic-link",
render: () => MagicLink(),
},
{
name: "electronic-signature-certificate",
render: () => ElectronicSignatureCertificate(),
},
];
async function build() {

View File

@@ -0,0 +1,31 @@
import { Text } from "@react-email/components";
import * as React from "react";
import EmailLayout, {
bodyText,
footerText,
} from "./components/EmailLayout";
export const ElectronicSignatureCertificate = () => {
return (
<EmailLayout
subject={`Your signed ${"{{.DocumentType}}"} — Certificate of Completion`}
>
<Text style={bodyText}>
Your <strong>{"{{.DocumentType}}"}</strong> has been signed
electronically. A Certificate of Completion is attached to this email
as a PDF document.
</Text>
<Text style={bodyText}>
The certificate contains a complete record of the signing event,
including the integrity seal, timestamp, and full audit trail.
</Text>
<Text style={footerText}>
If you have any questions, please contact support.
</Text>
</EmailLayout>
);
};
export default ElectronicSignatureCertificate;

View File

@@ -0,0 +1,12 @@
{{.SenderCompanyName}}
Hi {{.RecipientFullName}},
Your {{.DocumentType}} has been signed electronically. A Certificate of Completion is attached to this email as a PDF document.
The certificate contains a complete record of the signing event, including the integrity seal, timestamp, and audit trail.
If you have any questions, please contact support.
{{.SenderCompanyHeadquarterAddress}}
Powered By Probo