Skip to content

Commit 5827b9e

Browse files
committed
Implement getClientCapabilities (all false for now)
1 parent bdf2fbd commit 5827b9e

File tree

5 files changed

+64
-8
lines changed

5 files changed

+64
-8
lines changed

contrib/xyz.iinuwa.credentials.CredentialManager.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<arg name="request" type="a{sv}" direction="in"/>
1717
<arg type="a{sv}" direction="out"/>
1818
</method>
19+
<method name="GetClientCapabilities">
20+
<arg type="a{sv}" direction="out"/>
21+
</method>
1922
</interface>
2023
<interface name="org.freedesktop.DBus.Peer">
2124
<method name="Ping">

webext/add-on/background.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ function rcvFromContent(msg) {
3636
// const isCrossOrigin = origin === topOrigin
3737
// const isTopLevel = contentPort.sender.frameId === 0;
3838

39-
40-
const serializedOptions = serializeRequest(options)
41-
42-
console.debug(options.publicKey.challenge)
43-
console.debug("background script received options, passing onto native app")
44-
nativePort.postMessage({ requestId, cmd, options: serializedOptions, origin, topOrigin })
39+
if (options) {
40+
const serializedOptions = serializeRequest(options)
41+
42+
console.debug(options.publicKey.challenge)
43+
console.debug("background script received options, passing onto native app")
44+
nativePort.postMessage({ requestId, cmd, options: serializedOptions, origin, topOrigin })
45+
} else {
46+
console.debug("background script received message without arguments, passing onto native app")
47+
nativePort.postMessage({ requestId, cmd, origin, topOrigin })
48+
}
4549
}
4650

4751
function rcvFromNative(msg) {

webext/add-on/content.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ exportFunction(createCredential, navigator.credentials, { defineAs: "create"})
1414
exportFunction(getCredential, navigator.credentials, { defineAs: "get"})
1515

1616

17+
if (window.PublicKeyCredential) {
18+
console.log("overriding PublicKeyCredential.getClientCapabilities() in content script");
19+
exportFunction(getClientCapabilities, PublicKeyCredential, { defineAs: "getClientCapabilities"})
20+
}
21+
1722
function startRequest() {
1823
const requestId = requestCounter++;
1924
const {promise, resolve, reject } = window.Promise.withResolvers();
@@ -182,3 +187,10 @@ function getCredential(request) {
182187
webauthnPort.postMessage({ requestId, cmd: 'get', options, })
183188
return promise.then(cloneCredentialResponse)
184189
};
190+
191+
function getClientCapabilities() {
192+
console.log("forwarding getClientCapabilities call from content script to background script")
193+
const { requestId, promise } = startRequest();
194+
webauthnPort.postMessage({ requestId, cmd: 'getClientCapabilities', })
195+
return promise
196+
};

webext/app/credential_manager_shim.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ async def run(cmd, options, origin, top_origin):
343343

344344
interface = proxy_object.get_interface(
345345
'xyz.iinuwa.credentials.CredentialManagerUi1')
346-
logging.debug(f"COnnected to interface at {interface.path}")
346+
logging.debug(f"Connected to interface at {interface.path}")
347347

348348
if cmd == 'create':
349349
if 'publicKey' in options:
@@ -355,6 +355,12 @@ async def run(cmd, options, origin, top_origin):
355355
return await get_passkey(interface, options['publicKey'], origin, top_origin)
356356
else:
357357
raise Exception(f"Could not get unknown credential type: {options.keys()[0]}")
358+
elif cmd == 'getClientCapabilities':
359+
rsp = await interface.call_get_client_capabilities()
360+
response = {}
361+
for name, val in rsp.items():
362+
response[name] = val.value
363+
return response
358364
else:
359365
raise Exception(f"unknown cmd: {cmd}")
360366

@@ -366,7 +372,10 @@ async def run(cmd, options, origin, top_origin):
366372
request_id = receivedMessage['requestId']
367373
try:
368374
cmd = receivedMessage['cmd']
369-
options = receivedMessage['options']
375+
376+
options = None
377+
if 'options' in receivedMessage:
378+
options = receivedMessage['options']
370379
origin = receivedMessage['origin']
371380
top_origin = receivedMessage['topOrigin']
372381
loop = asyncio.get_event_loop()

xyz-iinuwa-credential-manager-portal-gtk/src/dbus.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,20 @@ impl CredentialManager {
241241
))
242242
}
243243
}
244+
245+
async fn get_client_capabilities(&self) -> fdo::Result<GetClientCapabilitiesResponse> {
246+
Ok(GetClientCapabilitiesResponse {
247+
conditional_create: false,
248+
conditional_get: false,
249+
hybrid_transport: false,
250+
passkey_platform_authenticator: false,
251+
user_verifying_platform_authenticator: false,
252+
related_origins: false,
253+
signal_all_accepted_credentials: false,
254+
signal_current_user_details: false,
255+
signal_unknown_credential: false,
256+
})
257+
}
244258
}
245259

246260
async fn create_password(
@@ -838,6 +852,20 @@ impl From<GetPublicKeyCredentialResponse> for GetCredentialResponse {
838852
}
839853
}
840854

855+
#[derive(SerializeDict, Type)]
856+
#[zvariant(signature = "dict")]
857+
pub struct GetClientCapabilitiesResponse {
858+
conditional_create: bool,
859+
conditional_get: bool,
860+
hybrid_transport: bool,
861+
passkey_platform_authenticator: bool,
862+
user_verifying_platform_authenticator: bool,
863+
related_origins: bool,
864+
signal_all_accepted_credentials: bool,
865+
signal_current_user_details: bool,
866+
signal_unknown_credential: bool,
867+
}
868+
841869
fn format_client_data_json(
842870
op: Operation,
843871
challenge: &str,

0 commit comments

Comments
 (0)