Skip to content

Commit c519a93

Browse files
committed
Re-generate electron&web bindings
1 parent 768374a commit c519a93

4 files changed

Lines changed: 280 additions & 0 deletions

File tree

bindings/electron/src/index.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ export type Result<T, E = Error> =
99
| { ok: true; value: T }
1010
| { ok: false; error: E }
1111

12+
export enum AdvisoryDeviceFilePrimaryProtection {
13+
AccountVault = 'AdvisoryDeviceFilePrimaryProtectionAccountVault',
14+
Keyring = 'AdvisoryDeviceFilePrimaryProtectionKeyring',
15+
OpenBao = 'AdvisoryDeviceFilePrimaryProtectionOpenBao',
16+
PKI = 'AdvisoryDeviceFilePrimaryProtectionPKI',
17+
Password = 'AdvisoryDeviceFilePrimaryProtectionPassword',
18+
}
19+
1220
export enum CancelledGreetingAttemptReason {
1321
AutomaticallyCancelled = 'CancelledGreetingAttemptReasonAutomaticallyCancelled',
1422
InconsistentPayload = 'CancelledGreetingAttemptReasonInconsistentPayload',
@@ -124,6 +132,12 @@ export interface AccountOrganizationsRevokedUser {
124132
}
125133

126134

135+
export interface AdvisoryDeviceFileProtection {
136+
primary: AdvisoryDeviceFilePrimaryProtection
137+
withTotp: boolean
138+
}
139+
140+
127141
export interface AsyncEnrollmentUntrusted {
128142
enrollmentId: string
129143
submittedOn: number
@@ -340,6 +354,7 @@ export interface ServerConfig {
340354
cryptpad: CryptPadConfig | null
341355
organizationBootstrap: OrganizationBootstrapConfig
342356
openbao: OpenBaoConfig | null
357+
advisoryDeviceFileProtection: Array<AdvisoryDeviceFileProtection>
343358
}
344359

345360

bindings/electron/src/meths.rs

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,58 @@ use neon::{
1111
};
1212
use std::str::FromStr;
1313

14+
// AdvisoryDeviceFilePrimaryProtection
15+
16+
#[allow(dead_code)]
17+
fn enum_advisory_device_file_primary_protection_js_to_rs<'a>(
18+
cx: &mut impl Context<'a>,
19+
raw_value: &str,
20+
) -> NeonResult<libparsec::AdvisoryDeviceFilePrimaryProtection> {
21+
match raw_value {
22+
"AdvisoryDeviceFilePrimaryProtectionAccountVault" => {
23+
Ok(libparsec::AdvisoryDeviceFilePrimaryProtection::AccountVault)
24+
}
25+
"AdvisoryDeviceFilePrimaryProtectionKeyring" => {
26+
Ok(libparsec::AdvisoryDeviceFilePrimaryProtection::Keyring)
27+
}
28+
"AdvisoryDeviceFilePrimaryProtectionOpenBao" => {
29+
Ok(libparsec::AdvisoryDeviceFilePrimaryProtection::OpenBao)
30+
}
31+
"AdvisoryDeviceFilePrimaryProtectionPKI" => {
32+
Ok(libparsec::AdvisoryDeviceFilePrimaryProtection::PKI)
33+
}
34+
"AdvisoryDeviceFilePrimaryProtectionPassword" => {
35+
Ok(libparsec::AdvisoryDeviceFilePrimaryProtection::Password)
36+
}
37+
_ => cx.throw_range_error(format!(
38+
"Invalid value `{raw_value}` for enum AdvisoryDeviceFilePrimaryProtection"
39+
)),
40+
}
41+
}
42+
43+
#[allow(dead_code)]
44+
fn enum_advisory_device_file_primary_protection_rs_to_js(
45+
value: libparsec::AdvisoryDeviceFilePrimaryProtection,
46+
) -> &'static str {
47+
match value {
48+
libparsec::AdvisoryDeviceFilePrimaryProtection::AccountVault => {
49+
"AdvisoryDeviceFilePrimaryProtectionAccountVault"
50+
}
51+
libparsec::AdvisoryDeviceFilePrimaryProtection::Keyring => {
52+
"AdvisoryDeviceFilePrimaryProtectionKeyring"
53+
}
54+
libparsec::AdvisoryDeviceFilePrimaryProtection::OpenBao => {
55+
"AdvisoryDeviceFilePrimaryProtectionOpenBao"
56+
}
57+
libparsec::AdvisoryDeviceFilePrimaryProtection::PKI => {
58+
"AdvisoryDeviceFilePrimaryProtectionPKI"
59+
}
60+
libparsec::AdvisoryDeviceFilePrimaryProtection::Password => {
61+
"AdvisoryDeviceFilePrimaryProtectionPassword"
62+
}
63+
}
64+
}
65+
1466
// CancelledGreetingAttemptReason
1567

