Skip to content

Commit efe219c

Browse files
authored
Update the README installation steps to include installation of warrant-js as a peer dependency (#14)
* Update the README to include installation of @warrantdev/warrant-js since it is a peer dependency * Update code examples in the README
1 parent 7d13108 commit efe219c

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ The Warrant React library provides components, hooks, and helper methods for con
99

1010
## Installation
1111

12-
Use `npm` to install the module:
12+
Use `npm` to install the core Warrant client module [`@warrantdev/warrant-js`](https://github.com/warrant-dev/warrant-js). This module includes methods shared across our client libraries (Vue, Angular, etc.) and additional types (for TypeScript users).
13+
14+
```sh
15+
npm install @warrantdev/warrant-js
16+
```
17+
18+
Use `npm` to install `@warrantdev/react-warrant-js`:
1319

1420
```sh
1521
npm install @warrantdev/react-warrant-js
@@ -199,7 +205,7 @@ export default MyComponent;
199205
`checkMany` is a utility function that returns a `Promise` which resolves with `true` if the user for the current session token has _all of_ or _any of_ (based on a specified `op`) a set of specified `warrants` and returns `false` otherwise.
200206

201207
```jsx
202-
import { CheckOp } from "@warrantdev/warrant-node";
208+
import { CheckOp } from "@warrantdev/warrant-js";
203209

204210
const { checkMany } = useWarrant();
205211

@@ -231,7 +237,7 @@ const userIsAuthorized = await checkMany({
231237
`hasPermission` is a utility function that returns a `Promise` which resolves with `true` if the user for the current session token has the specified `permissionId` and returns `false` otherwise.
232238

233239
```jsx
234-
import { CheckOp } from "@warrantdev/warrant-node";
240+
import { CheckOp } from "@warrantdev/warrant-js";
235241

236242
const { hasPermission } = useWarrant();
237243

@@ -247,7 +253,7 @@ const userHasPermission = await hasPermission({
247253
`hasFeature` is a utility function that returns a `Promise` which resolves with `true` if the user for the current session token has the specified `featureId` and returns `false` otherwise.
248254

249255
```jsx
250-
import { CheckOp } from "@warrantdev/warrant-node";
256+
import { CheckOp } from "@warrantdev/warrant-js";
251257

252258
const { hasFeature } = useWarrant();
253259

@@ -274,8 +280,10 @@ const MyComponent = () => {
274280
<ProtectedComponent
275281
warrants={[
276282
{
277-
objectType: "myObject",
278-
objectId: object.id,
283+
object: {
284+
objectType: "myObject",
285+
objectId: object.id,
286+
},
279287
relation: "view",
280288
},
281289
]}
@@ -365,8 +373,10 @@ const App = () => {
365373
*/}
366374
<Route path="/protected_route" exact component={withWarrantCheck(ProtectedPage, {
367375
warrants: [{
368-
objectType: "route",
369-
objectId: "protected_route",
376+
object: {
377+
objectType: "route",
378+
objectId: "protected_route",
379+
},
370380
relation: "view",
371381
}],
372382
redirectTo: "/public_route",
@@ -394,8 +404,10 @@ const MySecretComponent = () => {
394404
export default withWarrantCheck(MySecretComponent, {
395405
warrants: [
396406
{
397-
objectType: "component",
398-
objectId: "MySecretComponent",
407+
object: {
408+
objectType: "component",
409+
objectId: "MySecretComponent",
410+
},
399411
relation: "view",
400412
},
401413
],

0 commit comments

Comments
 (0)