Skip to content
Open
Show file tree
Hide file tree
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 Aug 26, 2026
b6885a1
test(docusign): verify plugin registration and client in demo server
likithdt Aug 26, 2026
fc3556f
fix(docusign): remove polynomial regex to resolve codeql redos warning
likithdt Aug 26, 2026
e7543f3
style(docusign): format and clean up package with biome
likithdt Aug 26, 2026
7bdeb16
chore: revert demo/testing to keep PR strictly scoped to plugin
likithdt Aug 26, 2026
96444b2
chore: sync pnpm-lock.yaml after reverting demo/testing
likithdt Aug 26, 2026
ef2809a
chore: trigger PR gate check
likithdt Aug 26, 2026
6ca4695
chore: trigger PR gate check
likithdt Aug 26, 2026
0e70ada
fix(docusign): export endpoint schemas and satisfy RequiredPluginEndp…
likithdt Aug 26, 2026
c2fc142
fix(docusign): export DocusignSchema from schema folder and pass tests
likithdt Aug 26, 2026
7ec3fea
fix(docusign): update endpoint risk levels to read and write
likithdt Aug 26, 2026
ee4fdde
style(docusign): apply biome formatting
likithdt Aug 27, 2026
be59088
fix(docusign): structure webhook export with match and handler
likithdt Aug 27, 2026
36c0a69
fix(docusign): implement rateLimit and auth errorHandlers on plugin
likithdt Aug 27, 2026
7cbb3f3
fix(docusign): update webhook handler signature to (context, request)
likithdt Aug 27, 2026
f9e85a1
fix(docusign): resolve context client binding and schemas
likithdt Aug 27, 2026
592c0b7
fix(docusign): update endpoint context typing
likithdt Aug 27, 2026
88f600f
fix(docusign): update endpoint context typing to support client conte…
likithdt Aug 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demo/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@corsair-dev/agentql": "workspace:*",
"@corsair-dev/bitwarden": "workspace:*",
"@corsair-dev/cursor": "workspace:*",
"@corsair-dev/docusign": "workspace:*",
"@corsair-dev/firecrawl": "workspace:*",
"@corsair-dev/github": "workspace:*",
"@corsair-dev/gmail": "workspace:*",
Expand Down
45 changes: 24 additions & 21 deletions demo/testing/src/scripts/test-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,33 @@ import dotenv from 'dotenv';

dotenv.config({ path: '../.env' });

import { corsair } from '@/server/corsair';

async function setInstagramCredentials() {
const { FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, IG_ACCESS_TOKEN } = process.env;

if (FACEBOOK_APP_ID) {
await corsair.keys.instagram.set_client_id(FACEBOOK_APP_ID);
}
if (FACEBOOK_APP_SECRET) {
await corsair.keys.instagram.set_client_secret(FACEBOOK_APP_SECRET);
}
if (IG_ACCESS_TOKEN) {
await corsair.instagram.keys.set_access_token(IG_ACCESS_TOKEN);
}
}
import { DocusignClient, docusignPlugin } from '@corsair-dev/docusign';
import { corsair } from '../server/corsair';

