instasign 1.1.0 → 1.1.3

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/index.d.cts CHANGED
@@ -1,203 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { WebhookEventType, WebhookPayloadMap } from '@instasign/types';
3
-
4
- type Metadata = Record<string, unknown>;
5
- /** A sign request nested inside an envelope response */
6
- interface EnvelopeSignRequest {
7
- requestId?: string;
8
- status?: Metadata;
9
- fileName?: string;
10
- fileUrl?: string;
11
- signedFileUrl?: string;
12
- metadata?: Metadata;
13
- clientReferenceId?: string;
14
- }
15
- /** A full envelope with its sign requests */
16
- interface Envelope {
17
- signUrl?: string;
18
- envelopeId?: string;
19
- name?: string;
20
- description?: string;
21
- status?: Metadata;
22
- clientReferenceId?: string;
23
- signRequests?: EnvelopeSignRequest[];
24
- }
25
- /** Envelope as returned in a list (includes createdAt as ISO string) */
26
- interface EnvelopeListItem extends Envelope {
27
- createdAt?: string;
28
- }
29
- interface CreateEnvelopeParams {
30
- /** The name of the envelope */
31
- name: string;
32
- /** The description of the envelope */
33
- description?: string;
34
- /** Associated metadata for the envelope */
35
- metadata?: Metadata;
36
- /** The expiration date of the envelope (ISO 8601) */
37
- expirationDate?: string;
38
- /** External reference ID for the client */
39
- clientReferenceId?: string;
40
- }
41
- interface GetEnvelopesParams {
42
- /** Filter by envelope name (case-insensitive regex) */
43
- name?: string;
44
- /** Filter by envelope status */
45
- status?: string;
46
- /** Filter by client reference ID */
47
- clientReferenceId?: string;
48
- signRequests?: Metadata[];
49
- /** Field to order by (createdAt or updatedAt) */
50
- orderBy?: string;
51
- /** Order direction (asc or desc) */
52
- orderDirection?: string;
53
- /** Filter by expiration date greater than or equal to */
54
- expirationDateStart?: string;
55
- /** Filter by expiration date less than or equal to */
56
- expirationDateEnd?: string;
57
- /** Number of items to skip for pagination */
58
- skip?: number;
59
- /** Maximum number of items to return */
60
- limit?: number;
61
- }
62
- interface UpdateEnvelopeMetadataParams {
63
- /** The unique identifier of the envelope */
64
- envelopeId: string;
65
- /** The metadata to be merged into the existing envelope metadata */
66
- metadata: Metadata;
67
- }
68
- interface RemoveSignRequestFromEnvelopeParams {
69
- /** The unique identifier of the envelope */
70
- envelopeId: string;
71
- /** The unique identifier of the sign request */
72
- requestId: string;
73
- }
74
- interface AddSignRequestToEnvelopeParams {
75
- /** The unique identifier of the envelope */
76
- envelopeId: string;
77
- /** The name of the file to be signed */
78
- filename: string;
79
- /** The base64 encoded content of the file */
80
- base64File?: string;
81
- /** Remote URL of the file. MUST be publicly accessible. */
82
- fileUrl?: string;
83
- /** Associated metadata for the sign request */
84
- metadata?: Metadata;
85
- }
86
- interface CreateEnvelopeResponse {
87
- envelopeId?: string;
88
- }
89
- interface OperationResponse {
90
- success?: boolean;
91
- message?: string;
92
- }
93
- interface UpdateEnvelopeMetadataResponse {
94
- envelopeId?: string;
95
- metadata?: Metadata;
96
- }
97
- interface AddSignRequestToEnvelopeResponse {
98
- requestId?: string;
99
- signUrl?: string;
100
- envelopeSignUrl?: string;
101
- }
102
- interface CreateSignRequestParams {
103
- /** The name of the file to be signed */
104
- filename: string;
105
- /** The base64 encoded content of the file */
106
- base64File?: string;
107
- /** Remote URL of the file. MUST be publicly accessible. */
108
- fileUrl?: string;
109
- /** Associated metadata for the sign request */
110
- metadata?: Metadata;
111
- }
112
- interface CompleteSignRequestParams {
113
- /** The unique identifier of the sign request to complete */
114
- requestId: string;
115
- /** The base64 encoded content of the signed file */
116
- signedFileDataBase64: string;
117
- }
118
- interface CreateSignRequestResponse {
119
- requestId?: string;
120
- signUrl?: string;
121
- }
122
- interface CompleteSignRequestResponse {
123
- signedFileUrl?: string;
124
- }
125
- interface SignRequestFile {
126
- requestId?: string;
127
- name?: string;
128
- originalFile?: string;
129
- signedFile?: string;
130
- metadata?: Metadata;
131
- status?: string;
132
- }
133
- type WebhookEvent = {
134
- [T in WebhookEventType]: {
135
- eventType: T;
136
- } & WebhookPayloadMap[T];
137
- }[WebhookEventType];
138
-
139
- declare class Envelopes {
140
- private client;
141
- constructor(client: AxiosInstance);
142
- /**
143
- * Create a new envelope
144
- */
145
- create(params: CreateEnvelopeParams): Promise<CreateEnvelopeResponse | undefined>;
146
- /**
147
- * List envelopes
148
- */
149
- list(params?: GetEnvelopesParams): Promise<EnvelopeListItem[] | undefined>;
150
- /**
151
- * Retrieve a single envelope with its sign requests
152
- */
153
- get(envelopeId: string): Promise<Envelope | undefined>;
154
- /**
155
- * Complete an envelope
156
- */
157
- complete(envelopeId: string): Promise<OperationResponse | undefined>;
158
- /**
159
- * Delete an envelope
160
- */
161
- delete(envelopeId: string): Promise<OperationResponse | undefined>;
162
- /**
163
- * Update envelope metadata
164
- */
165
- updateMetadata(params: UpdateEnvelopeMetadataParams): Promise<UpdateEnvelopeMetadataResponse | undefined>;
166
- /**
167
- * Remove a sign request from an envelope
168
- */
169
- removeSignRequest(params: RemoveSignRequestFromEnvelopeParams): Promise<OperationResponse | undefined>;
170
- /**
171
- * Add a sign request to an envelope
172
- */
173
- addSignRequest(params: AddSignRequestToEnvelopeParams): Promise<AddSignRequestToEnvelopeResponse | undefined>;
174
- }
175
-
176
- declare class SignRequests {
177
- private client;
178
- constructor(client: AxiosInstance);
179
- /**
180
- * Create a new sign request
181
- */
182
- create(params: CreateSignRequestParams): Promise<CreateSignRequestResponse | undefined>;
183
- /**
184
- * Complete a sign request
185
- */
186
- complete(params: CompleteSignRequestParams): Promise<CompleteSignRequestResponse | undefined>;
187
- /**
188
- * Get the file associated with a sign request
189
- */
190
- getFile(requestId: string): Promise<SignRequestFile | undefined>;
191
- }
192
-
193
- declare class Webhooks {
194
- private tolerance;
195
- constructor(tolerance?: number);
196
- /**
197
- * Verify and parse a webhook event
198
- */
199
- constructEvent(payload: string, signatureHeader: string, webhookSecret: string): WebhookEvent;
200
- }
2
+ import { WebhookEventType, WebhookPayloadMap } from './webhook.types.js';
201
3
 
