Skip to content

Commit 62ea1ed

Browse files
refactor: rename StoredCredential.id to session_id to avoid confusion
1 parent fc5bca9 commit 62ea1ed

File tree

19 files changed

+40
-40
lines changed

19 files changed

+40
-40
lines changed

crypto/src/mls/credential/credential_ref/find.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl CredentialRef {
7272
.map_err(KeystoreError::wrap("finding all credentials"))?
7373
.into_iter()
7474
.filter(|stored| {
75-
client_id.is_none_or(|client_id| client_id.as_ref() == stored.id)
75+
client_id.is_none_or(|client_id| client_id.as_ref() == stored.session_id)
7676
&& earliest_validity.is_none_or(|earliest_validity| earliest_validity == stored.created_at)
7777
&& ciphersuite.is_none_or(|ciphersuite| u16::from(ciphersuite) == stored.ciphersuite)
7878
&& public_key.is_none_or(|public_key| public_key == stored.public_key)
@@ -96,7 +96,7 @@ impl CredentialRef {
9696
&& let Ok(ciphersuite) = stored_credential.ciphersuite.try_into()
9797
{
9898
out.push(Self {
99-
client_id: ClientId(stored_credential.id.clone()),
99+
client_id: ClientId(stored_credential.session_id.clone()),
100100
r#type,
101101
ciphersuite,
102102
earliest_validity: stored_credential.created_at,

crypto/src/mls/credential/credential_ref/persistence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl CredentialRef {
6363
// these are the only checks we can currently do at the DB level: match the client id, creation timestamp,
6464
// public key and signature scheme
6565
.filter(|stored_credential|
66-
stored_credential.id == self.client_id().as_slice()
66+
stored_credential.session_id == self.client_id().as_slice()
6767
&& stored_credential.created_at == self.earliest_validity
6868
&& stored_credential.public_key == self.public_key
6969
&& stored_credential.ciphersuite == u16::from(self.ciphersuite)

crypto/src/mls/credential/persistence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl Credential {
2828

2929
let stored_credential = database
3030
.save(StoredCredential {
31-
id: self.client_id().to_owned().into_inner(),
31+
session_id: self.client_id().to_owned().into_inner(),
3232
credential: credential_data,
3333
created_at: Default::default(), // updated by the `.save` impl
3434
ciphersuite: u16::from(self.ciphersuite),

keystore-dump/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async fn main() -> anyhow::Result<()> {
6262
.ok_or_else(|| anyhow!("Cannot parse credential creation date"))?;
6363

6464
credentials.push(serde_json::json!({
65-
"id": cred.id,
65+
"session_id": cred.session_id,
6666
"credential": mls_credential,
6767
"created_at": date,
6868
"mls_keypair": mls_keypair,

keystore/src/connection/platform/generic/meta_migrations/v16.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub(crate) fn meta_migration(conn: &mut rusqlite::Connection) -> CryptoKeystoreR
4949
if let Some(c) = migrate_to_new_credential(&v5, &kp)? {
5050
tx.execute(
5151
"INSERT INTO mls_credentials_new (
52-
id,
52+
session_id,
5353
credential,
5454
created_at,
5555
signature_scheme,
@@ -58,7 +58,7 @@ pub(crate) fn meta_migration(conn: &mut rusqlite::Connection) -> CryptoKeystoreR
5858
)
5959
VALUES (?1, ?2, datetime(?3, 'unixepoch'), ?4, ?5, ?6)",
6060
(
61-
c.id.clone(),
61+
c.session_id.clone(),
6262
c.credential.clone(),
6363
c.created_at,
6464
c.signature_scheme,

keystore/src/connection/platform/generic/meta_migrations/v18.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(crate) fn meta_migration(conn: &mut rusqlite::Connection) -> CryptoKeystoreR
2626

2727
let mut credential_stmt = tx.prepare(&format!(
2828
"SELECT
29-
id,
29+
session_id,
3030
credential,
3131
unixepoch(created_at) AS created_at,
3232
signature_scheme,
@@ -39,7 +39,7 @@ pub(crate) fn meta_migration(conn: &mut rusqlite::Connection) -> CryptoKeystoreR
3939
let mut rows = credential_stmt.query([])?;
4040
while let Some(row) = rows.next()? {
4141
let v6 = V6Credential {
42-
id: row.get("id")?,
42+
session_id: row.get("session_id")?,
4343
credential: row.get("credential")?,
4444
created_at: row.get("created_at")?,
4545
signature_scheme: row.get("signature_scheme")?,
@@ -52,7 +52,7 @@ pub(crate) fn meta_migration(conn: &mut rusqlite::Connection) -> CryptoKeystoreR
5252
if let Some(ciphersuite) = ciphersuite_for_signature_scheme(v6.signature_scheme) {
5353
tx.execute(
5454
"INSERT INTO mls_credentials_new (
55-
id,
55+
session_id,
5656
credential,
5757
created_at,
5858
ciphersuite,
@@ -61,7 +61,7 @@ pub(crate) fn meta_migration(conn: &mut rusqlite::Connection) -> CryptoKeystoreR
6161
)
6262
VALUES (?1, ?2, datetime(?3, 'unixepoch'), ?4, ?5, ?6)",
6363
(
64-
v6.id.clone(),
64+
v6.session_id.clone(),
6565
v6.credential.clone(),
6666
v6.created_at,
6767
ciphersuite,

keystore/src/connection/platform/generic/meta_migrations/v19.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub(crate) fn meta_migration(conn: &mut rusqlite::Connection) -> CryptoKeystoreR
3434
Ok(StoredCredential {
3535
ciphersuite: row.get("ciphersuite")?,
3636
public_key: row.get("public_key")?,
37-
id: Vec::new(), // not relevant for this application
37+
session_id: Vec::new(), // not relevant for this application
3838
credential: Vec::new(), // not relevant for this application
3939
created_at: 0, // not relevant for this application
4040
private_key: Vec::new(), // not relevant for this application

keystore/src/connection/platform/generic/migrations/V16__prepare_credential_merge.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CREATE TABLE mls_credentials_new (
2-
id BLOB NOT NULL,
2+
session_id BLOB NOT NULL,
33
credential BLOB NOT NULL,
44
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
55
signature_scheme INT NOT NULL,

keystore/src/connection/platform/generic/migrations/V18__prepare_credential_ciphersuite.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CREATE TABLE mls_credentials_new (
2-
id BLOB NOT NULL,
2+
session_id BLOB NOT NULL,
33
credential BLOB NOT NULL,
44
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
55
ciphersuite INT NOT NULL,

keystore/src/connection/platform/generic/migrations/V20__credentials_new_primary_key.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CREATE TABLE mls_credentials_new (
22
public_key_sha256 TEXT UNIQUE NOT NULL,
33
public_key BLOB NOT NULL,
4-
id BLOB NOT NULL,
4+
session_id BLOB NOT NULL,
55
credential BLOB NOT NULL,
66
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
77
ciphersuite INT NOT NULL,
@@ -11,15 +11,15 @@ CREATE TABLE mls_credentials_new (
1111
INSERT INTO mls_credentials_new (
1212
public_key_sha256,
1313
public_key,
14-
id,
14+
session_id,
1515
credential,
1616
created_at,
1717
ciphersuite,
1818
private_key
1919
)
2020
SELECT sha256_blob(public_key),
2121
public_key,
22-
id,
22+
session_id,
2323
credential,
2424
created_at,
2525
ciphersuite,

0 commit comments

Comments
 (0)