-
Notifications
You must be signed in to change notification settings - Fork 453
feat(plugins): add DocuSign eSignature integration plugin #1146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
likithdt
wants to merge
18
commits into
corsairdev:main
Choose a base branch
from
likithdt:feat/docusign-plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8c4da68
feat(docusign): implement eSignature client, envelope/template endpoi…
likithdt b6885a1
test(docusign): verify plugin registration and client in demo server
likithdt fc3556f
fix(docusign): remove polynomial regex to resolve codeql redos warning
likithdt e7543f3
style(docusign): format and clean up package with biome
likithdt 7bdeb16
chore: revert demo/testing to keep PR strictly scoped to plugin
likithdt 96444b2
chore: sync pnpm-lock.yaml after reverting demo/testing
likithdt ef2809a
chore: trigger PR gate check
likithdt 6ca4695
chore: trigger PR gate check
likithdt 0e70ada
fix(docusign): export endpoint schemas and satisfy RequiredPluginEndp…
likithdt c2fc142
fix(docusign): export DocusignSchema from schema folder and pass tests
likithdt 7ec3fea
fix(docusign): update endpoint risk levels to read and write
likithdt ee4fdde
style(docusign): apply biome formatting
likithdt be59088
fix(docusign): structure webhook export with match and handler
likithdt 36c0a69
fix(docusign): implement rateLimit and auth errorHandlers on plugin
likithdt 7cbb3f3
fix(docusign): update webhook handler signature to (context, request)
likithdt f9e85a1
fix(docusign): resolve context client binding and schemas
likithdt 592c0b7
fix(docusign): update endpoint context typing
likithdt 88f600f
fix(docusign): update endpoint context typing to support client conte…
likithdt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| export interface DocusignAuthOptions { | ||
| accessToken: string; | ||
| accountId: string; | ||
| baseUri?: string; | ||
| } | ||
|
|
||
| export class DocusignClient { | ||
| public baseUri: string; | ||
| public accountId: string; | ||
| private token: string; | ||
|
|
||
| constructor(options: DocusignAuthOptions) { | ||
| this.accountId = options.accountId; | ||
| this.token = options.accessToken; | ||
|
|
||
| let root = options.baseUri?.trim() || 'https://demo.docusign.net/restapi'; | ||
| while (root.endsWith('/')) { | ||
| root = root.slice(0, -1); | ||
| } | ||
|
|
||
| this.baseUri = `${root}/v2.1/accounts/${this.accountId}`; | ||
| } | ||
|
|
||
| async request<T = any>( | ||
| endpoint: string, | ||
| options: RequestInit = {}, | ||
| ): Promise<T> { | ||
| const cleanPath = endpoint.startsWith('/') ? endpoint : `/${endpoint}`; | ||
| const url = `${this.baseUri}${cleanPath}`; | ||
|
|
||
| const response = await fetch(url, { | ||
| ...options, | ||
| headers: { | ||
| Authorization: `Bearer ${this.token}`, | ||
| 'Content-Type': 'application/json', | ||
| Accept: 'application/json', | ||
| ...options.headers, | ||
| }, | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| const errorText = await response.text(); | ||
| throw new Error(`DocuSign API Error (${response.status}): ${errorText}`); | ||
| } | ||
|
|
||
| return response.json() as Promise<T>; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { DocusignClient } from '../client'; | ||
|
|
||
| export interface CreateEnvelopeParams { | ||
| templateId?: string; | ||
| emailSubject: string; | ||
| status: 'sent' | 'created'; | ||
| templateRoles?: Array<{ | ||
| email: string; | ||
| name: string; | ||
| roleName: string; | ||
| }>; | ||
| documents?: Array<{ | ||
| documentId: string; | ||
| name: string; | ||
| fileExtension?: string; | ||
| documentBase64?: string; | ||
| }>; | ||
| recipients?: { | ||
| signers?: Array<{ | ||
| email: string; | ||
| name: string; | ||
| recipientId: string; | ||
| routingOrder?: string; | ||
| }>; | ||
| }; | ||
| } | ||
|
|
||
| export const createEnvelope = async (client: DocusignClient, params: CreateEnvelopeParams) => { | ||
| return client.request('/envelopes', { | ||
| method: 'POST', | ||
| body: JSON.stringify(params), | ||
| }); | ||
| }; | ||
|
|
||
| export const getEnvelope = async (client: DocusignClient, { envelopeId }: { envelopeId: string }) => { | ||
| return client.request(`/envelopes/${envelopeId}`); | ||
| }; | ||
|
|
||
| export const sendEnvelope = async (client: DocusignClient, { envelopeId }: { envelopeId: string }) => { | ||
| return client.request(`/envelopes/${envelopeId}`, { | ||
| method: 'PUT', | ||
| body: JSON.stringify({ status: 'sent' }), | ||
| }); | ||
| }; | ||
|
|
||
| export const createRecipientViewUrl = async ( | ||
| client: DocusignClient, | ||
| { | ||
| envelopeId, | ||
| ...params | ||
| }: { | ||
| envelopeId: string; | ||
| userName: string; | ||
| email: string; | ||
| returnUrl: string; | ||
| authenticationMethod?: string; | ||
| recipientId?: string; | ||
| } | ||
| ) => { | ||
| return client.request(`/envelopes/${envelopeId}/views/recipient`, { | ||
| method: 'POST', | ||
| body: JSON.stringify({ | ||
| authenticationMethod: 'none', | ||
| recipientId: '1', | ||
| ...params, | ||
| }), | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { DocusignClient } from '../client'; | ||
| import type { CreateEnvelopeParams, GetEnvelopeParams, ListTemplatesParams } from './types'; | ||
|
|
||
| export const createEnvelope = async (client: DocusignClient, params: CreateEnvelopeParams) => { | ||
| return client.request('/envelopes', { | ||
| method: 'POST', | ||
| body: JSON.stringify(params), | ||
| }); | ||
| }; | ||
|
|
||
| export const getEnvelope = async (client: DocusignClient, params: GetEnvelopeParams) => { | ||
| return client.request(`/envelopes/${params.envelopeId}`); | ||
| }; | ||
|
|
||
| export const sendEnvelope = async (client: DocusignClient, params: GetEnvelopeParams) => { | ||
| return client.request(`/envelopes/${params.envelopeId}`, { | ||
| method: 'PUT', | ||
| body: JSON.stringify({ status: 'sent' }), | ||
| }); | ||
| }; | ||
|
|
||
| export const listTemplates = async (client: DocusignClient, params?: ListTemplatesParams) => { | ||
| const query = new URLSearchParams(); | ||
| if (params?.count) query.append('count', String(params.count)); | ||
| if (params?.startPosition) query.append('start_position', String(params.startPosition)); | ||
| const qs = query.toString() ? `?${query.toString()}` : ''; | ||
| return client.request(`/templates${qs}`); | ||
| }; | ||
|
|
||
| export const getTemplate = async (client: DocusignClient, params: { templateId: string }) => { | ||
| return client.request(`/templates/${params.templateId}`); | ||
| }; | ||
|
|
||
| export * from './types'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { DocusignClient } from '../client'; | ||
|
|
||
| export const listTemplates = async ( | ||
| client: DocusignClient, | ||
| params?: { count?: number; startPosition?: number } | ||
| ) => { | ||
| const query = new URLSearchParams(); | ||
| if (params?.count) query.append('count', String(params.count)); | ||
| if (params?.startPosition) query.append('start_position', String(params.startPosition)); | ||
| const qs = query.toString() ? `?${query.toString()}` : ''; | ||
| return client.request(`/templates${qs}`); | ||
| }; | ||
|
|
||
| export const getTemplate = async (client: DocusignClient, { templateId }: { templateId: string }) => { | ||
| return client.request(`/templates/${templateId}`); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| export interface CreateEnvelopeParams { | ||
| templateId?: string; | ||
| emailSubject: string; | ||
| status: 'sent' | 'created'; | ||
| templateRoles?: Array<{ | ||
| email: string; | ||
| name: string; | ||
| roleName: string; | ||
| }>; | ||
| } | ||
|
|
||
| export interface GetEnvelopeParams { | ||
| envelopeId: string; | ||
| } | ||
|
|
||
| export interface ListTemplatesParams { | ||
| count?: number; | ||
| startPosition?: number; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.