202
4
  /**
203
5
  * This file was auto-generated by openapi-typescript.
@@ -205,7 +7,7 @@ declare class Webhooks {
205
7
  */
206
8
 
207
9
  interface paths {
208
- "/functions/addSignRequestToEnvelope": {
10
+ "/functions/envelope:add-sign-request": {
209
11
  parameters: {
210
12
  query?: never;
211
13
  header?: never;
@@ -214,7 +16,7 @@ interface paths {
214
16
  };
215
17
  get?: never;
216
18
  put?: never;
217
- /** Cloud Function: addSignRequestToEnvelope */
19
+ /** envelope:add-sign-request */
218
20
  post: {
219
21
  parameters: {
220
22
  query?: never;
@@ -225,15 +27,10 @@ interface paths {
225
27
  requestBody?: {
226
28
  content: {
227
29
  "application/json": {
228
- /** @description The unique identifier of the envelope */
229
30
  envelopeId: string;
230
- /** @description The name of the file to be signed */
231
31
  filename: string;
232
- /** @description The base64 encoded content of the file */
233
32
  base64File?: string;
234
- /** @description Remote URL of the file. MUST be publicly accessible. */
235
33
  fileUrl?: string;
236
- /** @description Associated metadata for the sign request */
237
34
  metadata?: {
238
35
  [key: string]: unknown;
239
36
  };
@@ -248,9 +45,9 @@ interface paths {
248
45
  };
249
46
  content: {
250
47
  "application/json": {
251
- result?: {
252
- requestId?: string;
253
- signUrl?: string;
48
+ result: {
49
+ requestId: string;
50
+ signUrl: string;
254
51
  envelopeSignUrl?: string;
255
52
  };
256
53
  };
@@ -264,7 +61,7 @@ interface paths {
264
61
  patch?: never;
265
62
  trace?: never;
266
63
  };
267
- "/functions/completeEnvelope": {
64
+ "/functions/envelope:complete": {
268
65
  parameters: {
269
66
  query?: never;
270
67
  header?: never;
@@ -273,7 +70,7 @@ interface paths {
273
70
  };
274
71
  get?: never;
275
72
  put?: never;
276
- /** Cloud Function: completeEnvelope */
73
+ /** envelope:complete */
277
74
  post: {
278
75
  parameters: {
279
76
  query?: never;
@@ -284,7 +81,6 @@ interface paths {
284
81
  requestBody?: {
285
82
  content: {
286
83
  "application/json": {
287
- /** @description The unique identifier of the envelope to mark as completed */
288
84
  envelopeId: string;
289
85
  };
290
86
  };
@@ -297,9 +93,9 @@ interface paths {
297
93
  };
298
94
  content: {
299
95
  "application/json": {
300
- result?: {
301
- success?: boolean;
302
- message?: string;
96
+ result: {
97
+ success: boolean;
98
+ message: string;
303
99
  };
304
100
  };
305
101
  };
@@ -312,7 +108,7 @@ interface paths {
312
108
  patch?: never;
313
109
  trace?: never;
314
110
  };
315
- "/functions/createEnvelope": {
111
+ "/functions/envelope:create": {
316
112
  parameters: {
317
113
  query?: never;
318
114
  header?: never;
@@ -321,7 +117,7 @@ interface paths {
321
117
  };
322
118
  get?: never;
323
119
  put?: never;
324
- /** Cloud Function: createEnvelope */
120
+ /** envelope:create */
325
121
  post: {
326
122
  parameters: {
327
123
  query?: never;
@@ -332,20 +128,13 @@ interface paths {
332
128
  requestBody?: {
333
129
  content: {
334
130
  "application/json": {
335
- /** @description The name of the envelope */
336
131
  name: string;
337
- /** @description The description of the envelope */
338
132
  description?: string;
339
- /** @description Associated metadata for the envelope */
340
133
  metadata?: {
341
134
  [key: string]: unknown;
342
135
  };
343
- /**
344
- * Format: date-time
345
- * @description The expiration date of the envelope
346
- */
136
+ /** Format: date-time */
347
137
  expirationDate?: string;
348
- /** @description External reference ID for the client */
349
138
  clientReferenceId?: string;
350
139
  };
351
140
  };
@@ -358,8 +147,8 @@ interface paths {
358
147
  };
359
148
  content: {
360
149
  "application/json": {
361
- result?: {
362
- envelopeId?: string;
150
+ result: {
151
+ envelopeId: string;
363
152
  };
364
153
  };
365
154
  };
@@ -372,7 +161,7 @@ interface paths {
372
161
  patch?: never;
373
162
  trace?: never;
374
163
  };
375
- "/functions/deleteEnvelope": {
164
+ "/functions/envelope:delete": {
376
165
  parameters: {
377
166
  query?: never;
378
167
  header?: never;
@@ -381,7 +170,7 @@ interface paths {
381
170
  };
382
171
  get?: never;
383
172
  put?: never;
384
- /** Cloud Function: deleteEnvelope */
173
+ /** envelope:delete */
385
174
  post: {
386
175
  parameters: {
387
176
  query?: never;
@@ -392,7 +181,6 @@ interface paths {
392
181
  requestBody?: {
393
182
  content: {
394
183
  "application/json": {
395
- /** @description The unique identifier of the envelope to delete */
396
184
  envelopeId: string;
397
185
  };
398
186
  };
@@ -405,8 +193,8 @@ interface paths {
405
193
  };
406
194
  content: {
407
195
  "application/json": {
408
- result?: {
409
- success?: boolean;
196
+ result: {
197
+ success: boolean;
410
198
  };
411
199
  };
412
200
  };
@@ -419,7 +207,7 @@ interface paths {
419
207
  patch?: never;
420
208
  trace?: never;
421
209
  };
422
- "/functions/getEnvelope": {
210
+ "/functions/envelope:get": {
423
211
  parameters: {
424
212
  query?: never;
425
213
  header?: never;
@@ -428,7 +216,7 @@ interface paths {
428
216
  };
429
217
  get?: never;
430
218
  put?: never;
431
- /** Cloud Function: getEnvelope */
219
+ /** envelope:get */
432
220
  post: {
433
221
  parameters: {
434
222
  query?: never;
@@ -439,8 +227,8 @@ interface paths {
439
227
  requestBody?: {
440
228
  content: {
441
229
  "application/json": {
442
- /** @description The unique identifier of the envelope */
443
230
  envelopeId: string;
231
+ includeSignRequests?: boolean;
444
232
  };
445
233
  };
446
234
  };
@@ -452,28 +240,33 @@ interface paths {
452
240
  };
453
241
  content: {
454
242
  "application/json": {
455
- result?: {
456
- signUrl?: string;
457
- envelopeId?: string;
458
- name?: string;
243
+ result: {
244
+ envelopeId: string;
245
+ name: string;
459
246
  description?: string;
460
- status?: {
461
- [key: string]: unknown;
462
- };
247
+ /** @enum {string} */
248
+ status: "pending" | "in-progress" | "completed" | "cancelled";
463
249
  clientReferenceId?: string;
464
- signRequests?: {
465
- requestId?: string;
466
- status?: {
467
- [key: string]: unknown;
468
- };
469
- fileName?: string;
470
- fileUrl?: string;
250
+ signRequestsCount: number;
251
+ signRequests: {
252
+ requestId: string;
253
+ /** @enum {string} */
254
+ status: "pending" | "completed" | "canceled" | "queued";
255
+ fileName: string;
256
+ fileUrl: string;
471
257
  signedFileUrl?: string;
472
- metadata?: {
258
+ metadata: {
473
259
  [key: string]: unknown;
474
260
  };
475
261
  clientReferenceId?: string;
476
262
  }[];
263
+ /** Format: date-time */
264
+ createdAt: string;
265
+ /** Format: date-time */
266
+ updatedAt: string;
267
+ /** Format: date-time */
268
+ expirationDate?: string;
269
+ signUrl?: string;
477
270
  };
478
271
  };
479
272
  };
@@ -486,7 +279,7 @@ interface paths {
486
279
  patch?: never;
487
280
  trace?: never;
488
281
  };
489
- "/functions/getEnvelopes": {
282
+ "/functions/envelope:list": {
490
283
  parameters: {
491
284
  query?: never;
492
285
  header?: never;
@@ -495,7 +288,7 @@ interface paths {
495
288
  };
496
289
  get?: never;
497
290
  put?: never;
498
- /** Cloud Function: getEnvelopes */
291
+ /** envelope:list */
499
292
  post: {
500
293
  parameters: {
501
294
  query?: never;
@@ -506,28 +299,20 @@ interface paths {
506
299
  requestBody?: {
507
300
  content: {
508
301
  "application/json": {
509
- /** @description Filter by envelope name (case-insensitive regex) */
510
302
  name?: string;
511
- /** @description Filter by envelope status */
512
- status?: string;
513
- /** @description Filter by client reference ID */
303
+ /** @enum {string} */
304
+ status?: "pending" | "in-progress" | "completed" | "cancelled";
514
305
  clientReferenceId?: string;
515
- /** @description Filter by a list of sign request IDs */
516
- signRequests?: {
517
- [key: string]: unknown;
518
- }[];
519
- /** @description Field to order by (createdAt or updatedAt) */
520
- orderBy?: string;
521
- /** @description Order direction (asc or desc) */
522
- orderDirection?: string;
523
- /** @description Filter by expiration date greater than or equal to */
306
+ signRequests?: string[];
307
+ /** @enum {string} */
308
+ orderBy?: "updatedAt" | "createdAt";
309
+ /** @enum {string} */
310
+ orderDirection?: "asc" | "desc";
524
311
  expirationDateStart?: string;
525
- /** @description Filter by expiration date less than or equal to */
526
312
  expirationDateEnd?: string;
527
- /** @description Number of items to skip for pagination */
528
313
  skip?: number;
529
- /** @description Maximum number of items to return */
530
314
  limit?: number;
315
+ includeSignRequests?: boolean;
531
316
  };
532
317
  };
533
318
  };
@@ -539,413 +324,33 @@ interface paths {
539
324
  };
540
325
  content: {
541
326
  "application/json": {
542
- result?: {
543
- signUrl?: string;
544
- envelopeId?: string;
545
- name?: string;
327
+ result: {
328
+ envelopeId: string;
329
+ name: string;
546
330
  description?: string;
547
- status?: {
548
- [key: string]: unknown;
549
- };
331
+ /** @enum {string} */
332
+ status: "pending" | "in-progress" | "completed" | "cancelled";
550
333
  clientReferenceId?: string;
551
- signRequests?: {
552
- requestId?: {
553
- [key: string]: unknown;
554
- };
555
- status?: {
556
- [key: string]: unknown;
557
- };
558
- fileName?: {
559
- [key: string]: unknown;
560
- };
561
- fileUrl?: {
562
- [key: string]: unknown;
563
- };
564
- signedFileUrl?: {
565
- [key: string]: unknown;
566
- };
567
- metadata?: {
568
- [key: string]: unknown;
569
- };
570
- clientReferenceId?: {
334
+ signRequestsCount: number;
335
+ signRequests: {
336
+ requestId: string;
337
+ /** @enum {string} */
338
+ status: "pending" | "completed" | "canceled" | "queued";
339
+ fileName: string;
340
+ fileUrl: string;
341
+ signedFileUrl?: string;
342
+ metadata: {
571
343
  [key: string]: unknown;
572
344
  };
345
+ clientReferenceId?: string;
573
346
  }[];
574
- createdAt?: {
575
- toDateString?: {
576
- [key: string]: unknown;
577
- };
578
- toTimeString?: {
579
- [key: string]: unknown;
580
- };
581
- toLocaleDateString?: {
582
- [key: string]: unknown;
583
- };
584
- toLocaleTimeString?: {
585
- [key: string]: unknown;
586
- };
587
- getTime?: {
588
- [key: string]: unknown;
589
- };
590
- getFullYear?: {
591
- [key: string]: unknown;
592
- };
593
- getUTCFullYear?: {
594
- [key: string]: unknown;
595
- };
596
- getMonth?: {
597
- [key: string]: unknown;
598
- };
599
- getUTCMonth?: {
600
- [key: string]: unknown;
601
- };
602
- getDate?: {
603
- [key: string]: unknown;
604
- };
605
- getUTCDate?: {
606
- [key: string]: unknown;
607
- };
608
- getDay?: {
609
- [key: string]: unknown;
610
- };
611
- getUTCDay?: {
612
- [key: string]: unknown;
613
- };
614
- getHours?: {
615
- [key: string]: unknown;
616
- };
617
- getUTCHours?: {
618
- [key: string]: unknown;
619
- };
620
- getMinutes?: {
621
- [key: string]: unknown;
622
- };
623
- getUTCMinutes?: {
624
- [key: string]: unknown;
625
- };
626
- getSeconds?: {
627
- [key: string]: unknown;
628
- };
629
- getUTCSeconds?: {
630
- [key: string]: unknown;
631
- };
632
- getMilliseconds?: {
633
- [key: string]: unknown;
634
- };
635
- getUTCMilliseconds?: {
636
- [key: string]: unknown;
637
- };
638
- getTimezoneOffset?: {
639
- [key: string]: unknown;
640
- };
641
- setTime?: {
642
- [key: string]: unknown;
643
- };
644
- setMilliseconds?: {
645
- [key: string]: unknown;
646
- };
647
- setUTCMilliseconds?: {
648
- [key: string]: unknown;
649
- };
650
- setSeconds?: {
651
- [key: string]: unknown;
652
- };
653
- setUTCSeconds?: {
654
- [key: string]: unknown;
655
- };
656
- setMinutes?: {
657
- [key: string]: unknown;
658
- };
659
- setUTCMinutes?: {
660
- [key: string]: unknown;
661
- };
662
- setHours?: {
663
- [key: string]: unknown;
664
- };
665
- setUTCHours?: {
666
- [key: string]: unknown;
667
- };
668
- setDate?: {
669
- [key: string]: unknown;
670
- };
671
- setUTCDate?: {
672
- [key: string]: unknown;
673
- };
674
- setMonth?: {
675
- [key: string]: unknown;
676
- };
677
- setUTCMonth?: {
678
- [key: string]: unknown;
679
- };
680
- setFullYear?: {
681
- [key: string]: unknown;
682
- };
683
- setUTCFullYear?: {
684
- [key: string]: unknown;
685
- };
686
- toUTCString?: {
687
- [key: string]: unknown;
688
- };
689
- toISOString?: {
690
- [key: string]: unknown;
691
- };
692
- toJSON?: {
693
- [key: string]: unknown;
694
- };
695
- getVarDate?: {
696
- [key: string]: unknown;
697
- };
698
- };
699
- updatedAt?: {
700
- toDateString?: {
701
- [key: string]: unknown;
702
- };
703
- toTimeString?: {
704
- [key: string]: unknown;
705
- };
706
- toLocaleDateString?: {
707
- [key: string]: unknown;
708
- };
709
- toLocaleTimeString?: {
710
- [key: string]: unknown;
711
- };
712
- getTime?: {
713
- [key: string]: unknown;
714
- };
715
- getFullYear?: {
716
- [key: string]: unknown;
717
- };
718
- getUTCFullYear?: {
719
- [key: string]: unknown;
720
- };
721
- getMonth?: {
722
- [key: string]: unknown;
723
- };
724
- getUTCMonth?: {
725
- [key: string]: unknown;
726
- };
727
- getDate?: {
728
- [key: string]: unknown;
729
- };
730
- getUTCDate?: {
731
- [key: string]: unknown;
732
- };
733
- getDay?: {
734
- [key: string]: unknown;
735
- };
736
- getUTCDay?: {
737
- [key: string]: unknown;
738
- };
739
- getHours?: {
740
- [key: string]: unknown;
741
- };
742
- getUTCHours?: {
743
- [key: string]: unknown;
744
- };
745
- getMinutes?: {
746
- [key: string]: unknown;
747
- };
748
- getUTCMinutes?: {
749
- [key: string]: unknown;
750
- };
751
- getSeconds?: {
752
- [key: string]: unknown;
753
- };
754
- getUTCSeconds?: {
755
- [key: string]: unknown;
756
- };
757
- getMilliseconds?: {
758
- [key: string]: unknown;
759
- };
760
- getUTCMilliseconds?: {
761
- [key: string]: unknown;
762
- };
763
- getTimezoneOffset?: {
764
- [key: string]: unknown;
765
- };
766
- setTime?: {
767
- [key: string]: unknown;
768
- };
769
- setMilliseconds?: {
770
- [key: string]: unknown;
771
- };
772
- setUTCMilliseconds?: {
773
- [key: string]: unknown;
774
- };
775
- setSeconds?: {
776
- [key: string]: unknown;
777
- };
778
- setUTCSeconds?: {
779
- [key: string]: unknown;
780
- };
781
- setMinutes?: {
782
- [key: string]: unknown;
783
- };
784
- setUTCMinutes?: {
785
- [key: string]: unknown;
786
- };
787
- setHours?: {
788
- [key: string]: unknown;
789
- };
790
- setUTCHours?: {
791
- [key: string]: unknown;
792
- };
793
- setDate?: {
794
- [key: string]: unknown;
795
- };
796
- setUTCDate?: {
797
- [key: string]: unknown;
798
- };
799
- setMonth?: {
800
- [key: string]: unknown;
801
- };
802
- setUTCMonth?: {
803
- [key: string]: unknown;
804
- };
805
- setFullYear?: {
806
- [key: string]: unknown;
807
- };
808
- setUTCFullYear?: {
809
- [key: string]: unknown;
810
- };
811
- toUTCString?: {
812
- [key: string]: unknown;
813
- };
814
- toISOString?: {
815
- [key: string]: unknown;
816
- };
817
- toJSON?: {
818
- [key: string]: unknown;
819
- };
820
- getVarDate?: {
821
- [key: string]: unknown;
822
- };
823
- };
824
- expirationDate?: {
825
- toDateString?: {
826
- [key: string]: unknown;
827
- };
828
- toTimeString?: {
829
- [key: string]: unknown;
830
- };
831
- toLocaleDateString?: {
832
- [key: string]: unknown;
833
- };
834
- toLocaleTimeString?: {
835
- [key: string]: unknown;
836
- };
837
- getTime?: {
838
- [key: string]: unknown;
839
- };
840
- getFullYear?: {
841
- [key: string]: unknown;
842
- };
843
- getUTCFullYear?: {
844
- [key: string]: unknown;
845
- };
846
- getMonth?: {
847
- [key: string]: unknown;
848
- };
849
- getUTCMonth?: {
850
- [key: string]: unknown;
851
- };
852
- getDate?: {
853
- [key: string]: unknown;
854
- };
855
- getUTCDate?: {
856
- [key: string]: unknown;
857
- };
858
- getDay?: {
859
- [key: string]: unknown;
860
- };
861
- getUTCDay?: {
862
- [key: string]: unknown;
863
- };
864
- getHours?: {
865
- [key: string]: unknown;
866
- };
867
- getUTCHours?: {
868
- [key: string]: unknown;
869
- };
870
- getMinutes?: {
871
- [key: string]: unknown;
872
- };
873
- getUTCMinutes?: {
874
- [key: string]: unknown;
875
- };
876
- getSeconds?: {
877
- [key: string]: unknown;
878
- };
879
- getUTCSeconds?: {
880
- [key: string]: unknown;
881
- };
882
- getMilliseconds?: {
883
- [key: string]: unknown;
884
- };
885
- getUTCMilliseconds?: {
886
- [key: string]: unknown;
887
- };
888
- getTimezoneOffset?: {
889
- [key: string]: unknown;
890
- };
891
- setTime?: {
892
- [key: string]: unknown;
893
- };
894
- setMilliseconds?: {
895
- [key: string]: unknown;
896
- };
897
- setUTCMilliseconds?: {
898
- [key: string]: unknown;
899
- };
900
- setSeconds?: {
901
- [key: string]: unknown;
902
- };
903
- setUTCSeconds?: {
904
- [key: string]: unknown;
905
- };
906
- setMinutes?: {
907
- [key: string]: unknown;
908
- };
909
- setUTCMinutes?: {
910
- [key: string]: unknown;
911
- };
912
- setHours?: {
913
- [key: string]: unknown;
914
- };
915
- setUTCHours?: {
916
- [key: string]: unknown;
917
- };
918
- setDate?: {
919
- [key: string]: unknown;
920
- };
921
- setUTCDate?: {
922
- [key: string]: unknown;
923
- };
924
- setMonth?: {
925
- [key: string]: unknown;
926
- };
927
- setUTCMonth?: {
928
- [key: string]: unknown;
929
- };
930
- setFullYear?: {
931
- [key: string]: unknown;
932
- };
933
- setUTCFullYear?: {
934
- [key: string]: unknown;
935
- };
936
- toUTCString?: {
937
- [key: string]: unknown;
938
- };
939
- toISOString?: {
940
- [key: string]: unknown;
941
- };
942
- toJSON?: {
943
- [key: string]: unknown;
944
- };
945
- getVarDate?: {
946
- [key: string]: unknown;
947
- };
948
- };
347
+ /** Format: date-time */
348
+ createdAt: string;
349
+ /** Format: date-time */
350
+ updatedAt: string;
351
+ /** Format: date-time */
352
+ expirationDate?: string;
353
+ signUrl?: string;
949
354
  }[];
950
355
  };
951
356
  };
@@ -958,7 +363,7 @@ interface paths {
958
363
  patch?: never;
959
364
  trace?: never;
960
365
  };
961
- "/functions/removeSignRequestFromEnvelope": {
366
+ "/functions/envelope:remove-sign-request": {
962
367
  parameters: {
963
368
  query?: never;
964
369
  header?: never;
@@ -967,7 +372,7 @@ interface paths {
967
372
  };
968
373
  get?: never;
969
374
  put?: never;
970
- /** Cloud Function: removeSignRequestFromEnvelope */
375
+ /** envelope:remove-sign-request */
971
376
  post: {
972
377
  parameters: {
973
378
  query?: never;
@@ -978,9 +383,7 @@ interface paths {
978
383
  requestBody?: {
979
384
  content: {
980
385
  "application/json": {
981
- /** @description The unique identifier of the envelope */
982
386
  envelopeId: string;
983
- /** @description The unique identifier of the sign request */
984
387
  requestId: string;
985
388
  };
986
389
  };
@@ -993,9 +396,9 @@ interface paths {
993
396
  };
994
397
  content: {
995
398
  "application/json": {
996
- result?: {
997
- success?: boolean;
998
- message?: string;
399
+ result: {
400
+ success: boolean;
401
+ message: string;
999
402
  };
1000
403
  };
1001
404
  };
@@ -1008,7 +411,7 @@ interface paths {
1008
411
  patch?: never;
1009
412
  trace?: never;
1010
413
  };
1011
- "/functions/updateEnvelopeMetadata": {
414
+ "/functions/envelope:update-metadata": {
1012
415
  parameters: {
1013
416
  query?: never;
1014
417
  header?: never;
@@ -1017,7 +420,7 @@ interface paths {
1017
420
  };
1018
421
  get?: never;
1019
422
  put?: never;
1020
- /** Cloud Function: updateEnvelopeMetadata */
423
+ /** envelope:update-metadata */
1021
424
  post: {
1022
425
  parameters: {
1023
426
  query?: never;
@@ -1028,9 +431,7 @@ interface paths {
1028
431
  requestBody?: {
1029
432
  content: {
1030
433
  "application/json": {
1031
- /** @description The unique identifier of the envelope */
1032
434
  envelopeId: string;
1033
- /** @description The metadata to be merged into the existing envelope metadata */
1034
435
  metadata: {
1035
436
  [key: string]: unknown;
1036
437
  };
@@ -1045,9 +446,9 @@ interface paths {
1045
446
  };
1046
447
  content: {
1047
448
  "application/json": {
1048
- result?: {
1049
- envelopeId?: string;
1050
- metadata?: {
449
+ result: {
450
+ envelopeId: string;
451
+ metadata: {
1051
452
  [key: string]: unknown;
1052
453
  };
1053
454
  };
@@ -1062,7 +463,7 @@ interface paths {
1062
463
  patch?: never;
1063
464
  trace?: never;
1064
465
  };
1065
- "/functions/completeSignRequest": {
466
+ "/functions/sign-request:complete": {
1066
467
  parameters: {
1067
468
  query?: never;
1068
469
  header?: never;
@@ -1071,7 +472,7 @@ interface paths {
1071
472
  };
1072
473
  get?: never;
1073
474
  put?: never;
1074
- /** Cloud Function: completeSignRequest */
475
+ /** sign-request:complete */
1075
476
  post: {
1076
477
  parameters: {
1077
478
  query?: never;
@@ -1082,9 +483,7 @@ interface paths {
1082
483
  requestBody?: {
1083
484
  content: {
1084
485
  "application/json": {
1085
- /** @description The unique identifier of the sign request to complete */
1086
486
  requestId: string;
1087
- /** @description The base64 encoded content of the signed file */
1088
487
  signedFileDataBase64: string;
1089
488
  };
1090
489
  };
@@ -1097,8 +496,8 @@ interface paths {
1097
496
  };
1098
497
  content: {
1099
498
  "application/json": {
1100
- result?: {
1101
- signedFileUrl?: string;
499
+ result: {
500
+ signedFileUrl: string;
1102
501
  };
1103
502
  };
1104
503
  };
@@ -1111,7 +510,7 @@ interface paths {
1111
510
  patch?: never;
1112
511
  trace?: never;
1113
512
  };
1114
- "/functions/createSignRequest": {
513
+ "/functions/sign-request:create": {
1115
514
  parameters: {
1116
515
  query?: never;
1117
516
  header?: never;
@@ -1120,7 +519,7 @@ interface paths {
1120
519
  };
1121
520
  get?: never;
1122
521
  put?: never;
1123
- /** Cloud Function: createSignRequest */
522
+ /** sign-request:create */
1124
523
  post: {
1125
524
  parameters: {
1126
525
  query?: never;
@@ -1131,16 +530,15 @@ interface paths {
1131
530
  requestBody?: {
1132
531
  content: {
1133
532
  "application/json": {
1134
- /** @description The name of the file to be signed */
1135
533
  filename: string;
1136
- /** @description The base64 encoded content of the file */
1137
534
  base64File?: string;
1138
- /** @description Remote URL of the file. MUST be publicly accessible. */
1139
535
  fileUrl?: string;
1140
- /** @description Associated metadata for the sign request */
1141
536
  metadata?: {
1142
537
  [key: string]: unknown;
1143
538
  };
539
+ clientReferenceId?: string;
540
+ /** Format: date-time */
541
+ expirationDate?: string;
1144
542
  };
1145
543
  };
1146
544
  };
@@ -1152,9 +550,9 @@ interface paths {
1152
550
  };
1153
551
  content: {
1154
552
  "application/json": {
1155
- result?: {
1156
- requestId?: string;
1157
- signUrl?: string;
553
+ result: {
554
+ requestId: string;
555
+ signUrl: string;
1158
556
  };
1159
557
  };
1160
558
  };
@@ -1167,7 +565,7 @@ interface paths {
1167
565
  patch?: never;
1168
566
  trace?: never;
1169
567
  };
1170
- "/functions/getFileFromRequestId": {
568
+ "/functions/sign-request:get": {
1171
569
  parameters: {
1172
570
  query?: never;
1173
571
  header?: never;
@@ -1176,7 +574,7 @@ interface paths {
1176
574
  };
1177
575
  get?: never;
1178
576
  put?: never;
1179
- /** Cloud Function: getFileFromRequestId */
577
+ /** sign-request:get */
1180
578
  post: {
1181
579
  parameters: {
1182
580
  query?: never;
@@ -1187,7 +585,6 @@ interface paths {
1187
585
  requestBody?: {
1188
586
  content: {
1189
587
  "application/json": {
1190
- /** @description The unique identifier of the sign request */
1191
588
  requestId: string;
1192
589
  };
1193
590
  };
@@ -1200,64 +597,21 @@ interface paths {
1200
597
  };
1201
598
  content: {
1202
599
  "application/json": {
1203
- result?: {
1204
- requestId?: string;
1205
- name?: string;
1206
- originalFile?: string;
600
+ result: {
601
+ requestId: string;
602
+ /** @enum {string} */
603
+ status: "pending" | "completed" | "canceled" | "queued";
604
+ fileName: string;
605
+ originalFile: string;
1207
606
  signedFile?: string;
1208
607
  metadata?: {
1209
608
  [key: string]: unknown;
1210
609
  };
1211
- status?: string;
1212
- };
1213
- };
1214
- };
1215
- };
1216
- };
1217
- };
1218
- delete?: never;
1219
- options?: never;
1220
- head?: never;
1221
- patch?: never;
1222
- trace?: never;
1223
- };
1224
- "/functions/getSignedFile": {
1225
- parameters: {
1226
- query?: never;
1227
- header?: never;
1228
- path?: never;
1229
- cookie?: never;
1230
- };
1231
- get?: never;
1232
- put?: never;
1233
- /** Cloud Function: getSignedFile */
1234
- post: {
1235
- parameters: {
1236
- query?: never;
1237
- header?: never;
1238
- path?: never;
1239
- cookie?: never;
1240
- };
1241
- requestBody?: {
1242
- content: {
1243
- "application/json": {
1244
- /** @description The unique identifier of the sign request */
1245
- requestId: string;
1246
- };
1247
- };
1248
- };
1249
- responses: {
1250
- /** @description Successful response */
1251
- 200: {
1252
- headers: {
1253
- [name: string]: unknown;
1254
- };
1255
- content: {
1256
- "application/json": {
1257
- result?: {
1258
- fileName?: string;
1259
- fileUrl?: string;
1260
- signedFileUrl?: string;
610
+ clientReferenceId?: string;
611
+ /** Format: date-time */
612
+ createdAt: string;
613
+ /** Format: date-time */
614
+ updatedAt: string;
1261
615
  };
1262
616
  };
1263
617
  };
@@ -1270,7 +624,7 @@ interface paths {
1270
624
  patch?: never;
1271
625
  trace?: never;
1272
626
  };
1273
- "/functions/updateSignRequestMetadata": {
627
+ "/functions/sign-request:update-metadata": {
1274
628
  parameters: {
1275
629
  query?: never;
1276
630
  header?: never;
@@ -1279,7 +633,7 @@ interface paths {
1279
633
  };
1280
634
  get?: never;
1281
635
  put?: never;
1282
- /** Cloud Function: updateSignRequestMetadata */
636
+ /** sign-request:update-metadata */
1283
637
  post: {
1284
638
  parameters: {
1285
639
  query?: never;
@@ -1290,9 +644,7 @@ interface paths {
1290
644
  requestBody?: {
1291
645
  content: {
1292
646
  "application/json": {
1293
- /** @description The unique identifier of the sign request */
1294
647
  requestId: string;
1295
- /** @description The metadata to be merged into the existing sign request metadata */
1296
648
  metadata: {
1297
649
  [key: string]: unknown;
1298
650
  };
@@ -1307,9 +659,9 @@ interface paths {
1307
659
  };
1308
660
  content: {
1309
661
  "application/json": {
1310
- result?: {
1311
- requestId?: string;
1312
- metadata?: {
662
+ result: {
663
+ requestId: string;
664
+ metadata: {
1313
665
  [key: string]: unknown;
1314
666
  };
1315
667
  };
@@ -1327,58 +679,7 @@ interface paths {
1327
679
  }
1328
680
  type webhooks = Record<string, never>;
1329
681
  interface components {
1330
- schemas: {
1331
- ApiLog: {
1332
- apiKey?: string;
1333
- functionName?: string;
1334
- statusCode?: string;
1335
- statusMessage?: string;
1336
- };
1337
- Authentication: {
1338
- apiKey?: string;
1339
- name?: string;
1340
- status?: string;
1341
- expirationDate?: string;
1342
- callbackUrl?: string;
1343
- webhookSecret?: string;
1344
- };
1345
- Envelope: {
1346
- name?: string;
1347
- description?: string;
1348
- envelopeId?: string;
1349
- signRequests?: string;
1350
- status?: string;
1351
- metadata?: string;
1352
- apiKey?: string;
1353
- expirationDate?: string;
1354
- isDeleted?: string;
1355
- clientReferenceId?: string;
1356
- };
1357
- SignRequest: {
1358
- status?: string;
1359
- file?: string;
1360
- fileName?: string;
1361
- signedFile?: string;
1362
- requestId?: string;
1363
- metadata?: string;
1364
- apiKey?: string;
1365
- expirationDate?: string;
1366
- isDeleted?: string;
1367
- clientReferenceId?: string;
1368
- };
1369
- WebhookLog: {
1370
- status?: string;
1371
- message?: string;
1372
- signRequest?: string;
1373
- envelope?: string;
1374
- eventType?: string;
1375
- delivered?: string;
1376
- retryCount?: string;
1377
- nextRetryAt?: string;
1378
- payload?: string;
1379
- apiKey?: string;
1380
- };
1381
- };
682
+ schemas: never;
1382
683
  responses: never;
1383
684
  parameters: never;
1384
685
  requestBodies: never;
@@ -1388,6 +689,119 @@ interface components {
1388
689
  type $defs = Record<string, never>;
1389
690
  type operations = Record<string, never>;
1390
691
 
692
+ interface OperationResponse {
693
+ success?: boolean;
694
+ message?: string;
695
+ }
696
+ /** Extract the result type from a Cloud Function response */
697
+ type ResponseResult<P extends keyof paths> = NonNullable<NonNullable<paths[P]['post']['responses']>[200]['content']>['application/json']['result'];
698
+ /** Extract the request body type from a Cloud Function */
699
+ type RequestBody<P extends keyof paths> = NonNullable<NonNullable<paths[P]['post']['requestBody']>['content']>['application/json'];
700
+
701
+ /** A full envelope with its sign requests */
702
+ type Envelope = ResponseResult<'/functions/envelope:get'>;
703
+ /** Envelope as returned in a list */
704
+ type EnvelopeListItem = ResponseResult<'/functions/envelope:list'>[number];
705
+ type CreateEnvelopeParams = RequestBody<'/functions/envelope:create'>;
706
+ type GetEnvelopesParams = RequestBody<'/functions/envelope:list'>;
707
+ type UpdateEnvelopeMetadataParams = RequestBody<'/functions/envelope:update-metadata'>;
708
+ type RemoveSignRequestFromEnvelopeParams = RequestBody<'/functions/envelope:remove-sign-request'>;
709
+ type AddSignRequestToEnvelopeParams = RequestBody<'/functions/envelope:add-sign-request'>;
710
+ type CreateEnvelopeResponse = ResponseResult<'/functions/envelope:create'>;
711
+ type UpdateEnvelopeMetadataResponse = ResponseResult<'/functions/envelope:update-metadata'>;
712
+ type AddSignRequestToEnvelopeResponse = ResponseResult<'/functions/envelope:add-sign-request'>;
713
+
714
+ /** A single sign request */
715
+ type SignRequest = ResponseResult<'/functions/envelope:get'>['signRequests'][number];
716
+ type CreateSignRequestParams = RequestBody<'/functions/sign-request:create'>;
717
+ type CompleteSignRequestParams = RequestBody<'/functions/sign-request:complete'>;
718
+ type CreateSignRequestResponse = ResponseResult<'/functions/sign-request:create'>;
719
+ type CompleteSignRequestResponse = ResponseResult<'/functions/sign-request:complete'>;
720
+
721
+ type WebhookEvent = {
722
+ [T in WebhookEventType]: {
723
+ eventType: T;
724
+ } & WebhookPayloadMap[T];
725
+ }[WebhookEventType];
726
+ type EnvelopeCreatedEvent = Extract<WebhookEvent, {
727
+ eventType: 'envelope_created';
728
+ }>;
729
+ type EnvelopeExpiredEvent = Extract<WebhookEvent, {
730
+ eventType: 'envelope_expired';
731
+ }>;
732
+ type SignRequestCreatedEvent = Extract<WebhookEvent, {
733
+ eventType: 'sign_request_created';
734
+ }>;
735
+ type SignRequestSignedEvent = Extract<WebhookEvent, {
736
+ eventType: 'sign_request_signed';
737
+ }>;
738
+ type SignRequestExpiredEvent = Extract<WebhookEvent, {
739
+ eventType: 'sign_request_expired';
740
+ }>;
741
+
742
+ declare class Envelopes {
743
+ private client;
744
+ constructor(client: AxiosInstance);
745
+ /**
746
+ * Create a new envelope
747
+ */
748
+ create(params: CreateEnvelopeParams): Promise<CreateEnvelopeResponse | undefined>;
749
+ /**
750
+ * List envelopes
751
+ */
752
+ list(params?: GetEnvelopesParams): Promise<Envelope[] | undefined>;
753
+ /**
754
+ * Retrieve a single envelope with its sign requests
755
+ */
756
+ get(envelopeId: string): Promise<Envelope | undefined>;
757
+ /**
758
+ * Complete an envelope
759
+ */
760
+ complete(envelopeId: string): Promise<OperationResponse | undefined>;
761
+ /**
762
+ * Delete an envelope
763
+ */
764
+ delete(envelopeId: string): Promise<OperationResponse | undefined>;
765
+ /**
766
+ * Update envelope metadata
767
+ */
768
+ updateMetadata(params: UpdateEnvelopeMetadataParams): Promise<UpdateEnvelopeMetadataResponse | undefined>;
769
+ /**
770
+ * Remove a sign request from an envelope
771
+ */
772
+ removeSignRequest(params: RemoveSignRequestFromEnvelopeParams): Promise<OperationResponse | undefined>;
773
+ /**
774
+ * Add a sign request to an envelope
775
+ */
776
+ addSignRequest(params: AddSignRequestToEnvelopeParams): Promise<AddSignRequestToEnvelopeResponse | undefined>;
777
+ }
778
+
779
+ declare class SignRequests {
780
+ private client;
781
+ constructor(client: AxiosInstance);
782
+ /**
783
+ * Create a new sign request
784
+ */
785
+ create(params: CreateSignRequestParams): Promise<CreateSignRequestResponse | undefined>;
786
+ /**
787
+ * Complete a sign request
788
+ */
789
+ complete(params: CompleteSignRequestParams): Promise<CompleteSignRequestResponse | undefined>;
790
+ /**
791
+ * Get the file associated with a sign request
792
+ */
793
+ get(requestId: string): Promise<SignRequest | undefined>;
794
+ }
795
+
796
+ declare class Webhooks {
797
+ private tolerance;
798
+ constructor(tolerance?: number);
799
+ /**
800
+ * Verify and parse a webhook event
801
+ */
802
+ constructEvent(payload: string, signatureHeader: string, webhookSecret: string): WebhookEvent;
803
+ }
804
+
1391
805
  interface IInstasignConfig {
1392
806
  apiKey: string;
1393
807
  appId?: string;
@@ -1397,10 +811,10 @@ interface IInstasignConfig {
1397
811
  }
1398
812
  declare class Instasign {
1399
813
  private client;
1400
- envelopes: Envelopes;
1401
- signRequests: SignRequests;
1402
- webhooks: Webhooks;
814
+ readonly envelopes: Envelopes;
815
+ readonly signRequests: SignRequests;
816
+ readonly webhooks: Webhooks;
1403
817
  constructor(config: IInstasignConfig);
1404
818
  }
1405
819
 
1406
- export { type $defs, Envelopes, type IInstasignConfig, Instasign, SignRequests, Webhooks, type components, type operations, type paths, type webhooks };
820
+ export { type $defs, type AddSignRequestToEnvelopeParams, type AddSignRequestToEnvelopeResponse, type CompleteSignRequestParams, type CompleteSignRequestResponse, type CreateEnvelopeParams, type CreateEnvelopeResponse, type CreateSignRequestParams, type CreateSignRequestResponse, type Envelope, type EnvelopeCreatedEvent, type EnvelopeExpiredEvent, type EnvelopeListItem, Envelopes, type GetEnvelopesParams, type IInstasignConfig, Instasign, type OperationResponse, type RemoveSignRequestFromEnvelopeParams, type RequestBody, type ResponseResult, type SignRequest, type SignRequestCreatedEvent, type SignRequestExpiredEvent, type SignRequestSignedEvent, SignRequests, type UpdateEnvelopeMetadataParams, type UpdateEnvelopeMetadataResponse, type WebhookEvent, Webhooks, type components, type operations, type paths, type webhooks };