Skip to content

Commit

Permalink
Merge pull request #103 from matrix-org/valere/crypto_session_status
Browse files Browse the repository at this point in the history
Add a new crypto session state event
  • Loading branch information
BillCarsonFr authored May 6, 2024
2 parents a113706 + 6c0c517 commit f10d044
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2021 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.app.features.analytics.plan

import im.vector.app.features.analytics.itf.VectorAnalyticsEvent

// GENERATED FILE, DO NOT EDIT. FOR MORE INFORMATION VISIT
// https://github.com/matrix-org/matrix-analytics-events/

/**
* Describe the current session crypto state, that is if the session is verified
* or not, if recovery is correctly setup.
*/
data class CryptoSessionStateChange(
val recoveryState: RecoveryState,
val verificationState: VerificationState,
) : VectorAnalyticsEvent {

enum class VerificationState {
/**
* The device is unverified.
*/
NotVerified,

/**
* The device is considered to be verified, it has been signed by its
* user identity.
*/
Verified,
}

enum class RecoveryState {

/**
* No default secret storage key exists or it is disabled explicitly
* using the account data event.
*/
Disabled,

/**
* Secret storage is set up and we have all the secrets locally.
*/
Enabled,

/**
* Secret storage is set up but we're missing some secrets.
*/
Incomplete,
}

override fun getName() = "CryptoSessionState"

override fun getProperties(): Map<String, Any>? {
return mutableMapOf<String, Any>().apply {
put("recoveryState", recoveryState.name)
put("verificationState", verificationState.name)
}.takeIf { it.isNotEmpty() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ data class UserProperties(
* Number of spaces (and sub-spaces) the user is joined to.
*/
val numSpaces: Int? = null,
/**
* Describe the current session recovery state, that if 4S is setup,
* complete (all secrets cached) or not.
*/
val recoveryState: RecoveryState? = null,
/**
* Describe the current session verification state, that is if the
* session is verified or not.
*/
val verificationState: VerificationState? = null,
) {

enum class FtueUseCaseSelection {
Expand Down Expand Up @@ -87,12 +97,47 @@ data class UserProperties(
Unreads,
}

enum class VerificationState {

/**
* The device is unverified.
*/
NotVerified,

/**
* The device is considered to be verified, it has been signed by its
* user identity.
*/
Verified,
}

enum class RecoveryState {

/**
* No default secret storage key exists or it is disabled explicitly
* using the account data event.
*/
Disabled,

/**
* Secret storage is set up and we have all the secrets locally.
*/
Enabled,

/**
* Secret storage is set up but we're missing some secrets.
*/
Incomplete,
}

fun getProperties(): Map<String, Any>? {
return mutableMapOf<String, Any>().apply {
allChatsActiveFilter?.let { put("allChatsActiveFilter", it.name) }
ftueUseCaseSelection?.let { put("ftueUseCaseSelection", it.name) }
numFavouriteRooms?.let { put("numFavouriteRooms", it) }
numSpaces?.let { put("numSpaces", it) }
recoveryState?.let { put("recoveryState", it.name) }
verificationState?.let { put("verificationState", it.name) }
}.takeIf { it.isNotEmpty() }
}
}
26 changes: 26 additions & 0 deletions schemas/CryptoSessionStateChange.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"type": "object",
"description": "Describe the current session crypto state, that is if the session is verified or not, if recovery is correctly setup.",
"properties": {
"eventName": {
"enum": ["CryptoSessionState"]
},
"verificationState": {
"type": "string",
"oneOf": [
{"const": "Verified", "description": "The device is considered to be verified, it has been signed by its user identity."},
{"const": "NotVerified", "description": "The device is unverified."}
]
},
"recoveryState": {
"type": "string",
"oneOf": [
{"const": "Enabled", "description": "Secret storage is set up and we have all the secrets locally."},
{"const": "Disabled", "description": "No default secret storage key exists or it is disabled explicitly using the account data event."},
{"const": "Incomplete", "description": "Secret storage is set up but we're missing some secrets."}
]
}
},
"required": ["eventName","verificationState", "recoveryState"],
"additionalProperties": false
}
17 changes: 17 additions & 0 deletions schemas/UserProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@
{"const": "Group", "description": "Modern layout."},
{"const": "Compact", "description": "Modern layout with compact option enabled."}
]
},
"verificationState": {
"description": "Describe the current session verification state, that is if the session is verified or not.",
"type": "string",
"oneOf": [
{"const": "Verified", "description": "The device is considered to be verified, it has been signed by its user identity."},
{"const": "NotVerified", "description": "The device is unverified."}
]
},
"recoveryState": {
"description": "Describe the current session recovery state, that if 4S is setup, complete (all secrets cached) or not.",
"type": "string",
"oneOf": [
{"const": "Enabled", "description": "Secret storage is set up and we have all the secrets locally."},
{"const": "Disabled", "description": "No default secret storage key exists or it is disabled explicitly using the account data event."},
{"const": "Incomplete", "description": "Secret storage is set up but we're missing some secrets."}
]
}
},
"required": [],
Expand Down
58 changes: 58 additions & 0 deletions types/swift/CryptoSessionStateChange.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