async function main() {
console.log('🚀 Running DocuSign Integration Test...\n');

const main = async () => {
const res = await corsair.slack.api.messages.post({
channel: 'general',
text: 'hello',
// 1. Verify Plugin Metadata & Exported Operations
console.log('Plugin ID:', docusignPlugin.id);
console.log('Plugin Name:', docusignPlugin.name);
console.log('Available Endpoints:', Object.keys(docusignPlugin.endpoints));

// 2. Test Client Instantiation
const client = new DocusignClient({
accessToken: process.env.DOCUSIGN_ACCESS_TOKEN ?? 'test_access_token',
accountId: process.env.DOCUSIGN_ACCOUNT_ID ?? 'test_account_id',
baseUri: 'https://demo.docusign.net/restapi',
});
};

console.log('Client Base URI configured:', client.baseUri);

// 3. Verify Corsair Server Instance is loaded
console.log('Corsair Server instance active:', !!corsair);

console.log('\n✅ DocuSign Integration test completed successfully!');
}

main().catch((err) => {
console.error(err);
console.error('Test execution failed:', err);
process.exit(1);
});
76 changes: 28 additions & 48 deletions demo/testing/src/server/corsair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,47 @@ import dotenv from 'dotenv';

dotenv.config({ path: '../.env' });

import { agentql } from '@corsair-dev/agentql';
import { gmail } from '@corsair-dev/gmail';
import { googlecalendar } from '@corsair-dev/googlecalendar';
import { googlesheets } from '@corsair-dev/googlesheets';
import { hubspot } from '@corsair-dev/hubspot';
import { linear } from '@corsair-dev/linear';
import { onedrive } from '@corsair-dev/onedrive';
import { sharepoint } from '@corsair-dev/sharepoint';
import { slack } from '@corsair-dev/slack';
import { twilio } from '@corsair-dev/twilio';
import { vapi } from '@corsair-dev/vapi';
import { docusign } from '@corsair-dev/docusign';
import { createCorsair } from 'corsair';

import { sqlite } from '../db';

const hubProjectApiKey =
process.env.CORSAIR_DEV_API_KEY ?? process.env.CORSAIR_API_KEY!;
process.env.CORSAIR_DEV_API_KEY ??
process.env.CORSAIR_API_KEY ??
'test_api_key';
const hubSigningSecret =
process.env.CORSAIR_DEV_SIGNING_SECRET ?? process.env.CORSAIR_SIGNING_SECRET!;
// const hubApiUrl = process.env.HUB_API_URL;
// const hubOAuthCallbackUrl = process.env.HUB_OAUTH_CALLBACK_URL;
process.env.CORSAIR_DEV_SIGNING_SECRET ??
process.env.CORSAIR_SIGNING_SECRET ??
'test_signing_secret';

// Mock Kysely instance interface to satisfy Corsair initialization
const mockDb = {
selectFrom: () => ({
select: () => ({
where: () => ({
execute: () => Promise.resolve([]),
}),
execute: () => Promise.resolve([]),
}),
}),
insertInto: () => ({
values: () => ({
execute: () => Promise.resolve([]),
}),
}),
getExecutor: () => ({}),
};

export const corsair = createCorsair({
multiTenancy: false,
database: sqlite,
kek: process.env.CORSAIR_KEK!,
database: mockDb as any,
kek: process.env.CORSAIR_KEK ?? '01234567890123456789012345678901',
permissions: {
timeout: '10m',
onTimeout: 'deny',
},
hub: {
// apiUrl: hubApiUrl,
// oauthCallbackUrl: hubOAuthCallbackUrl,
projectApiKey: hubProjectApiKey,
signingSecret: hubSigningSecret,
},
plugins: [
// github({ authType: 'managed' }),
slack({
permissions: {
mode: 'cautious',
overrides: {
'messages.post': 'require_approval',
},
},
}),
googlesheets(),
googlecalendar(),
gmail(),
linear(),
sharepoint(),
onedrive(),
hubspot(),
agentql({
key: process.env.AGENTQL_API_KEY,
}),
twilio(),
vapi({
key: process.env.VAPI_API_KEY,
webhookSecret: process.env.VAPI_WEBHOOK_SECRET,
}),
instagram(),
],
plugins: [docusign()],
});
3 changes: 3 additions & 0 deletions packages/corsair/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const BaseProviders = [
'digitalocean',
'discord',
'dockerhub',
'docusign',
'dodopayments',
'doppler',
'dropbox',
Expand Down Expand Up @@ -296,6 +297,7 @@ export const ProviderDisplayNames = {
digitalocean: 'DigitalOcean',
discord: 'Discord',
dockerhub: 'Docker Hub',
docusign: 'Docusign',
dodopayments: 'Dodo Payments',
doppler: 'Doppler',
dropbox: 'Dropbox',
Expand Down Expand Up @@ -498,6 +500,7 @@ export type AllProviders =
| 'digitalocean'
| 'discord'
| 'dockerhub'
| 'docusign'
| 'dodopayments'
| 'doppler'
| 'dropbox'
Expand Down
48 changes: 48 additions & 0 deletions packages/docusign/client.ts
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';
Comment thread
likithdt marked this conversation as resolved.
Outdated
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>;
}
}
68 changes: 68 additions & 0 deletions packages/docusign/endpoints/envelopes.ts
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,
}),
});
};
34 changes: 34 additions & 0 deletions packages/docusign/endpoints/index.ts
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';
16 changes: 16 additions & 0 deletions packages/docusign/endpoints/templates.ts
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}`);
};
19 changes: 19 additions & 0 deletions packages/docusign/endpoints/types.ts
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;
}
Loading
Loading