Skip to content

Commit a823b5f

Browse files
refactor(device): Remove smartcard device
Should use `PKI` device instead
1 parent b68046e commit a823b5f

File tree

31 files changed

+58
-673
lines changed

31 files changed

+58
-673
lines changed

bindings/electron/src/index.d.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,17 +1075,13 @@ export interface AvailableDeviceTypePassword {
10751075
export interface AvailableDeviceTypeRecovery {
10761076
tag: "AvailableDeviceTypeRecovery"
10771077
}
1078-
export interface AvailableDeviceTypeSmartcard {
1079-
tag: "AvailableDeviceTypeSmartcard"
1080-
}
10811078
export type AvailableDeviceType =
10821079
| AvailableDeviceTypeAccountVault
10831080
| AvailableDeviceTypeKeyring
10841081
| AvailableDeviceTypeOpenBao
10851082
| AvailableDeviceTypePKI
10861083
| AvailableDeviceTypePassword
10871084
| AvailableDeviceTypeRecovery
1088-
| AvailableDeviceTypeSmartcard
10891085

10901086

10911087
// BootstrapOrganizationError
@@ -2328,17 +2324,12 @@ export interface DeviceAccessStrategyPassword {
23282324
password: string
23292325
key_file: string
23302326
}
2331-
export interface DeviceAccessStrategySmartcard {
2332-
tag: "DeviceAccessStrategySmartcard"
2333-
key_file: string
2334-
}
23352327
export type DeviceAccessStrategy =
23362328
| DeviceAccessStrategyAccountVault
23372329
| DeviceAccessStrategyKeyring
23382330
| DeviceAccessStrategyOpenBao
23392331
| DeviceAccessStrategyPKI
23402332
| DeviceAccessStrategyPassword
2341-
| DeviceAccessStrategySmartcard
23422333

23432334

23442335
// DeviceSaveStrategy
@@ -2365,17 +2356,12 @@ export interface DeviceSaveStrategyPassword {
23652356
tag: "DeviceSaveStrategyPassword"
23662357
password: string
23672358
}
2368-
export interface DeviceSaveStrategySmartcard {
2369-
tag: "DeviceSaveStrategySmartcard"
2370-
certificate_reference: X509CertificateReference
2371-
}
23722359
export type DeviceSaveStrategy =
23732360
| DeviceSaveStrategyAccountVault
23742361
| DeviceSaveStrategyKeyring
23752362
| DeviceSaveStrategyOpenBao
23762363
| DeviceSaveStrategyPKI
23772364
| DeviceSaveStrategyPassword
2378-
| DeviceSaveStrategySmartcard
23792365

23802366

23812367
// EntryStat

bindings/electron/src/meths.rs

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6524,7 +6524,6 @@ fn variant_available_device_type_js_to_rs<'a>(
65246524
}
65256525
"AvailableDeviceTypePassword" => Ok(libparsec::AvailableDeviceType::Password {}),
65266526
"AvailableDeviceTypeRecovery" => Ok(libparsec::AvailableDeviceType::Recovery {}),
6527-
"AvailableDeviceTypeSmartcard" => Ok(libparsec::AvailableDeviceType::Smartcard {}),
65286527
_ => cx.throw_type_error("Object is not a AvailableDeviceType"),
65296528
}
65306529
}
@@ -6574,10 +6573,6 @@ fn variant_available_device_type_rs_to_js<'a>(
65746573
let js_tag = JsString::try_new(cx, "AvailableDeviceTypeRecovery").or_throw(cx)?;
65756574
js_obj.set(cx, "tag", js_tag)?;
65766575
}
6577-
libparsec::AvailableDeviceType::Smartcard { .. } => {
6578-
let js_tag = JsString::try_new(cx, "AvailableDeviceTypeSmartcard").or_throw(cx)?;
6579-
js_obj.set(cx, "tag", js_tag)?;
6580-
}
65816576
}
65826577
Ok(js_obj)
65836578
}
@@ -9405,20 +9400,6 @@ fn variant_device_access_strategy_js_to_rs<'a>(
94059400
};
94069401
Ok(libparsec::DeviceAccessStrategy::Password { password, key_file })
94079402
}
9408-
"DeviceAccessStrategySmartcard" => {
9409-
let key_file = {
9410-
let js_val: Handle<JsString> = obj.get(cx, "keyFile")?;
9411-
{
9412-
let custom_from_rs_string =
9413-
|s: String| -> Result<_, &'static str> { Ok(std::path::PathBuf::from(s)) };
9414-
match custom_from_rs_string(js_val.value(cx)) {
9415-
Ok(val) => val,
9416-
Err(err) => return cx.throw_type_error(err),
9417-
}
9418-
}
9419-
};
9420-
Ok(libparsec::DeviceAccessStrategy::Smartcard { key_file })
9421-
}
94229403
_ => cx.throw_type_error("Object is not a DeviceAccessStrategy"),
94239404
}
94249405
}
@@ -9541,23 +9522,6 @@ fn variant_device_access_strategy_rs_to_js<'a>(
95419522
.or_throw(cx)?;
95429523
js_obj.set(cx, "keyFile", js_key_file)?;
95439524
}
9544-
libparsec::DeviceAccessStrategy::Smartcard { key_file, .. } => {
9545-
let js_tag = JsString::try_new(cx, "DeviceAccessStrategySmartcard").or_throw(cx)?;
9546-
js_obj.set(cx, "tag", js_tag)?;
9547-
let js_key_file = JsString::try_new(cx, {
9548-
let custom_to_rs_string = |path: std::path::PathBuf| -> Result<_, _> {
9549-
path.into_os_string()
9550-
.into_string()
9551-
.map_err(|_| "Path contains non-utf8 characters")
9552-
};
9553-
match custom_to_rs_string(key_file) {
9554-
Ok(ok) => ok,
9555-
Err(err) => return cx.throw_type_error(err.to_string()),
9556-
}
9557-
})
9558-
.or_throw(cx)?;
9559-
js_obj.set(cx, "keyFile", js_key_file)?;
9560-
}
95619525
}
95629526
Ok(js_obj)
95639527
}
@@ -9635,15 +9599,6 @@ fn variant_device_save_strategy_js_to_rs<'a>(
96359599
};
96369600
Ok(libparsec::DeviceSaveStrategy::Password { password })
96379601
}
9638-
"DeviceSaveStrategySmartcard" => {
9639-
let certificate_reference = {
9640-
let js_val: Handle<JsObject> = obj.get(cx, "certificateReference")?;
9641-
struct_x509_certificate_reference_js_to_rs(cx, js_val)?
9642-
};
9643-
Ok(libparsec::DeviceSaveStrategy::Smartcard {
9644-
certificate_reference,
9645-
})
9646-
}
96479602
_ => cx.throw_type_error("Object is not a DeviceSaveStrategy"),
96489603
}
96499604
}
@@ -9703,16 +9658,6 @@ fn variant_device_save_strategy_rs_to_js<'a>(
97039658
let js_password = JsString::try_new(cx, password).or_throw(cx)?;
97049659
js_obj.set(cx, "password", js_password)?;
97059660
}
9706-
libparsec::DeviceSaveStrategy::Smartcard {
9707-
certificate_reference,
9708-
..
9709-
} => {
9710-
let js_tag = JsString::try_new(cx, "DeviceSaveStrategySmartcard").or_throw(cx)?;
9711-
js_obj.set(cx, "tag", js_tag)?;
9712-
let js_certificate_reference =
9713-
struct_x509_certificate_reference_rs_to_js(cx, certificate_reference)?;
9714-
js_obj.set(cx, "certificateReference", js_certificate_reference)?;
9715-
}
97169661
}
97179662
Ok(js_obj)
97189663
}

