Page MenuHomePhorge

D10213.1767483039.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D10213.1767483039.diff

diff --git a/services/identity/src/constants.rs b/services/identity/src/constants.rs
--- a/services/identity/src/constants.rs
+++ b/services/identity/src/constants.rs
@@ -66,6 +66,8 @@
pub const USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE: &str = "walletAddress";
pub const USERS_TABLE_DEVICES_MAP_SOCIAL_PROOF_ATTRIBUTE_NAME: &str =
"socialProof";
+pub const USERS_TABLE_DEVICELIST_TIMESTAMP_ATTRIBUTE_NAME: &str =
+ "deviceListTimestamp";
pub const USERS_TABLE_USERNAME_INDEX: &str = "username-index";
pub const USERS_TABLE_WALLET_ADDRESS_INDEX: &str = "walletAddress-index";
@@ -88,6 +90,40 @@
pub const RESERVED_USERNAMES_TABLE: &str = "identity-reserved-usernames";
pub const RESERVED_USERNAMES_TABLE_PARTITION_KEY: &str = "username";
+pub mod devices_table {
+ /// table name
+ pub const NAME: &str = "identity-devices";
+ pub const TIMESTAMP_INDEX_NAME: &str = "deviceList-timestamp-index";
+
+ /// partition key
+ pub const ATTR_USER_ID: &str = "userID";
+ /// sort key
+ pub const ATTR_ITEM_ID: &str = "itemID";
+
+ // itemID prefixes (one shouldn't be a prefix of the other)
+ pub const DEVICE_ITEM_KEY_PREFIX: &str = "device-";
+ pub const DEVICE_LIST_KEY_PREFIX: &str = "devicelist-";
+
+ // device-specific attrs
+ pub const ATTR_DEVICE_TYPE: &str = "deviceType";
+ pub const ATTR_DEVICE_KEY_INFO: &str = "deviceKeyInfo";
+ pub const ATTR_CONTENT_PREKEY: &str = "contentPreKey";
+ pub const ATTR_NOTIF_PREKEY: &str = "notifPreKey";
+
+ // IdentityKeyInfo constants
+ pub const ATTR_KEY_PAYLOAD: &str = "keyPayload";
+ pub const ATTR_KEY_PAYLOAD_SIGNATURE: &str = "keyPayloadSignature";
+ pub const ATTR_SOCIAL_PROOF: &str = "socialProof";
+
+ // PreKey constants
+ pub const ATTR_PREKEY: &str = "preKey";
+ pub const ATTR_PREKEY_SIGNATURE: &str = "preKeySignature";
+
+ // device-list-specific attrs
+ pub const ATTR_TIMESTAMP: &str = "timestamp";
+ pub const ATTR_DEVICE_IDS: &str = "deviceIDs";
+}
+
// One time keys table, which need to exist in their own table to ensure
// atomicity of additions and removals
pub mod one_time_keys_table {
diff --git a/services/identity/src/database.rs b/services/identity/src/database.rs
--- a/services/identity/src/database.rs
+++ b/services/identity/src/database.rs
@@ -49,6 +49,8 @@
use crate::token::{AccessTokenData, AuthType};
pub use grpc_clients::identity::DeviceType;
+mod device_list;
+
#[derive(Serialize, Deserialize)]
pub struct OlmKeys {
pub curve25519: String,
diff --git a/services/identity/src/database/device_list.rs b/services/identity/src/database/device_list.rs
new file mode 100644
--- /dev/null
+++ b/services/identity/src/database/device_list.rs
@@ -0,0 +1,47 @@
+// TODO: get rid of this
+#![allow(dead_code)]
+
+use std::collections::HashMap;
+
+use aws_sdk_dynamodb::model::AttributeValue;
+use chrono::{DateTime, Utc};
+
+use crate::grpc_services::protos::unauth::DeviceType;
+
+type RawAttributes = HashMap<String, AttributeValue>;
+
+#[derive(Clone, Debug)]
+pub enum DevicesTableRow {
+ Device(DeviceRow),
+ DeviceList(DeviceListRow),
+}
+
+#[derive(Clone, Debug)]
+pub struct DeviceRow {
+ pub user_id: String,
+ pub device_id: String,
+ pub device_type: DeviceType,
+ pub device_key_info: IdentityKeyInfo,
+ pub content_prekey: PreKey,
+ pub notif_prekey: PreKey,
+}
+
+#[derive(Clone, Debug)]
+pub struct DeviceListRow {
+ pub user_id: String,
+ pub timestamp: DateTime<Utc>,
+ pub device_ids: Vec<String>,
+}
+
+#[derive(Clone, Debug)]
+pub struct IdentityKeyInfo {
+ pub payload: String,
+ pub payload_signature: String,
+ pub social_proof: Option<String>,
+}
+
+#[derive(Clone, Debug)]
+pub struct PreKey {
+ pub pre_key: String,
+ pub pre_key_signature: String,
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 3, 11:30 PM (14 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5891328
Default Alt Text
D10213.1767483039.diff (3 KB)

Event Timeline