biscuit-auth / biscuit

delegated, decentralized, capabilities based authorization token
Apache License 2.0
961 stars 25 forks source link

`.type()` function #134

Open divarvel opened 1 year ago

divarvel commented 1 year ago

Ill-typed operations currently make evaluation fail. This makes it easy to have datalog evaluation errors, since introducing a new fact with terms of an unexpected types can make a rule blow up somewhere else.

If we go ahead with lazy || and &&, introducing a typeof operator would allow guarding operations with a type check, providing a way to avoid evaluation failure in the face of terms of unexpected types.

For instance:

`check if resource($resource), $resource.type() == "string" && resource.starts_with("file_")`

using a .type() method call would integrate cleanly with the existing parser, that's why i used it instead of a typeof operator syntax, but that can be debated later.