Skip to content

Commit 57b83c3

Browse files
committed
gateway: swap order of parent_window and options
1 parent a036a7e commit 57b83c3

File tree

6 files changed

+49
-24
lines changed

6 files changed

+49
-24
lines changed

credentialsd-common/src/model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{fmt::Display, path::PathBuf};
22

3-
use serde::{Deserialize, Serialize, de::Visitor};
3+
use serde::{Deserialize, Serialize};
44
use zvariant::{SerializeDict, Type};
55

66
pub use libwebauthn::ops::webauthn::{

credentialsd/src/dbus/gateway.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ impl<C: CredentialRequestController + Send + Sync + 'static> CredentialGateway<C
217217
&self,
218218
#[zbus(header)] header: Header<'_>,
219219
#[zbus(connection)] connection: &Connection,
220+
parent_window: Optional<WindowHandle>,
220221
request: CreateCredentialRequest,
221-
window_handle: Optional<WindowHandle>,
222222
) -> Result<CreateCredentialResponse, Error> {
223223
let (_origin, is_same_origin, _top_origin) =
224224
check_origin(request.origin.as_deref(), request.is_same_origin)
@@ -253,7 +253,7 @@ impl<C: CredentialRequestController + Send + Sync + 'static> CredentialGateway<C
253253
.controller
254254
.lock()
255255
.await
256-
.request_credential(requesting_app, cred_request, window_handle.into())
256+
.request_credential(requesting_app, cred_request, parent_window.into())
257257
.await?;
258258

259259
if let CredentialResponse::CreatePublicKeyCredentialResponse(cred_response) = response {
@@ -284,8 +284,8 @@ impl<C: CredentialRequestController + Send + Sync + 'static> CredentialGateway<C
284284
&self,
285285
#[zbus(header)] header: Header<'_>,
286286
#[zbus(connection)] connection: &Connection,
287+
parent_window: Optional<WindowHandle>,
287288
request: GetCredentialRequest,
288-
window_handle: Optional<WindowHandle>,
289289
) -> Result<GetCredentialResponse, Error> {
290290
let (_origin, is_same_origin, _top_origin) =
291291
check_origin(request.origin.as_deref(), request.is_same_origin)
@@ -318,7 +318,7 @@ impl<C: CredentialRequestController + Send + Sync + 'static> CredentialGateway<C
318318
.controller
319319
.lock()
320320
.await
321-
.request_credential(requesting_app, cred_request, window_handle.into())
321+
.request_credential(requesting_app, cred_request, parent_window.into())
322322
.await?;
323323

324324
if let CredentialResponse::GetPublicKeyCredentialResponse(cred_response) = response {

demo_client/gui.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def create_passkey(
319319
"publicKey": Variant("a{sv}", {"request_json": Variant("s", req_json)}),
320320
}
321321

322-
rsp = interface.call_create_credential_sync([req, window_handle])
322+
rsp = interface.call_create_credential_sync([window_handle, req])
323323

324324
# print("Received response")
325325
# pprint(rsp)
@@ -358,7 +358,7 @@ def get_passkey(interface, window_handle, origin, top_origin, rp_id, cred_ids, c
358358
"publicKey": Variant("a{sv}", {"request_json": Variant("s", req_json)}),
359359
}
360360

361-
rsp = interface.call_get_credential_sync([req, window_handle])
361+
rsp = interface.call_get_credential_sync([window_handle, req])
362362
# print("Received response")
363363
# pprint(rsp)
364364
if rsp["type"].value != "public-key":

demo_client/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async def create_password(interface):
114114
},
115115
),
116116
}
117-
rsp = await interface.call_create_credential([password_req, ""])
117+
rsp = await interface.call_create_credential(["", password_req])
118118
return rsp
119119

120120

@@ -131,7 +131,7 @@ async def get_password(interface):
131131
],
132132
),
133133
}
134-
rsp = await interface.call_get_credential(password_req)
134+
rsp = await interface.call_get_credential(["", password_req])
135135
if rsp["type"].value == "password":
136136
cred = rsp["password"].value
137137
id = cred["id"].value
@@ -174,7 +174,7 @@ async def create_passkey(interface, origin, top_origin, rp_id, user_handle, user
174174
"publicKey": Variant("a{sv}", {"request_json": Variant("s", req_json)}),
175175
}
176176

177-
rsp = await interface.call_create_credential(req)
177+
rsp = await interface.call_create_credential(["", req])
178178

179179
print("Received response")
180180
pprint(rsp)
@@ -215,7 +215,7 @@ async def get_passkey(
215215
"publicKey": Variant("a{sv}", {"request_json": Variant("s", req_json)}),
216216
}
217217

218-
rsp = await interface.call_get_credential([req, ""])
218+
rsp = await interface.call_get_credential(["", req])
219219
print("Received response")
220220
pprint(rsp)
221221
if rsp["type"].value != "public-key":

doc/api.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,21 @@ it would pass this request to this API:
153153
}
154154
```
155155

156+
## Window Identifiers
157+
158+
For window identifiers, we follow the same format as the
159+
[XDG Desktop Portal conventions for window identifiers][xdg-window-identifiers].
160+
161+
Where a `parent_window` is specified, the value should be a string in the format:
162+
163+
`<window_system>:<handle>`
164+
165+
The supported window systems are `wayland` and `x11`.
166+
167+
If the client does not have a window or cannot access it, pass an empty string.
168+
169+
[xdg-window-identifiers]: https://flatpak.github.io/xdg-desktop-portal/docs/window-identifiers.html
170+
156171
# Gateway API
157172

158173
The Gateway is the entrypoint for public clients to retrieve and store
@@ -174,14 +189,19 @@ for what kind of credential the client would like to create.
174189
### Request
175190

176191
```
177-
CreateCredentialRequest[a{sv}] {
178-
origin: string
179-
is_same_origin: string
180-
type: CredentialType
181-
<extra_fields>
182-
}
192+
CreateCredentialRequest(
193+
IN parent_window s,
194+
IN options a{sv} {
195+
origin: string
196+
is_same_origin: string
197+
type: CredentialType
198+
<extra_fields>
199+
}
200+
)
183201
```
184202

203+
For information on `parent_window`, see [Window Identifiers](#window-identifiers).
204+
185205
> TODO: We should make this a tagged enum
186206
187207
```
@@ -287,13 +307,18 @@ credentials the client will accept.
287307
### Request
288308

289309
```
290-
GetCredentialRequest[a{sv}] {
291-
origin: string
292-
is_same_origin: string
293-
publicKey: GetPublicKeyCredentialOptions?
294-
}
310+
GetCredentialRequest (
311+
IN parent_window s
312+
IN options a{sv} {
313+
origin: string
314+
is_same_origin: string
315+
publicKey: GetPublicKeyCredentialOptions?
316+
}
317+
)
295318
```
296319

320+
For information on `parent_window`, see [Window Identifiers](#window-identifiers).
321+
297322
Note that while only one credential type can be specified in
298323
`CreateCredential()`, credential types in this `GetCredential()` are not mutually
299324
exclusive: as new credential types are added to the specification, a client may

doc/xyz.iinuwa.credentialsd.Credentials.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
</interface>
1010
<interface name="xyz.iinuwa.credentialsd.Credentials1">
1111
<method name="CreateCredential">
12-
<arg name="request" type="(a{sv}s)" direction="in"/>
12+
<arg name="request" type="(sa{sv})" direction="in"/>
1313
<arg type="a{sv}" direction="out"/>
1414
</method>
1515
<method name="GetCredential">
16-
<arg name="request" type="(a{sv}s)" direction="in"/>
16+
<arg name="request" type="(sa{sv})" direction="in"/>
1717
<arg type="a{sv}" direction="out"/>
1818
</method>
1919
<method name="GetClientCapabilities">

0 commit comments

Comments
 (0)