Skip to content

Commit e538fe1

Browse files
committed
Merge branch 'tim/new_verif_method_oidc' into 'master'
feat: Upgrade verif method with new OIDC provider fields (BREAKING) See merge request TankerHQ/sdk-rust!171
2 parents b34f598 + 6fab187 commit e538fe1

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/verification_methods.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ pub enum VerificationMethod {
1515
Passphrase,
1616
VerificationKey,
1717
#[allow(clippy::upper_case_acronyms)]
18-
OIDCIDToken,
18+
OIDCIDToken {
19+
provider_id: String,
20+
provider_display_name: String,
21+
},
1922
PhoneNumber(String),
2023
PreverifiedEmail(String),
2124
PreverifiedPhoneNumber(String),
@@ -46,28 +49,38 @@ impl VerificationMethod {
4649
match ctype.into() {
4750
CMethodType::Email => {
4851
// SAFETY: If we get a valid Email verification method, the email is a valid string
49-
let c_email = unsafe { CStr::from_ptr(method.value) };
52+
let c_email = unsafe { CStr::from_ptr(method.value1) };
5053
let email = c_email.to_str().unwrap().into();
5154
Ok(VerificationMethod::Email(email))
5255
}
5356
CMethodType::Passphrase => Ok(VerificationMethod::Passphrase),
5457
CMethodType::VerificationKey => Ok(VerificationMethod::VerificationKey),
55-
CMethodType::OIDCIDToken => Ok(VerificationMethod::OIDCIDToken),
58+
CMethodType::OIDCIDToken => {
59+
// SAFETY: If we get a valid OIDC verification method, the values are valid strings
60+
let c_prov_id = unsafe { CStr::from_ptr(method.value1) };
61+
let provider_id = c_prov_id.to_str().unwrap().into();
62+
let c_prov_name = unsafe { CStr::from_ptr(method.value2) };
63+
let provider_display_name = c_prov_name.to_str().unwrap().into();
64+
Ok(VerificationMethod::OIDCIDToken {
65+
provider_id,
66+
provider_display_name,
67+
})
68+
}
5669
CMethodType::PhoneNumber => {
5770
// SAFETY: If we get a valid PhoneNumber verification method, the number is a valid string
58-
let c_phone_number = unsafe { CStr::from_ptr(method.value) };
71+
let c_phone_number = unsafe { CStr::from_ptr(method.value1) };
5972
let phone_number = c_phone_number.to_str().unwrap().into();
6073
Ok(VerificationMethod::PhoneNumber(phone_number))
6174
}
6275
CMethodType::PreverifiedEmail => {
6376
// SAFETY: If we get a valid Email verification method, the email is a valid string
64-
let c_preverified_email = unsafe { CStr::from_ptr(method.value) };
77+
let c_preverified_email = unsafe { CStr::from_ptr(method.value1) };
6578
let preverified_email = c_preverified_email.to_str().unwrap().into();
6679
Ok(VerificationMethod::PreverifiedEmail(preverified_email))
6780
}
6881
CMethodType::PreverifiedPhoneNumber => {
6982
// SAFETY: If we get a valid PhoneNumber verification method, the number is a valid string
70-
let c_preverified_phone_number = unsafe { CStr::from_ptr(method.value) };
83+
let c_preverified_phone_number = unsafe { CStr::from_ptr(method.value1) };
7184
let preverified_phone_number = c_preverified_phone_number.to_str().unwrap().into();
7285
Ok(VerificationMethod::PreverifiedPhoneNumber(
7386
preverified_phone_number,

0 commit comments

Comments
 (0)