Egov.Fod.BackComponents 10.0.1

Prefix Reserved
dotnet add package Egov.Fod.BackComponents --version 10.0.1
                    
NuGet\Install-Package Egov.Fod.BackComponents -Version 10.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Egov.Fod.BackComponents" Version="10.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Egov.Fod.BackComponents" Version="10.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Egov.Fod.BackComponents" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Egov.Fod.BackComponents --version 10.0.1
                    
#r "nuget: Egov.Fod.BackComponents, 10.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Egov.Fod.BackComponents@10.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Egov.Fod.BackComponents&version=10.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Egov.Fod.BackComponents&version=10.0.1
                    
Install as a Cake Tool

Fod.BackComponents

Standard backend components and integrations for E-Government (FOD) services in .NET. This library provides a unified interface for MDocs, MNotify, MSign, MPower, and MConnect services.

NuGet Version

Features

  • MDocs Integration — Document generation (PDF) from templates, QR code injection, upload to MDocs, and MinIO file storage.
  • MNotify Integration — Sending notifications, error alerts, and confirmation messages via MNotify.
  • MSign Integration — Digital signature of PDF documents and arbitrary data hashes via MSign SOAP service.
  • MPower Integration — Authorization lookup, verification, and power-of-attorney checks.
  • MConnect Integration — Inter-governmental data exchange: person verification, organization lookup, and entity-relationship checks via SOAP ambassador.

Installation

Install via NuGet:

dotnet add package Fod.BackComponents

Setup and Registration

Register the services in your Program.cs (or Startup.cs) using the provided Dependency Injection extensions from Fod.BackComponents.DependencyInjection.

1. MDocs / File Storage

Registers IFileStorage with MinIO and MDocs API clients.

builder.Services.AddFileStorage(builder.Configuration);

Configuration (appsettings.json):

{
  "MDocs": {
    "BaseAddress": "https://mdocs.api.example.com",
    "FrontendAddress": "https://mdocs.example.com"
  },
  "Minio": {
    "Endpoint": "play.min.io",
    "AccessKey": "YOUR_ACCESS_KEY",
    "SecretKey": "YOUR_SECRET_KEY",
    "BucketName": "your-bucket",
    "WithSsl": "true"
  }
}

All keys above are required; the registration will throw ArgumentException if any is missing.

2. MNotify

Registers INotificationService.

builder.Services.AddMNotify(builder.Configuration);

Configuration:

{
  "MNotify": {
    "BaseAddress": "https://mnotify.api.example.com"
  }
}

3. MSign

Registers ISignatureService. You must supply your own implementation (typically inheriting SignatureServiceBase) to handle the persistence hooks.

builder.Services.AddMSign<MySignatureService>(builder.Configuration);

Configuration:

{
  "MSign": {
    "ApiAddress": "https://msign.api.example.com",
    "FrontendAddress": "https://msign.example.com",
    "ServiceRootUrl": "https://your-app.example.com"
  }
}

All three keys are required.

4. MPower

Registers IMPowerService. Uses an HttpClient with optional client-certificate authentication via SystemCertificateOptions.

builder.Services.AddMPower(builder.Configuration);

Configuration:

{
  "MPower": {
    "BaseAddress": "https://mpower.api.example.com"
  }
}

5. MConnect

Registers IFodMConnectService with the FOD SOAP ambassador.

builder.Services.AddFodGenericMConnect(builder.Configuration);

Configuration:

{
  "MConnect": {
    "FodAmbassadorAddress": "https://mconnect.example.com",
    "Options": {
      "CallingEntity": "YOUR_IDNO",
      "CallBasis": "Law/Regulation reference",
      "CallReason": "Purpose of the call"
    }
  }
}

FodAmbassadorAddress and all three Options fields (CallingEntity, CallBasis, CallReason) are required.


Library Usage

MDocs: Document Generation & Storage (IFileStorage)

IFileStorage provides five methods:

Method Description
GenerateDocumentAsync<T>(model, documentTypeCode, fileName, language?, ct) Generates a PDF from a template and returns a FileStreamResult.
GenerateDocumentWithQrAsync<T>(model, templateName, fileName, language?, ct) Generates a PDF with an auto-injected QR code and returns (FileStreamResult, Guid).
UploadFileToMDocsAsync(model, ct) Uploads an existing file stream to MDocs and returns the reservation Guid.
GenerateAndUploadToMDocsAsync<T>(model, ct) Generates a PDF and uploads it to MDocs in one step.
UploadMinioFileAsync(storePath, stream, ct) Uploads a file directly to MinIO storage.

Example — Generate a PDF:

public class MyDocumentService(IFileStorage fileStorage)
{
    public async Task<FileStreamResult> GeneratePdf(MyData data, CancellationToken ct)
    {
        var result = await fileStorage.GenerateDocumentAsync(
            data, "TEMPLATE_CODE", "Document.pdf", "ro", ct);
        return result.Value;
    }
}

Example — Generate with QR code and upload:

To embed a QR code, implement IHasQrCode on your model:

public class MyDocModel : IHasQrCode
{
    public string Name { get; set; } = string.Empty;
    public string? QrCode { get; set; } // populated automatically
}

Then call:

var (fileResult, reservationId) = (await fileStorage.GenerateDocumentWithQrAsync(
    myDocModel, "TEMPLATE_CODE", "Doc.pdf", cancellationToken: ct)).Value;

Example — Generate and upload in one step:

