Skip to content

Commit

Permalink
introductions and some context (#43)
Browse files Browse the repository at this point in the history
Signed-off-by: Ana Goessens <ana@animo.id>
  • Loading branch information
anagoessens committed Jun 27, 2022
1 parent 190902c commit 2b3ea26
Show file tree
Hide file tree
Showing 19 changed files with 391 additions and 268 deletions.
38 changes: 37 additions & 1 deletion README.md
@@ -1,4 +1,30 @@
# Website
<p align="center">
<br />
<img
alt="Hyperledger Aries logo"
src="https://raw.githubusercontent.com/hyperledger/aries-framework-javascript/aa31131825e3331dc93694bc58414d955dcb1129/images/aries-logo.png"
height="250px"
/>
</p>
<h1 align="center"><b>Aries JavaScript Documentation</b></h1>
<p align="center">
<a
href="https://raw.githubusercontent.com/hyperledger/aries-framework-javascript/main/LICENSE"
><img
alt="License"
src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"
/></a>
</p>
<br />
<p align="center">
<a href="#getting-started">Getting started</a> &nbsp;|&nbsp;
<a href="#contributing">Contributing</a> &nbsp;|&nbsp;
<a href="#license">License</a>
</p>

Aries JavaScipt is an ecosystem of self-sovereign identity development tools, with [Aries Framework JavaScipt](https://github.com/hyperledger/aries-framework-javascript) at the center. This documentation site serves to make it as easy as possible for developers of any level to get started with building self-sovereign identity solutions.

# Getting Started

This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.

Expand Down Expand Up @@ -39,3 +65,13 @@ $ GIT_USER=<Your GitHub username> yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

## Contributing

The docs are a work in progress, contributions are incredibly appreciated! If you're looking to contribute check out the [contribution guideline](https://github.com/hyperledger/aries-javascript-docs/blob/main/CONTRIBUTING.md).

Issues are also welcomed as it gives us a good idea of the work still needing to be done.

## Licence

Aries JavaScript Documentation is licensed under the [Apache License Version 2.0 (Apache-2.0)](/LICENSE).
4 changes: 3 additions & 1 deletion guides/getting-started/index.md
@@ -1,3 +1,5 @@
# Getting started

In this section we will go over everything you need to get started.
In this section we will go over everything you need to get started on a technical level. First there are specific installation guides for NodeJS and React Native. Aries JavaScript works for creating both serverside application (commonly but not always issuer and verifyer) and mobile applications (commonly holder apps). Depending on your use case you can follow the installation guides for [NodeJS](./installation/nodejs/index.md), [React Native](/installation/react-native/index.md), or both.

After the installation of your prerequisites is complete, we'll walk you through the [initial setup](./set-up/index.md) of the framework.
226 changes: 11 additions & 215 deletions guides/getting-started/installation/index.md
@@ -1,222 +1,18 @@
# Setup
# Installation

> This guide assumes you have followed the install guides from the previous
> section for your platform and a valid [Node.js](https://nodejs.org) or [React
> Native](https://reactnative.dev) project setup.
In order to work with the Aries JavaScript Ecosystem, you first have to setup your work environment. We strive to create an easy and accessible ecosystem, so the prerequisites are not too large.

### Installing the required dependencies
Feel free to click through all the installation guides and setup, if you're looking for specifics however, you can see a summary below.

First we have to install the minimal amount of dependencies that are required
for using the Aries Ecosystem.
Very simply put:

<!--tabs-->
**Do you want to build a mobile app?**

# Node.js
- Have [NodeJS](https://nodejs.org/en/) installed (but no need to follow the [NodeJS installation](./installation/nodejs/index.md) guide as it pertains to the `@aries-framework/node` package).
- Follow the [React Native installation](./installation/react-native/index.md) guide.
- Follow the [set up](./../set-up/index.md) guide.

```console
yarn add @aries-framework/core @aries-framework/node
```
**Do you want to build a server-side app?**

# React Native

```console
yarn add @aries-framework/core @aries-framework/react-native react-native-fs react-native-get-random-values
```

<!--/tabs-->

### Additional setup

<!--tabs-->

# Node.js

no additional setup is required

# React Native

Since [React Native](https://reactnative.dev) does not have an implementation
for
[`crypto.getRandomValues()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues)
we have to setup a polyfill for this. We have to do this at the entrypoint of
the application. This could is most likely `index.(js|ts|jsx|tsx)` at the root
of your application.

```diff title="index.tsx" showLineNumbers
+ import 'react-native-get-random-values'
```

In addition you need add support for resolving modules with the `.cjs` extension, as this is used by some of AFJ's dependencies and not automatically supported by React Native.

```js title="metro.config.js" showLineNumbers
module.exports = {
// ... other Metro config options ...
resolver: {
// make sure this includes `cjs` (and other extensions you need)
sourceExts: ['js', 'json', 'ts', 'tsx', 'cjs'],
},
}
```

<!--/tabs-->

### Setting up the agent

> this section does not assume any knowledge of the agent configuration.
> [Here](../../tutorials/agent-config) we will discuss in-depth what every
> field in the configuration does and when to set it.
In order to use the agent in the application we have to configure and
initialize it. This following configuration is quite generic and possibly not
enough for your specific use cases. Please refer to the
[tutorials](../../tutorials/index) for a more use-case-specific agent setup.

<!--tabs-->

# Node.js

```typescript showLineNumbers
import type { InitConfig } from '@aries-framework/core'
import { Agent } from '@aries-framework/core'
import { agentDependencies } from '@aries-framework/node'

const config: InitConfig = {
label: 'docs-nodejs-agent',
walletConfig: {
id: 'wallet-id',
key: 'testkey0000000000000000000000000',
},
}

const agent = new Agent(config, agentDependencies)
```

# React Native

```typescript showLineNumbers
import type { InitConfig } from '@aries-framework/core'
import { Agent } from '@aries-framework/core'
import { agentDependencies } from '@aries-framework/react-native'

const config: InitConfig = {
label: 'docs-rn-agent',
walletConfig: {
id: 'wallet-id',
key: 'testkey0000000000000000000000000',
},
}

const agent = new Agent(config, agentDependencies)
```

<!--/tabs-->

### Setting up the transports

After creating an `Agent` instance, we have to set an outbound transport that
will handle traffic from the agent. It is also possible to set an inbound
transport in the same way as the outbound transport, but it is built-in, so not
required.

<!--tabs-->

# Node.js

Sets up an HTTP outbound and inbound transport.

```typescript showLineNumbers
import { HttpOutboundTransport, WsOutboundTransport, HttpInboundTransport } from '@aries-framework/core'

agent.registerOutboundTransport(new HttpOutboundTransport())
agent.registerInboundTransport(new HttpInboundTransport({ port: 3000 }))
```

# React Native

For mobile agents the WebSocket transport is often required. We will go into
more depth about the reasons for this in the mediation section [TODO: mediator
section](https://example.org)

```typescript showLineNumbers
import { WsOutboundTransport, HttpOutboundTransport } from '@aries-framework/core'

agent.registerOutboundTransport(new WsOutboundTransport())
agent.registerOutboundTransport(new HttpOutboundTransport())
```

<!--/tabs-->

### Initializing the agent

```typescript showLineNumbers
// ...

const agent = new Agent(config, agentDependencies)

const initialize = async () => await agent.initialize().catch(console.error)
```

### Full code snippet

<!--tabs-->

# Node.js

```typescript showLineNumbers
import type { InitConfig } from '@aries-framework/core'
import { Agent } from '@aries-framework/core'
import { agentDependencies } from '@aries-framework/node'

// The agent initialization configuration
const config: InitConfig = {
label: 'docs-nodejs-agent',
walletConfig: {
id: 'wallet-id',
key: 'testkey0000000000000000000000000',
},
}

// Creating an agent instance
const agent = new Agent(config, agentDependencies)

// Registering the required in- and outbound transports
agent.registerOutboundTransport(new HttpOutboundTransport())
agent.registerInboundTransport(new HttpInboundTransport({ port: 3000 }))

// Function to initialize the agent
const initialize = async () => await agent.initialize().catch(console.error)
```

# React Native

```typescript showLineNumbers
import type { InitConfig } from '@aries-framework/core'
import { Agent, WsOutboundTransport, HttpOutboundTransport } from '@aries-framework/core'
import { agentDependencies } from '@aries-framework/react-native'

// The agent initialization configuration
const config: InitConfig = {
label: 'docs-rn-agent',
walletConfig: {
id: 'wallet-id',
key: 'testkey0000000000000000000000000',
},
}

// Creating an agent instance
const agent = new Agent(config, agentDependencies)

// Registering the required outbound transport
agent.registerOutboundTransport(new HttpOutboundTransport())
agent.registerOutboundTransport(new WsOutboundTransport())

// Function to initialize the agent
const initialize = async () => await agent.initialize().catch(console.error)
```

<!--/tabs-->

### Useful resources

- [Hyperledger Aries RFC - 004:
Agents](https://github.com/hyperledger/aries-rfcs/blob/main/concepts/0004-agents/README.md)
- Follow the [NodeJS installation](./installation/nodejs/index.md) guide.
- Follow the [set up](./../set-up/index.md) guide.
18 changes: 18 additions & 0 deletions guides/getting-started/installation/nodejs/index.md
@@ -0,0 +1,18 @@
# NodeJS

To work with [Aries Framework
JavaScript](https://github.com/hyperledger/aries-framework-javascript) we need
to install some dependencies. We will go over the specific installation process for each platform. Ga ahead an pick your system of choice to get started!

- [Linux](./linux.md)
- [Windows](./windows.md)
- [Apple (Intel)](./apple-intel.md)
- [Apple (Arm)](./apple-arm.md)

The specific dependencies that you will install are the following. They will come up in the installlation guides, but are summarized here to give insight into what you will install.

- [NodeJS](https://nodejs.org)
- [yarn](https://classic.yarnpkg.com/lang/en/docs/install) or [npm](https://www.npmjs.com/)
- [libsodium](https://github.com/jedisct1/libsodium)
- [libzmq](https://github.com/zeromq/libzmq)
- [indy-sdk](https://github.com/hyperledger/indy-sdk).

0 comments on commit 2b3ea26

Please sign in to comment.