// GENERATED FILE, DO NOT EDIT. FOR MORE INFORMATION VISIT
// https://github.com/matrix-org/matrix-analytics-events/

/// Describe the current session crypto state, that is if the session is verified or not, if recovery is correctly setup.
extension AnalyticsEvent {
public struct CryptoSessionStateChange: AnalyticsEventProtocol {
public let eventName = "CryptoSessionState"

public let recoveryState: RecoveryState
public let verificationState: VerificationState

public init(recoveryState: RecoveryState, verificationState: VerificationState) {
self.recoveryState = recoveryState
self.verificationState = verificationState
}

public enum VerificationState: String {
/// The device is unverified.
case NotVerified
/// The device is considered to be verified, it has been signed by its user identity.
case Verified
}

public enum RecoveryState: String {
/// No default secret storage key exists or it is disabled explicitly using the account data event.
case Disabled
/// Secret storage is set up and we have all the secrets locally.
case Enabled
/// Secret storage is set up but we're missing some secrets.
case Incomplete
}

public var properties: [String: Any] {
return [
"recoveryState": recoveryState.rawValue,
"verificationState": verificationState.rawValue
]
}
}
}
28 changes: 26 additions & 2 deletions types/swift/UserProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ extension AnalyticsEvent {
public let numFavouriteRooms: Int?
/// Number of spaces (and sub-spaces) the user is joined to.
public let numSpaces: Int?
/// Describe the current session recovery state, that if 4S is setup, complete (all secrets cached) or not.
public let recoveryState: RecoveryState?
/// Describe the current session verification state, that is if the session is verified or not.
public let verificationState: VerificationState?

public init(allChatsActiveFilter: AllChatsActiveFilter?, ftueUseCaseSelection: FtueUseCaseSelection?, numFavouriteRooms: Int?, numSpaces: Int?) {
public init(allChatsActiveFilter: AllChatsActiveFilter?, ftueUseCaseSelection: FtueUseCaseSelection?, numFavouriteRooms: Int?, numSpaces: Int?, recoveryState: RecoveryState?, verificationState: VerificationState?) {
self.allChatsActiveFilter = allChatsActiveFilter
self.ftueUseCaseSelection = ftueUseCaseSelection
self.numFavouriteRooms = numFavouriteRooms
self.numSpaces = numSpaces
self.recoveryState = recoveryState
self.verificationState = verificationState
}

public enum FtueUseCaseSelection: String {
Expand All @@ -61,12 +67,30 @@ extension AnalyticsEvent {
case Unreads
}

public enum VerificationState: String {
/// The device is unverified.
case NotVerified
/// The device is considered to be verified, it has been signed by its user identity.
case Verified
}

public enum RecoveryState: String {
/// No default secret storage key exists or it is disabled explicitly using the account data event.
case Disabled
/// Secret storage is set up and we have all the secrets locally.
case Enabled
/// Secret storage is set up but we're missing some secrets.
case Incomplete
}

public var properties: [String: Any?] {
return [
"allChatsActiveFilter": allChatsActiveFilter?.rawValue,
"ftueUseCaseSelection": ftueUseCaseSelection?.rawValue,
"numFavouriteRooms": numFavouriteRooms,
"numSpaces": numSpaces
"numSpaces": numSpaces,
"recoveryState": recoveryState?.rawValue,
"verificationState": verificationState?.rawValue
]
}
}
Expand Down

0 comments on commit f10d044

Please sign in to comment.