var model = new GenerateAndUploadToMDocsModel<MyData>
{
    Model = myData,
    Language = "ro",
    DocumentTypeCode = "TEMPLATE_CODE",
    FileName = "Contract.pdf",
    Principal = "your-principal",
    CreatedBy = "your-system",
    Recipients = [ new DocumentRecipient { For = "recipientId", Permission = Permission.View } ]
};
var docId = await fileStorage.GenerateAndUploadToMDocsAsync(model, ct);

Example — Upload existing file to MDocs:

var uploadModel = new UploadToMDocsModel
{
    Stream = myMemoryStream,
    DocumentTypeCode = "DOC_TYPE",
    FileName = "Report.pdf",
    Principal = "your-principal",
    CreatedBy = "your-system",
    Recipients = [ new DocumentRecipient { For = "recipientId", Permission = Permission.View } ]
};
var reservationId = await fileStorage.UploadFileToMDocsAsync(uploadModel, ct);

MNotify: Sending Notifications (INotificationService)

Method Description
SendNotificationAsync(request, ct) Sends a general notification. Returns the notification Guid.
SendErrorNotificationAsync(errorMessage, ct) Sends an error notification.
SendConfirmationNotificationAsync(ct, message?, templateId?) Sends a confirmation notification using an optional template.

Example:

public class MyNotifyService(INotificationService notificationService)
{
    public async Task SendError(string message, CancellationToken ct)
    {
        await notificationService.SendErrorNotificationAsync(message, ct);
    }

    public async Task SendConfirmation(Guid templateId, CancellationToken ct)
    {
        await notificationService.SendConfirmationNotificationAsync(ct, "Your request was approved.", templateId);
    }
}

MSign: Digital Signatures (ISignatureService)

ISignatureService has two groups of methods:

Service methods (implemented by SignatureServiceBase):

Method Description
SignDocumentAsync(request, ct) Submits a PDF to MSign for signing; returns a redirect URL.
SignHashAsync<T>(model, ct) Serialises an object, computes SHA-256, submits for hash-signing; returns a redirect URL.
GetSignedObjectAsync(mSignId, ct) Retrieves the signed content (PDF or signature bytes) from MSign.
GenerateHash<T>(obj, ct) Computes the SHA-256 hash of the JSON-serialised object.

Abstract hooks (you must implement these in your subclass):

Method Description
SaveSignedDocument(model, ct) Persist the signed PDF bytes after a successful callback.
SaveSignableObject(model, ct) Persist the JSON/XML snapshot and hash when a sign request is created.
SaveHashSignature(model, ct) Persist the signature bytes after a successful hash callback.

Example — Custom implementation:

public class MySignatureService : SignatureServiceBase
{
    public MySignatureService(ILogger<MySignatureService> logger) : base(logger) { }

    public override Task<Result<bool>> SaveSignedDocument(SaveSignedDocumentModel model, CancellationToken ct)
    {
        // Persist model.Content (signed PDF bytes) to your database/storage
        return Task.FromResult(Result<bool>.Success(true));
    }

    public override Task<Result<bool>> SaveSignableObject(SignableObjectModel model, CancellationToken ct)
    {
        // Persist the serialised object snapshot and hash
        return Task.FromResult(Result<bool>.Success(true));
    }

    public override Task<Result<bool>> SaveHashSignature(SaveSignedHashModel model, CancellationToken ct)
    {
        // Persist the hash signature bytes
        return Task.FromResult(Result<bool>.Success(true));
    }
}

Usage:

// Sign a PDF document — redirect the user to the returned URL
var redirectUrl = (await signatureService.SignDocumentAsync(request, ct)).Value;

// Sign an object by hash
var redirectUrl = (await signatureService.SignHashAsync(objectSignatureModel, ct)).Value;

MPower: Authorization Checks (IMPowerService)

Method Description
GetAuthorizationByCodeAsync(authorizationCode, ct) Gets authorization details by its unique code.
GetAuthorizationByActorsAsync(typeCode, authorizingIdnx, authorizedIdnx, ct) Gets authorization by actor IDNXs.
GetAuthorizationsAsync(typeCode, authorizingIdnx, authorizedIdnx, ct) Gets a list of authorizations for the specified actors.
VerifyAuthorizationAsync(typeCode, authorizationCode, authorizingIdnx, authorizedIdnx, ct) Verifies if a specific authorization is valid. Returns bool.

Example:

public class MyAuthService(IMPowerService mPowerService)
{
    public async Task<bool> CanAct(string typeCode, string code, string principalIdnx, string agentIdnx, CancellationToken ct)
    {
        var result = await mPowerService.VerifyAuthorizationAsync(typeCode, code, principalIdnx, agentIdnx, ct);
        return result.Value;
    }

    public async Task<AuthorizationModel> GetAuthorization(string code, CancellationToken ct)
    {
        var result = await mPowerService.GetAuthorizationByCodeAsync(code, ct);
        return result.Value;
    }
}

MConnect: Data Integration (IFodMConnectService)

Method Description
VerifyPersonAsync(request) Verifies person data via MConnect.
GetOrganizationNameAsync(request) Retrieves an organization name.
VerifyEntitiesRelationshipAsync(request) Verifies the relationship between two entities.

Example:

public class MyMConnectService(IFodMConnectService mConnectService)
{
    public async Task<FodVerifyPersonResponse> VerifyPerson(FodVerifyPersonRequest request)
    {
        var result = await mConnectService.VerifyPersonAsync(request);
        return result.Value;
    }

    public async Task<FodGetOrganizationNameResponse> GetOrgName(FodGetOrganizationNameRequest request)
    {
        var result = await mConnectService.GetOrganizationNameAsync(request);
        return result.Value;
    }
}

License

This project is licensed under the MIT License — see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.1 153 4/15/2026