1668
#[allow(dead_code)]
@@ -761,6 +813,44 @@ fn struct_account_organizations_revoked_user_rs_to_js<'a>(
761813
Ok(js_obj)
762814
}
763815

816+
// AdvisoryDeviceFileProtection
817+
818+
#[allow(dead_code)]
819+
fn struct_advisory_device_file_protection_js_to_rs<'a>(
820+
cx: &mut impl Context<'a>,
821+
obj: Handle<'a, JsObject>,
822+
) -> NeonResult<libparsec::AdvisoryDeviceFileProtection> {
823+
let primary = {
824+
let js_val: Handle<JsString> = obj.get(cx, "primary")?;
825+
{
826+
let js_string = js_val.value(cx);
827+
enum_advisory_device_file_primary_protection_js_to_rs(cx, js_string.as_str())?
828+
}
829+
};
830+
let with_totp = {
831+
let js_val: Handle<JsBoolean> = obj.get(cx, "withTotp")?;
832+
js_val.value(cx)
833+
};
834+
Ok(libparsec::AdvisoryDeviceFileProtection { primary, with_totp })
835+
}
836+
837+
#[allow(dead_code)]
838+
fn struct_advisory_device_file_protection_rs_to_js<'a>(
839+
cx: &mut impl Context<'a>,
840+
rs_obj: libparsec::AdvisoryDeviceFileProtection,
841+
) -> NeonResult<Handle<'a, JsObject>> {
842+
let js_obj = cx.empty_object();
843+
let js_primary = JsString::try_new(
844+
cx,
845+
enum_advisory_device_file_primary_protection_rs_to_js(rs_obj.primary),
846+
)
847+
.or_throw(cx)?;
848+
js_obj.set(cx, "primary", js_primary)?;
849+
let js_with_totp = JsBoolean::new(cx, rs_obj.with_totp);
850+
js_obj.set(cx, "withTotp", js_with_totp)?;
851+
Ok(js_obj)
852+
}
853+
764854
// AsyncEnrollmentUntrusted
765855

766856
#[allow(dead_code)]
@@ -3215,11 +3305,26 @@ fn struct_server_config_js_to_rs<'a>(
32153305
}
32163306
}
32173307
};
3308+
let advisory_device_file_protection = {
3309+
let js_val: Handle<JsArray> = obj.get(cx, "advisoryDeviceFileProtection")?;
3310+
{
3311+
let size = js_val.len(cx);
3312+
let mut v = Vec::with_capacity(size as usize);
3313+
for i in 0..size {
3314+
let js_item: Handle<JsObject> = js_val.get(cx, i)?;
3315+
v.push(struct_advisory_device_file_protection_js_to_rs(
3316+
cx, js_item,
3317+
)?);
3318+
}
3319+
v
3320+
}
3321+
};
32183322
Ok(libparsec::ServerConfig {
32193323
account,
32203324
cryptpad,
32213325
organization_bootstrap,
32223326
openbao,
3327+
advisory_device_file_protection,
32233328
})
32243329
}
32253330

@@ -3244,6 +3349,24 @@ fn struct_server_config_rs_to_js<'a>(
32443349
None => JsNull::new(cx).as_value(cx),
32453350
};
32463351
js_obj.set(cx, "openbao", js_openbao)?;
3352+
let js_advisory_device_file_protection = {
3353+
// JsArray::new allocates with `undefined` value, that's why we `set` value
3354+
let js_array = JsArray::new(cx, rs_obj.advisory_device_file_protection.len());
3355+
for (i, elem) in rs_obj
3356+
.advisory_device_file_protection
3357+
.into_iter()
3358+
.enumerate()
3359+
{
3360+
let js_elem = struct_advisory_device_file_protection_rs_to_js(cx, elem)?;
3361+
js_array.set(cx, i as u32, js_elem)?;
3362+
}
3363+
js_array
3364+
};
3365+
js_obj.set(
3366+
cx,
3367+
"advisoryDeviceFileProtection",
3368+
js_advisory_device_file_protection,
3369+
)?;
32473370
Ok(js_obj)
32483371
}
32493372

bindings/web/src/meths.rs

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,60 @@ use wasm_bindgen::JsCast;
1313
#[allow(unused_imports)]
1414
use wasm_bindgen_futures::*;
1515

