diff --git a/.changeset/tough-cows-kiss.md b/.changeset/tough-cows-kiss.md deleted file mode 100644 index 793cc9e..0000000 --- a/.changeset/tough-cows-kiss.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -"@styra/opa-react": minor ---- - -Add `fromResults` to support unwrapping policy evaluation results - -This allows us to unwrap results returned from OPA to turn them into a boolean. - -Previously, anything different from undefined and false was taken to mean "authorized". Now, we can work with policy evaluation results like - -```json -{ - "result": false, - "details": "..." -} -``` - -by providing a `fromResults` function like - -```ts -const fromResults = (r?: Result): boolean => - ((r as Record)["foobar"] as boolean) ?? false; -``` - -As with input and path, this can (optionally) be set with `` (property `defaultFromResults`), and with `` (property `fromResult`), or passed to `useAuthz()`. diff --git a/packages/opa-react/CHANGELOG.md b/packages/opa-react/CHANGELOG.md index fb7cb3b..07638e0 100644 --- a/packages/opa-react/CHANGELOG.md +++ b/packages/opa-react/CHANGELOG.md @@ -1,5 +1,31 @@ # @styra/opa-react +## 0.3.0 + +### Minor Changes + +- d2b2abc: Add `fromResults` to support unwrapping policy evaluation results + + This allows us to unwrap results returned from OPA to turn them into a boolean. + + Previously, anything different from undefined and false was taken to mean "authorized". Now, we can work with policy evaluation results like + + ```json + { + "result": false, + "details": "..." + } + ``` + + by providing a `fromResults` function like + + ```ts + const fromResults = (r?: Result): boolean => + ((r as Record)["foobar"] as boolean) ?? false; + ``` + + As with input and path, this can (optionally) be set with `` (property `defaultFromResults`), and with `` (property `fromResult`), or passed to `useAuthz()`. + ## 0.2.1 ### Patch Changes diff --git a/packages/opa-react/package.json b/packages/opa-react/package.json index 8379f12..6c1511f 100644 --- a/packages/opa-react/package.json +++ b/packages/opa-react/package.json @@ -1,6 +1,6 @@ { "name": "@styra/opa-react", - "version": "0.2.1", + "version": "0.3.0", "repository": { "type": "git", "url": "https://github.com/StyraInc/opa-typescript.git",