|
| 1 | +# File Input Cloud Storage Extension App Reference Implementation |
| 2 | +## Introduction |
| 3 | +This reference implementation simulates an external service that imports files from cloud storage to [Docusign Navigator](https://www.docusign.com/products/platform/navigator). This reference implementation is useful for: |
| 4 | + |
| 5 | +- Reviewing the format of requests to and responses from an external service that implements the file input cloud storage extension |
| 6 | +- Seeing how the extension functions when invoked from Navigator |
| 7 | + |
| 8 | +## Authentication |
| 9 | +This reference implementation supports two [authentication](https://developers.docusign.com/extension-apps/build-an-extension-app/it-infrastructure/authorization/) flows: |
| 10 | +* [Authorization Code Grant](https://developers.docusign.com/extension-apps/build-an-extension-app/it-infrastructure/authorization/#authorization-code-grant) – required for public extension apps |
| 11 | +* [Client Credentials Grant](https://developers.docusign.com/extension-apps/build-an-extension-app/it-infrastructure/authorization/#client-credentials-grant) – available to private extension apps. See [Choosing private distribution instead of public](https://developers.docusign.com/extension-apps/extension-apps-101/choosing-private-distribution/). |
| 12 | + |
| 13 | +*Private extension apps can use either authentication method, but public extension apps must use Authorization Code Grant.* |
| 14 | + |
| 15 | +**Note:** In the current release, only Client Credentials Grant is supported. |
| 16 | + |
| 17 | +## Hosted version (no setup required) |
| 18 | +You can use the hosted version of this reference implementation by directly uploading the appropriate manifest file located in the [manifests/hosted/](manifests/hosted) folder to the Docusign Developer Console. See [Upload your manifest and create the extension app](#3-upload-your-manifest-and-create-the-extension-app). |
| 19 | + |
| 20 | +**Note:** The provided manifest includes `clientId` and `clientSecret` values used in the sample authentication connection. These do not authenticate to a real system, but the hosted reference implementation requires these exact values. |
| 21 | + |
| 22 | +## Choose your setup: Local or cloud deployment |
| 23 | +If you want to run the app locally using Node.js and ngrok, follow the [local setup instructions](#local-setup-instructions) below. |
| 24 | + |
| 25 | +If you want to deploy the app to the cloud using Docker and Terraform, see the [Terraform deployment guide](terraform/README.md). This includes cloud-specific setup instructions for the following cloud providers: |
| 26 | +- [Amazon Web Services](https://aws.amazon.com/) |
| 27 | +- [Microsoft Azure](https://azure.microsoft.com/) |
| 28 | +- [Google Cloud Platform](https://cloud.google.com/) |
| 29 | + |
| 30 | +## Local setup instructions |
| 31 | + |
| 32 | +### Video walkthrough |
| 33 | +[](https://youtube.com/playlist?list=PLXpRTgmbu4oq4VDLJBA2BO6psxf8vkVoq&feature=shared) |
| 34 | + |
| 35 | +### 1. Clone the repository |
| 36 | +Run the following command to clone the repository: |
| 37 | +```bash |
| 38 | +git clone https://github.com/docusign/extension-app-file-input-cloud-storage-reference-implementation.git |
| 39 | +``` |
| 40 | + |
| 41 | +### 2. Generate secret values |
| 42 | +If you already have values for `JWT_SECRET_KEY`, `OAUTH_CLIENT_ID`, `OAUTH_CLIENT_SECRET`, and `AUTHORIZATION_CODE`, you may skip this step. |
| 43 | + |
| 44 | +The easiest way to generate a secret value is to run the following command: |
| 45 | +```bash |
| 46 | +node -e "console.log(require('crypto').randomBytes(64).toString('hex'));" |
| 47 | +``` |
| 48 | + |
| 49 | +You will need values for `JWT_SECRET_KEY`, `OAUTH_CLIENT_ID`, `OAUTH_CLIENT_SECRET`, and `AUTHORIZATION_CODE`. |
| 50 | + |
| 51 | +### 3. Set the environment variables for the cloned repository |
| 52 | +- If you're running this in a development environment, create a copy of `example.development.env` and save it as `development.env`. |
| 53 | +- If you're running this in a production environment, create a copy of `example.production.env` and save it as `production.env`. |
| 54 | +- Replace `JWT_SECRET_KEY`, `OAUTH_CLIENT_ID`, `OAUTH_CLIENT_SECRET`, and `AUTHORIZATION_CODE` in `development.env` or `production.env` with your generated values. These values will be used to configure the sample proxy's mock authentication server. |
| 55 | +- Set the `clientId` value in the manifest.json file to the same value as `OAUTH_CLIENT_ID`. |
| 56 | +- Set the `clientSecret` value in the manifest.json file to the same value as `OAUTH_CLIENT_SECRET`. |
| 57 | +### 4. [Install and configure Node.js and npm on your machine](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) |
| 58 | +### 5. Install dependencies |
| 59 | +Run the following command to install the necessary dependencies: |
| 60 | +```bash |
| 61 | +npm install |
| 62 | +``` |
| 63 | +### 6. Run the proxy server |
| 64 | +#### Development mode: |
| 65 | +Start the proxy server in development mode by running the command: |
| 66 | +```bash |
| 67 | +npm run dev |
| 68 | +``` |
| 69 | + |
| 70 | +This will create a local server on the port in the `development.env` file (port 3000 by default) that listens for local changes that trigger a rebuild. |
| 71 | + |
| 72 | +#### Production mode: |
| 73 | +Start the proxy server in production mode by running the commands: |
| 74 | +```bash |
| 75 | +npm run build |
| 76 | +npm run start |
| 77 | +``` |
| 78 | + |
| 79 | +This will start a production build on the port in the `production.env` file (port 3000 by default). |
| 80 | +## Set up ngrok |
| 81 | +### 1. [Install and configure ngrok for your machine](https://ngrok.com/docs/getting-started/) |
| 82 | +### 2. Start ngrok |
| 83 | +Run the following command to create a publicly accessible tunnel to your localhost: |
| 84 | + |
| 85 | +```bash |
| 86 | +ngrok http <PORT> |
| 87 | +``` |
| 88 | + |
| 89 | +Replace `<PORT>` with the port number in the `development.env` or `production.env` file. |
| 90 | + |
| 91 | +### 3. Save the forwarding address |
| 92 | +Copy the `Forwarding` address from the response. You’ll need this address in your `manifest.json` file. |
| 93 | + |
| 94 | +```bash |
| 95 | +ngrok |
| 96 | + |
| 97 | +Send your ngrok traffic logs to Datadog: https://ngrok.com/blog-post/datadog-log |
| 98 | + |
| 99 | +Session Status online |
| 100 | +Account email@domain.com (Plan: Free) |
| 101 | +Update update available (version 3.3.1, Ctrl-U to update) |
| 102 | +Version 3.3.0 |
| 103 | +Region United States (us) |
| 104 | +Latency 60ms |
| 105 | +Web Interface http://127.0.0.1:4040 |
| 106 | +Forwarding https://bbd7-12-202-171-35.ngrok-free.app -> http: |
| 107 | + |
| 108 | +Connections ttl opn rt1 rt5 p50 p90 |
| 109 | + 0 0 0.00 0.00 0.00 0.00 |
| 110 | +``` |
| 111 | + |
| 112 | +In this example, the `Forwarding` address to copy is `https://bbd7-12-202-171-35.ngrok-free.app`. |
| 113 | +## Create an extension app |
| 114 | +### 1. Prepare your app manifest |
| 115 | +Choose a manifest from the [manifests](manifests/) folder based on the appropriate [authentication](#authentication) use case. Replace `<PROXY_BASE_URL>` in your manifest.json file with the ngrok forwarding address in the following sections: |
| 116 | +- `connections.params.customConfig.tokenUrl` |
| 117 | +- `connections.params.customConfig.authorizationUrl` |
| 118 | +- `actions.params.uri` Replace this value for all of the actions. |
| 119 | +### 2. Navigate to the [Developer Console](https://devconsole.docusign.com/apps) |
| 120 | +Log in with your Docusign developer credentials. You can sign up for a free developer account [here](https://www.docusign.com/developers/sandbox). |
| 121 | +### 3. Upload your manifest and create the extension app |
| 122 | +To [create your extension app](https://developers.docusign.com/extension-apps/build-an-extension-app/create/), select **Create App > By editing the manifest**. In the app manifest editor that opens, upload your manifest file or paste into the editor itself; then select **Validate**. Once the editor validates your manifest, select **Create App.** |
| 123 | +### 4. Test the extension app |
| 124 | +This reference implementation simulates an external cloud storage service. After you have created an extension app in the Developer Console that connects to the reference implementation, you can run tests that send requests to it. Requests from the calling application are saved to the [logs](logs/) folder. The reference implementation sends responses to the calling application. This reference implementation processes the file input cloud storage extension's actions and capability as follows: |
| 125 | +- Get File: Uploads files from the reference implementation's [agreements](agreements/) folder to Navigator. |
| 126 | +- List Drives: Returns mock data. |
| 127 | +- List Directory Contents: Returns the folders and files from the reference implementation's [agreements](agreements/) folder. |
| 128 | +- Search: Returns folders and files from the reference implementation's [agreements](agreements/) folder where the folder or file name matches the supplied search string. |
| 129 | +#### [Integration tests](https://developers.docusign.com/extension-apps/build-an-extension-app/test/integration-tests/) |
| 130 | +You can run these tests from the Developer Console to test each supported action and capability for the extension. These tests allow you to construct the request body and see the response. |
| 131 | +#### [Functional tests](https://developers.docusign.com/extension-apps/build-an-extension-app/test/functional-tests/) |
| 132 | +This type of test shows how the extension functions when invoked from an [extension point](https://developers.docusign.com/extension-apps/extension-apps-101/concepts/extensions-and-extension-points/#extension-points). For file input cloud storage, the extension point is [Navigator](https://support.docusign.com/s/document-item?bundleId=pqz1702943441912&topicId=adf1702945446135.html). |
| 133 | + |
| 134 | + |
| 135 | + |
| 136 | + |
| 137 | + |
0 commit comments