bindings/generator/api/device.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class AvailableDeviceType(Variant):
2626
Keyring = VariantItemUnit
2727
Password = VariantItemUnit
2828
Recovery = VariantItemUnit
29-
Smartcard = VariantItemUnit
3029

3130
class PKI:
3231
certificate_ref: X509CertificateReference
@@ -45,9 +44,6 @@ class Keyring:
4544
class Password:
4645
password: Password
4746

48-
class Smartcard:
49-
certificate_reference: X509CertificateReference
50-
5147
class PKI:
5248
certificate_ref: X509CertificateReference
5349

@@ -70,9 +66,6 @@ class Password:
7066
password: Password
7167
key_file: Path
7268

73-
class Smartcard:
74-
key_file: Path
75-
7669
class PKI:
7770
key_file: Path
7871

bindings/web/src/meths.rs

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6837,7 +6837,6 @@ fn variant_available_device_type_js_to_rs(
68376837
}
68386838
"AvailableDeviceTypePassword" => Ok(libparsec::AvailableDeviceType::Password {}),
68396839
"AvailableDeviceTypeRecovery" => Ok(libparsec::AvailableDeviceType::Recovery {}),
6840-
"AvailableDeviceTypeSmartcard" => Ok(libparsec::AvailableDeviceType::Smartcard {}),
68416840
_ => Err(JsValue::from(TypeError::new(
68426841
"Object is not a AvailableDeviceType",
68436842
))),
@@ -6896,13 +6895,6 @@ fn variant_available_device_type_rs_to_js(
68966895
&"AvailableDeviceTypeRecovery".into(),
68976896
)?;
68986897
}
6899-
libparsec::AvailableDeviceType::Smartcard { .. } => {
6900-
Reflect::set(
6901-
&js_obj,
6902-
&"tag".into(),
6903-
&"AvailableDeviceTypeSmartcard".into(),
6904-
)?;
6905-
}
69066898
}
69076899
Ok(js_obj)
69086900
}
@@ -10152,23 +10144,6 @@ fn variant_device_access_strategy_js_to_rs(
1015210144
};
1015310145
Ok(libparsec::DeviceAccessStrategy::Password { password, key_file })
1015410146
}
10155-
"DeviceAccessStrategySmartcard" => {
10156-
let key_file = {
10157-
let js_val = Reflect::get(&obj, &"keyFile".into())?;
10158-
js_val
10159-
.dyn_into::<JsString>()
10160-
.ok()
10161-
.and_then(|s| s.as_string())
10162-
.ok_or_else(|| TypeError::new("Not a string"))
10163-
.and_then(|x| {
10164-
let custom_from_rs_string = |s: String| -> Result<_, &'static str> {
10165-
Ok(std::path::PathBuf::from(s))
10166-
};
10167-
custom_from_rs_string(x).map_err(|e| TypeError::new(e.as_ref()))
10168-
})?
10169-
};
10170-
Ok(libparsec::DeviceAccessStrategy::Smartcard { key_file })
10171-
}
1017210147
_ => Err(JsValue::from(TypeError::new(
1017310148
"Object is not a DeviceAccessStrategy",
1017410149
))),
@@ -10306,26 +10281,6 @@ fn variant_device_access_strategy_rs_to_js(
1030610281
});
1030710282
Reflect::set(&js_obj, &"keyFile".into(), &js_key_file)?;
1030810283
}
10309-
libparsec::DeviceAccessStrategy::Smartcard { key_file, .. } => {
10310-
Reflect::set(
10311-
&js_obj,
10312-
&"tag".into(),
10313-
&"DeviceAccessStrategySmartcard".into(),
10314-
)?;
10315-
let js_key_file = JsValue::from_str({
10316-
let custom_to_rs_string = |path: std::path::PathBuf| -> Result<_, _> {
10317-
path.into_os_string()
10318-
.into_string()
10319-
.map_err(|_| "Path contains non-utf8 characters")
10320-
};
10321-
match custom_to_rs_string(key_file) {
10322-
Ok(ok) => ok,
10323-
Err(err) => return Err(JsValue::from(TypeError::new(&err.to_string()))),
10324-
}
10325-
.as_ref()
10326-
});
10327-
Reflect::set(&js_obj, &"keyFile".into(), &js_key_file)?;
10328-
}
1032910284
}
1033010285
Ok(js_obj)
1033110286
}
@@ -10431,15 +10386,6 @@ fn variant_device_save_strategy_js_to_rs(
1043110386
};
1043210387
Ok(libparsec::DeviceSaveStrategy::Password { password })
1043310388
}
10434-
"DeviceSaveStrategySmartcard" => {
10435-
let certificate_reference = {
10436-
let js_val = Reflect::get(&obj, &"certificateReference".into())?;
10437-
struct_x509_certificate_reference_js_to_rs(js_val)?
10438-
};
10439-
Ok(libparsec::DeviceSaveStrategy::Smartcard {
10440-
certificate_reference,
10441-
})
10442-
}
1044310389
_ => Err(JsValue::from(TypeError::new(
1044410390
"Object is not a DeviceSaveStrategy",
1044510391
))),
@@ -10504,23 +10450,6 @@ fn variant_device_save_strategy_rs_to_js(
1050410450
let js_password = JsValue::from_str(password.as_ref());
1050510451
Reflect::set(&js_obj, &"password".into(), &js_password)?;
1050610452
}
10507-
libparsec::DeviceSaveStrategy::Smartcard {
10508-
certificate_reference,
10509-
..
10510-
} => {
10511-
Reflect::set(
10512-
&js_obj,
10513-
&"tag".into(),
10514-
&"DeviceSaveStrategySmartcard".into(),
10515-
)?;
10516-
let js_certificate_reference =
10517-
struct_x509_certificate_reference_rs_to_js(certificate_reference)?;
10518-
Reflect::set(
10519-
&js_obj,
10520-
&"certificateReference".into(),
10521-
&js_certificate_reference,
10522-
)?;
10523-
}
1052410453
}
1052510454
Ok(js_obj)
1052610455
}