16+
// AdvisoryDeviceFilePrimaryProtection
17+
18+
#[allow(dead_code)]
19+
fn enum_advisory_device_file_primary_protection_js_to_rs(
20+
raw_value: &str,
21+
) -> Result<libparsec::AdvisoryDeviceFilePrimaryProtection, JsValue> {
22+
match raw_value {
23+
"AdvisoryDeviceFilePrimaryProtectionAccountVault" => {
24+
Ok(libparsec::AdvisoryDeviceFilePrimaryProtection::AccountVault)
25+
}
26+
"AdvisoryDeviceFilePrimaryProtectionKeyring" => {
27+
Ok(libparsec::AdvisoryDeviceFilePrimaryProtection::Keyring)
28+
}
29+
"AdvisoryDeviceFilePrimaryProtectionOpenBao" => {
30+
Ok(libparsec::AdvisoryDeviceFilePrimaryProtection::OpenBao)
31+
}
32+
"AdvisoryDeviceFilePrimaryProtectionPKI" => {
33+
Ok(libparsec::AdvisoryDeviceFilePrimaryProtection::PKI)
34+
}
35+
"AdvisoryDeviceFilePrimaryProtectionPassword" => {
36+
Ok(libparsec::AdvisoryDeviceFilePrimaryProtection::Password)
37+
}
38+
_ => {
39+
let range_error =
40+
RangeError::new("Invalid value for enum AdvisoryDeviceFilePrimaryProtection");
41+
range_error.set_cause(&JsValue::from(raw_value));
42+
Err(JsValue::from(range_error))
43+
}
44+
}
45+
}
46+
47+
#[allow(dead_code)]
48+
fn enum_advisory_device_file_primary_protection_rs_to_js(
49+
value: libparsec::AdvisoryDeviceFilePrimaryProtection,
50+
) -> &'static str {
51+
match value {
52+
libparsec::AdvisoryDeviceFilePrimaryProtection::AccountVault => {
53+
"AdvisoryDeviceFilePrimaryProtectionAccountVault"
54+
}
55+
libparsec::AdvisoryDeviceFilePrimaryProtection::Keyring => {
56+
"AdvisoryDeviceFilePrimaryProtectionKeyring"
57+
}
58+
libparsec::AdvisoryDeviceFilePrimaryProtection::OpenBao => {
59+
"AdvisoryDeviceFilePrimaryProtectionOpenBao"
60+
}
61+
libparsec::AdvisoryDeviceFilePrimaryProtection::PKI => {
62+
"AdvisoryDeviceFilePrimaryProtectionPKI"
63+
}
64+
libparsec::AdvisoryDeviceFilePrimaryProtection::Password => {
65+
"AdvisoryDeviceFilePrimaryProtectionPassword"
66+
}
67+
}
68+
}
69+
1670
// CancelledGreetingAttemptReason
1771

1872
#[allow(dead_code)]
@@ -787,6 +841,47 @@ fn struct_account_organizations_revoked_user_rs_to_js(
787841
Ok(js_obj)
788842
}
789843

844+
// AdvisoryDeviceFileProtection
845+
846+
#[allow(dead_code)]
847+
fn struct_advisory_device_file_protection_js_to_rs(
848+
obj: JsValue,
849+
) -> Result<libparsec::AdvisoryDeviceFileProtection, JsValue> {
850+
let primary = {
851+
let js_val = Reflect::get(&obj, &"primary".into())?;
852+
{
853+
let raw_string = js_val.as_string().ok_or_else(|| {
854+
let type_error = TypeError::new("value is not a string");
855+
type_error.set_cause(&js_val);
856+
JsValue::from(type_error)
857+
})?;
858+
enum_advisory_device_file_primary_protection_js_to_rs(raw_string.as_str())
859+
}?
860+
};
861+
let with_totp = {
862+
let js_val = Reflect::get(&obj, &"withTotp".into())?;
863+
js_val
864+
.dyn_into::<Boolean>()
865+
.map_err(|_| TypeError::new("Not a boolean"))?
866+
.value_of()
867+
};
868+
Ok(libparsec::AdvisoryDeviceFileProtection { primary, with_totp })
869+
}
870+
871+
#[allow(dead_code)]
872+
fn struct_advisory_device_file_protection_rs_to_js(
873+
rs_obj: libparsec::AdvisoryDeviceFileProtection,
874+
) -> Result<JsValue, JsValue> {
875+
let js_obj = Object::new().into();
876+
let js_primary = JsValue::from_str(enum_advisory_device_file_primary_protection_rs_to_js(
877+
rs_obj.primary,
878+
));
879+
Reflect::set(&js_obj, &"primary".into(), &js_primary)?;
880+
let js_with_totp = rs_obj.with_totp.into();
881+
Reflect::set(&js_obj, &"withTotp".into(), &js_with_totp)?;
882+
Ok(js_obj)
883+
}
884+
790885
// AsyncEnrollmentUntrusted
791886

