Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Commit

Permalink
Polish a few docs pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjacobson committed Jun 29, 2022
1 parent 17e43a3 commit cf12801
Show file tree
Hide file tree
Showing 434 changed files with 34,671 additions and 4,977 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Dev

```
npm install
npm run init-sdk-docgen
npm start
```

Expand Down
5 changes: 0 additions & 5 deletions docs/api/_category_.json

This file was deleted.

4 changes: 4 additions & 0 deletions docs/developers/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "Developers",
"position": 4
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ sidebar_position: 4
# Log In with Audius

<center><img src="/img/oauthpopup.png" height="488" width="252" alt="Log In with Audius popup" /></center>
<center>
<em>Log In with Audius dialog</em>
</center>

Log In with Audius lets you retrieve and verify a user's Audius profile information without making the user give you their Audius password.

Expand All @@ -18,10 +15,12 @@ Log In with Audius lets you retrieve and verify a user's Audius profile informat
<div id="audiusLogInButton"></div>
```

```js title="script.js"
```js title="script.js" showLineNumbers
import Web3 from "web3";
import { sdk } from "@audius/sdk";

window.Web3 = Web3

const audiusSdk = sdk({ appName: "Name of your app goes here" });

audiusSdk.oauth.init((res) => {
Expand All @@ -39,22 +38,18 @@ audiusSdk.oauth.renderButton(document.getElementById("audiusLogInButton"));

## Full Reference

### 0. Install the SDK
### 1. Install the JavaScript SDK

:::note

If you are not able to use the Javascript SDK (for example, if you are developing a mobile app), skip to [Manual Implementation](#manual-implementation).
If you are not able to use the JavaScript SDK (for example, if you are developing a mobile app), skip to [Manual Implementation](#manual-implementation).

:::

In your terminal, run the following commands:

```bash
npm install web3
```
In your terminal, run the following:

```bash
npm install @audius/sdk
npm install web3 @audius/sdk
```

Then, initialize the SDK:
Expand All @@ -68,12 +63,12 @@ const audiusSdk = sdk({ appName: "Name of your app goes here" });
```

