Skip to content

Commit 22de775

Browse files
Initial commit with squashed history
0 parents  commit 22de775

File tree

91 files changed

+9189
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+9189
-0
lines changed

Containerfile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Global arguments
2+
ARG BASE_IMAGE=node:lts-alpine
3+
ARG APP_DIR=/usr/src/app
4+
ARG UID=1000
5+
ARG GID=1000
6+
ARG PORT=3000
7+
8+
# Base stage
9+
FROM ${BASE_IMAGE} AS base
10+
ARG APP_DIR
11+
ARG UID
12+
ARG GID
13+
ARG PORT
14+
15+
RUN mkdir -p ${APP_DIR} && \
16+
chown -R ${UID}:${GID} ${APP_DIR}
17+
18+
USER ${UID}:${GID}
19+
20+
WORKDIR ${APP_DIR}
21+
22+
ENV PORT=${PORT}
23+
EXPOSE ${PORT}
24+
25+
COPY --chown=${UID}:${GID} package.json .
26+
27+
# Dependencies stage
28+
FROM base AS dependencies
29+
ARG APP_DIR
30+
31+
RUN npm install && \
32+
npm cache clean --force && \
33+
touch ${APP_DIR}/production.env && \
34+
touch ${APP_DIR}/development.env
35+
36+
ENV PATH=${APP_DIR}/node_modules/.bin:$PATH
37+
38+
# Development stage
39+
FROM dependencies AS development
40+
ARG UID
41+
ARG GID
42+
43+
ENV NODE_ENV=development
44+
45+
COPY --chown=${UID}:${GID} . .
46+
47+
CMD ["npm", "run", "dev"]
48+
49+
# Build stage
50+
FROM dependencies AS build
51+
ARG UID
52+
ARG GID
53+
54+
COPY --chown=${UID}:${GID} . .
55+
56+
RUN npm run build
57+
58+
# Production stage
59+
FROM dependencies AS production
60+
ARG UID
61+
ARG GID
62+
ARG APP_DIR
63+
64+
ENV NODE_ENV=production
65+
66+
COPY --chown=${UID}:${GID} ./public ./public
67+
COPY --chown=${UID}:${GID} ./views ./views
68+
COPY --chown=${UID}:${GID} --from=build ${APP_DIR}/dist ./dist
69+
70+
CMD ["node", "./dist", "--env=production"]

Dockerfile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Global arguments
2+
ARG BASE_IMAGE=node:lts-alpine
3+
ARG APP_DIR=/usr/src/app
4+
ARG UID=1000
5+
ARG GID=1000
6+
ARG PORT=3000
7+
8+
# Base stage
9+
FROM ${BASE_IMAGE} AS base
10+
ARG APP_DIR
11+
ARG UID
12+
ARG GID
13+
ARG PORT
14+
15+
RUN mkdir -p ${APP_DIR} && \
16+
chown -R ${UID}:${GID} ${APP_DIR}
17+
18+
USER ${UID}:${GID}
19+
20+
WORKDIR ${APP_DIR}
21+
22+
ENV PORT=${PORT}
23+
EXPOSE ${PORT}
24+
25+
# Dependencies stage
26+
FROM base AS dependencies
27+
ARG APP_DIR
28+
29+
RUN --mount=type=bind,source=./package.json,target=${APP_DIR}/package.json \
30+
--mount=type=cache,target=${APP_DIR}/.npm,uid=$UID,gid=$GID,mode=0755,sharing=locked \
31+
npm install && \
32+
touch ${APP_DIR}/production.env && \
33+
touch ${APP_DIR}/development.env
34+
35+
ENV PATH=${APP_DIR}/node_modules/.bin:$PATH
36+
37+
# Development stage
38+
FROM dependencies AS development
39+
ARG UID
40+
ARG GID
41+
42+
ENV NODE_ENV=development
43+
44+
COPY --chown=${UID}:${GID} . .
45+
46+
CMD ["npm", "run", "dev"]
47+
48+
# Build stage
49+
FROM dependencies AS build
50+
ARG UID
51+
ARG GID
52+
53+
COPY --chown=${UID}:${GID} . .
54+
55+
RUN npm run build
56+
57+
# Production stage
58+
FROM dependencies AS production
59+
ARG UID
60+
ARG GID
61+
ARG APP_DIR
62+
63+
ENV NODE_ENV=production
64+
65+
COPY --chown=${UID}:${GID} package.json .
66+
COPY --chown=${UID}:${GID} ./views ./views
67+
COPY --chown=${UID}:${GID} --from=build ${APP_DIR}/dist ./dist
68+
69+
CMD ["node", "./dist", "--env=production"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 DocuSign Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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+
[![Reference implementation videos](https://img.youtube.com/vi/_4p7GWK5aoA/0.jpg)](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+
Binary file not shown.
84.6 KB
Binary file not shown.
71.7 KB
Binary file not shown.
79.1 KB
Binary file not shown.
89.8 KB
Binary file not shown.
78.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)