@memberjunction/esignature-docusign 0.0.1 → 5.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DocuSignSignatureProvider.d.ts +63 -0
- package/dist/DocuSignSignatureProvider.d.ts.map +1 -0
- package/dist/DocuSignSignatureProvider.js +412 -0
- package/dist/DocuSignSignatureProvider.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/package.json +28 -7
- package/README.md +0 -45
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { BaseSignatureProvider, CreateEnvelopeRequest, EnvelopeResult, EnvelopeStatus, EnvelopeStatusResult, NormalizedSignatureEvent, OperationResult, SignatureOperation, SignatureProviderConfig, SignedDocumentResult, WebhookVerificationResult } from '@memberjunction/esignature';
|
|
2
|
+
/** Maps a DocuSign envelope/recipient status string onto our normalized lifecycle. */
|
|
3
|
+
export declare function mapDocuSignStatus(status: string): EnvelopeStatus;
|
|
4
|
+
/**
|
|
5
|
+
* DocuSign driver for the MemberJunction eSignature primitive — REST integration via the JWT grant
|
|
6
|
+
* flow. Resolved by the engine through `MJGlobal.ClassFactory` by the key `'DocuSign'`.
|
|
7
|
+
*
|
|
8
|
+
* Credentials are injected by the engine via {@link initialize} (resolved + decrypted from the
|
|
9
|
+
* Credential Engine); this provider does not read environment variables. The DocuSign user must
|
|
10
|
+
* have granted consent for the JWT scopes (`signature impersonation`).
|
|
11
|
+
*/
|
|
12
|
+
export declare class DocuSignSignatureProvider extends BaseSignatureProvider {
|
|
13
|
+
protected readonly providerKey = "DocuSign";
|
|
14
|
+
private config;
|
|
15
|
+
initialize(config: SignatureProviderConfig): Promise<void>;
|
|
16
|
+
get IsConfigured(): boolean;
|
|
17
|
+
getSupportedOperations(): SignatureOperation[];
|
|
18
|
+
CreateEnvelope(req: CreateEnvelopeRequest): Promise<EnvelopeResult>;
|
|
19
|
+
GetEnvelopeStatus(externalEnvelopeId: string): Promise<EnvelopeStatusResult>;
|
|
20
|
+
DownloadSignedDocument(externalEnvelopeId: string): Promise<SignedDocumentResult>;
|
|
21
|
+
VoidEnvelope(externalEnvelopeId: string, reason: string): Promise<OperationResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Normalize a DocuSign Connect webhook payload. Handles the two common JSON shapes:
|
|
24
|
+
* - Connect "JSON SIM" / Aggregate: `{ event, data: { envelopeId, envelopeSummary: { status, statusChangedDateTime } } }`
|
|
25
|
+
* - Legacy / flat envelope payload: `{ envelopeId, status, statusChangedDateTime }`
|
|
26
|
+
* Returns null when neither shape yields an envelope id (e.g. recipient-only events we ignore).
|
|
27
|
+
*/
|
|
28
|
+
ParseWebhookEvent(payload: unknown, _headers: Record<string, string>): NormalizedSignatureEvent | null;
|
|
29
|
+
/**
|
|
30
|
+
* Verify a DocuSign Connect HMAC. DocuSign signs the exact request body with HMAC-SHA256 using
|
|
31
|
+
* each configured Connect key and sends the base64 digest in `X-DocuSign-Signature-1`. Fails
|
|
32
|
+
* closed when no key is configured or the raw body is unavailable.
|
|
33
|
+
*/
|
|
34
|
+
VerifyWebhookSignature(rawBody: Buffer | undefined, headers: Record<string, string>, _payload?: unknown): WebhookVerificationResult;
|
|
35
|
+
/** Constant-time byte comparison; false on length mismatch (which timingSafeEqual would throw on).
|
|
36
|
+
* `Uint8Array.from(...)` strips the Buffer→ArrayBufferLike narrowing TS 5.9's node:crypto
|
|
37
|
+
* typings reject (they want a concrete ArrayBuffer, not Buffer's SharedArrayBuffer-tolerant union). */
|
|
38
|
+
private safeEqual;
|
|
39
|
+
/** Case-insensitive header lookup (Express lower-cases, but be defensive). */
|
|
40
|
+
private headerValue;
|
|
41
|
+
private asRecord;
|
|
42
|
+
private readField;
|
|
43
|
+
private buildEnvelopeDefinition;
|
|
44
|
+
private buildDocument;
|
|
45
|
+
private buildSigner;
|
|
46
|
+
private buildCustomFields;
|
|
47
|
+
private fetchRecipientStatuses;
|
|
48
|
+
/** Obtains an OAuth access token via the JWT grant. */
|
|
49
|
+
private getAccessToken;
|
|
50
|
+
private authHeaders;
|
|
51
|
+
private jsonAuthHeaders;
|
|
52
|
+
private errorText;
|
|
53
|
+
private errorMessage;
|
|
54
|
+
private notConfiguredMessage;
|
|
55
|
+
private readString;
|
|
56
|
+
/**
|
|
57
|
+
* Normalize a pasted RSA private key into a valid PEM. Handles the common credential-entry
|
|
58
|
+
* mistakes: literal `\n` escapes, lost line breaks, and a missing BEGIN/END header/footer
|
|
59
|
+
* (e.g. when only the base64 body was pasted into a form). Returns undefined if no key.
|
|
60
|
+
*/
|
|
61
|
+
private normalizePrivateKey;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=DocuSignSignatureProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocuSignSignatureProvider.d.ts","sourceRoot":"","sources":["../src/DocuSignSignatureProvider.ts"],"names":[],"mappings":"AAMA,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EAGf,kBAAkB,EAClB,uBAAuB,EAEvB,oBAAoB,EACpB,yBAAyB,EAC5B,MAAM,4BAA4B,CAAC;AAoBpC,sFAAsF;AACtF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAmBhE;AAED;;;;;;;GAOG;AACH,qBACa,yBAA0B,SAAQ,qBAAqB;IAChE,SAAS,CAAC,QAAQ,CAAC,WAAW,cAAc;IAE5C,OAAO,CAAC,MAAM,CAA+B;IAEhC,UAAU,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBvE,IAAW,YAAY,IAAI,OAAO,CAEjC;IAEM,sBAAsB,IAAI,kBAAkB,EAAE;IAexC,cAAc,CAAC,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;IAsCnE,iBAAiB,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAqB5E,sBAAsB,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAwBjF,YAAY,CAAC,kBAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA0B/F;;;;;OAKG;IACI,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,wBAAwB,GAAG,IAAI;IAoC7G;;;;OAIG;IACI,sBAAsB,CACzB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,QAAQ,CAAC,EAAE,OAAO,GACnB,yBAAyB;IAqB5B;;4GAEwG;IACxG,OAAO,CAAC,SAAS;IAIjB,8EAA8E;IAC9E,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,uBAAuB;IAa/B,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,WAAW;IAsBnB,OAAO,CAAC,iBAAiB;YASX,sBAAsB;IAoBpC,uDAAuD;YACzC,cAAc;IAiC5B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,eAAe;YAIT,SAAS;IAKvB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,UAAU;IAKlB;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;CAqB9B"}
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
8
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
9
|
+
// jsonwebtoken is a CommonJS module; under ESM the named `sign` export isn't available,
|
|
10
|
+
// so we import the default and destructure. (A bare `import { sign }` throws at runtime.)
|
|
11
|
+
import jwt from 'jsonwebtoken';
|
|
12
|
+
const { sign: jwtSign } = jwt;
|
|
13
|
+
import { BaseSignatureProvider, } from '@memberjunction/esignature';
|
|
14
|
+
/** Header DocuSign Connect uses for the first HMAC signature over the raw request body. */
|
|
15
|
+
const DOCUSIGN_HMAC_HEADER = 'x-docusign-signature-1';
|
|
16
|
+
/** Maps a DocuSign envelope/recipient status string onto our normalized lifecycle. */
|
|
17
|
+
export function mapDocuSignStatus(status) {
|
|
18
|
+
switch ((status || '').toLowerCase()) {
|
|
19
|
+
case 'created':
|
|
20
|
+
return 'Draft';
|
|
21
|
+
case 'sent':
|
|
22
|
+
return 'Sent';
|
|
23
|
+
case 'delivered':
|
|
24
|
+
return 'Delivered';
|
|
25
|
+
case 'signed':
|
|
26
|
+
return 'Signed';
|
|
27
|
+
case 'completed':
|
|
28
|
+
return 'Completed';
|
|
29
|
+
case 'declined':
|
|
30
|
+
return 'Declined';
|
|
31
|
+
case 'voided':
|
|
32
|
+
return 'Voided';
|
|
33
|
+
default:
|
|
34
|
+
return 'Unknown';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* DocuSign driver for the MemberJunction eSignature primitive — REST integration via the JWT grant
|
|
39
|
+
* flow. Resolved by the engine through `MJGlobal.ClassFactory` by the key `'DocuSign'`.
|
|
40
|
+
*
|
|
41
|
+
* Credentials are injected by the engine via {@link initialize} (resolved + decrypted from the
|
|
42
|
+
* Credential Engine); this provider does not read environment variables. The DocuSign user must
|
|
43
|
+
* have granted consent for the JWT scopes (`signature impersonation`).
|
|
44
|
+
*/
|
|
45
|
+
let DocuSignSignatureProvider = class DocuSignSignatureProvider extends BaseSignatureProvider {
|
|
46
|
+
constructor() {
|
|
47
|
+
super(...arguments);
|
|
48
|
+
this.providerKey = 'DocuSign';
|
|
49
|
+
this.config = null;
|
|
50
|
+
}
|
|
51
|
+
async initialize(config) {
|
|
52
|
+
const integrationKey = this.readString(config, 'integrationKey');
|
|
53
|
+
const userId = this.readString(config, 'userId');
|
|
54
|
+
const accountId = this.readString(config, 'accountId');
|
|
55
|
+
const privateKey = this.normalizePrivateKey(this.readString(config, 'privateKey'));
|
|
56
|
+
if (!integrationKey || !userId || !accountId || !privateKey) {
|
|
57
|
+
this.config = null;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.config = {
|
|
61
|
+
integrationKey,
|
|
62
|
+
userId,
|
|
63
|
+
accountId,
|
|
64
|
+
privateKey,
|
|
65
|
+
oauthBase: this.readString(config, 'oauthBase') || 'account-d.docusign.com',
|
|
66
|
+
restBase: this.readString(config, 'restBase') || 'https://demo.docusign.net/restapi',
|
|
67
|
+
connectHmacKey: this.readString(config, 'connectHmacKey'),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
get IsConfigured() {
|
|
71
|
+
return this.config !== null;
|
|
72
|
+
}
|
|
73
|
+
getSupportedOperations() {
|
|
74
|
+
return [
|
|
75
|
+
'CreateEnvelope',
|
|
76
|
+
'GetEnvelopeStatus',
|
|
77
|
+
'DownloadSignedDocument',
|
|
78
|
+
'VoidEnvelope',
|
|
79
|
+
'ApplyTemplate',
|
|
80
|
+
'CreateEmbeddedSigningUrl',
|
|
81
|
+
'ParseWebhookEvent',
|
|
82
|
+
'VerifyWebhookSignature',
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
// ---- Core operations -------------------------------------------------------------------------
|
|
86
|
+
async CreateEnvelope(req) {
|
|
87
|
+
const config = this.config;
|
|
88
|
+
if (!config) {
|
|
89
|
+
return { Success: false, ErrorMessage: this.notConfiguredMessage() };
|
|
90
|
+
}
|
|
91
|
+
if (!req.documents?.length) {
|
|
92
|
+
return { Success: false, ErrorMessage: 'No documents were provided to sign.' };
|
|
93
|
+
}
|
|
94
|
+
if (!req.recipients?.length) {
|
|
95
|
+
return { Success: false, ErrorMessage: 'No recipients were provided.' };
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const accessToken = await this.getAccessToken(config);
|
|
99
|
+
const envelopeDefinition = this.buildEnvelopeDefinition(req);
|
|
100
|
+
const resp = await fetch(`${config.restBase}/v2.1/accounts/${config.accountId}/envelopes`, {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: this.jsonAuthHeaders(accessToken),
|
|
103
|
+
body: JSON.stringify(envelopeDefinition),
|
|
104
|
+
});
|
|
105
|
+
if (!resp.ok) {
|
|
106
|
+
return { Success: false, ErrorMessage: await this.errorText('envelope creation', resp) };
|
|
107
|
+
}
|
|
108
|
+
const json = (await resp.json());
|
|
109
|
+
if (!json.envelopeId) {
|
|
110
|
+
return { Success: false, ErrorMessage: 'DocuSign did not return an envelope ID.' };
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
Success: true,
|
|
114
|
+
externalEnvelopeId: json.envelopeId,
|
|
115
|
+
status: mapDocuSignStatus(json.status || (req.sendImmediately === false ? 'created' : 'sent')),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
return { Success: false, ErrorMessage: this.errorMessage(e) };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async GetEnvelopeStatus(externalEnvelopeId) {
|
|
123
|
+
const config = this.config;
|
|
124
|
+
if (!config) {
|
|
125
|
+
return { Success: false, status: 'Unknown', ErrorMessage: this.notConfiguredMessage() };
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
const accessToken = await this.getAccessToken(config);
|
|
129
|
+
const base = `${config.restBase}/v2.1/accounts/${config.accountId}/envelopes/${externalEnvelopeId}`;
|
|
130
|
+
const resp = await fetch(base, { headers: this.authHeaders(accessToken) });
|
|
131
|
+
if (!resp.ok) {
|
|
132
|
+
return { Success: false, status: 'Unknown', ErrorMessage: await this.errorText('status check', resp) };
|
|
133
|
+
}
|
|
134
|
+
const json = (await resp.json());
|
|
135
|
+
const recipients = await this.fetchRecipientStatuses(base, accessToken);
|
|
136
|
+
return { Success: true, status: mapDocuSignStatus(json.status || ''), recipients };
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
return { Success: false, status: 'Unknown', ErrorMessage: this.errorMessage(e) };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async DownloadSignedDocument(externalEnvelopeId) {
|
|
143
|
+
const config = this.config;
|
|
144
|
+
if (!config) {
|
|
145
|
+
return { Success: false, ErrorMessage: this.notConfiguredMessage() };
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
const accessToken = await this.getAccessToken(config);
|
|
149
|
+
const resp = await fetch(`${config.restBase}/v2.1/accounts/${config.accountId}/envelopes/${externalEnvelopeId}/documents/combined`, { headers: this.authHeaders(accessToken) });
|
|
150
|
+
if (!resp.ok) {
|
|
151
|
+
return { Success: false, ErrorMessage: await this.errorText('document download', resp) };
|
|
152
|
+
}
|
|
153
|
+
const bytes = Buffer.from(await resp.arrayBuffer());
|
|
154
|
+
return {
|
|
155
|
+
Success: true,
|
|
156
|
+
document: { bytes, filename: `${externalEnvelopeId}.pdf`, contentType: 'application/pdf' },
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
return { Success: false, ErrorMessage: this.errorMessage(e) };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async VoidEnvelope(externalEnvelopeId, reason) {
|
|
164
|
+
const config = this.config;
|
|
165
|
+
if (!config) {
|
|
166
|
+
return { Success: false, ErrorMessage: this.notConfiguredMessage() };
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
const accessToken = await this.getAccessToken(config);
|
|
170
|
+
const resp = await fetch(`${config.restBase}/v2.1/accounts/${config.accountId}/envelopes/${externalEnvelopeId}`, {
|
|
171
|
+
method: 'PUT',
|
|
172
|
+
headers: this.jsonAuthHeaders(accessToken),
|
|
173
|
+
body: JSON.stringify({ status: 'voided', voidedReason: reason }),
|
|
174
|
+
});
|
|
175
|
+
if (!resp.ok) {
|
|
176
|
+
return { Success: false, ErrorMessage: await this.errorText('void', resp) };
|
|
177
|
+
}
|
|
178
|
+
return { Success: true };
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
return { Success: false, ErrorMessage: this.errorMessage(e) };
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// ---- Inbound webhook (DocuSign Connect) ------------------------------------------------------
|
|
185
|
+
/**
|
|
186
|
+
* Normalize a DocuSign Connect webhook payload. Handles the two common JSON shapes:
|
|
187
|
+
* - Connect "JSON SIM" / Aggregate: `{ event, data: { envelopeId, envelopeSummary: { status, statusChangedDateTime } } }`
|
|
188
|
+
* - Legacy / flat envelope payload: `{ envelopeId, status, statusChangedDateTime }`
|
|
189
|
+
* Returns null when neither shape yields an envelope id (e.g. recipient-only events we ignore).
|
|
190
|
+
*/
|
|
191
|
+
ParseWebhookEvent(payload, _headers) {
|
|
192
|
+
const root = this.asRecord(payload);
|
|
193
|
+
if (!root) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
const data = this.asRecord(root.data);
|
|
197
|
+
const summary = data ? this.asRecord(data.envelopeSummary) : undefined;
|
|
198
|
+
const envelopeId = this.readField(data, 'envelopeId') ??
|
|
199
|
+
this.readField(root, 'envelopeId') ??
|
|
200
|
+
this.readField(summary, 'envelopeId');
|
|
201
|
+
if (!envelopeId) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
const rawStatus = this.readField(summary, 'status') ??
|
|
205
|
+
this.readField(data, 'status') ??
|
|
206
|
+
this.readField(root, 'status') ??
|
|
207
|
+
'';
|
|
208
|
+
const occurredAt = this.readField(summary, 'statusChangedDateTime') ??
|
|
209
|
+
this.readField(root, 'statusChangedDateTime') ??
|
|
210
|
+
this.readField(root, 'generatedDateTime') ??
|
|
211
|
+
new Date().toISOString();
|
|
212
|
+
return {
|
|
213
|
+
externalEnvelopeId: envelopeId,
|
|
214
|
+
status: mapDocuSignStatus(rawStatus),
|
|
215
|
+
occurredAt,
|
|
216
|
+
raw: payload,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Verify a DocuSign Connect HMAC. DocuSign signs the exact request body with HMAC-SHA256 using
|
|
221
|
+
* each configured Connect key and sends the base64 digest in `X-DocuSign-Signature-1`. Fails
|
|
222
|
+
* closed when no key is configured or the raw body is unavailable.
|
|
223
|
+
*/
|
|
224
|
+
VerifyWebhookSignature(rawBody, headers, _payload) {
|
|
225
|
+
const secret = this.config?.connectHmacKey;
|
|
226
|
+
if (!secret) {
|
|
227
|
+
return 'NotConfigured';
|
|
228
|
+
}
|
|
229
|
+
// A secret IS configured, so from here any failure to match is a hard reject.
|
|
230
|
+
if (!rawBody) {
|
|
231
|
+
return 'Failed';
|
|
232
|
+
}
|
|
233
|
+
const providedHeader = this.headerValue(headers, DOCUSIGN_HMAC_HEADER);
|
|
234
|
+
if (!providedHeader) {
|
|
235
|
+
return 'Failed';
|
|
236
|
+
}
|
|
237
|
+
// Compare the decoded signature bytes, not the base64 strings, so encoding variance
|
|
238
|
+
// (padding/whitespace) can't cause a spurious mismatch.
|
|
239
|
+
const provided = Buffer.from(providedHeader, 'base64');
|
|
240
|
+
const expected = createHmac('sha256', secret).update(new Uint8Array(rawBody)).digest();
|
|
241
|
+
return this.safeEqual(provided, expected) ? 'Verified' : 'Failed';
|
|
242
|
+
}
|
|
243
|
+
/** Constant-time byte comparison; false on length mismatch (which timingSafeEqual would throw on).
|
|
244
|
+
* `Uint8Array.from(...)` strips the Buffer→ArrayBufferLike narrowing TS 5.9's node:crypto
|
|
245
|
+
* typings reject (they want a concrete ArrayBuffer, not Buffer's SharedArrayBuffer-tolerant union). */
|
|
246
|
+
safeEqual(a, b) {
|
|
247
|
+
return a.length === b.length && timingSafeEqual(Uint8Array.from(a), Uint8Array.from(b));
|
|
248
|
+
}
|
|
249
|
+
/** Case-insensitive header lookup (Express lower-cases, but be defensive). */
|
|
250
|
+
headerValue(headers, name) {
|
|
251
|
+
const direct = headers[name];
|
|
252
|
+
if (direct) {
|
|
253
|
+
return direct;
|
|
254
|
+
}
|
|
255
|
+
const lower = name.toLowerCase();
|
|
256
|
+
for (const [k, v] of Object.entries(headers)) {
|
|
257
|
+
if (k.toLowerCase() === lower) {
|
|
258
|
+
return v;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
asRecord(value) {
|
|
264
|
+
return value && typeof value === 'object' ? value : undefined;
|
|
265
|
+
}
|
|
266
|
+
readField(obj, key) {
|
|
267
|
+
const v = obj?.[key];
|
|
268
|
+
return typeof v === 'string' && v.length > 0 ? v : undefined;
|
|
269
|
+
}
|
|
270
|
+
// ---- Envelope construction -------------------------------------------------------------------
|
|
271
|
+
buildEnvelopeDefinition(req) {
|
|
272
|
+
return {
|
|
273
|
+
emailSubject: req.title || 'Please sign this document',
|
|
274
|
+
emailBlurb: req.message,
|
|
275
|
+
status: req.sendImmediately === false ? 'created' : 'sent',
|
|
276
|
+
documents: req.documents.map((doc, i) => this.buildDocument(doc, i)),
|
|
277
|
+
recipients: {
|
|
278
|
+
signers: req.recipients.map((r, i) => this.buildSigner(r, i, req.documents.length)),
|
|
279
|
+
},
|
|
280
|
+
customFields: this.buildCustomFields(req.metadata),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
buildDocument(doc, index) {
|
|
284
|
+
const ext = (doc.filename.split('.').pop() || 'pdf').toLowerCase();
|
|
285
|
+
return {
|
|
286
|
+
documentBase64: doc.bytes.toString('base64'),
|
|
287
|
+
name: doc.filename,
|
|
288
|
+
fileExtension: ext,
|
|
289
|
+
documentId: doc.documentId || String(index + 1),
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
buildSigner(recipient, index, documentCount) {
|
|
293
|
+
const recipientId = String(index + 1);
|
|
294
|
+
// Place a sign-here tab on page 1 of every document for this signer.
|
|
295
|
+
const signHereTabs = Array.from({ length: documentCount }, (_, d) => ({
|
|
296
|
+
documentId: String(d + 1),
|
|
297
|
+
pageNumber: '1',
|
|
298
|
+
xPosition: '100',
|
|
299
|
+
yPosition: '100',
|
|
300
|
+
}));
|
|
301
|
+
return {
|
|
302
|
+
email: recipient.email,
|
|
303
|
+
name: recipient.name || recipient.email,
|
|
304
|
+
recipientId,
|
|
305
|
+
routingOrder: String(recipient.routingOrder ?? 1),
|
|
306
|
+
tabs: { signHereTabs },
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
buildCustomFields(metadata) {
|
|
310
|
+
if (!metadata || Object.keys(metadata).length === 0) {
|
|
311
|
+
return undefined;
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
textCustomFields: Object.entries(metadata).map(([name, value]) => ({ name, value, show: 'false' })),
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
async fetchRecipientStatuses(envelopeBase, accessToken) {
|
|
318
|
+
const resp = await fetch(`${envelopeBase}/recipients`, { headers: this.authHeaders(accessToken) });
|
|
319
|
+
if (!resp.ok) {
|
|
320
|
+
return undefined;
|
|
321
|
+
}
|
|
322
|
+
const json = (await resp.json());
|
|
323
|
+
if (!json.signers?.length) {
|
|
324
|
+
return undefined;
|
|
325
|
+
}
|
|
326
|
+
return json.signers.map((s) => ({
|
|
327
|
+
email: s.email,
|
|
328
|
+
name: s.name,
|
|
329
|
+
status: mapDocuSignStatus(s.status || ''),
|
|
330
|
+
externalRecipientId: s.recipientId,
|
|
331
|
+
signedAt: s.signedDateTime,
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
// ---- OAuth + HTTP helpers --------------------------------------------------------------------
|
|
335
|
+
/** Obtains an OAuth access token via the JWT grant. */
|
|
336
|
+
async getAccessToken(config) {
|
|
337
|
+
const now = Math.floor(Date.now() / 1000);
|
|
338
|
+
const assertion = jwtSign({
|
|
339
|
+
iss: config.integrationKey,
|
|
340
|
+
sub: config.userId,
|
|
341
|
+
aud: config.oauthBase,
|
|
342
|
+
iat: now,
|
|
343
|
+
exp: now + 3600,
|
|
344
|
+
scope: 'signature impersonation',
|
|
345
|
+
}, config.privateKey, { algorithm: 'RS256' });
|
|
346
|
+
const resp = await fetch(`https://${config.oauthBase}/oauth/token`, {
|
|
347
|
+
method: 'POST',
|
|
348
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
349
|
+
body: new URLSearchParams({
|
|
350
|
+
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
|
|
351
|
+
assertion,
|
|
352
|
+
}),
|
|
353
|
+
});
|
|
354
|
+
if (!resp.ok) {
|
|
355
|
+
throw new Error(await this.errorText('auth', resp));
|
|
356
|
+
}
|
|
357
|
+
const json = (await resp.json());
|
|
358
|
+
if (!json.access_token) {
|
|
359
|
+
throw new Error('DocuSign auth returned no access token.');
|
|
360
|
+
}
|
|
361
|
+
return json.access_token;
|
|
362
|
+
}
|
|
363
|
+
authHeaders(accessToken) {
|
|
364
|
+
return { Authorization: `Bearer ${accessToken}` };
|
|
365
|
+
}
|
|
366
|
+
jsonAuthHeaders(accessToken) {
|
|
367
|
+
return { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json' };
|
|
368
|
+
}
|
|
369
|
+
async errorText(operation, resp) {
|
|
370
|
+
const text = await resp.text().catch(() => '');
|
|
371
|
+
return `DocuSign ${operation} failed (${resp.status}): ${text}`;
|
|
372
|
+
}
|
|
373
|
+
errorMessage(e) {
|
|
374
|
+
return e instanceof Error ? e.message : String(e);
|
|
375
|
+
}
|
|
376
|
+
notConfiguredMessage() {
|
|
377
|
+
return 'DocuSign is not configured. Provide integrationKey, userId, accountId, and privateKey via the Credential Engine.';
|
|
378
|
+
}
|
|
379
|
+
readString(config, key) {
|
|
380
|
+
const value = config[key];
|
|
381
|
+
return typeof value === 'string' ? value : undefined;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Normalize a pasted RSA private key into a valid PEM. Handles the common credential-entry
|
|
385
|
+
* mistakes: literal `\n` escapes, lost line breaks, and a missing BEGIN/END header/footer
|
|
386
|
+
* (e.g. when only the base64 body was pasted into a form). Returns undefined if no key.
|
|
387
|
+
*/
|
|
388
|
+
normalizePrivateKey(raw) {
|
|
389
|
+
if (!raw) {
|
|
390
|
+
return undefined;
|
|
391
|
+
}
|
|
392
|
+
// Convert literal backslash-n to real newlines, normalize CRLF, and trim.
|
|
393
|
+
let key = raw.replace(/\\n/g, '\n').replace(/\r\n/g, '\n').trim();
|
|
394
|
+
const headerRe = /-----BEGIN [A-Z ]*PRIVATE KEY-----/;
|
|
395
|
+
const footerRe = /-----END [A-Z ]*PRIVATE KEY-----/;
|
|
396
|
+
if (headerRe.test(key) && footerRe.test(key)) {
|
|
397
|
+
return key; // already a well-formed PEM
|
|
398
|
+
}
|
|
399
|
+
// No PEM markers — assume the base64 body was pasted alone. Re-wrap as PKCS#1 RSA.
|
|
400
|
+
const body = key.replace(/-----[A-Z ]+-----/g, '').replace(/\s+/g, '');
|
|
401
|
+
if (!body) {
|
|
402
|
+
return undefined;
|
|
403
|
+
}
|
|
404
|
+
const wrapped = body.match(/.{1,64}/g)?.join('\n') ?? body;
|
|
405
|
+
return `-----BEGIN RSA PRIVATE KEY-----\n${wrapped}\n-----END RSA PRIVATE KEY-----\n`;
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
DocuSignSignatureProvider = __decorate([
|
|
409
|
+
RegisterClass(BaseSignatureProvider, 'DocuSign')
|
|
410
|
+
], DocuSignSignatureProvider);
|
|
411
|
+
export { DocuSignSignatureProvider };
|
|
412
|
+
//# sourceMappingURL=DocuSignSignatureProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocuSignSignatureProvider.js","sourceRoot":"","sources":["../src/DocuSignSignatureProvider.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,wFAAwF;AACxF,0FAA0F;AAC1F,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;AAC9B,OAAO,EACH,qBAAqB,GAcxB,MAAM,4BAA4B,CAAC;AAiBpC,2FAA2F;AAC3F,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AAEtD,sFAAsF;AACtF,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC5C,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;QACnC,KAAK,SAAS;YACV,OAAO,OAAO,CAAC;QACnB,KAAK,MAAM;YACP,OAAO,MAAM,CAAC;QAClB,KAAK,WAAW;YACZ,OAAO,WAAW,CAAC;QACvB,KAAK,QAAQ;YACT,OAAO,QAAQ,CAAC;QACpB,KAAK,WAAW;YACZ,OAAO,WAAW,CAAC;QACvB,KAAK,UAAU;YACX,OAAO,UAAU,CAAC;QACtB,KAAK,QAAQ;YACT,OAAO,QAAQ,CAAC;QACpB;YACI,OAAO,SAAS,CAAC;IACzB,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,qBAAqB;IAA7D;;QACgB,gBAAW,GAAG,UAAU,CAAC;QAEpC,WAAM,GAA0B,IAAI,CAAC;IAiajD,CAAC;IA/ZU,KAAK,C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AAC;YAC3C,OAAO,GAAG,CAAC,CAAC,4BAA4B;QAC5C,CAAC;QAED,mFAAmF;QACnF,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACvE,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;QAC3D,OAAO,oCAAoC,OAAO,mCAAmC,CAAC;IAC1F,CAAC;CACJ,CAAA;AApaY,yBAAyB;IADrC,aAAa,CAAC,qBAAqB,EAAE,UAAU,CAAC;GACpC,yBAAyB,CAoarC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,6BAA6B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// PUBLIC API SURFACE AREA
|
|
2
|
+
// Side-effect: importing this barrel registers the DocuSign driver with MJGlobal.ClassFactory
|
|
3
|
+
// via the @RegisterClass decorator on DocuSignSignatureProvider.
|
|
4
|
+
export * from './DocuSignSignatureProvider.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,8FAA8F;AAC9F,iEAAiE;AACjE,cAAc,6BAA6B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/esignature-docusign",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
"version": "5.40.1",
|
|
4
|
+
"description": "DocuSign driver for the MemberJunction eSignature primitive. Registers a BaseSignatureProvider implementation via @RegisterClass(BaseSignatureProvider, 'DocuSign') using the DocuSign REST API and JWT-grant OAuth.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"/dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc && tsc-alias -f",
|
|
13
|
+
"watch": "tsc -w",
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"test:watch": "vitest",
|
|
16
|
+
"test:coverage": "vitest run --coverage"
|
|
17
|
+
},
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@memberjunction/esignature": "5.40.1",
|
|
21
|
+
"@memberjunction/global": "5.40.1",
|
|
22
|
+
"jsonwebtoken": "^9.0.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/jsonwebtoken": "^9.0.0"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/MemberJunction/MJ"
|
|
30
|
+
}
|
|
10
31
|
}
|
package/README.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# @memberjunction/esignature-docusign
|
|
2
|
-
|
|
3
|
-
## ⚠️ IMPORTANT NOTICE ⚠️
|
|
4
|
-
|
|
5
|
-
**This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
|
|
6
|
-
|
|
7
|
-
This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
|
|
8
|
-
|
|
9
|
-
## Purpose
|
|
10
|
-
|
|
11
|
-
This package exists to:
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@memberjunction/esignature-docusign`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
15
|
-
|
|
16
|
-
## What is OIDC Trusted Publishing?
|
|
17
|
-
|
|
18
|
-
OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
|
|
19
|
-
|
|
20
|
-
## Setup Instructions
|
|
21
|
-
|
|
22
|
-
To properly configure OIDC trusted publishing for this package:
|
|
23
|
-
|
|
24
|
-
1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
28
|
-
|
|
29
|
-
## DO NOT USE THIS PACKAGE
|
|
30
|
-
|
|
31
|
-
This package is a placeholder for OIDC configuration only. It:
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
36
|
-
|
|
37
|
-
## More Information
|
|
38
|
-
|
|
39
|
-
For more details about npm's trusted publishing feature, see:
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
**Maintained for OIDC setup purposes only**
|