webauthn-json icon indicating copy to clipboard operation
webauthn-json copied to clipboard

Add `prf` extension

Open lgarron opened this issue 3 years ago • 6 comments

https://github.com/w3c/webauthn/pull/1732 re-added this: https://w3c.github.io/webauthn/#prf-extension

We need to add support here:

https://github.com/github/webauthn-json/blob/5206e71dd596929bb30ee46534e59f9bc20c68ee/src/webauthn-json/extended/schema.ts#L12-L34

https://github.com/github/webauthn-json/blob/5206e71dd596929bb30ee46534e59f9bc20c68ee/src/webauthn-json/extended/json.ts#L12-L36

lgarron avatar Jul 18 '22 18:07 lgarron

Hey @lgarron, I am new to this codebase. But would like to take up this issue.

imrishabh18 avatar Jul 18 '22 21:07 imrishabh18

Hey @lgarron, I am new to this codebase. But would like to take up this issue.

Feel free to tackle a PR. Do you need any help beyond the links above?

lgarron avatar Aug 11 '22 07:08 lgarron

The following is working for me:

webauthnJSON.schema.credentialCreationOptions.publicKey.schema.extensions.schema.prf = {
            required: false,
            schema: {
                eval: {
                    required: false,
                    schema: {
                        first: {
                            required: true,
                            schema: "convert"
                        }
                    }
                },
                evalByCredential: {
                    required: false,
                    schema: "copy",
                    derive: function (input) {
                        console.log("derive");
                        console.log(input);
                        let evalByCredentialObject = input.evalByCredential;
                        if (!(evalByCredentialObject instanceof Object)) {
                            return;
                        }
                        for (const [key, value] of Object.entries(evalByCredentialObject)) {
                            console.log("first: " + value.first);
                            value.first = $this.base64urlToBuffer(value.first);
                        }
                        return evalByCredentialObject;
                    }
                }
            }
        };
        webauthnJSON.schema.credentialCreationOptions.publicKey.schema.extensions.schema.uvm = {
            required: false,
            schema: "copy"
        };
        webauthnJSON.schema.publicKeyCredentialWithAttestation.clientExtensionResults.schema.prf = {
            required: false,
            schema: {
                enabled: {
                    required: false,
                    schema: "copy"
                },
                results: {
                    required: false,
                    schema: {
                        first: {
                            required: true,
                            schema: "convert"
                        }
                    }
                }
            }
        };
        webauthnJSON.schema.publicKeyCredentialWithAttestation.clientExtensionResults.schema.uvm = {
            required: false,
            schema: "copy"
        };

Only getting evalByCredential right was a bit tricky.

fcorneli avatar Oct 15 '23 07:10 fcorneli

See also: https://github.com/e-Contract/enterprise-jsf/blob/master/ejsf-taglib/src/main/resources/META-INF/resources/ejsf/webauthn.js#L18

fcorneli avatar Nov 01 '23 15:11 fcorneli

Hey @lgarron 👋 ,

I want to take this up.

raashidanwar avatar Jan 01 '24 18:01 raashidanwar

@raashidanwar As I no longer work at GitHub, I can't maintain this project. Perhaps @KyFaSt or @fletchto99 can tell you if this project is open to contributions.

lgarron avatar Jan 01 '24 23:01 lgarron