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

UCAN Policy syntax #13

Open
Gozala opened this issue Jun 5, 2024 · 0 comments
Open

UCAN Policy syntax #13

Gozala opened this issue Jun 5, 2024 · 0 comments

Comments

@Gozala
Copy link

Gozala commented Jun 5, 2024

Me and @expede had discussed this a lot in the side channels and after a long hold I have hard time finding any of it so I have decided to document the syntax here.

// Policy holds if all inner rules are `true` if contains no rules it is considered `true`.
type Policy = Rule[]
type Rule =
   | Or
   | And
   | Not
   | Some
   | Every
   | Constraint

type Constraint
  | Is
  | Compare
  | Like

// jq style selector for details see https://github.com/ucan-wg/delegation/issues/5
type Selector = `.${string}`
// Any data that can be expressed in IPLD data model
type Constant = Data
type Operand = Constant | Selector

// Asserts that operands are equal
type Is = ['==', Operand, Operand]
// Asserts operands by via comparison operator
type Compare = ['>' | '<' | '>=' | '<=', Operand, Operand]
// Asserts that operand matches a pattern. The `*` symbol in pattern
type Like = [operator: 'like', pattern: string, operand: Selector]

// Rule is `true` if every enclosed rule is `false`.
type Not = [operator: "not", ...Rule[]]
// Rule it `true` if every enclosed rule is `true`.
type And = [operator: "and", ...Rule[]]
// Rule is `true` if some enclosed rule is `true`.
type Or = [operator: "or", ...Rule[]]

// Rule is true if some member matching a selector satisfies every enclosed rule.
// Enclosed rule selector context is the selected item
type Some = ["some", Selector, ...Rule[]]

// Rule is true if every member matching a selector satisfies every enclosed rule
// Enclosed rule selector context is the selected item
type Every = ["every", Selector, ...Rule[]]
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

1 participant