# @akordacorp/assembly

> Contract Assembly Integration Resources (JS/CSS)

Latest version **1.1.2** (published 2022-03-10) · SEE LICENSE IN LICENSE.md license · 0 weekly downloads

## Install

```sh
npm install @akordacorp/assembly
pnpm add @akordacorp/assembly
yarn add @akordacorp/assembly
bun add @akordacorp/assembly
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2022-03-10 |
| First published | 2022-03-10 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE.md |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Matt Meiske |
| Maintainers | akordacorp |

## Links

- npm: https://www.npmjs.com/package/@akordacorp/assembly
- npm.io page: https://npm.io/package/@akordacorp/assembly

## Recent versions

- 1.1.2 (latest) — 2022-03-10
- 1.1.1 — 2022-03-10
- 1.1.0 — 2022-03-10
- 1.0.0 — 2022-03-10

## README

# Akorda - Developer Integration - Contract Assembly

This package contains two files:

* `akorda-assembly.js`
* `akorda-assembly.css`

These two resources are used to integrate Akorda's Contract Assembly feature into third-party environments.

### Installation

```
yarn add @akordacorp/assembly
```

or

```
npm install @akordacorp/assembly
```

### Usage

Once the browser has loaded the two resources (*akorda-assembly.js* and *akorda-assembly.css*), you can load Akorda's contract assembly feature using the js function `AkordaAssembly()`. For example:

```javascript
// reference the id of your contract playbook template that you'd like to use.
// Assembly Questions should be configured for this playbook.
const akordaPlaybookId = 892;

// the "config" argument is an object that includes various
// properties (some required) for talking to the Akorda
// application. More information about the config option
// properties can be found in the documentation below.
const config = {
  // the Akorda application URL (omitted if using a proxy)
  appUrl: "https://app.akorda.com",
  // the jwt token obtained via your client credentials (omitted if using a proxy)
  accessToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbkFzIjoiYWRtaW4iLCJpYXQiOjE0MjI3Nzk2Mzh9.gzSraSYS8EXBxLN_oWnFSRgCzcmJmMjLiuyu5CSpyHI",
  // the id of the DOM element in which to load the assembly feature.
  targetElementId: "akorda-assembly",
  // required information about the user
  userInfo: {
    firstName: "Jane",
    lastName: "Doe",
    email: "jane.doe@akorda.com"
  },
};

// Call the AkordaAssembly() function with the required arguments
AkordaAssembly(akordaPlaybookId, config);

```

### Config Properties

***`config.appUrl`*** In a standard production environment, this url will be same url as the production Akorda application: **https://app.akorda.com**. If you are using an Akorda development or staging environment, this url may be different. Ask your Akorda representative for more information.

***Important***: If you are proxing the calls to Akorda on the server, you must omit this property from the config.

---

***`config.targetElementId`*** In your web page, this is the ID of the DOM element in which you want the Akorda Contract Assembly feature to appear. The default is `akorda-assembly`, and might appear in the html of your web page as:

```html
<div id="akorda-assembly"></div>
```

---

***`config.accessToken`*** The JWT token that will be used for authentication and authorization in the Akorda application. You can acquire a token via the Akorda application by sending an HTTP POST request to `{appUrl}/api/login/authorize`, and include the form values: `client_id` and `client_secret`. Please contact your Akorda representative for these details.

---

***`config.userInfo`*** An object with the following structure:

```json
 {
    firstName: "Jane",
    lastName: "Doe",
    email: "jane.doe@akorda.com"
  }
```

This information allows Akorda to properly send emails on behalf of the user.

### Use a Proxy
The best way to integrate Akorda Assembly is to use a server-side proxy that will avoid the challenges associated with cross-origin requests from the browser and keep your accessToken away from your client-side code.

For example, when the user loads your web page, your server could obtain a JWT access token using the Akorda provided client credentials (*client_id* and *client_secret*), and then return the page with a cookie (named `Authorization`) that has the JWT access token as the value.

Then, when your client code calls `AkordaAssembly(playbookId, config)`, **omit** the `appUrl` and the `accessToken` from the *config* object. By omitting these, all data requests will be sent to your server instead of Akorda's application.

Next, proxy the Akorda API calls (they all start with "/api") along with the authorization cookie to the Akorda application url (e.g., https://app.akorda.com).

An example/reference implementation (built using a simple NodeJS Express web app) is available here: https://github.com/akordacorp/assembly-reference-implementation.

And if you need help, don't hesitate to contact your Akorda representative.

---
_Source: https://npm.io/package/@akordacorp/assembly · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
