diff --git a/guides/extensions/push-notifications.md b/guides/extensions/push-notifications.md new file mode 100644 index 00000000..abf736e3 --- /dev/null +++ b/guides/extensions/push-notifications.md @@ -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: + + + +## npm + +```sh +npm i @aries-framework/push-notifications +``` + +## Yarn + +```sh +yarn add @aries-framework/push-notifications +``` + + + +## 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') + +``` diff --git a/guides/extensions/push-notifications/index.md b/guides/extensions/push-notifications/index.md deleted file mode 100644 index e554c6e4..00000000 --- a/guides/extensions/push-notifications/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# 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. diff --git a/guides/extensions/push-notifications/setup.md b/guides/extensions/push-notifications/setup.md deleted file mode 100644 index db065d20..00000000 --- a/guides/extensions/push-notifications/setup.md +++ /dev/null @@ -1,21 +0,0 @@ -# Setup - -To use the Push Notifications package, you need to have set up Aries Framework JavaScript according to the AFJ repository (See [Getting Started](../../getting-started/index.md) section). - -Then add the Push Notifications plugin package to your project: - - - -## npm - -```sh -npm i @aries-framework/push-notifications -``` - -## Yarn - -```sh -yarn add @aries-framework/push-notifications -``` - - diff --git a/guides/extensions/react-hooks.md b/guides/extensions/react-hooks.md new file mode 100644 index 00000000..c0592047 --- /dev/null +++ b/guides/extensions/react-hooks.md @@ -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: + + + +## npm + +```sh +npm i @aries-framework/react-hooks@^0.5 +``` + +## Yarn + +```sh +yarn add @aries-framework/react-hooks@^0.5 +``` + + + +## 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 ``. 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 + + return /* Your app here */ +} +``` + +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 } /> +} +``` + +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) +``` diff --git a/guides/extensions/react-hooks/index.md b/guides/extensions/react-hooks/index.md deleted file mode 100644 index 67e9e4f3..00000000 --- a/guides/extensions/react-hooks/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# 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. diff --git a/guides/extensions/react-hooks/setup.md b/guides/extensions/react-hooks/setup.md deleted file mode 100644 index e966f8f4..00000000 --- a/guides/extensions/react-hooks/setup.md +++ /dev/null @@ -1,23 +0,0 @@ -# Setup - -To use the React Hooks package, you need to have set up Aries Framework JavaScript according to the AFJ repository (See [Getting Started](../../getting-started/index.md) section). - -## Installation - -To add the React Hooks package to your project (after completing the setup step above), simply run: - - - -## npm - -```sh -npm i @aries-framework/react-hooks -``` - -## Yarn - -```sh -yarn add @aries-framework/react-hooks -``` - - diff --git a/guides/extensions/redux-store.md b/guides/extensions/redux-store.md new file mode 100644 index 00000000..c0c42475 --- /dev/null +++ b/guides/extensions/redux-store.md @@ -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: + + + +## npm + +```sh +npm i @aries-framework/redux-store +``` + +## Yarn + +```sh +yarn add @aries-framework/redux-store +``` + + diff --git a/guides/extensions/redux-store/index.md b/guides/extensions/redux-store/index.md deleted file mode 100644 index 424d64c5..00000000 --- a/guides/extensions/redux-store/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# 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. diff --git a/guides/extensions/redux-store/setup.md b/guides/extensions/redux-store/setup.md deleted file mode 100644 index cc2f0732..00000000 --- a/guides/extensions/redux-store/setup.md +++ /dev/null @@ -1,23 +0,0 @@ -# Setup - -To use the Redux Store package, you need to have set up Aries Framework JavaScript according to the AFJ repository (See [Getting Started](../../getting-started/index.md) section). - -## Installation - -To add the Redux Store package to your project (after completing the setup step above), simply run: - - - -## npm - -```sh -npm i @aries-framework/redux-store -``` - -## Yarn - -```sh -yarn add @aries-framework/redux-store -``` - - diff --git a/guides/extensions/rest.md b/guides/extensions/rest.md new file mode 100644 index 00000000..4614a54e --- /dev/null +++ b/guides/extensions/rest.md @@ -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. ). + +### 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 +``` diff --git a/guides/extensions/rest/index.md b/guides/extensions/rest/index.md deleted file mode 100644 index 08c6d12d..00000000 --- a/guides/extensions/rest/index.md +++ /dev/null @@ -1,9 +0,0 @@ -# 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. diff --git a/guides/extensions/rest/setup.md b/guides/extensions/rest/setup.md deleted file mode 100644 index 7c71d2a8..00000000 --- a/guides/extensions/rest/setup.md +++ /dev/null @@ -1,35 +0,0 @@ -# Setup - -> 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. - -## Quick 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. ). - -### 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 -``` diff --git a/sidebars.js b/sidebars.js index 5bf3b2a0..8a64e92d 100644 --- a/sidebars.js +++ b/sidebars.js @@ -104,28 +104,24 @@ const sidebars = { link: { type: 'doc', id: 'extensions/index' }, items: [ { - type: 'category', + type: 'doc', label: 'REST API', - link: { type: 'doc', id: 'extensions/rest/index' }, - items: ['extensions/rest/setup'], + id: 'extensions/rest', }, { - type: 'category', + type: 'doc', label: 'React Hooks', - link: { type: 'doc', id: 'extensions/react-hooks/index' }, - items: ['extensions/react-hooks/setup'], + id: 'extensions/react-hooks', }, { - type: 'category', + type: 'doc', label: 'Redux Store', - link: { type: 'doc', id: 'extensions/redux-store/index' }, - items: ['extensions/redux-store/setup'], + id: 'extensions/redux-store', }, { - type: 'category', + type: 'doc', label: 'Push Notifications', - link: { type: 'doc', id: 'extensions/push-notifications/index' }, - items: ['extensions/push-notifications/setup'], + id: 'extensions/push-notifications', }, ], },