Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nbf and nnc to be null #63

Open
bgins opened this issue Apr 1, 2022 · 3 comments
Open

Allow nbf and nnc to be null #63

bgins opened this issue Apr 1, 2022 · 3 comments

Comments

@bgins
Copy link
Contributor

bgins commented Apr 1, 2022

Summary

Problem

ts-ucan does not allow nbf and nnc to be null.

Impact

ts-ucan reports an invalid payload when either of these fields are null.

Solution

Allow the fields to be null when validating payloads.

The fields are checked here:

ts-ucan/src/types.ts

Lines 122 to 123 in 978dfd2

&& (!util.hasProp(obj, "nbf") || typeof obj.nbf === "number")
&& (!util.hasProp(obj, "nnc") || typeof obj.nnc === "string")

@cdata
Copy link
Member

cdata commented Apr 1, 2022

On the rs-ucan side, it would be trivial for us to omit these fields when they are not used. It would probably be better to omit them as it improves payload size (however marginally).

Do you have an opinion about what to do with fct? The spec says this field is optional, but current we emit an empty array no matter what.

@cdata
Copy link
Member

cdata commented Apr 1, 2022

As an optimization/mitigation, I changed rs-ucan's serialization to omit these fields when unused: ucan-wg/rs-ucan@7203f32

Published as https://crates.io/crates/ucan/0.5.0-alpha.6

Tokens generated by rs-ucan are now accepted and interpreted correctly by the validator 👍

@matheus23
Copy link
Member

Do you have an opinion about what to do with fct? The spec says this field is optional, but current we emit an empty array no matter what.

Omitting fct and an empty fct array should I think be treated exactly the same way. So, in that case I'd err on the side of omitting the field?

And we should probably start doing that in ts-ucan as well, if we're not doing that already :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants