BccCode.Privacy.Client
0.1.30
dotnet add package BccCode.Privacy.Client --version 0.1.30
NuGet\Install-Package BccCode.Privacy.Client -Version 0.1.30
<PackageReference Include="BccCode.Privacy.Client" Version="0.1.30" />
<PackageVersion Include="BccCode.Privacy.Client" Version="0.1.30" />
<PackageReference Include="BccCode.Privacy.Client" />
paket add BccCode.Privacy.Client --version 0.1.30
#r "nuget: BccCode.Privacy.Client, 0.1.30"
#:package BccCode.Privacy.Client@0.1.30
#addin nuget:?package=BccCode.Privacy.Client&version=0.1.30
#tool nuget:?package=BccCode.Privacy.Client&version=0.1.30
BCC Privacy Client (.NET)
Machine-to-machine client for the BCC Privacy API, built on BCC Platform like the Core API and Notifications clients.
Install
dotnet add package BccCode.Privacy.Client
Register
The installer follows bcc-platform-sdks' pattern (docs/dotnet/openapi-sdk-installer.md), like the Core API client: the credential overloads configure the platform with AddBccPlatform, and every request carries the platform's cached, auto-refreshing token.
With an environment and the client credentials (one call):
services.AddBccPrivacyClient(AppEnvironment.Prod, "client-id", "client-secret");
With the BCC platform already configured, for example because the service uses several BCC SDKs:
services.AddBccPlatform(AppEnvironment.Prod); // credentials from the BccAuth section
services.AddBccPrivacyClient();
AddBccPrivacyClient(environment), AddBccPrivacyClient(environment, oAuthOptions) and AddBccPrivacyClient(environment, authConfig) mirror the other AddBccPlatform overloads.
The token is requested for the platform's M2M audience (api.bcc.no, sandbox-api.bcc.no in sandbox), the same one the Core API uses, with the scope privacy.catalogue#read.
| Environment | Privacy API |
|---|---|
Prod |
https://privacy.bcc.no |
Sandbox |
https://privacy.sandbox.bcc.no |
Emulator |
BccPlatform:ServiceUrls:privacy, else {BccPlatform:BaseUrl}/privacy |
For any other host, pass its base URL: services.AddBccPrivacyClient("https://localhost:13000"), with the platform configured.
Use
var personalData = await privacyClient.GetPersonalDataAsync();
var processes = await privacyClient.GetProcessesAsync();
GetPersonalDataAsync returns every personal-data item (names in each language, classification and scopes), including items no process uses yet.
GetProcessesAsync returns every active process (controller, purposes in each language, legal basis, validity) with the personal-data items it uses, the groups of people the data is about, how long it is kept, and the controller's privacy notice.
| Method | Scope |
|---|---|
GetPersonalDataAsync |
privacy.catalogue#read |
GetProcessesAsync |
privacy.catalogue#read |
PutProcessAsync |
privacy.processes#write |
GetOwnProcessesAsync |
privacy.processes#write |
DeleteProcessAsync |
privacy.processes#write |
PutDataControllerNoticeAsync |
privacy.processes#write |
PutItemAsync |
privacy.items#write |
The client application must be granted the scope on the Core API resource in Auth0. Scope names are constants on
PrivacyApiScopes (named PrivacyScope before 0.1.0; renamed so it does not clash with the request scope of the
BccCode.Privacy library packages). Register the client with the scopes it needs, for example
AddBccPrivacyClient(PrivacyApiScopes.CatalogueRead, PrivacyApiScopes.ProcessesWrite, PrivacyApiScopes.ItemsWrite).
Writing processes and items
An application writes its own processes and personal-data items with machine credentials. The code is the id;
writing the same document again changes nothing, and a changed process becomes a new version. The owner is the
application's AppUID: the token must carry it in the app_uid claim, as for Core API (add it to the client's machine
claims in sign-on; 403 without it). Only a client carrying the AppUID that created a process, item or notice may change
or delete it (403 otherwise).
var item = await privacyClient.PutItemAsync("dietary-needs", new PrivacyItemDocument
{
Name = "Dietary needs",
Classification = PrivacyCatalogueClassification.SensitivePersonalData,
Scopes = ["persons.dietary#read"],
});
var process = await privacyClient.PutProcessAsync("event-registration", new PrivacyProcessDocument
{
DataControllerId = organisationUid,
Name = "Event registration",
LegalBasis = PrivacyCatalogueLegalBasis.Contract,
RequiresFamilyConsent = true,
Countries = ["NO"],
PersonalData = [item.PersonalDataId],
Translations = [new() { LanguageCode = "EN", Purpose = "Register you for the event", Description = "…", WithdrawalWarning = "…" }],
DataSubjects = [new() { Code = "participants", Name = "Participants", Translations = [new() { LanguageCode = "NO", Name = "Deltakere" }] }],
// GDPR Art. 26: the organisations deciding the processing together with the data controller, by name. Left out
// (null): unchanged on an existing process; [] clears them. The catalogue returns them as JointControllers.
JointControllers = ["Example Partner AS"],
// A period says what it is counted from: Collection, LastUse, RelationshipEnds, or Other with its text per language.
Retention = new()
{
Kind = PrivacyCatalogueRetentionKind.Period, Period = 2, Unit = PrivacyCatalogueRetentionUnit.Years,
From = PrivacyCatalogueRetentionStart.Other,
FromText = [new() { LanguageCode = "EN", Text = "after the event" }, new() { LanguageCode = "NO", Text = "etter arrangementet" }],
},
});
// process.Action: Created, Updated (new version) or Unchanged
// The processes this application owns, e.g. to remove the ones it no longer declares.
var mine = await privacyClient.GetOwnProcessesAsync();
// An application deletes a process it owns and nobody relies on (archived, then deleted; the code is never reused).
// 409 while any person's consent to it is given.
await privacyClient.DeleteProcessAsync("event-registration");
// A data controller's privacy notice, owned by the application and linked as the controller's notice.
var notice = await privacyClient.PutDataControllerNoticeAsync(organisationUid,
new PrivacyNoticeDocument { Name = "Privacy policy", Url = new Uri("https://example.org/privacy") });
Failed calls throw PrivacyApiException with the status code and response body.
Events
Privacy publishes PrivacyCatalogueUpdated (no.bcc.privacy.catalogue.updated) through BCC PubSub when the catalogue changes.
Subscribing needs privacy.catalogue#read and pubsub#subscribe; the event carries ids only, so read the catalogue again when it arrives.
await privacyClient.SubscribeAsync<PrivacyCatalogueUpdated>("https://my-service.bcc.no/webhooks/pubsub", "my-service-privacy-catalogue");
Subscriptions use the registered IPubSubClient (AddBccPubSub()), else one built on the platform's credentials.
A Wolverine application can receive it through the BCC PubSub transport (BccCode.PubSub.Wolverine) instead: opts.ListenToBccPubSubTopic<PrivacyCatalogueUpdated>().
Privacy also publishes PrivacyConsentWithdrawn (no.bcc.privacy.consent-withdrawn, scope privacy#consent-withdrawn) when a person's consent ends.
Contracts and versions
The types in this package are Privacy's published contract (SVC-1):
Each event has a JSON schema per event type in
contracts/events/. An event type without a version suffix is version 1; a breaking change gets a new type with a.v2suffix, published beside the old one.The API's OpenAPI document is committed in
api/BccCode.Privacy.Api/BccCode.Privacy.Api.json. A breaking change gets a new path, served beside the old one.Changes are additive. The old version stays for the period stated in its release note: at least 90 days, and until every known consumer has moved.
Contract types use init properties: build them with object initializers, so an added field changes no constructor. The constructors with parameters from 0.x still compile, but are hidden; prefer object initializers.
contracts/client-contract.txtpins every property and enum value. A removed, renamed or changed line fails the contract tests; an added one is reviewed by updating the file.contracts/variable-values.schema.jsonis the one JSON schema for process variable values (PRV-26): a variable's default, limits and an adoption's values, per variable type. Privacy validates typed values against it and serves it atGET /api/catalogue/vocabulary/variable-values-schema(GetVariableValuesSchemaAsync); submit typed values it accepts.
To update the committed schemas and the baseline after an additive change, run the integration tests' contract tests
with UPDATE_CONTRACTS=1 and commit the files:
UPDATE_CONTRACTS=1 dotnet test --project ./api/BccCode.Privacy.IntegrationTests/BccCode.Privacy.IntegrationTests.csproj --filter-namespace "BccCode.Privacy.IntegrationTests.Contracts"
Releases
.github/workflows/sdk-dotnet-publish.yml publishes the package to NuGet; the version follows bcc-core-api's SDK workflow.
A merge to main that changes sdk/dotnet publishes <major>.<minor>.<n> once the integration tests pass, where <n> counts the SDK's commits since the last sdk-dotnet-v<major>.<minor>.0 tag (0.0.<n> until the first tag).
A pull request only builds and packs; nothing is published from it.
To publish a beta (<version>-beta.<run>) from a branch, run the workflow by hand on that branch; a required reviewer of the nuget-beta environment approves the run before it publishes.
Tag a commit sdk-dotnet-v<major>.<minor>.0, or (while no tag exists) merge a commit whose subject starts with feat: or feat(<scope>):, to start a new minor version.
The process declaration types (PrivacyProcessDeclarationDocument, PrivacyAdoptionRule, PrivacyDeclarationWriteResult,
IPrivacyDeclarationClient) ship in this package; BccCode.Privacy.Hosting takes the published package, never the source.
See the .NET SDK section of the integration guide for usage.
| Product | Versions 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. |
-
net10.0
- BccCode.Platform.Apis (>= 2.0.0.22)
- BccCode.Platform.Config (>= 2.0.0.22)
- BccCode.PubSub.Client (>= 1.0.49)
- Microsoft.Extensions.Http (>= 10.0.15)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on BccCode.Privacy.Client:
| Package | Downloads |
|---|---|
|
BccCode.Privacy.Hosting
One AddPrivacy() for BCC Privacy: the EF Core, ASP.NET Core and Wolverine packages wired together, defaults per environment, the privacy document at /.well-known/bcc-privacy, and the application's processes and data items pushed to the Privacy API at deploy. |
GitHub repositories
This package is not used by any popular GitHub repositories.