792887
#[allow(dead_code)]
@@ -3348,11 +3443,26 @@ fn struct_server_config_js_to_rs(obj: JsValue) -> Result<libparsec::ServerConfig
33483443
Some(struct_open_bao_config_js_to_rs(js_val)?)
33493444
}
33503445
};
3446+
let advisory_device_file_protection = {
3447+
let js_val = Reflect::get(&obj, &"advisoryDeviceFileProtection".into())?;
3448+
{
3449+
let js_val = js_val
3450+
.dyn_into::<Array>()
3451+
.map_err(|_| TypeError::new("Not an array"))?;
3452+
let mut converted = Vec::with_capacity(js_val.length() as usize);
3453+
for x in js_val.iter() {
3454+
let x_converted = struct_advisory_device_file_protection_js_to_rs(x)?;
3455+
converted.push(x_converted);
3456+
}
3457+
converted
3458+
}
3459+
};
33513460
Ok(libparsec::ServerConfig {
33523461
account,
33533462
cryptpad,
33543463
organization_bootstrap,
33553464
openbao,
3465+
advisory_device_file_protection,
33563466
})
33573467
}
33583468

@@ -3378,6 +3488,24 @@ fn struct_server_config_rs_to_js(rs_obj: libparsec::ServerConfig) -> Result<JsVa
33783488
None => JsValue::NULL,
33793489
};
33803490
Reflect::set(&js_obj, &"openbao".into(), &js_openbao)?;
3491+
let js_advisory_device_file_protection = {
3492+
// Array::new_with_length allocates with `undefined` value, that's why we `set` value
3493+
let js_array = Array::new_with_length(rs_obj.advisory_device_file_protection.len() as u32);
3494+
for (i, elem) in rs_obj
3495+
.advisory_device_file_protection
3496+
.into_iter()
3497+
.enumerate()
3498+
{
3499+
let js_elem = struct_advisory_device_file_protection_rs_to_js(elem)?;
3500+
js_array.set(i as u32, js_elem);
3501+
}
3502+
js_array.into()
3503+
};
3504+
Reflect::set(
3505+
&js_obj,
3506+
&"advisoryDeviceFileProtection".into(),
3507+
&js_advisory_device_file_protection,
3508+
)?;
33813509
Ok(js_obj)
33823510
}
33833511

client/src/plugins/libparsec/definitions.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ export type Result<T, E = Error> =
1010
| { ok: true; value: T }
1111
| { ok: false; error: E }
1212

13+
export enum AdvisoryDeviceFilePrimaryProtection {
14+
AccountVault = 'AdvisoryDeviceFilePrimaryProtectionAccountVault',
15+
Keyring = 'AdvisoryDeviceFilePrimaryProtectionKeyring',
16+
OpenBao = 'AdvisoryDeviceFilePrimaryProtectionOpenBao',
17+
PKI = 'AdvisoryDeviceFilePrimaryProtectionPKI',
18+
Password = 'AdvisoryDeviceFilePrimaryProtectionPassword',
19+
}
20+
1321
export enum CancelledGreetingAttemptReason {
1422
AutomaticallyCancelled = 'CancelledGreetingAttemptReasonAutomaticallyCancelled',
1523
InconsistentPayload = 'CancelledGreetingAttemptReasonInconsistentPayload',
@@ -204,6 +212,11 @@ export interface AccountOrganizationsRevokedUser {
204212
currentProfile: UserProfile
205213
}
206214

215+
export interface AdvisoryDeviceFileProtection {
216+
primary: AdvisoryDeviceFilePrimaryProtection
217+
withTotp: boolean
218+
}
219+
207220
export interface AsyncEnrollmentUntrusted {
208221
enrollmentId: AsyncEnrollmentID
209222
submittedOn: DateTime
@@ -394,6 +407,7 @@ export interface ServerConfig {
394407
cryptpad: CryptPadConfig | null
395408
organizationBootstrap: OrganizationBootstrapConfig
396409
openbao: OpenBaoConfig | null
410+
advisoryDeviceFileProtection: Array<AdvisoryDeviceFileProtection>
397411
}
398412

399413
export interface ServerOrganizationConfig {

0 commit comments

Comments
 (0)