Skip to content

Consent management component #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 27 additions & 28 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
name: Check
on:
push:
branches:
- main
pull_request:
push:
branches:
- main
pull_request:

env:
EDGEE_API_TOKEN: ${{ secrets.EDGEE_API_TOKEN }}

jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
full-ci:
name: Full CI (${{ matrix.dir }})
runs-on: ubuntu-latest
strategy:
matrix:
dir: [consent-management, data-collection]
defaults:
run:
working-directory: ${{ matrix.dir }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: "Set up Dotnet SDK"
run: |
wget https://download.visualstudio.microsoft.com/download/pr/c526dc3b-5240-4449-ba07-ed9a3610fe09/442f1cf6e4e832eea0b045f9e108c8b7/dotnet-sdk-10.0.100-preview.2.25164.34-linux-x64.tar.gz
mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-10.0.100-preview.2.25164.34-linux-x64.tar.gz -C $HOME/dotnet
- name: "Set up Dotnet SDK"
run: |
wget https://download.visualstudio.microsoft.com/download/pr/c526dc3b-5240-4449-ba07-ed9a3610fe09/442f1cf6e4e832eea0b045f9e108c8b7/dotnet-sdk-10.0.100-preview.2.25164.34-linux-x64.tar.gz
mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-10.0.100-preview.2.25164.34-linux-x64.tar.gz -C $HOME/dotnet

- name: Install edgee
uses: edgee-cloud/[email protected]
- name: Install edgee
uses: edgee-cloud/[email protected]

- name: Build component
run: |
export DOTNET_ROOT=$HOME/dotnet
export PATH=$HOME/dotnet:$PATH
edgee component build

- name: Verify .wasm file exists
run: |
if [ ! -f "./dc_component.wasm" ]; then
echo "❌ Error: dc_component.wasm not found" >&2
exit 1
fi
- name: Build component
run: |
export DOTNET_ROOT=$HOME/dotnet
export PATH=$HOME/dotnet:$PATH
edgee component build
2 changes: 1 addition & 1 deletion .gitignore → consent-management/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.edgee/
bin/
obj/
dc-component.wasm
component.wasm
46 changes: 46 additions & 0 deletions consent-management/Component.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace ConsentManagementWorld.wit.exports.edgee.components.v1_0_0;

public struct Settings {
public string Example { get; }

public Settings(List<(string, string)> settings) {
Example = string.Empty;
foreach (var setting in settings) {
if (setting.Item1 == "example") {
Example = setting.Item2;
}
}
}
}

public struct Cookies {
public string Example { get; }

public Cookies(List<(string, string)> cookies) {
Example = string.Empty;
foreach (var cookie in cookies) {
if (cookie.Item1 == "example") {
Example = cookie.Item2;
}
}
}
}

public class ConsentManagementImpl: IConsentManagement {
public static IConsentManagement.Consent? Map(List<(string, string)> cookies, List<(string, string)> settings) {
Settings s = new Settings(settings);
Cookies c = new Cookies(cookies);

if (c.Example == string.Empty) {
return null;
} else if (c.Example == "granted") {
return IConsentManagement.Consent.GRANTED;
} else if (c.Example == "denied") {
return IConsentManagement.Consent.DENIED;
} else {
return IConsentManagement.Consent.PENDING;
}

}
}

File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions consent-management/edgee-component.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
manifest-version = 1

[component]
name = "example-cs-consent-management-component"
version = "1.0.0"
category = "consent-management"
subcategory = "consent-mapping"
description = "Example CSharp component for consent management"
documentation = "https://github.com/edgee-cloud/example-cs-component"
repository = "https://github.com/edgee-cloud/example-cs-component"
language = "CSharp"
wit-version = "1.0.0"

[component.build]
command = "dotnet build && mv ./bin/Debug/net10.0/wasi-wasm/publish/example-cs-component.wasm ./component.wasm"
output_path = "./component.wasm"

[component.settings.example]
title = "Example Config Field"
type = "string"
26 changes: 26 additions & 0 deletions consent-management/example-cs-component.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>example_cs_component</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<UseAppHost>false</UseAppHost>
<PublishTrimmed>true</PublishTrimmed>
<InvariantGlobalization>true</InvariantGlobalization>
<SelfContained>true</SelfContained>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BytecodeAlliance.Componentize.DotNet.Wasm.SDK" Version="0.5.0-preview00008" />
<PackageReference Include="runtime.linux-x64.microsoft.dotnet.ilcompiler.llvm" Version="10.0.0-alpha.1.25075.1" />
</ItemGroup>

<ItemGroup>
<Wit Remove="**\*.wit" />
<Wit Include=".edgee/wit" World="consent-management" />
</ItemGroup>

</Project>
File renamed without changes.
4 changes: 4 additions & 0 deletions data-collection/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.edgee/
bin/
obj/
component.wasm
File renamed without changes.
13 changes: 13 additions & 0 deletions data-collection/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.PHONY: all
MAKEFLAGS += --silent

all: help

help:
@grep -E '^[a-zA-Z1-9\._-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| sed -e "s/^Makefile://" -e "s///" \
| awk 'BEGIN { FS = ":.*?## " }; { printf "\033[36m%-30s\033[0m %s\n", $$1, $$2 }'

build:
edgee components build
30 changes: 30 additions & 0 deletions data-collection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div align="center">
<p align="center">
<a href="https://www.edgee.cloud">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.edgee.cloud/img/component-dark.svg">
<img src="https://cdn.edgee.cloud/img/component.svg" height="100" alt="Edgee">
</picture>
</a>
</p>
</div>

<h1 align="center">Example dotnet component for Edgee</h1>

This is an example of a C# Edgee Component.

## Setup
Requirements:
- [edgee-cli](https://github.com/edgee-cloud/edgee)
- [dotnet SDK 10.0](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)
- Modify the csproj file to match your OS:
- On Linux
```dotnet add package runtime.linux-x64.microsoft.dotnet.ilcompiler.llvm --prerelease```
- On Windows
```dotnet add package runtime.win-x64.microsoft.dotnet.ilcompiler.llvm --prerelease```

## Building

```shell
$ make build
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
manifest-version = 1

[component]
name = "example-cs-component"
name = "example-cs-data-collection-component"
version = "1.0.0"
category = "data-collection"
subcategory = "analytics"
Expand Down
9 changes: 9 additions & 0 deletions data-collection/nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>