@verdocs/js-sdk 1.1.14 → 1.2.0

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.
@@ -2,8 +2,8 @@ export interface IInitials {
2
2
  id?: string;
3
3
  profile_id: string;
4
4
  url: string;
5
- created_at?: Date;
6
- updated_at?: Date;
5
+ created_at?: string;
6
+ updated_at?: string;
7
7
  }
8
8
  /**
9
9
  * Create an initials block. In a typical signing workflow, the user is asked at the beginning of the process to "adopt"
@@ -5,6 +5,18 @@
5
5
  * In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
6
6
  * discarded once signing is complete.
7
7
  *
8
+ * Note that endpoint configuration functions return the instance, so they can be chained, e.g.
9
+ *
10
+ * ```typescript
11
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
12
+ *
13
+ * const endpoint = new VerdocsEndpoint();
14
+ * endpoint
15
+ * .logRequests(true)
16
+ * .setClientID('1234)
17
+ * .setTimeout(5000);
18
+ * ```
19
+ *
8
20
  * @module
9
21
  */
10
22
  import { AxiosInstance } from 'axios';
@@ -15,7 +27,7 @@ export declare class VerdocsEndpoint {
15
27
  * Create a new Endpoint to call Verdocs services.
16
28
  *
17
29
  * ```typescript
18
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
30
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
19
31
  *
20
32
  * console.log('Current timeout', Transport.getEndpoint().defaults.timeout);
21
33
  * ```
@@ -28,67 +40,67 @@ export declare class VerdocsEndpoint {
28
40
  * Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
29
41
  *
30
42
  * ```typescript
31
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
43
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
32
44
  *
33
- * const endpoint = new Endpoint();
45
+ * const endpoint = new VerdocsEndpoint();
34
46
  * endpoint.setTimeout(3000);
35
47
  * ```
36
48
  */
37
- setTimeout(timeout: number): void;
49
+ setTimeout(timeout: number): VerdocsEndpoint;
38
50
  /**
39
51
  * Set the Client ID for Verdocs API calls.
40
52
  *
41
53
  * ```typescript
42
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
54
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
43
55
  *
44
- * const endpoint = new Endpoint();
56
+ * const endpoint = new VerdocsEndpoint();
45
57
  * endpoint.setClientID('1234);
46
58
  * ```
47
59
  */
48
- setClientID(clientID: string): void;
60
+ setClientID(clientID: string): VerdocsEndpoint;
49
61
  /**
50
62
  * Set the auth token that will be used for Verdocs API calls.
51
63
  *
52
64
  * ```typescript
53
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
65
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
54
66
  *
55
- * const endpoint = new Endpoint();
67
+ * const endpoint = new VerdocsEndpoint();
56
68
  * endpoint.setAuthorization(accessToken);
57
69
  * ```
58
70
  */
59
- setAuthorization(accessToken: string | null): void;
71
+ setAuthorization(accessToken: string | null): VerdocsEndpoint;
60
72
  /**
61
73
  * Set the auth token used for signing sessions. Separating user from signing auth allows the same endpoint to be
62
74
  * used for multiple operations, although it is recommended that a separate endpoint be created for each operation.
63
75
  *
64
76
  * ```typescript
65
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
77
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
66
78
  *
67
- * const endpoint = new Endpoint();
79
+ * const endpoint = new VerdocsEndpoint();
68
80
  * endpoint.setSigningAuthorization(accessToken);
69
81
  * ```
70
82
  */
71
- setSigningAuthorization(accessToken: string | null): void;
83
+ setSigningAuthorization(accessToken: string | null): VerdocsEndpoint;
72
84
  /**
73
85
  * Set the base URL for API calls. May also be set via the constructor.
74
86
  *
75
87
  * ```typescript
76
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
88
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
77
89
  *
78
- * const endpoint = new Endpoint();
90
+ * const endpoint = new VerdocsEndpoint();
79
91
  * endpoint.setBaseURL('https://api.verdocs.com');
80
92
  * ```
81
93
  */
82
- setBaseURL(url: string): void;
94
+ setBaseURL(url: string): VerdocsEndpoint;
83
95
  /**
84
96
  * Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
85
97
  *
86
98
  * ```typescript
87
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
99
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
88
100
  *
89
- * const endpoint = new Endpoint();
101
+ * const endpoint = new VerdocsEndpoint();
90
102
  * endpoint.logRequests(true);
91
103
  * ```
92
104
  */
93
- logRequests(enable: boolean): void;
105
+ logRequests(enable: boolean): VerdocsEndpoint;
94
106
  }
@@ -5,12 +5,24 @@
5
5
  * In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
6
6
  * discarded once signing is complete.
7
7
  *
8
+ * Note that endpoint configuration functions return the instance, so they can be chained, e.g.
9
+ *
10
+ * ```typescript
11
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
12
+ *
13
+ * const endpoint = new VerdocsEndpoint();
14
+ * endpoint
15
+ * .logRequests(true)
16
+ * .setClientID('1234)
17
+ * .setTimeout(5000);
18
+ * ```
19
+ *
8
20
  * @module
9
21
  */
10
22
  import axios from 'axios';
11
23
  var requestLogger = function (r) {
12
24
  // tslint:disable-next-line
13
- console.log("[JS-SDK] ".concat(r.method.toUpperCase(), " ").concat(r.baseURL).concat(r.url), r.data ? JSON.stringify(r.data) : '');
25
+ console.debug("[JS-SDK] ".concat(r.method.toUpperCase(), " ").concat(r.baseURL).concat(r.url), r.data ? JSON.stringify(r.data) : '');
14
26
  return r;
15
27
  };
16
28
  var VerdocsEndpoint = /** @class */ (function () {
@@ -18,7 +30,7 @@ var VerdocsEndpoint = /** @class */ (function () {
18
30
  * Create a new Endpoint to call Verdocs services.
19
31
  *
20
32
  * ```typescript
21
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
33
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
22
34
  *
23
35
  * console.log('Current timeout', Transport.getEndpoint().defaults.timeout);
24
36
  * ```
@@ -35,85 +47,90 @@ var VerdocsEndpoint = /** @class */ (function () {
35
47
  * Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
36
48
  *
37
49
  * ```typescript
38
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
50
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
39
51
  *
40
- * const endpoint = new Endpoint();
52
+ * const endpoint = new VerdocsEndpoint();
41
53
  * endpoint.setTimeout(3000);
42
54
  * ```
43
55
  */
44
56
  VerdocsEndpoint.prototype.setTimeout = function (timeout) {
45
57
  this.api.defaults.timeout = timeout;
58
+ return this;
46
59
  };
47
60
  /**
48
61
  * Set the Client ID for Verdocs API calls.
49
62
  *
50
63
  * ```typescript
51
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
64
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
52
65
  *
53
- * const endpoint = new Endpoint();
66
+ * const endpoint = new VerdocsEndpoint();
54
67
  * endpoint.setClientID('1234);
55
68
  * ```
56
69
  */
57
70
  VerdocsEndpoint.prototype.setClientID = function (clientID) {
58
- this.api.defaults.headers['X-Client-ID'] = clientID;
71
+ this.api.defaults.headers.common['X-Client-ID'] = clientID;
72
+ return this;
59
73
  };
60
74
  /**
61
75
  * Set the auth token that will be used for Verdocs API calls.
62
76
  *
63
77
  * ```typescript
64
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
78
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
65
79
  *
66
- * const endpoint = new Endpoint();
80
+ * const endpoint = new VerdocsEndpoint();
67
81
  * endpoint.setAuthorization(accessToken);
68
82
  * ```
69
83
  */
70
84
  VerdocsEndpoint.prototype.setAuthorization = function (accessToken) {
71
85
  if (accessToken) {
72
- this.api.defaults.headers.Authorization = "Bearer ".concat(accessToken);
86
+ this.api.defaults.headers.common.Authorization = "Bearer ".concat(accessToken);
73
87
  }
74
88
  else {
75
- delete this.api.defaults.headers.Authorization;
89
+ delete this.api.defaults.headers.common.Authorization;
76
90
  }
91
+ return this;
77
92
  };
78
93
  /**
79
94
  * Set the auth token used for signing sessions. Separating user from signing auth allows the same endpoint to be
80
95
  * used for multiple operations, although it is recommended that a separate endpoint be created for each operation.
81
96
  *
82
97
  * ```typescript
83
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
98
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
84
99
  *
85
- * const endpoint = new Endpoint();
100
+ * const endpoint = new VerdocsEndpoint();
86
101
  * endpoint.setSigningAuthorization(accessToken);
87
102
  * ```
88
103
  */
89
104
  VerdocsEndpoint.prototype.setSigningAuthorization = function (accessToken) {
90
105
  if (accessToken) {
91
- this.api.defaults.headers.signer = "Bearer ".concat(accessToken);
106
+ this.api.defaults.headers.common.signer = "Bearer ".concat(accessToken);
92
107
  }
93
108
  else {
94
- delete this.api.defaults.headers.signer;
109
+ delete this.api.defaults.headers.common.signer;
95
110
  }
111
+ return this;
96
112
  };
97
113
  /**
98
114
  * Set the base URL for API calls. May also be set via the constructor.
99
115
  *
100
116
  * ```typescript
101
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
117
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
102
118
  *
103
- * const endpoint = new Endpoint();
119
+ * const endpoint = new VerdocsEndpoint();
104
120
  * endpoint.setBaseURL('https://api.verdocs.com');
105
121
  * ```
106
122
  */
107
123
  VerdocsEndpoint.prototype.setBaseURL = function (url) {
108
124
  this.api.defaults.baseURL = url;
125
+ return this;
109
126
  };
110
127
  /**
111
128
  * Enable or disable request logging. This may expose sensitive data in the console log, so it should only be used for debugging.
112
129
  *
113
130
  * ```typescript
114
- * import {Endpoint} from '@verdocs/js-sdk/HTTP';
131
+ * import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
115
132
  *
116
- * const endpoint = new Endpoint();
133
+ * const endpoint = new VerdocsEndpoint();
117
134
  * endpoint.logRequests(true);
118
135
  * ```
119
136
  */
@@ -124,6 +141,7 @@ var VerdocsEndpoint = /** @class */ (function () {
124
141
  else if (!enable && this.requestLoggerId !== null) {
125
142
  this.api.interceptors.request.eject(this.requestLoggerId);
126
143
  }
144
+ return this;
127
145
  };
128
146
  return VerdocsEndpoint;
129
147
  }());
@@ -1,4 +1,13 @@
1
1
  import { ITemplateField } from './Types';
2
+ /**
3
+ * Add a field to a template.
4
+ */
2
5
  export declare const createField: (templateId: string, params: ITemplateField) => Promise<ITemplateField>;
6
+ /**
7
+ * Update a template field.
8
+ */
3
9
  export declare const editField: (templateId: string, fieldName: string, params: ITemplateField) => Promise<ITemplateField>;
10
+ /**
11
+ * REmove a field from a template.
12
+ */
4
13
  export declare const deleteField: (templateId: string, fieldName: string) => Promise<any>;
@@ -1,14 +1,23 @@
1
1
  import { getEndpoint } from '../HTTP/Transport';
2
+ /**
3
+ * Add a field to a template.
4
+ */
2
5
  export var createField = function (templateId, params) {
3
6
  return getEndpoint()
4
7
  .api.post("/templates/".concat(templateId, "/pages/"), params)
5
8
  .then(function (r) { return r.data; });
6
9
  };
10
+ /**
11
+ * Update a template field.
12
+ */
7
13
  export var editField = function (templateId, fieldName, params) {
8
14
  return getEndpoint()
9
15
  .api.put("/templates/".concat(templateId, "/pages/").concat(fieldName), params)
10
16
  .then(function (r) { return r.data; });
11
17
  };
18
+ /**
19
+ * REmove a field from a template.
20
+ */
12
21
  export var deleteField = function (templateId, fieldName) {
13
22
  return getEndpoint()
14
23
  .api.delete("/templates/".concat(templateId, "/pages/").concat(fieldName))
@@ -1,5 +1,17 @@
1
1
  import { IPage } from './Types';
2
+ /**
3
+ * Add a page to a template
4
+ */
2
5
  export declare const createPage: (templateId: string, params: IPage) => Promise<IPage>;
6
+ /**
7
+ * Update a template page.
8
+ */
3
9
  export declare const editPage: (templateId: string, sequence: string) => Promise<any>;
10
+ /**
11
+ * Get a page from a template.
12
+ */
4
13
  export declare const getPage: (templateId: string, sequence: string) => Promise<any>;
14
+ /**
15
+ * Delete a page from a template
16
+ */
5
17
  export declare const deletePage: (templateId: string, sequence: string) => Promise<any>;
@@ -1,19 +1,31 @@
1
1
  import { getEndpoint } from '../HTTP/Transport';
2
+ /**
3
+ * Add a page to a template
4
+ */
2
5
  export var createPage = function (templateId, params) {
3
6
  return getEndpoint()
4
7
  .api.post("/templates/".concat(templateId, "/pages/"), params)
5
8
  .then(function (r) { return r.data; });
6
9
  };
10
+ /**
11
+ * Update a template page.
12
+ */
7
13
  export var editPage = function (templateId, sequence) {
8
14
  return getEndpoint()
9
15
  .api.put("/templates/".concat(templateId, "/pages/").concat(sequence))
10
16
  .then(function (r) { return r.data; });
11
17
  };
18
+ /**
19
+ * Get a page from a template.
20
+ */
12
21
  export var getPage = function (templateId, sequence) {
13
22
  return getEndpoint()
14
23
  .api.get("/templates/".concat(templateId, "/pages/").concat(sequence))
15
24
  .then(function (r) { return r.data; });
16
25
  };
26
+ /**
27
+ * Delete a page from a template
28
+ */
17
29
  export var deletePage = function (templateId, sequence) {
18
30
  return getEndpoint()
19
31
  .api.delete("/templates/".concat(templateId, "/pages/").concat(sequence))
@@ -1,4 +1,11 @@
1
1
  import { ITemplateField, IRole } from './Types';
2
+ /**
3
+ * A "role" is an individual participant in a signing flow, such as a signer or CC contact. Roles are identified by
4
+ * their names, which must be unique (e.g. 'Recipient 1'). Template fields are assigned to roles for signing operations,
5
+ * so you may have 'Recipient 1 Signature 1' and so forth.
6
+ *
7
+ * @module
8
+ */
2
9
  export declare const createRole: (templateId: string, params: IRole) => Promise<IRole>;
3
10
  export declare const getRoles: (templateId: string) => Promise<IRole[]>;
4
11
  export declare const getRole: (templateId: string, roleName: string) => Promise<IRole>;
@@ -1,4 +1,11 @@
1
1
  import { getEndpoint } from '../HTTP/Transport';
2
+ /**
3
+ * A "role" is an individual participant in a signing flow, such as a signer or CC contact. Roles are identified by
4
+ * their names, which must be unique (e.g. 'Recipient 1'). Template fields are assigned to roles for signing operations,
5
+ * so you may have 'Recipient 1 Signature 1' and so forth.
6
+ *
7
+ * @module
8
+ */
2
9
  export var createRole = function (templateId, params) {
3
10
  return getEndpoint()
4
11
  .api.post("/templates/".concat(templateId, "/roles/"), params)
@@ -117,7 +117,7 @@ export interface ITag {
117
117
  export interface ITags {
118
118
  name: string;
119
119
  featured?: boolean;
120
- created_at?: Date;
120
+ created_at?: string;
121
121
  }
122
122
  export interface IStar {
123
123
  template_id: string;
@@ -141,8 +141,8 @@ export interface ITemplateAsset {
141
141
  name: string;
142
142
  page_numbers: number;
143
143
  id?: string;
144
- updated_at?: Date;
145
- created_at?: Date;
144
+ updated_at?: string;
145
+ created_at?: string;
146
146
  template_id: string;
147
147
  mime: string;
148
148
  thumbnail_url: string;
@@ -188,7 +188,7 @@ export interface IPage {
188
188
  }
189
189
  export interface IReminder {
190
190
  id?: string;
191
- created_at?: Date;
191
+ created_at?: string;
192
192
  is_on: boolean;
193
193
  setup_time: number;
194
194
  interval_time: number;
@@ -0,0 +1,12 @@
1
+ export interface FileWithData {
2
+ lastModified: number;
3
+ size: number;
4
+ type: string;
5
+ name: string;
6
+ data: string;
7
+ }
8
+ /**
9
+ * Given a File, extract the file's content as a base64 encoded data URL. The response will have a prefix that
10
+ * includes the MIME type of the file, e.g. "data:image/jpeg;base64,iVBORw0K......"
11
+ */
12
+ export declare const fileToDataUrl: (file: File) => Promise<FileWithData>;
package/Utils/Files.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Given a File, extract the file's content as a base64 encoded data URL. The response will have a prefix that
3
+ * includes the MIME type of the file, e.g. "data:image/jpeg;base64,iVBORw0K......"
4
+ */
5
+ export var fileToDataUrl = function (file) {
6
+ return new Promise(function (resolve, reject) {
7
+ var reader = new FileReader();
8
+ reader.onload = function () {
9
+ return resolve({
10
+ lastModified: file.lastModified,
11
+ size: file.size,
12
+ type: file.type,
13
+ name: file.name,
14
+ data: reader.result,
15
+ });
16
+ };
17
+ reader.onerror = reject;
18
+ if (file) {
19
+ reader.readAsDataURL(file);
20
+ }
21
+ else {
22
+ reject(new Error('Invalid file'));
23
+ }
24
+ });
25
+ };
package/Utils/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * as Colors from './Colors';
2
2
  export * as DateTime from './DateTime';
3
3
  export * as Fields from './Fields';
4
+ export * as Files from './Files';
4
5
  export * as Locales from './Locales';
5
6
  export * as Token from './Token';
package/Utils/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * as Colors from './Colors';
2
2
  export * as DateTime from './DateTime';
3
3
  export * as Fields from './Fields';
4
+ export * as Files from './Files';
4
5
  export * as Locales from './Locales';
5
6
  export * as Token from './Token';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "1.1.14",
3
+ "version": "1.2.0",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",
@@ -44,7 +44,7 @@
44
44
  "access": "public"
45
45
  },
46
46
  "dependencies": {
47
- "axios": "^0.21.1"
47
+ "axios": "^0.25.0"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "typescript": "4.2.x || 4.3.x || 4.4.x || 4.5.x"