:::tip
See complete instructions [here](sdk/index#installation) to install and initialize the Javascript SDK.
See complete instructions [here](sdk/index#installation) to install and initialize the JavaScript SDK.
:::

### 1. Initialize the SDK `oauth` feature
### 2. Initialize the SDK `oauth` feature

```js
```js showLineNumbers
audiusSdk.oauth.init(
(res) => {
// This will run if the user logged in successfully.
Expand All @@ -100,9 +95,9 @@ audiusSdk.oauth.init(
);
```

### 2. Render the Log In button
### 3. Render the Log In button

```js title="In your JS"
```js title="In your JS" showLineNumbers
audiusSdk.oauth.renderButton(document.getElementById("audiusLogInButton"), {
size: "large",
corners: "pill",
Expand All @@ -124,19 +119,19 @@ You can use [this playground](https://9ncjui.csb.app/) to see how these customiz

If you don't want to use `renderButton`, you can implement a login button yourself and invoke the login popup with [`audiusSdk.oauth.login()`](sdk-oauth-methods#oauthlogin).

### 3. Optional: Show loader until the button is ready
### 4. Optional: Show loader until the button is ready

The button may take up to a couple of seconds to load. You may want to show a loading indicator until the button has loaded for an optimal user experience.

```html title="In your HTML"
```html title="In your HTML" showLineNumbers
<!-- Surround your element that will be replaced with the Log In with Audius button with a parent, e.g.: -->
<div id="parent">
<div id="audiusLogInButton"></div>
<div id="loading">Loading...</div>
</div>
```

```javascript title="In your JS"
```javascript title="In your JS" showLineNumbers
const observer = new MutationObserver(function (mutations_list) {
mutations_list.forEach(function (mutation) {
mutation.addedNodes.forEach(function (added_node) {
Expand All @@ -157,7 +152,7 @@ observer.observe(document.querySelector("#parent"), {

The log in button will be rendered with an id of `audius-login-button`. As shown above, you can detect when the element has been added using a MutationObserver.

### 4. Done!
### 5. Done!

[See examples](#examples)

Expand Down Expand Up @@ -205,7 +200,7 @@ The JWT payload contains the following information about the user:

## Manual Implementation

If you are not able to use the Audius Javascript SDK, you may implement Log In with Audius manually by following the steps below.
If you are not able to use the Audius JavaScript SDK, you may implement Log In with Audius manually by following the steps below.

### 1. Open the Log In with Audius prompt page

Expand Down Expand Up @@ -245,24 +240,29 @@ You must open this page with the required URL parameters, described below.

**Example**

```html
```html noInline
<a
href="https://audius.co/oauth/auth?scope=read&app_name=My%20Demo%20App&redirect_uri=https://mydemoapp.com/oauth/receive-token&state=a4e0761e-8c21-4e20-819d-5a4daeab4ea9"
>Click me to log in with Audius!</a
>
```

### 1.5 Remember to handle early exiting (i.e. failure) of the authentication flow
:::tip
Remember to handle early exiting (i.e. failure) of the authentication flow

If the user exits the authentication flow before completing it--e.g. by closing the window--your app should detect this and have the UI respond accordingly.

:::

### 2. Receive the response

#### **If you used a redirect URI**:

When the user has successfully authenticated, the Log In with Audius page will redirect to the redirect URI that you specified, **with 1) the JWT containing the user profile, and 2) the original state value you provided (if any) included in the URI fragment** (or query string, if `response_mode` was set to `query`). To illustrate, going off the example above where we opened the login page with the following URL:

`https://audius.co/oauth/auth?scope=read&app_name=My%20Demo%20App&redirect_uri=https://mydemoapp.com/oauth/receive-token&state=a4e0761e-8c21-4e20-819d-5a4daeab4ea9`
```noInline
https://audius.co/oauth/auth?scope=read&app_name=My%20Demo%20App&redirect_uri=https://mydemoapp.com/oauth/receive-token&state=a4e0761e-8c21-4e20-819d-5a4daeab4ea9
```

when the user successsfully authenticates, the login page would redirect to:

Expand All @@ -284,7 +284,9 @@ When the user has successfully authenticated, the Log In with Audius page will s

For instance, if your app opened the login page using the following URL:

`https://audius.co/oauth/auth?scope=read&app_name=My%20Demo%20App&redirect_uri=https://mydemoapp.com/oauth/receive-token&state=a4e0761e-8c21-4e20-819d-5a4daeab4ea9`
```noInline
https://audius.co/oauth/auth?scope=read&app_name=My%20Demo%20App&redirect_uri=https://mydemoapp.com/oauth/receive-token&state=a4e0761e-8c21-4e20-819d-5a4daeab4ea9
```

the message would look like this:

Expand All @@ -301,7 +303,7 @@ where `<JWT>` is a [JSON web token](https://jwt.io/introduction) containing the
Make sure that your `postMessage` event listener validates that the origin of the incoming event is `https://audius.co`!
:::

### **3. Verify the response**
### 3. Verify the response

Extract the JWT (`token`) from the URI fragment or query string (if you used a redirect) or the event message (if you used `postmessage`).

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions docs/protocol/content-node/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "Content Node",
"position": 4
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
---
sidebar_label: Content Node
sidebar_position: 3
sidebar_label: Architecture
sidebar_position: 2
---

# Content Node
# Architecture

## Overview
## Web Server

An Audius Content Node maintains the availability of all content in the network.
Content types include user and track metadata, user and track images, and audio content.

*NOTE - Previously, there was a concept of a ”creator node” that was separate from a content node. These have been combined into a single node type rather than being separate, with ”content node” referring to the merged type. Some references to ”creator node” still exist in Audius code and in other documentation; those can safely be assumed to be referring to the content nodes outlined here.*

All registered content nodes are visible here: https://dashboard.audius.org/services/creator-node

## Architecture

**Web Server**

The content node's core service is a web server with an HTTP API to process incoming requests and perform the following functions:
The Content Node's core service is a web server with an HTTP API to process incoming requests and perform the following functions:

- user & track metadata upload
- user & track image upload
Expand All @@ -27,24 +16,24 @@ The content node's core service is a web server with an HTTP API to process inco

*The web server is a [NodeJS](https://nodejs.org) [Express app](https://expressjs.com/).*

**Persistent Storage (Postgres)**
## Persistent Storage (Postgres)

It stores all data in a postgresql database and all images and metadata objects on its file system.

Pointers to all content and metadata stored on disk are persisted in the Postgres DB.

*Postgres is managed in the codebase using the [Sequelize ORM](https://sequelize.org/master/) which includes migrations, models and validations*

**Redis**
## Redis

A [Redis client](https://redis.io/) is used for for resource locking, request rate limiting, and limited caching and key storage.

*Redis is managed in the codebase through the [ioredis](https://github.com/luin/ioredis) npm package*

**Track Segmenting**
## Track Segmenting

As defined by the [Audius protocol](https://whitepaper.audius.co), the content node uses [FFMPEG](https://ffmpeg.org/ffmpeg.html) to segment & transcode all uploaded track files before storing/serving.

**Data Redundancy**
## Data Redundancy**

As defined by the [Audius protocol](https://whitepaper.audius.co), all content is stored redundantly across multiple nodes to maximize availability. This is all done automatically - every node monitors every other node in the network to ensure minimum redundancy of all data, transfering files as required.
25 changes: 25 additions & 0 deletions docs/protocol/content-node/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
sidebar_label: Overview
sidebar_position: 1
---

# Overview

An Audius Content Node is a service that stores and maintains the availability of all content across the Audius network.
Content types include user, track, and playlist metadata, images and artwork, and audio content.

[github repository](https://github.com/AudiusProject/audius-protocol/tree/master/creator-node)
[registered discovery nodes](https://dashboard.audius.org/#/services/content-node)

Design Goals

1. Surface the Audius Storage Protocol for storing and serving images and audio
2. Keep data consistently replicated and available
3. Provide an interface to handle content upload, transcoding, and identification
4. Allow users to maintain agency over where and how their data is stored amongst Content Nodes

:::note

The Content Node may be referred to as the Creator Node. These services are the same.

:::
9 changes: 7 additions & 2 deletions docs/protocol/discovery-node/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ sidebar_position: 1
An Audius Discovery Node is a service that indexes the metadata and availability of data across the protocol for Audius users to query. The indexed content includes user, track, and album/playlist information along with social features. The data is stored for quick access, updated on a regular interval, and made available for clients via a RESTful API.

[github repository](https://github.com/AudiusProject/audius-protocol/tree/master/discovery-provider)

*NOTE - previously the discovery node was also referred to as "discovery provider" or "discovery node". These names all refer to the same service, the discovery node.*
[registered discovery nodes](https://dashboard.audius.org/#/services/discovery-node)

Design Goals

1. Expose queryable endpoints which listeners/creators can interact with
2. Reliably store relevant blockchain events
3. Continuously monitor the blockchain and ensure stored data is up to date with the network

:::note

The Discovery Node may be referred to as the Discovery Provider. These services are the same.

:::
2 changes: 1 addition & 1 deletion docs/token/running-a-node/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Please join the node operator discord channel on the [Audius discord server](htt

On a VM that meets the minimum requirements from above run:

```sh
```bash
bash <(curl https://raw.githubusercontent.com/AudiusProject/audius-docker-compose/main/install.sh)
```

Expand Down
5 changes: 3 additions & 2 deletions docs/welcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ sidebar_label: Welcome
sidebar_position: 1
---

# 🎶 Welcome 🎶
# Welcome

Welcome to the Audius technical documentation!
![](/img/dev.jpg)

Welcome to the Audius technical documentation!

## What is Audius?

Expand Down
18 changes: 9 additions & 9 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const darkCodeTheme = require("prism-react-renderer/themes/dracula");
path: "docs",
routeBasePath: "/",
sidebarPath: require.resolve("./sidebars.js"),
// editUrl: 'https://github.com/AudiusProject/docs.audius.org/',
editUrl: 'https://github.com/AudiusProject/docs.audius.org/',
},
theme: {
customCss: require.resolve("./src/css/custom.css"),
Expand All @@ -39,7 +39,7 @@ const darkCodeTheme = require("prism-react-renderer/themes/dracula");
// Plugin / TypeDoc options
{
plugin: ["typedoc-plugin-audius-theme"],
out: "./api/sdk",
out: "./developers/sdk",
entryPoints: ["./node_modules/@audius/sdk/src/sdk/index.ts"],
tsconfig: "./node_modules/@audius/sdk/tsconfig.json",
excludeInternal: true,
Expand Down Expand Up @@ -93,18 +93,18 @@ const darkCodeTheme = require("prism-react-renderer/themes/dracula");
position: "left",
},
{
to: "protocol/overview",
label: "Protocol",
to: "/category/protocol",
position: "left",
},
{
to: "api/rest-api",
label: "API",
label: "Token",
to: "/category/token",
position: "left",
},
{
to: "token/audio",
label: "Token",
label: "Developers",
to: "/category/developers",
position: "left",
},
{
Expand Down Expand Up @@ -144,8 +144,8 @@ const darkCodeTheme = require("prism-react-renderer/themes/dracula");
to: "protocol/overview",
},
{
label: "API",
to: "api/rest-api",
label: "Developers",
to: "/category/developers",
},
],
},
Expand Down
Loading

0 comments on commit cf12801

Please sign in to comment.