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

feat: update extension packages docs #129

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions guides/extensions/push-notifications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Push Notifications

The Push Notifications plugin package provides a way for you to register your APNs and Firebase push notification token at an agent, allowing you to use push notifications directly from AFJ.

:::note

This document is for version **`0.5.x`** of the `@aries-framework/push-notifications` package, that works with `@aries-framework/core` version **`0.4.x`**. Extension packages (such as Push Notifications) are versioned separately from the core packages.

:::

## Installation

To add the Push Notifications plugin package to your existing project simply run:

<!--tabs-->

## npm

```sh
npm i @aries-framework/push-notifications
```

## Yarn

```sh
yarn add @aries-framework/push-notifications
```

<!--tabs-->

## Usage

```ts
import { PushNotificationsApnsModule, PushNotificationsFcmModule } from '@aries-framework/push-notifications'
import { } from '@aries-framework/core'

const agent = new Agent({
/** agent config... */,
// Register the modules
modules: {
pushNotificationsApns: new PushNotificationsApnsModule(),
pushNotificationsFcm: new PushNotificationsFcmModule(),
},
}
})

await agent.initialize()

/* -- iOS -- */

// To send apns device info to another agent you have to acquire the device token and send it.
await agent.modules.pushNotificationsApns.sendDeviceInfo(
'a-valid-connection-id'
{ deviceToken: '123' },
)

// To get the device info and the used service back from the other agent
await agent.modules.pushNotificationsApns.getDeviceInfo('a-valid-connection')

/* -- fcm / Android -- */

// To send fcm, primarily Android, device info to another agent you have to acquire the device token and send it.
await agent.modules.pushNotificationsFcm.sendDeviceInfo(
'a-valid-connection-id'
{ deviceToken: '123' },
)

// To get the device info and the used service back from the other agent
await agent.modules.pushNotificationsFcm.getDeviceInfo('a-valid-connection')

```
3 changes: 0 additions & 3 deletions guides/extensions/push-notifications/index.md

This file was deleted.

21 changes: 0 additions & 21 deletions guides/extensions/push-notifications/setup.md

This file was deleted.

108 changes: 108 additions & 0 deletions guides/extensions/react-hooks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# React Hooks

The React Hooks package exposes useful React hooks that allow you to easily interact with AFJ from a React client application.

These hooks provide a simple way to query agent data in a client application, allowing you to focus on the user interface.

:::note

This document is for version **`0.5.x`** of the `@aries-framework/react-hooks` package, that works with `@aries-framework/core` version **`0.4.x`**. Extension packages (such as React Hooks) are versioned separately from the core packages.

:::

## Installation

To add the React Hooks package to your existing project simply run:

<!--tabs-->

## npm

```sh
npm i @aries-framework/react-hooks@^0.5
```

## Yarn

```sh
yarn add @aries-framework/react-hooks@^0.5
```

<!--/tabs-->

## Usage

This package exposes useful React hooks that allow you to easily interact with AFJ.

Everything exported from Hooks:

```ts
import AgentProvider, {
useAgent,
useConnections,
useConnectionById,
useCredentials,
useCredentialById,
useCredentialByState,
useProofs,
useProofById,
useProofByState,
} from '@aries-framework/react-hooks'
```

First step is to wrap your entire app in our `<AgentProvider/>`. The provider takes an initialized agent. The base of your app should look something like this:

```tsx
import AgentProvider from '@aries-framework/react-hooks'

const App = () => {
const [agent, setAgent] = useState(undefined)

const initializeAgent = async () => {
const appAgent = new Agent({
/* agent options */
})
await appAgent.initialize()
setAgent(appAgent)
}

useEffect(() => {
initializeAgent()
}, [])

if (!agent) return <LoadingComponent />

return <AgentProvider agent={agent}>/* Your app here */</AgentProvider>
}
```

And that's it! Your app should be set up to receive all the necessary data your app will need! Now let's see how we actually get that data to our components.

The `useAgent` hook returns `{ agent, loading }` so anytime you need access to any of the methods tied to the agent, you can `useAgent()` anywhere.

The following is an example of how you could use the `useConnections` hook to render a full list of all a user's connections.

```ts
import { useConnections } from '@aries-framework/react-hooks'

const MyConnectionsComponent = () => {
// all base hooks return an array of objects and a loading boolean
const { connections, loading } = useConnections()

return <FlatList data={connections} renderItem={({ item }) => <MyListItem connection={item} />} />
}
```

The three base hooks: `useConnections`, `useCredentials`, and `useProofs` work just like the above! Just call the hook, destructure the data, and pass it through!

Each base hook has a `ById` version that returns a singular record. For example if I wanted only a specific connectionRecord, I'd do this.

```ts
const connection = useConnectionById(id)
```

More commonly, you'll want to get a filtered list of records based off of their state. Well, Hooray! We have a `ByState` version as well. For example, you can do this:

```ts
const credentials = useCredentialByState(CredentialState.OfferReceived)
```
5 changes: 0 additions & 5 deletions guides/extensions/react-hooks/index.md

This file was deleted.

23 changes: 0 additions & 23 deletions guides/extensions/react-hooks/setup.md

This file was deleted.

31 changes: 31 additions & 0 deletions guides/extensions/redux-store.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Redux Store

The Redux Store is an implementation of state management that can be used to build React & React Native SSI clients using AFJ.

The Redux Store allows you to integrate state management for the most important parts of using AFJ in a client application (mediation, connections, credentials and proofs), allowing you to sync UI state with the state of the agent as it interacts with other agents through the framework.

:::note

This document is for version **`0.4.x`** of the `@aries-framework/redux-store` package, that works with `@aries-framework/core` version **`0.4.x`**. Extension packages (such as Redux Store) are versioned separately from the core packages.

:::

## Installation

To add the Redux Store package to your existing project simply run:

<!--tabs-->

## npm

```sh
npm i @aries-framework/redux-store
```

## Yarn

```sh
yarn add @aries-framework/redux-store
```

<!--tabs-->
5 changes: 0 additions & 5 deletions guides/extensions/redux-store/index.md

This file was deleted.

23 changes: 0 additions & 23 deletions guides/extensions/redux-store/setup.md

This file was deleted.

52 changes: 52 additions & 0 deletions guides/extensions/rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# REST API

The Aries Framework JavaScript (AFJ) REST API provides simple RESTful endpoints for AFJ methods, to allow you stand up an agent for communication over the internet instantly. You simply provide your agent configuration. The REST endpoints allow you to interact with your agent over HTTP and WebSockets.

The AFJ REST API is the most convenient way for self-sovereign identity (SSI) developers to interact with SSI agents.

- ⭐ **Endpoints** to create connections, issue credentials, and request proofs.
- 💻 **CLI** that makes it super easy to start an instance of the REST API.
- 🌐 **Interoperable** with all major Aries implementations.

:::danger

The `@aries-framework/rest` package has not been updated to work with the latest version (**`0.4.x`**) of `@aries-framework/core`. The documentation in this section is for version **`0.9.x`** of the `@aries-framework/rest` package, that works with `@aries-framework/core` version **`0.2.x`**. Extension packages (such as REST API) are versioned separately from the core packages.

:::

## Quick Setup

:::info

This guide assumes you have followed the install guides for the framework (See [Getting Started](../../getting-started/index.md) section) for your platform and a valid [Node.js](https://nodejs.org) project setup.

:::

Using the CLI is the easiest way to get started with REST API.

You can do this directly on your machine.

### Directly on computer

After installing and confirming that Libindy is installed, simply run:

```sh
npx -p @aries-framework/rest afj-rest start \
--label "AFJ Rest" \
--wallet-id "walletId" \
--wallet-key "walletKey" \
--endpoint http://localhost:5000 \
--admin-port 3000 \
--outbound-transport http \
--inbound-transport http 5000
```

The REST API provides an OpenAPI schema that can easily be viewed using the SwaggerUI that is provided with the server. The endpoint documentation can be viewed at the `/docs` endpoint (e.g. <http://localhost:3000/docs>).

### Configuration

To find out all available configuration options from the CLI, you can run the CLI command with `--help`. This will print a full list of all available options.

```sh
npx -p @aries-framework/rest afj-rest start --help
```
9 changes: 0 additions & 9 deletions guides/extensions/rest/index.md

This file was deleted.

35 changes: 0 additions & 35 deletions guides/extensions/rest/setup.md

This file was deleted.

Loading
Loading