decentralized-identity / presentation-exchange

Specification that codifies an inter-related pair of data formats for defining proof presentations (Presentation Definition) and subsequent proof submissions (Presentation Submission)
https://identity.foundation/presentation-exchange
Apache License 2.0
82 stars 37 forks source link

Evaluation of first JSONPath match only - intentional or not? #399

Closed danielfett closed 9 months ago

danielfett commented 1 year ago

The current spec says in Section 8:

For each [JSONPath](https://goessner.net/articles/JsonPath/) expression in the path array (incrementing from the 0-index), evaluate the JSONPath expression against the candidate input and repeat the following subsequence on the result.

Repeat until a Field Query Result is found, or the path array elements are exhausted:
    If the result returned no JSONPath match, skip to the next path array element.
    Else, evaluate the first JSONPath match (candidate) as follows:
        If the fields object has no filter, or if candidate validates against the [JSON Schema](https://json-schema.org/specification.html) descriptor specified in filter, then:
        [NOTE](https://identity.foundation/presentation-exchange/#note-8)

        Predicate Feature Only

        If the fields object has a predicate, set Field Query Result to the boolean value resulting from evaluating the Field Query Result against the [JSON Schema](https://json-schema.org/specification.html) descriptor value of the filter property.

        Else
            set Field Query Result to be candidate
        Else, skip to the next path array element.

A JSONPath expression always returns a nodelist i.e., zero or more nodes matching the defined criteria. An example for a path array from the spec:

              "path": [
                "$.credentialSubject.account[*].id",
                "$.vc.credentialSubject.account[*].id",
                "$.account[*].id"
              ],

If I'm reading Section 8 correctly, it says that the expressions in path are evaluated one after the other, but for each expression, only the first result of the nodelist is evaluated ("skip to the next path array element").

This does not seem to be the intended meaning.

bumblefudge commented 1 year ago

hi @dtmcg

csuwildcat commented 9 months ago

Wording adjusted in https://github.com/decentralized-identity/presentation-exchange/commit/50b335dc28468ac32ad2145bdec71662a20d4504