Skip to content

Commit 2e0ad33

Browse files
committed
Initial commit
#1
1 parent af557a1 commit 2e0ad33

24 files changed

Lines changed: 1356 additions & 1 deletion

Plugins.Base64.sln

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35728.132
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowSynx.Plugins.Base64", "src\FlowSynx.Plugins.Base64.csproj", "{1E193BA0-1258-413C-AED0-213EBF98355C}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7AC4BFEB-7690-4A0F-8C70-E5FFD5615061}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{51AA6910-974D-4C55-91C9-ACEA06C23D58}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowSynx.Plugin.Base64.UnitTests", "tests\FlowSynx.Plugin.Base64.UnitTests.csproj", "{A09C0968-0580-42E2-A4BC-2383AB1A5C5F}"
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Debug|Any CPU = Debug|Any CPU
17+
Release|Any CPU = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{1E193BA0-1258-413C-AED0-213EBF98355C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{1E193BA0-1258-413C-AED0-213EBF98355C}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{1E193BA0-1258-413C-AED0-213EBF98355C}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{1E193BA0-1258-413C-AED0-213EBF98355C}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{A09C0968-0580-42E2-A4BC-2383AB1A5C5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{A09C0968-0580-42E2-A4BC-2383AB1A5C5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{A09C0968-0580-42E2-A4BC-2383AB1A5C5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{A09C0968-0580-42E2-A4BC-2383AB1A5C5F}.Release|Any CPU.Build.0 = Release|Any CPU
28+
EndGlobalSection
29+
GlobalSection(SolutionProperties) = preSolution
30+
HideSolutionNode = FALSE
31+
EndGlobalSection
32+
GlobalSection(NestedProjects) = preSolution
33+
{1E193BA0-1258-413C-AED0-213EBF98355C} = {7AC4BFEB-7690-4A0F-8C70-E5FFD5615061}
34+
{A09C0968-0580-42E2-A4BC-2383AB1A5C5F} = {51AA6910-974D-4C55-91C9-ACEA06C23D58}
35+
EndGlobalSection
36+
EndGlobal

README.md

Lines changed: 148 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,148 @@
1-
# plugin-base64
1+
# FlowSynx Base64 Plugin
2+
3+
The **FlowSynx Base64 Plugin** is a built-in, plug-and-play integration for the FlowSynx automation engine. It enables encoding, decoding, and validation of Base64-encoded data within workflows, with no custom coding required.
4+
5+
This plugin is automatically installed by the FlowSynx engine when selected in the workflow builder. It is not intended for standalone developer usage outside the FlowSynx platform.
6+
7+
---
8+
9+
## Purpose
10+
11+
The Base64 Plugin allows FlowSynx users to:
12+
13+
- Encode raw data (strings or byte arrays) into Base64 format.
14+
- Decode Base64-encoded data back into its original form.
15+
- Validate whether a given string is properly Base64-encoded.
16+
17+
It integrates seamlessly into FlowSynx no-code/low-code workflows for data transformation and validation tasks.
18+
19+
---
20+
21+
## Supported Operations
22+
23+
- **encode**: Encodes the `Data` parameter into a Base64 string.
24+
- **decode**: Decodes a Base64 string in `Data` back into its original form.
25+
- **valid**: Checks if the `Data` parameter is a valid Base64-encoded string and returns a boolean result.
26+
27+
---
28+
29+
## Input Parameters
30+
31+
The plugin accepts the following parameters:
32+
33+
- `Operation` (string): **Required.** The type of operation to perform. Supported values are `encode`, `decode`, and `valid`.
34+
- `Data` (object): **Required.** The input data to process. For `encode`, this can be a string or byte array. For `decode` and `valid`, this must be a Base64-encoded string.
35+
36+
### Example input
37+
38+
```json
39+
{
40+
"Operation": "encode",
41+
"Data": "Hello, FlowSynx!"
42+
}
43+
```
44+
45+
---
46+
47+
## Operation Examples
48+
49+
### encode Operation
50+
51+
**Input Parameters:**
52+
53+
```json
54+
{
55+
"Operation": "encode",
56+
"Data": "Hello, FlowSynx!"
57+
}
58+
```
59+
60+
**Output:**
61+
62+
```json
63+
"SGVsbG8sIEZsb3dTeW54IQ=="
64+
```
65+
66+
---
67+
68+
### decode Operation
69+
70+
**Input Parameters:**
71+
72+
```json
73+
{
74+
"Operation": "decode",
75+
"Data": "SGVsbG8sIEZsb3dTeW54IQ=="
76+
}
77+
```
78+
79+
**Output:**
80+
81+
```json
82+
"Hello, FlowSynx!"
83+
```
84+
85+
---
86+
87+
### valid Operation
88+
89+
**Input Parameters:**
90+
91+
```json
92+
{
93+
"Operation": "valid",
94+
"Data": "SGVsbG8sIEZsb3dTeW54IQ=="
95+
}
96+
```
97+
98+
**Output:**
99+
100+
```json
101+
true
102+
```
103+
104+
**Example with invalid Base64 string:**
105+
106+
```json
107+
{
108+
"Operation": "valid",
109+
"Data": "Not a valid Base64!!"
110+
}
111+
```
112+
113+
**Output:**
114+
115+
```json
116+
false
117+
```
118+
119+
---
120+
121+
## Example Use Case in FlowSynx
122+
123+
1. Add the Base64 plugin to your FlowSynx workflow.
124+
2. Set `Operation` to one of: `encode`, `decode`, or `valid`.
125+
3. Provide input data in `Data`.
126+
4. Use the plugin output downstream in your workflow for further processing or decision-making.
127+
128+
---
129+
130+
## Debugging Tips
131+
132+
- If `decode` fails, ensure the `Data` parameter contains a valid Base64-encoded string.
133+
- The `valid` operation can be used prior to `decode` to avoid runtime errors.
134+
- For non-UTF8 encoded binary data, make sure your workflow handles byte arrays correctly.
135+
136+
---
137+
138+
## Security Notes
139+
140+
- No data is persisted unless explicitly configured.
141+
- All operations run in a secure sandbox within FlowSynx.
142+
- Only authorized platform users can view or modify configurations.
143+
144+
---
145+
146+
## License
147+
148+
© FlowSynx. All rights reserved.3

src/Base64Plugin.cs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
using FlowSynx.PluginCore;
2+
using FlowSynx.PluginCore.Extensions;
3+
using FlowSynx.Plugins.Base64.Models;
4+
using FlowSynx.Plugins.Base64.Services;
5+
6+
namespace FlowSynx.Plugins.Base64;
7+
8+
public class Base64Plugin : IPlugin
9+
{
10+
private readonly IGuidProvider _guidProvider;
11+
private readonly IReflectionGuard _reflectionGuard;
12+
private IPluginLogger? _logger;
13+
private bool _isInitialized;
14+
15+
public Base64Plugin() : this(new GuidProvider(), new DefaultReflectionGuard()) { }
16+
17+
internal Base64Plugin(IGuidProvider guidProvider, IReflectionGuard reflectionGuard)
18+
{
19+
_guidProvider = guidProvider ?? throw new ArgumentNullException(nameof(guidProvider));
20+
_reflectionGuard = reflectionGuard ?? throw new ArgumentNullException(nameof(reflectionGuard));
21+
}
22+
23+
public PluginMetadata Metadata => new()
24+
{
25+
Id = Guid.Parse("8f3e97d1-f1a4-40df-9241-644097a56382"),
26+
Name = "Base64",
27+
CompanyName = "FlowSynx",
28+
Description = Resources.PluginDescription,
29+
Version = new Version(1, 0, 0),
30+
Category = PluginCategory.Data,
31+
Authors = new List<string> { "FlowSynx" },
32+
Copyright = "© FlowSynx. All rights reserved.",
33+
Icon = "flowsynx.png",
34+
ReadMe = "README.md",
35+
RepositoryUrl = "https://github.com/flowsynx/plugin-base64",
36+
ProjectUrl = "https://flowsynx.io",
37+
Tags = new List<string>() { "flowSynx", "base64", "data", "data-platform", "encoding", "decoding" },
38+
MinimumFlowSynxVersion = new Version(1, 1, 1),
39+
};
40+
41+
public PluginSpecifications? Specifications { get; set; }
42+
43+
public Type SpecificationsType => typeof(Base64PluginSpecifications);
44+
45+
private Dictionary<string, IBase64OperationHandler> OperationMap => new(StringComparer.OrdinalIgnoreCase)
46+
{
47+
["encode"] = new EncodeOperationHandler(_guidProvider),
48+
["decode"] = new DecodeOperationHandler(_guidProvider),
49+
["valid"] = new ValidOperationHandler(_guidProvider)
50+
};
51+
52+
public IReadOnlyCollection<string> SupportedOperations => OperationMap.Keys;
53+
54+
public Task Initialize(IPluginLogger logger)
55+
{
56+
if (_reflectionGuard.IsCalledViaReflection())
57+
throw new InvalidOperationException(Resources.ReflectionBasedAccessIsNotAllowed);
58+
59+
ArgumentNullException.ThrowIfNull(logger);
60+
_logger = logger;
61+
_isInitialized = true;
62+
return Task.CompletedTask;
63+
}
64+
65+
public Task<object?> ExecuteAsync(PluginParameters parameters, CancellationToken cancellationToken)
66+
{
67+
cancellationToken.ThrowIfCancellationRequested();
68+
69+
if (_reflectionGuard.IsCalledViaReflection())
70+
throw new InvalidOperationException(Resources.ReflectionBasedAccessIsNotAllowed);
71+
72+
if (!_isInitialized)
73+
throw new InvalidOperationException($"Plugin '{Metadata.Name}' v{Metadata.Version} is not initialized.");
74+
75+
var inputParameter = parameters.ToObject<InputParameter>();
76+
if (!OperationMap.TryGetValue(inputParameter.Operation, out var handler))
77+
throw new NotSupportedException($"Operation '{inputParameter.Operation}' is not supported.");
78+
79+
var context = ParseDataToContext(inputParameter.Data);
80+
return Task.FromResult(handler.Handle(context));
81+
}
82+
83+
private PluginContext ParseDataToContext(object? data)
84+
{
85+
if (data is null)
86+
throw new ArgumentNullException(nameof(data), "Input data cannot be null.");
87+
88+
return data switch
89+
{
90+
PluginContext singleContext => singleContext,
91+
IEnumerable<PluginContext> => throw new NotSupportedException("List of PluginContext is not supported."),
92+
string strData => new PluginContext(_guidProvider.NewGuid().ToString(), "Data") { Content = strData },
93+
_ => throw new NotSupportedException("Unsupported input data format.")
94+
};
95+
}
96+
}

src/FlowSynx.Plugins.Base64.csproj

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<PropertyGroup Condition="'$(Configuration)'=='Release'">
10+
<DebugSymbols>False</DebugSymbols>
11+
<DebugType>None</DebugType>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<PackageReference Include="FlowSynx.PluginCore" Version="1.3.3" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<InternalsVisibleTo Include="FlowSynx.Plugin.Base64.UnitTests" />
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<Compile Update="Resources.Designer.cs">
24+
<DesignTime>True</DesignTime>
25+
<AutoGen>True</AutoGen>
26+
<DependentUpon>Resources.resx</DependentUpon>
27+
</Compile>
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<EmbeddedResource Update="Resources.resx">
32+
<Generator>ResXFileCodeGenerator</Generator>
33+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
34+
</EmbeddedResource>
35+
</ItemGroup>
36+
37+
<ItemGroup>
38+
<None Update="flowsynx.png">
39+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
40+
</None>
41+
<None Update="README.md">
42+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
43+
</None>
44+
</ItemGroup>
45+
46+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using FlowSynx.PluginCore;
2+
3+
namespace FlowSynx.Plugins.Base64.Models;
4+
5+
public class Base64PluginSpecifications : PluginSpecifications
6+
{
7+
8+
}

src/Models/InputParameter.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace FlowSynx.Plugins.Base64.Models;
2+
3+
internal class InputParameter
4+
{
5+
public string Operation { get; set; } = string.Empty;
6+
public object? Data { get; set; }
7+
}

0 commit comments

Comments
 (0)