@@ -44,17 +44,17 @@ const opa = new OPAClient(serverURL);
4444For a simple boolean response without input, use the SDK as follows:
4545
4646``` ts
47- const allowed = await opa .authorize (path );
47+ const allowed = await opa .evaluate (path );
4848console .log (allowed ? " allowed!" : " denied!" );
4949```
5050
51- Note that ` allowed ` will be of type ` any ` . You can change that by providing type parameters to ` authorize ` :
51+ Note that ` allowed ` will be of type ` any ` . You can change that by providing type parameters to ` evaluate ` :
5252
5353``` ts
54- const allowed = await opa .authorize <never , boolean >(path );
54+ const allowed = await opa .evaluate <never , boolean >(path );
5555```
5656
57- The first parameter is the type of ` input ` passed into ` authorized ` ; we don't have any in this example, so you can use anything for it (` any ` , ` unknown ` , or ` never ` ).
57+ The first parameter is the type of ` input ` passed into ` evaluate ` ; we don't have any in this example, so you can use anything for it (` any ` , ` unknown ` , or ` never ` ).
5858
5959<details ><summary >HTTP Request</summary >
6060
@@ -69,11 +69,11 @@ Content-Type: application/json
6969
7070### Input
7171
72- Input is provided as a second (optional) argument to ` authorize ` :
72+ Input is provided as a second (optional) argument to ` evaluate ` :
7373
7474``` ts
7575const input = { user: " alice" };
76- const allowed = await opa .authorize (path , input );
76+ const allowed = await opa .evaluate (path , input );
7777console .log (allowed ? " allowed!" : " denied!" );
7878```
7979
@@ -84,7 +84,7 @@ interface myInput {
8484 user: string ;
8585}
8686const input: myInput = { user: " alice" };
87- const allowed = await opa .authorize <myInput , boolean >(path , input );
87+ const allowed = await opa .evaluate <myInput , boolean >(path , input );
8888console .log (allowed ? " allowed!" : " denied!" );
8989```
9090
@@ -101,7 +101,7 @@ Content-Type: application/json
101101
102102### Result Types
103103
104- When the result of the policy evaluation is more complex, you can pass its type to ` authorized ` and get a typed result:
104+ When the result of the policy evaluation is more complex, you can pass its type to ` evaluate ` and get a typed result:
105105
106106``` ts
107107interface myInput {
@@ -112,8 +112,8 @@ interface myResult {
112112 details: string [];
113113}
114114const input: myInput = { user: " alice" };
115- const result = await opa .authorize <myInput , myResult >(path , input );
116- console .log (result .authorized ? " allowed!" : " denied!" );
115+ const result = await opa .evaluate <myInput , myResult >(path , input );
116+ console .log (result .evaluated ? " allowed!" : " denied!" );
117117```
118118
119119### Input Transformations
@@ -132,7 +132,7 @@ class A {
132132 }
133133}
134134const inp = new A (" alice" , [1 , 2 , true ]);
135- const allowed = await opa .authorize <myInput , boolean >(path , inp );
135+ const allowed = await opa .evaluate <myInput , boolean >(path , inp );
136136console .log (allowed ? " allowed!" : " denied!" );
137137```
138138
@@ -154,7 +154,7 @@ class A implements ToInput {
154154 }
155155}
156156const inp = new A (" alice" , [1 , 2 , true ]);
157- const allowed = await opa .authorize <myInput , boolean >(path , inp );
157+ const allowed = await opa .evaluate <myInput , boolean >(path , inp );
158158console .log (allowed ? " allowed!" : " denied!" );
159159```
160160
@@ -185,7 +185,7 @@ Assuming that the policy evaluates to
185185you can turn it into a boolean result like this:
186186
187187``` ts
188- const allowed = await opa .authorize <any , boolean >(
188+ const allowed = await opa .evaluate <any , boolean >(
189189 path ,
190190 undefined ,
191191 (r ? : Result ) => (r as Record <string , any >)[" allowed" ] ?? false ,
@@ -204,7 +204,7 @@ router.get("/tickets/:id", [param("id").isInt().toInt()], async (req, res) => {
204204 const {
205205 params: { id },
206206 } = req;
207- await authz .authorized (path, { action: " get" , id }, req);
207+ await authz .evaluated (path, { action: " get" , id }, req);
208208
209209 const ticket = await prisma .tickets .findUniqueOrThrow ({
210210 where: { id },
0 commit comments