feat(consent): add versioned append-only consent ledger C1-C5

This commit is contained in:
shira committed 2026-10-06 14:52:33 +03:00
1 parent 008254e44a
commit de49f93b0b
64 files changed
+9244 -132

No files matched your search

@@ -3353,6 +3353,39 @@ type ConfirmEmailForbidden Problem
func (*ConfirmEmailForbidden) confirmEmailRes() {}
// Organization of a c4 consent as the consent recorded it. `name` is a snapshot of the name that the
// shown consent text carried at the time of the consent, and the stored text hash proves that text
// with this name; a later rename of the organization does not change it, so it can differ from the
// current name.
// Ref: #/components/schemas/ConsentOrganization
type ConsentOrganization struct {
// Identifier of the organization.
ID uuid.UUID `json:"id"`
// Name of the organization in the consent text at the time of the consent. Plain text; clients show it
// as text, never as HTML.
Name string `json:"name"`
}
// GetID returns the value of ID.
func (s *ConsentOrganization) GetID() uuid.UUID {
return s.ID
}
// GetName returns the value of Name.
func (s *ConsentOrganization) GetName() string {
return s.Name
}
// SetID sets the value of ID.
func (s *ConsentOrganization) SetID(val uuid.UUID) {
s.ID = val
}
// SetName sets the value of Name.
func (s *ConsentOrganization) SetName(val string) {
s.Name = val
}
// Consent whose text the client may read before an account exists. Only the consents given at
// registration are listed: `c1` is the consent to the processing of personal data.
// Ref: #/components/schemas/ConsentPurpose
@@ -3390,6 +3423,452 @@ func (s *ConsentPurpose) UnmarshalText(data []byte) error {
}
}
// One of the independent consents of PRD FR01. A grant or a revocation of one purpose never changes
// another.
//
// - c1: processing of personal data, given at registration.
// - c2: publication of the candidate card. The record proves the consent to the published text; which
// fields were published and when is evidence of the publication history (TASK-088), not of this
// record. Adding a field scope to c2 records later is an additive change.
// - c3: automatic categorization. Without it the candidate can request a manual assessment by the
// same rubric.
// - c4: transfer of the selected contact data to one organization, currently given only in an
// invitation acceptance.
// - c5: import of FSP results.
//
// ConsentPurpose lists the subset whose text the client may read before an account exists.
// Ref: #/components/schemas/ConsentPurposeCode
type ConsentPurposeCode string
const (
ConsentPurposeCodeC1 ConsentPurposeCode = "c1"
ConsentPurposeCodeC2 ConsentPurposeCode = "c2"
ConsentPurposeCodeC3 ConsentPurposeCode = "c3"
ConsentPurposeCodeC4 ConsentPurposeCode = "c4"
ConsentPurposeCodeC5 ConsentPurposeCode = "c5"
)
// AllValues returns all ConsentPurposeCode values.
func (ConsentPurposeCode) AllValues() []ConsentPurposeCode {
return []ConsentPurposeCode{
ConsentPurposeCodeC1,
ConsentPurposeCodeC2,
ConsentPurposeCodeC3,
ConsentPurposeCodeC4,
ConsentPurposeCodeC5,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s ConsentPurposeCode) MarshalText() ([]byte, error) {
switch s {
case ConsentPurposeCodeC1:
return []byte(s), nil
case ConsentPurposeCodeC2:
return []byte(s), nil
case ConsentPurposeCodeC3:
return []byte(s), nil
case ConsentPurposeCodeC4:
return []byte(s), nil
case ConsentPurposeCodeC5:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *ConsentPurposeCode) UnmarshalText(data []byte) error {
switch ConsentPurposeCode(data) {
case ConsentPurposeCodeC1:
*s = ConsentPurposeCodeC1
return nil
case ConsentPurposeCodeC2:
*s = ConsentPurposeCodeC2
return nil
case ConsentPurposeCodeC3:
*s = ConsentPurposeCodeC3
return nil
case ConsentPurposeCodeC4:
*s = ConsentPurposeCodeC4
return nil
case ConsentPurposeCodeC5:
*s = ConsentPurposeCodeC5
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// One record of the consent ledger as its subject reads it: the purpose, the text version the subject
// accepted, where and when the consent was given, its state, and the revocation. A c4 record also
// names the organization, the contact fields, and the invitation with its terms version; these fields
// are null for every other purpose. The server also stores the SHA-256 hash of exactly the text the
// subject saw, which a client never sends or receives.
// Ref: #/components/schemas/ConsentRecord
type ConsentRecord struct {
// Identifier of the record.
ID uuid.UUID `json:"id"`
Purpose ConsentPurposeCode `json:"purpose"`
State ConsentState `json:"state"`
// Version of the consent text that the subject accepted.
TextVersion ConsentTextVersion `json:"text_version"`
Source ConsentSource `json:"source"`
GrantedAt Timestamp `json:"granted_at"`
// Moment of the revocation, or null unless `state` is `revoked`.
RevokedAt NilTimestamp `json:"revoked_at"`
// Who recorded the revocation, or null unless `state` is `revoked`.
RevocationSource NilConsentRevocationSource `json:"revocation_source"`
// Organization that a c4 consent allows to read the fields, with the name the consent text showed, or
// null for every other purpose.
Organization NilConsentOrganization `json:"organization"`
// Contact fields that a c4 consent covers, or null for every other purpose. One kind never implies
// another.
Fields []ContactFieldKind `json:"fields"`
// Invitation whose acceptance gave a c4 consent, or null for every other purpose.
InvitationID NilUUID `json:"invitation_id"`
// Terms version that the acceptance accepted, or null for every other purpose.
InvitationTermsVersion NilInvitationTermsVersion `json:"invitation_terms_version"`
}
// GetID returns the value of ID.
func (s *ConsentRecord) GetID() uuid.UUID {
return s.ID
}
// GetPurpose returns the value of Purpose.
func (s *ConsentRecord) GetPurpose() ConsentPurposeCode {
return s.Purpose
}
// GetState returns the value of State.
func (s *ConsentRecord) GetState() ConsentState {
return s.State
}
// GetTextVersion returns the value of TextVersion.
func (s *ConsentRecord) GetTextVersion() ConsentTextVersion {
return s.TextVersion
}
// GetSource returns the value of Source.
func (s *ConsentRecord) GetSource() ConsentSource {
return s.Source
}
// GetGrantedAt returns the value of GrantedAt.
func (s *ConsentRecord) GetGrantedAt() Timestamp {
return s.GrantedAt
}
// GetRevokedAt returns the value of RevokedAt.
func (s *ConsentRecord) GetRevokedAt() NilTimestamp {
return s.RevokedAt
}
// GetRevocationSource returns the value of RevocationSource.
func (s *ConsentRecord) GetRevocationSource() NilConsentRevocationSource {
return s.RevocationSource
}
// GetOrganization returns the value of Organization.
func (s *ConsentRecord) GetOrganization() NilConsentOrganization {
return s.Organization
}
// GetFields returns the value of Fields.
func (s *ConsentRecord) GetFields() []ContactFieldKind {
return s.Fields
}
// GetInvitationID returns the value of InvitationID.
func (s *ConsentRecord) GetInvitationID() NilUUID {
return s.InvitationID
}
// GetInvitationTermsVersion returns the value of InvitationTermsVersion.
func (s *ConsentRecord) GetInvitationTermsVersion() NilInvitationTermsVersion {
return s.InvitationTermsVersion
}
// SetID sets the value of ID.
func (s *ConsentRecord) SetID(val uuid.UUID) {
s.ID = val
}
// SetPurpose sets the value of Purpose.
func (s *ConsentRecord) SetPurpose(val ConsentPurposeCode) {
s.Purpose = val
}
// SetState sets the value of State.
func (s *ConsentRecord) SetState(val ConsentState) {
s.State = val
}
// SetTextVersion sets the value of TextVersion.
func (s *ConsentRecord) SetTextVersion(val ConsentTextVersion) {
s.TextVersion = val
}
// SetSource sets the value of Source.
func (s *ConsentRecord) SetSource(val ConsentSource) {
s.Source = val
}
// SetGrantedAt sets the value of GrantedAt.
func (s *ConsentRecord) SetGrantedAt(val Timestamp) {
s.GrantedAt = val
}
// SetRevokedAt sets the value of RevokedAt.
func (s *ConsentRecord) SetRevokedAt(val NilTimestamp) {
s.RevokedAt = val
}
// SetRevocationSource sets the value of RevocationSource.
func (s *ConsentRecord) SetRevocationSource(val NilConsentRevocationSource) {
s.RevocationSource = val
}
// SetOrganization sets the value of Organization.
func (s *ConsentRecord) SetOrganization(val NilConsentOrganization) {
s.Organization = val
}
// SetFields sets the value of Fields.
func (s *ConsentRecord) SetFields(val []ContactFieldKind) {
s.Fields = val
}
// SetInvitationID sets the value of InvitationID.
func (s *ConsentRecord) SetInvitationID(val NilUUID) {
s.InvitationID = val
}
// SetInvitationTermsVersion sets the value of InvitationTermsVersion.
func (s *ConsentRecord) SetInvitationTermsVersion(val NilInvitationTermsVersion) {
s.InvitationTermsVersion = val
}
// One page of the consent ledger of the current account, newest grant first.
// Ref: #/components/schemas/ConsentRecordList
type ConsentRecordList struct {
// Records of the page.
Items []ConsentRecord `json:"items"`
Page PageInfo `json:"page"`
}
// GetItems returns the value of Items.
func (s *ConsentRecordList) GetItems() []ConsentRecord {
return s.Items
}
// GetPage returns the value of Page.
func (s *ConsentRecordList) GetPage() PageInfo {
return s.Page
}
// SetItems sets the value of Items.
func (s *ConsentRecordList) SetItems(val []ConsentRecord) {
s.Items = val
}
// SetPage sets the value of Page.
func (s *ConsentRecordList) SetPage(val PageInfo) {
s.Page = val
}
// ConsentRecordListHeaders wraps ConsentRecordList with response headers.
type ConsentRecordListHeaders struct {
CacheControl CacheControlNoStore
Response ConsentRecordList
}
// GetCacheControl returns the value of CacheControl.
func (s *ConsentRecordListHeaders) GetCacheControl() CacheControlNoStore {
return s.CacheControl
}
// GetResponse returns the value of Response.
func (s *ConsentRecordListHeaders) GetResponse() ConsentRecordList {
return s.Response
}
// SetCacheControl sets the value of CacheControl.
func (s *ConsentRecordListHeaders) SetCacheControl(val CacheControlNoStore) {
s.CacheControl = val
}
// SetResponse sets the value of Response.
func (s *ConsentRecordListHeaders) SetResponse(val ConsentRecordList) {
s.Response = val
}
func (*ConsentRecordListHeaders) listMyConsentsRes() {}
// Who recorded a revocation.
//
// - consent_settings: the subject revoked the consent in the product.
// - support_request: an operator recorded a revocation that the subject requested through support.
//
// Ref: #/components/schemas/ConsentRevocationSource
type ConsentRevocationSource string
const (
ConsentRevocationSourceConsentSettings ConsentRevocationSource = "consent_settings"
ConsentRevocationSourceSupportRequest ConsentRevocationSource = "support_request"
)
// AllValues returns all ConsentRevocationSource values.
func (ConsentRevocationSource) AllValues() []ConsentRevocationSource {
return []ConsentRevocationSource{
ConsentRevocationSourceConsentSettings,
ConsentRevocationSourceSupportRequest,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s ConsentRevocationSource) MarshalText() ([]byte, error) {
switch s {
case ConsentRevocationSourceConsentSettings:
return []byte(s), nil
case ConsentRevocationSourceSupportRequest:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *ConsentRevocationSource) UnmarshalText(data []byte) error {
switch ConsentRevocationSource(data) {
case ConsentRevocationSourceConsentSettings:
*s = ConsentRevocationSourceConsentSettings
return nil
case ConsentRevocationSourceSupportRequest:
*s = ConsentRevocationSourceSupportRequest
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// Where the subject gave the consent.
//
// - registration: the c1 acceptance of RegisterAccount.
// - consent_settings: the consent settings of the account, for c1, c2, c3, and c5 (planned, TASK-063
// and TASK-064).
// - invitation_acceptance: the c4 acceptance of AcceptMyInvitation.
//
// A c4 given when sending an application (PRD Q9) is planned as an additional value.
// Ref: #/components/schemas/ConsentSource
type ConsentSource string
const (
ConsentSourceRegistration ConsentSource = "registration"
ConsentSourceConsentSettings ConsentSource = "consent_settings"
ConsentSourceInvitationAcceptance ConsentSource = "invitation_acceptance"
)
// AllValues returns all ConsentSource values.
func (ConsentSource) AllValues() []ConsentSource {
return []ConsentSource{
ConsentSourceRegistration,
ConsentSourceConsentSettings,
ConsentSourceInvitationAcceptance,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s ConsentSource) MarshalText() ([]byte, error) {
switch s {
case ConsentSourceRegistration:
return []byte(s), nil
case ConsentSourceConsentSettings:
return []byte(s), nil
case ConsentSourceInvitationAcceptance:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *ConsentSource) UnmarshalText(data []byte) error {
switch ConsentSource(data) {
case ConsentSourceRegistration:
*s = ConsentSourceRegistration
return nil
case ConsentSourceConsentSettings:
*s = ConsentSourceConsentSettings
return nil
case ConsentSourceInvitationAcceptance:
*s = ConsentSourceInvitationAcceptance
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// State of a consent record, computed from the ledger.
//
// - active: the consent holds. For c1, c2, c3, and c5 it is the newest unrevoked record of its
// purpose; every unrevoked c4 record is active, one per accepted invitation.
// - superseded: the subject later accepted another text version of the same purpose and has not
// revoked either. The record stays as evidence for its own time; it never applies to c4.
// - revoked: the consent was revoked. The record keeps its grant and its one revocation time; a later
// grant is a new record and never reopens it.
//
// Ref: #/components/schemas/ConsentState
type ConsentState string
const (
ConsentStateActive ConsentState = "active"
ConsentStateSuperseded ConsentState = "superseded"
ConsentStateRevoked ConsentState = "revoked"
)
// AllValues returns all ConsentState values.
func (ConsentState) AllValues() []ConsentState {
return []ConsentState{
ConsentStateActive,
ConsentStateSuperseded,
ConsentStateRevoked,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s ConsentState) MarshalText() ([]byte, error) {
switch s {
case ConsentStateActive:
return []byte(s), nil
case ConsentStateSuperseded:
return []byte(s), nil
case ConsentStateRevoked:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *ConsentState) UnmarshalText(data []byte) error {
switch ConsentState(data) {
case ConsentStateActive:
*s = ConsentStateActive
return nil
case ConsentStateSuperseded:
*s = ConsentStateSuperseded
return nil
case ConsentStateRevoked:
*s = ConsentStateRevoked
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// Currently published consent text. The server stores an acceptance with `text_version` and the hash
// of exactly this text.
// Ref: #/components/schemas/ConsentText
@@ -6367,6 +6846,14 @@ func NewPracticeItemContentItemContent(v PracticeItemContent) ItemContent {
return s
}
type ListMyConsentsBadRequest Problem
func (*ListMyConsentsBadRequest) listMyConsentsRes() {}
type ListMyConsentsUnauthorized Problem
func (*ListMyConsentsUnauthorized) listMyConsentsRes() {}
type ListMyInvitationsBadRequest Problem
func (*ListMyInvitationsBadRequest) listMyInvitationsRes() {}
@@ -9105,6 +9592,96 @@ func (o NilCandidateExperience) Or(d CandidateExperience) CandidateExperience {
return d
}
// NewNilConsentOrganization returns new NilConsentOrganization with value set to v.
func NewNilConsentOrganization(v ConsentOrganization) NilConsentOrganization {
return NilConsentOrganization{
Value: v,
}
}
// NilConsentOrganization is nullable ConsentOrganization.
type NilConsentOrganization struct {
Value ConsentOrganization
Null bool
}
// SetTo sets value to v.
func (o *NilConsentOrganization) SetTo(v ConsentOrganization) {
o.Null = false
o.Value = v
}
// IsNull returns true if value is Null.
func (o NilConsentOrganization) IsNull() bool { return o.Null }
// SetToNull sets value to null.
func (o *NilConsentOrganization) SetToNull() {
o.Null = true
var v ConsentOrganization
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o NilConsentOrganization) Get() (v ConsentOrganization, ok bool) {
if o.Null {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o NilConsentOrganization) Or(d ConsentOrganization) ConsentOrganization {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewNilConsentRevocationSource returns new NilConsentRevocationSource with value set to v.
func NewNilConsentRevocationSource(v ConsentRevocationSource) NilConsentRevocationSource {
return NilConsentRevocationSource{
Value: v,
}
}
// NilConsentRevocationSource is nullable ConsentRevocationSource.
type NilConsentRevocationSource struct {
Value ConsentRevocationSource
Null bool
}
// SetTo sets value to v.
func (o *NilConsentRevocationSource) SetTo(v ConsentRevocationSource) {
o.Null = false
o.Value = v
}
// IsNull returns true if value is Null.
func (o NilConsentRevocationSource) IsNull() bool { return o.Null }
// SetToNull sets value to null.
func (o *NilConsentRevocationSource) SetToNull() {
o.Null = true
var v ConsentRevocationSource
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o NilConsentRevocationSource) Get() (v ConsentRevocationSource, ok bool) {
if o.Null {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o NilConsentRevocationSource) Or(d ConsentRevocationSource) ConsentRevocationSource {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewNilContactAccessBlock returns new NilContactAccessBlock with value set to v.
func NewNilContactAccessBlock(v ContactAccessBlock) NilContactAccessBlock {
return NilContactAccessBlock{
@@ -9825,6 +10402,51 @@ func (o NilInvitationNeedReference) Or(d InvitationNeedReference) InvitationNeed
return d
}
// NewNilInvitationTermsVersion returns new NilInvitationTermsVersion with value set to v.
func NewNilInvitationTermsVersion(v InvitationTermsVersion) NilInvitationTermsVersion {
return NilInvitationTermsVersion{
Value: v,
}
}
// NilInvitationTermsVersion is nullable InvitationTermsVersion.
type NilInvitationTermsVersion struct {
Value InvitationTermsVersion
Null bool
}
// SetTo sets value to v.
func (o *NilInvitationTermsVersion) SetTo(v InvitationTermsVersion) {
o.Null = false
o.Value = v
}
// IsNull returns true if value is Null.
func (o NilInvitationTermsVersion) IsNull() bool { return o.Null }
// SetToNull sets value to null.
func (o *NilInvitationTermsVersion) SetToNull() {
o.Null = true
var v InvitationTermsVersion
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o NilInvitationTermsVersion) Get() (v InvitationTermsVersion, ok bool) {
if o.Null {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o NilInvitationTermsVersion) Or(d InvitationTermsVersion) InvitationTermsVersion {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewNilNeedDomainName returns new NilNeedDomainName with value set to v.
func NewNilNeedDomainName(v NeedDomainName) NilNeedDomainName {
return NilNeedDomainName{
@@ -11114,6 +11736,52 @@ func (s *OnboardingStep) UnmarshalText(data []byte) error {
}
}
// NewOptConsentState returns new OptConsentState with value set to v.
func NewOptConsentState(v ConsentState) OptConsentState {
return OptConsentState{
Value: v,
Set: true,
}
}
// OptConsentState is optional ConsentState.
type OptConsentState struct {
Value ConsentState
Set bool
}
// IsSet returns true if OptConsentState was set.
func (o OptConsentState) IsSet() bool { return o.Set }
// Reset unsets value.
func (o *OptConsentState) Reset() {
var v ConsentState
o.Value = v
o.Set = false
}
// SetTo sets value to v.
func (o *OptConsentState) SetTo(v ConsentState) {
o.Set = true
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o OptConsentState) Get() (v ConsentState, ok bool) {
if !o.Set {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o OptConsentState) Or(d ConsentState) ConsentState {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewOptInt32 returns new OptInt32 with value set to v.
func NewOptInt32(v int32) OptInt32 {
return OptInt32{