cli/src/commands/device/change_authentication.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,6 @@ pub async fn main(args: Args) -> anyhow::Result<()> {
5353
}
5454
}
5555

56-
AvailableDeviceType::Smartcard => {
57-
todo!("read smartcard #11270");
58-
// DeviceAccessStrategy::Smartcard {
59-
// certificate_reference: todo!(),
60-
// key_file: device.key_file_path.clone(),
61-
// }
62-
}
63-
6456
AvailableDeviceType::PKI { .. } => {
6557
todo!("read PKI #11270");
6658
// DeviceAccessStrategy::PKI {

cli/src/commands/device/overwrite_server_url.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ pub async fn main(args: Args) -> anyhow::Result<()> {
3232
}
3333
}
3434

35-
AvailableDeviceType::Smartcard => {
36-
todo!("read smartcard #11270");
37-
// DeviceAccessStrategy::Smartcard {
38-
// certificate_reference: todo!(),
39-
// key_file: device.key_file_path.clone(),
40-
// }
41-
}
42-
4335
AvailableDeviceType::PKI { .. } => {
4436
todo!("read PKI #11270");
4537
// DeviceAccessStrategy::PKI {

cli/src/utils.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,6 @@ pub async fn load_and_unlock_device(
246246
password,
247247
}
248248
}
249-
AvailableDeviceType::Smartcard => {
250-
todo!("read smartcard #11270");
251-
// DeviceAccessStrategy::Smartcard {
252-
// certificate_reference: todo!(),
253-
// key_file: device.key_file_path.clone(),
254-
// }
255-
}
256249
AvailableDeviceType::PKI { .. } => {
257250
todo!("read PKI #11270");
258251
// DeviceAccessStrategy::PKI {

client/electron/src/cspRules.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ export function setupContentSecurityPolicy(customScheme: string): void {
310310

311311
if (!matchingRule) {
312312
log.error(
313-
`No CSP rule found for protocol: ${url.protocol}, host: ${url.host}, path: ${url.pathname.substring(0, 100)}${url.pathname.length > 100 ? '...' : ''}`,
313+
`No CSP rule found for protocol: ${url.protocol}, host: ${url.host}, path: ${url.pathname.substring(0, 100)}${
314+
url.pathname.length > 100 ? '...' : ''
315+
}`,
314316
);
315317
// Apply a strict CSP to block potentially dangerous resources
316318
responseHeaders['Content-Security-Policy'] = ["default-src 'none'"];

0 commit comments

Comments
 (0)