internal

package
v0.0.0-...-891d188 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const NoEncryptedDevice = "device-default"

NoEncryptedDevice is the device ID used when there are no E2E messages sent by this user

Variables

View Source
var RedactRules = map[string][]redaction{
	"all": {
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
	},

	"m.room.create": {
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.name": {
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.topic": {
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.avatar": {
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.canonical_alias": {
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.server_acl": {
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
	},
	"m.reaction": {
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.encryption": {
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.guest_access": {
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.history_visibility": {
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.join_rules": {
		{
			// contains filtered or unexported fields
		},
	},
	"org.matrix.room.preview_urls": {
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.tombstone": {
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.pinned_events": {
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.member": {
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.power_levels": {
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.encrypted": {
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.redaction": {
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
	},
	"m.room.message": {
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
		{
			// contains filtered or unexported fields
		},
	},
}

RedactRules are the rules to apply. Only the event types present in this map will be kept, all other ones are dropped. Only keys matched in the redact rules are kept, all other keys are dropped, hence some rules are pass-through (e.g. room_version, type)

Functions

func ConvertToBlueprint

func ConvertToBlueprint(s *Snapshot, serverName string) (*b.Blueprint, error)

ConvertToBlueprint converts a /sync snapshot to a Complement blueprint

func LoadSyncData

func LoadSyncData(hsURL, token, tempFile string) (json.RawMessage, error)

LoadSyncData loads sync data from disk or by doing a /sync request

Types

type AnonMappings

type AnonMappings struct {
	Users             map[string]string          // real user ID -> anonymised
	UsersCount        int                        // counter for generating anonymous user IDs
	Devices           map[string]string          // real device ID -> anonymised device ID
	DevicesCount      int                        // counter for generating anonymous devices
	Servers           map[string]string          // real server name -> anonymised server name
	ServersCount      int                        // counter for generating anonymous servers
	Rooms             map[string]string          // real room ID -> anonymised room ID, counter is from sorted room IDs
	AnonUserToDevices map[string]map[string]bool // anon user -> anon devices
	SingleServerName  string                     // if set, all users get to live on this single server
}

AnonMappings contains the mappings to convert live sync data to anonymous sync data. This is done via incremental counts rather than hashing which is potentially vulnerable to reverse lookup attacks.

func (*AnonMappings) Device

func (a *AnonMappings) Device(userID, deviceID string) string

func (*AnonMappings) Room

func (a *AnonMappings) Room(roomID string) string

func (*AnonMappings) Server

func (a *AnonMappings) Server(realServer string) string

func (*AnonMappings) SetRoom

func (a *AnonMappings) SetRoom(roomID, anonRoomID string)

func (*AnonMappings) User

func (a *AnonMappings) User(userID string) string

type AnonSnapshotRoom

type AnonSnapshotRoom struct {
	ID       string
	Creator  string
	State    []json.RawMessage
	Timeline []json.RawMessage
}

type Snapshot

type Snapshot struct {
	Rooms          []AnonSnapshotRoom
	Servers        []string
	AccountDataDMs map[string][]string
	Devices        map[string][]string
	UserID         string // the anonymous user whose snapshot this is - important for setting account data
}

Snapshot is the output produced by this script

func Redact

func Redact(syncData []byte, anonMappings AnonMappings) *Snapshot

Redact syncData into an anonymised snapshot

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL