@verdocs/js-sdk 1.3.3 → 2.0.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.
Files changed (72) hide show
  1. package/Documents/Documents.d.ts +26 -9
  2. package/Documents/Documents.js +42 -27
  3. package/Documents/Initials.d.ts +2 -1
  4. package/Documents/Initials.js +3 -4
  5. package/Documents/Recipients.d.ts +5 -1
  6. package/Documents/Recipients.js +6 -4
  7. package/Documents/Signatures.d.ts +14 -4
  8. package/Documents/Signatures.js +21 -13
  9. package/Documents/index.d.ts +0 -1
  10. package/Documents/index.js +0 -1
  11. package/Organizations/ApiKeys.d.ts +6 -5
  12. package/Organizations/ApiKeys.js +15 -16
  13. package/Organizations/Groups.d.ts +8 -7
  14. package/Organizations/Groups.js +21 -22
  15. package/Organizations/Invitations.d.ts +8 -7
  16. package/Organizations/Invitations.js +21 -22
  17. package/Organizations/Members.d.ts +6 -5
  18. package/Organizations/Members.js +15 -16
  19. package/Organizations/Organizations.d.ts +7 -6
  20. package/Organizations/Organizations.js +18 -19
  21. package/Organizations/Webhooks.d.ts +3 -2
  22. package/Organizations/Webhooks.js +6 -7
  23. package/Organizations/Whitelabel.d.ts +3 -2
  24. package/Organizations/Whitelabel.js +6 -7
  25. package/Search/Content.d.ts +4 -3
  26. package/Search/Content.js +9 -10
  27. package/Templates/Fields.d.ts +4 -3
  28. package/Templates/Fields.js +9 -10
  29. package/Templates/Pages.d.ts +5 -4
  30. package/Templates/Pages.js +12 -13
  31. package/Templates/Reminders.d.ts +5 -4
  32. package/Templates/Reminders.js +12 -13
  33. package/Templates/Roles.d.ts +8 -7
  34. package/Templates/Roles.js +21 -22
  35. package/Templates/Stars.d.ts +3 -2
  36. package/Templates/Stars.js +6 -7
  37. package/Templates/Tags.d.ts +7 -6
  38. package/Templates/Tags.js +18 -19
  39. package/Templates/TemplateDocuments.d.ts +5 -4
  40. package/Templates/TemplateDocuments.js +12 -13
  41. package/Templates/Templates.d.ts +7 -6
  42. package/Templates/Templates.js +18 -19
  43. package/Templates/Validators.d.ts +3 -2
  44. package/Templates/Validators.js +7 -10
  45. package/Users/Auth.d.ts +9 -22
  46. package/Users/Auth.js +18 -71
  47. package/Users/Billing.d.ts +1 -1
  48. package/Users/Billing.js +1 -1
  49. package/Users/Notifications.d.ts +2 -1
  50. package/Users/Notifications.js +3 -4
  51. package/Users/Profiles.d.ts +11 -10
  52. package/Users/Profiles.js +30 -31
  53. package/Users/Types.d.ts +1 -1
  54. package/Utils/Token.d.ts +1 -1
  55. package/Utils/Token.js +2 -2
  56. package/{HTTP → Utils}/globalThis.d.ts +0 -0
  57. package/{HTTP → Utils}/globalThis.js +0 -0
  58. package/VerdocsEndpoint.d.ts +188 -0
  59. package/VerdocsEndpoint.js +285 -0
  60. package/index.d.ts +1 -1
  61. package/index.js +1 -1
  62. package/package.json +1 -1
  63. package/Documents/Stars.d.ts +0 -2
  64. package/Documents/Stars.js +0 -40
  65. package/HTTP/Transport.d.ts +0 -34
  66. package/HTTP/Transport.js +0 -47
  67. package/HTTP/Types.d.ts +0 -1
  68. package/HTTP/Types.js +0 -1
  69. package/HTTP/VerdocsEndpoint.d.ts +0 -106
  70. package/HTTP/VerdocsEndpoint.js +0 -141
  71. package/HTTP/index.d.ts +0 -3
  72. package/HTTP/index.js +0 -3
@@ -1,3 +1,4 @@
1
1
  import { IStar, ITemplatesSummary } from './Types';
2
- export declare const getStars: (templateId: string) => Promise<IStar[]>;
3
- export declare const toggleStar: (templateId: string) => Promise<ITemplatesSummary>;
2
+ import { VerdocsEndpoint } from '../VerdocsEndpoint';
3
+ export declare const getStars: (endpoint: VerdocsEndpoint, templateId: string) => Promise<IStar[]>;
4
+ export declare const toggleStar: (endpoint: VerdocsEndpoint, templateId: string) => Promise<ITemplatesSummary>;
@@ -1,11 +1,10 @@
1
- import { getEndpoint } from '../HTTP/Transport';
2
- export var getStars = function (templateId) {
3
- return getEndpoint()
4
- .api.get("/templates/".concat(templateId, "/stars/"))
1
+ export var getStars = function (endpoint, templateId) {
2
+ return endpoint.api //
3
+ .get("/templates/".concat(templateId, "/stars/"))
5
4
  .then(function (r) { return r.data; });
6
5
  };
7
- export var toggleStar = function (templateId) {
8
- return getEndpoint()
9
- .api.get("/templates/".concat(templateId, "/stars/toggle"))
6
+ export var toggleStar = function (endpoint, templateId) {
7
+ return endpoint.api //
8
+ .get("/templates/".concat(templateId, "/stars/toggle"))
10
9
  .then(function (r) { return r.data; });
11
10
  };
@@ -6,27 +6,28 @@
6
6
  * @module
7
7
  */
8
8
  import { ITemplateTag, ITag } from './Types';
9
+ import { VerdocsEndpoint } from '../VerdocsEndpoint';
9
10
  /**
10
11
  * Apply a tag to a template.
11
12
  */
12
- export declare const addTemplateTag: (templateId: string, params: ITag) => Promise<ITemplateTag>;
13
+ export declare const addTemplateTag: (endpoint: VerdocsEndpoint, templateId: string, params: ITag) => Promise<ITemplateTag>;
13
14
  /**
14
15
  * Get all tags for a template.
15
16
  */
16
- export declare const getTemplateTags: (templateId: string) => Promise<ITemplateTag[]>;
17
+ export declare const getTemplateTags: (endpoint: VerdocsEndpoint, templateId: string) => Promise<ITemplateTag[]>;
17
18
  /**
18
19
  * Remove a tag from a template.
19
20
  */
20
- export declare const deleteTemplateTag: (templateId: string, tagName: string) => Promise<any>;
21
+ export declare const deleteTemplateTag: (endpoint: VerdocsEndpoint, templateId: string, tagName: string) => Promise<any>;
21
22
  /**
22
23
  * Create an Organization-wide tag.
23
24
  */
24
- export declare const createTag: (name: string) => Promise<ITag>;
25
+ export declare const createTag: (endpoint: VerdocsEndpoint, name: string) => Promise<ITag>;
25
26
  /**
26
27
  * Get an Organization-wide tag.
27
28
  */
28
- export declare const getTag: (name: string) => Promise<ITag>;
29
+ export declare const getTag: (endpoint: VerdocsEndpoint, name: string) => Promise<ITag>;
29
30
  /**
30
31
  * Get all tags available for use by an Organization.
31
32
  */
32
- export declare const getAllTags: () => Promise<ITag[]>;
33
+ export declare const getAllTags: (endpoint: VerdocsEndpoint) => Promise<ITag[]>;
package/Templates/Tags.js CHANGED
@@ -5,52 +5,51 @@
5
5
  *
6
6
  * @module
7
7
  */
8
- import { getEndpoint } from '../HTTP/Transport';
9
8
  /**
10
9
  * Apply a tag to a template.
11
10
  */
12
- export var addTemplateTag = function (templateId, params) {
13
- return getEndpoint()
14
- .api.post("/templates/".concat(templateId, "/tags/"), params)
11
+ export var addTemplateTag = function (endpoint, templateId, params) {
12
+ return endpoint.api //
13
+ .post("/templates/".concat(templateId, "/tags/"), params)
15
14
  .then(function (r) { return r.data; });
16
15
  };
17
16
  /**
18
17
  * Get all tags for a template.
19
18
  */
20
- export var getTemplateTags = function (templateId) {
21
- return getEndpoint()
22
- .api.get("/templates/".concat(templateId, "/tags/"))
19
+ export var getTemplateTags = function (endpoint, templateId) {
20
+ return endpoint.api //
21
+ .get("/templates/".concat(templateId, "/tags/"))
23
22
  .then(function (r) { return r.data; });
24
23
  };
25
24
  /**
26
25
  * Remove a tag from a template.
27
26
  */
28
- export var deleteTemplateTag = function (templateId, tagName) {
29
- return getEndpoint()
30
- .api.post("/templates/".concat(templateId, "/tags/").concat(tagName))
27
+ export var deleteTemplateTag = function (endpoint, templateId, tagName) {
28
+ return endpoint.api //
29
+ .post("/templates/".concat(templateId, "/tags/").concat(tagName))
31
30
  .then(function (r) { return r.data; });
32
31
  };
33
32
  /**
34
33
  * Create an Organization-wide tag.
35
34
  */
36
- export var createTag = function (name) {
37
- return getEndpoint()
38
- .api.post('/tags', { tag_name: name })
35
+ export var createTag = function (endpoint, name) {
36
+ return endpoint.api //
37
+ .post('/tags', { tag_name: name })
39
38
  .then(function (r) { return r.data; });
40
39
  };
41
40
  /**
42
41
  * Get an Organization-wide tag.
43
42
  */
44
- export var getTag = function (name) {
45
- return getEndpoint()
46
- .api.get("/tags/".concat(name))
43
+ export var getTag = function (endpoint, name) {
44
+ return endpoint.api //
45
+ .get("/tags/".concat(name))
47
46
  .then(function (r) { return r.data; });
48
47
  };
49
48
  /**
50
49
  * Get all tags available for use by an Organization.
51
50
  */
52
- export var getAllTags = function () {
53
- return getEndpoint()
54
- .api.get('/tags')
51
+ export var getAllTags = function (endpoint) {
52
+ return endpoint.api //
53
+ .get('/tags')
55
54
  .then(function (r) { return r.data; });
56
55
  };
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
+ import { VerdocsEndpoint } from '../VerdocsEndpoint';
6
7
  import { ITemplateDocument } from './Types';
7
8
  /**
8
9
  * Get all the Template Documents associated to a particular Template.
@@ -13,7 +14,7 @@ import { ITemplateDocument } from './Types';
13
14
  * await TemplateDocument.getDocuments(templateID);
14
15
  * ```
15
16
  */
16
- export declare const getTemplateDocuments: (templateId: string) => Promise<ITemplateDocument[]>;
17
+ export declare const getTemplateDocuments: (endpoint: VerdocsEndpoint, templateId: string) => Promise<ITemplateDocument[]>;
17
18
  /**
18
19
  * Create a Document for a particular Template.
19
20
  *
@@ -23,7 +24,7 @@ export declare const getTemplateDocuments: (templateId: string) => Promise<ITemp
23
24
  * await TemplateDocument.createDocument(templateID, params);
24
25
  * ```
25
26
  */
26
- export declare const createTemplateDocument: (templateId: string, params: any) => Promise<ITemplateDocument>;
27
+ export declare const createTemplateDocument: (endpoint: VerdocsEndpoint, templateId: string, params: any) => Promise<ITemplateDocument>;
27
28
  /**
28
29
  * Get a specific Document.
29
30
  *
@@ -33,7 +34,7 @@ export declare const createTemplateDocument: (templateId: string, params: any) =
33
34
  * await TemplateDocument.getDocument(templateID, documentID);
34
35
  * ```
35
36
  */
36
- export declare const getTemplateDocument: (templateId: string, documentId: string) => Promise<ITemplateDocument>;
37
+ export declare const getTemplateDocument: (endpoint: VerdocsEndpoint, templateId: string, documentId: string) => Promise<ITemplateDocument>;
37
38
  /**
38
39
  * Delete a specific Document.
39
40
  *
@@ -43,4 +44,4 @@ export declare const getTemplateDocument: (templateId: string, documentId: strin
43
44
  * await TemplateDocument.deleteDocument(templateID, documentID);
44
45
  * ```
45
46
  */
46
- export declare const deleteTemplateDocument: (templateId: string, documentId: string) => Promise<any>;
47
+ export declare const deleteTemplateDocument: (endpoint: VerdocsEndpoint, templateId: string, documentId: string) => Promise<any>;
@@ -3,7 +3,6 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import { getEndpoint } from '../HTTP/Transport';
7
6
  /**
8
7
  * Get all the Template Documents associated to a particular Template.
9
8
  *
@@ -13,9 +12,9 @@ import { getEndpoint } from '../HTTP/Transport';
13
12
  * await TemplateDocument.getDocuments(templateID);
14
13
  * ```
15
14
  */
16
- export var getTemplateDocuments = function (templateId) {
17
- return getEndpoint()
18
- .api.get("/templates/".concat(templateId, "/documents/"))
15
+ export var getTemplateDocuments = function (endpoint, templateId) {
16
+ return endpoint.api //
17
+ .get("/templates/".concat(templateId, "/documents/"))
19
18
  .then(function (r) { return r.data; });
20
19
  };
21
20
  /**
@@ -27,9 +26,9 @@ export var getTemplateDocuments = function (templateId) {
27
26
  * await TemplateDocument.createDocument(templateID, params);
28
27
  * ```
29
28
  */
30
- export var createTemplateDocument = function (templateId, params) {
31
- return getEndpoint()
32
- .api.post("/templates/".concat(templateId, "/documents/"), params)
29
+ export var createTemplateDocument = function (endpoint, templateId, params) {
30
+ return endpoint.api //
31
+ .post("/templates/".concat(templateId, "/documents/"), params)
33
32
  .then(function (r) { return r.data; });
34
33
  };
35
34
  /**
@@ -41,9 +40,9 @@ export var createTemplateDocument = function (templateId, params) {
41
40
  * await TemplateDocument.getDocument(templateID, documentID);
42
41
  * ```
43
42
  */
44
- export var getTemplateDocument = function (templateId, documentId) {
45
- return getEndpoint()
46
- .api.get("/templates/".concat(templateId, "/documents/").concat(documentId))
43
+ export var getTemplateDocument = function (endpoint, templateId, documentId) {
44
+ return endpoint.api //
45
+ .get("/templates/".concat(templateId, "/documents/").concat(documentId))
47
46
  .then(function (r) { return r.data; });
48
47
  };
49
48
  /**
@@ -55,8 +54,8 @@ export var getTemplateDocument = function (templateId, documentId) {
55
54
  * await TemplateDocument.deleteDocument(templateID, documentID);
56
55
  * ```
57
56
  */
58
- export var deleteTemplateDocument = function (templateId, documentId) {
59
- return getEndpoint()
60
- .api.delete("/templates/".concat(templateId, "/documents/").concat(documentId))
57
+ export var deleteTemplateDocument = function (endpoint, templateId, documentId) {
58
+ return endpoint.api //
59
+ .delete("/templates/".concat(templateId, "/documents/").concat(documentId))
61
60
  .then(function (r) { return r.data; });
62
61
  };
@@ -5,6 +5,7 @@
5
5
  * @module
6
6
  */
7
7
  import { ITemplate, ITemplatesSearchResult, ITemplatesSummary } from './Types';
8
+ import { VerdocsEndpoint } from '../VerdocsEndpoint';
8
9
  export interface IGetTemplatesParams {
9
10
  is_starred?: boolean;
10
11
  is_creator?: boolean;
@@ -22,7 +23,7 @@ export interface IGetTemplatesParams {
22
23
  * await Templates.getTemplates({ is_organization: true });
23
24
  * ```
24
25
  */
25
- export declare const getTemplates: (params?: IGetTemplatesParams) => Promise<any[]>;
26
+ export declare const getTemplates: (endpoint: VerdocsEndpoint, params?: IGetTemplatesParams) => Promise<any[]>;
26
27
  /**
27
28
  * Get one template by its ID.
28
29
  *
@@ -32,7 +33,7 @@ export declare const getTemplates: (params?: IGetTemplatesParams) => Promise<any
32
33
  * const template = await Templates.getTemplate('83da3d70-7857-4392-b876-c4592a304bc9');
33
34
  * ```
34
35
  */
35
- export declare const getTemplate: (templateId: string) => Promise<any>;
36
+ export declare const getTemplate: (endpoint: VerdocsEndpoint, templateId: string) => Promise<any>;
36
37
  /**
37
38
  * Create a template.
38
39
  *
@@ -42,7 +43,7 @@ export declare const getTemplate: (templateId: string) => Promise<any>;
42
43
  * const newTemplate = await Templates.createTemplate({...});
43
44
  * ```
44
45
  */
45
- export declare const createTemplate: (params: any) => Promise<ITemplate>;
46
+ export declare const createTemplate: (endpoint: VerdocsEndpoint, params: any) => Promise<ITemplate>;
46
47
  /**
47
48
  * Update a template.
48
49
  *
@@ -52,7 +53,7 @@ export declare const createTemplate: (params: any) => Promise<ITemplate>;
52
53
  * const updatedTemplate = await Templates.updateTemplate('83da3d70-7857-4392-b876-c4592a304bc9', { name: 'New Name' });
53
54
  * ```
54
55
  */
55
- export declare const updateTemplate: (templateId: string, params: any) => Promise<ITemplate>;
56
+ export declare const updateTemplate: (endpoint: VerdocsEndpoint, templateId: string, params: any) => Promise<ITemplate>;
56
57
  /**
57
58
  * Search for templates matching various criteria.
58
59
  *
@@ -62,7 +63,7 @@ export declare const updateTemplate: (templateId: string, params: any) => Promis
62
63
  * const {result, page, total} = await Templates.search({ ... });
63
64
  * ```
64
65
  */
65
- export declare const searchTemplates: (params: any) => Promise<ITemplatesSearchResult>;
66
+ export declare const searchTemplates: (endpoint: VerdocsEndpoint, params: any) => Promise<ITemplatesSearchResult>;
66
67
  /**
67
68
  * Get a summary of template data, typically used to populate admin panel dashboard pages.
68
69
  *
@@ -72,4 +73,4 @@ export declare const searchTemplates: (params: any) => Promise<ITemplatesSearchR
72
73
  * const summary = await Templates.getSummary(0);
73
74
  * ```
74
75
  */
75
- export declare const getSummary: (page: number) => Promise<ITemplatesSummary>;
76
+ export declare const getSummary: (endpoint: VerdocsEndpoint, page: number) => Promise<ITemplatesSummary>;
@@ -40,7 +40,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
40
40
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
41
41
  }
42
42
  };
43
- import { getEndpoint } from '../HTTP/Transport';
44
43
  /**
45
44
  * Get all templates accessible by the caller, with optional filters.
46
45
  *
@@ -53,9 +52,9 @@ import { getEndpoint } from '../HTTP/Transport';
53
52
  * await Templates.getTemplates({ is_organization: true });
54
53
  * ```
55
54
  */
56
- export var getTemplates = function (params) {
57
- return getEndpoint()
58
- .api.get('/templates/', { params: params })
55
+ export var getTemplates = function (endpoint, params) {
56
+ return endpoint.api //
57
+ .get('/templates/', { params: params })
59
58
  .then(function (r) { return r.data; });
60
59
  };
61
60
  /**
@@ -67,9 +66,9 @@ export var getTemplates = function (params) {
67
66
  * const template = await Templates.getTemplate('83da3d70-7857-4392-b876-c4592a304bc9');
68
67
  * ```
69
68
  */
70
- export var getTemplate = function (templateId) {
71
- return getEndpoint()
72
- .api.get("/templates/".concat(templateId))
69
+ export var getTemplate = function (endpoint, templateId) {
70
+ return endpoint.api //
71
+ .get("/templates/".concat(templateId))
73
72
  .then(function (r) { return r.data; });
74
73
  };
75
74
  /**
@@ -81,9 +80,9 @@ export var getTemplate = function (templateId) {
81
80
  * const newTemplate = await Templates.createTemplate({...});
82
81
  * ```
83
82
  */
84
- export var createTemplate = function (params) {
85
- return getEndpoint()
86
- .api.post('/templates/', params)
83
+ export var createTemplate = function (endpoint, params) {
84
+ return endpoint.api //
85
+ .post('/templates/', params)
87
86
  .then(function (r) { return r.data; });
88
87
  };
89
88
  /**
@@ -95,9 +94,9 @@ export var createTemplate = function (params) {
95
94
  * const updatedTemplate = await Templates.updateTemplate('83da3d70-7857-4392-b876-c4592a304bc9', { name: 'New Name' });
96
95
  * ```
97
96
  */
98
- export var updateTemplate = function (templateId, params) {
99
- return getEndpoint()
100
- .api.put("/templates/".concat(templateId), params)
97
+ export var updateTemplate = function (endpoint, templateId, params) {
98
+ return endpoint.api //
99
+ .put("/templates/".concat(templateId), params)
101
100
  .then(function (r) { return r.data; });
102
101
  };
103
102
  /**
@@ -109,10 +108,10 @@ export var updateTemplate = function (templateId, params) {
109
108
  * const {result, page, total} = await Templates.search({ ... });
110
109
  * ```
111
110
  */
112
- export var searchTemplates = function (params) { return __awaiter(void 0, void 0, void 0, function () {
111
+ export var searchTemplates = function (endpoint, params) { return __awaiter(void 0, void 0, void 0, function () {
113
112
  return __generator(this, function (_a) {
114
- return [2 /*return*/, getEndpoint()
115
- .api.post('/templates/search', params)
113
+ return [2 /*return*/, endpoint.api //
114
+ .post('/templates/search', params)
116
115
  .then(function (r) { return r.data; })];
117
116
  });
118
117
  }); };
@@ -125,10 +124,10 @@ export var searchTemplates = function (params) { return __awaiter(void 0, void 0
125
124
  * const summary = await Templates.getSummary(0);
126
125
  * ```
127
126
  */
128
- export var getSummary = function (page) { return __awaiter(void 0, void 0, void 0, function () {
127
+ export var getSummary = function (endpoint, page) { return __awaiter(void 0, void 0, void 0, function () {
129
128
  return __generator(this, function (_a) {
130
- return [2 /*return*/, getEndpoint()
131
- .api.post('/templates/summary', { page: page })
129
+ return [2 /*return*/, endpoint.api //
130
+ .post('/templates/summary', { page: page })
132
131
  .then(function (r) { return r.data; })];
133
132
  });
134
133
  }); };
@@ -1,4 +1,5 @@
1
1
  import { IRole, ITag } from './Types';
2
+ import { VerdocsEndpoint } from '../VerdocsEndpoint';
2
3
  export interface IValidator {
3
4
  name: string;
4
5
  regex: string;
@@ -12,8 +13,8 @@ export interface IValidator {
12
13
  * await Documents.getDocuments(templateID);
13
14
  * ```
14
15
  */
15
- export declare const getValidators: () => Promise<IValidator[]>;
16
- export declare const getValidator: (validatorName: string) => Promise<IValidator>;
16
+ export declare const getValidators: (endpoint: VerdocsEndpoint) => Promise<IValidator[]>;
17
+ export declare const getValidator: (endpoint: VerdocsEndpoint, validatorName: string) => Promise<IValidator>;
17
18
  export declare const isValidEmail: (value: string) => boolean;
18
19
  export declare const isValidPhone: (value: string) => boolean;
19
20
  export declare const isValidRoleName: (value: string, roles: IRole[]) => boolean;
@@ -1,5 +1,4 @@
1
1
  import { simpleE164Validator } from '../Utils/Locales';
2
- import { getEndpoint } from '../HTTP/Transport';
3
2
  /**
4
3
  * Get all defined validators
5
4
  *
@@ -9,14 +8,14 @@ import { getEndpoint } from '../HTTP/Transport';
9
8
  * await Documents.getDocuments(templateID);
10
9
  * ```
11
10
  */
12
- export var getValidators = function () {
13
- return getEndpoint()
14
- .api.get('/validators')
11
+ export var getValidators = function (endpoint) {
12
+ return endpoint.api //
13
+ .get('/validators')
15
14
  .then(function (r) { return r.data; });
16
15
  };
17
- export var getValidator = function (validatorName) {
18
- return getEndpoint()
19
- .api.get("/validators/".concat(validatorName))
16
+ export var getValidator = function (endpoint, validatorName) {
17
+ return endpoint.api //
18
+ .get("/validators/".concat(validatorName))
20
19
  .then(function (r) { return r.data; });
21
20
  };
22
21
  var EmailRegEx = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
@@ -24,6 +23,4 @@ export var isValidEmail = function (value) { return EmailRegEx.test(value); };
24
23
  export var isValidPhone = function (value) { return simpleE164Validator(value); };
25
24
  export var isValidRoleName = function (value, roles) { return roles.findIndex(function (role) { return role.name === value; }) !== -1; };
26
25
  var TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
27
- export var isValidTag = function (value, tags) {
28
- return TagRegEx.test(value) || tags.findIndex(function (tag) { return tag.name === value; }) !== -1;
29
- };
26
+ export var isValidTag = function (value, tags) { return TagRegEx.test(value) || tags.findIndex(function (tag) { return tag.name === value; }) !== -1; };
package/Users/Auth.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { IActiveSession, IAuthenticateAppRequest, IAuthenticateUserRequest, TokenValidationRequest, UpdateEmailRequest } from './Types';
1
+ import { IAuthenticateAppRequest, IAuthenticateUserRequest } from './Types';
2
+ import { TokenValidationRequest, UpdateEmailRequest, UpdatePasswordRequest } from './Types';
2
3
  import { IAuthenticateResponse, TokenValidationResponse, UpdateEmailResponse, UpdatePasswordResponse } from './Types';
3
- import { UpdatePasswordRequest } from './Types';
4
- import { ISigningSession } from '../Documents/Types';
4
+ import { VerdocsEndpoint } from '../VerdocsEndpoint';
5
5
  /**
6
6
  * Authenticate to Verdocs via user/password authentication
7
7
  *
@@ -13,7 +13,7 @@ import { ISigningSession } from '../Documents/Types';
13
13
  * Transport.setAuthToken(accessToken);
14
14
  * ```
15
15
  */
16
- export declare const authenticateUser: (params: IAuthenticateUserRequest) => Promise<IAuthenticateResponse>;
16
+ export declare const authenticateUser: (endpoint: VerdocsEndpoint, params: IAuthenticateUserRequest) => Promise<IAuthenticateResponse>;
17
17
  /**
18
18
  * Authenticate to Verdocs via client ID / Secret authentication. **NOTE: This is only suitable for
19
19
  * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
@@ -29,7 +29,7 @@ export declare const authenticateUser: (params: IAuthenticateUserRequest) => Pro
29
29
  * Transport.setAuthToken(accessToken);
30
30
  * ```
31
31
  */
32
- export declare const authenticateApp: (params: IAuthenticateAppRequest) => Promise<IAuthenticateResponse>;
32
+ export declare const authenticateApp: (endpoint: VerdocsEndpoint, params: IAuthenticateAppRequest) => Promise<IAuthenticateResponse>;
33
33
  /**
34
34
  * Validate a token. Only Verdocs tokens will be accepted. Most applications can decode tokens locally,
35
35
  * because tokens will be validated when API calls are made anyway. However, high-security applications
@@ -44,7 +44,7 @@ export declare const authenticateApp: (params: IAuthenticateAppRequest) => Promi
44
44
  * }
45
45
  * ```
46
46
  */
47
- export declare const validateToken: (params: TokenValidationRequest) => Promise<TokenValidationResponse>;
47
+ export declare const validateToken: (endpoint: VerdocsEndpoint, params: TokenValidationRequest) => Promise<TokenValidationResponse>;
48
48
  /**
49
49
  * If called before the session expires, this will refresh the caller's session and tokens.
50
50
  *
@@ -56,7 +56,7 @@ export declare const validateToken: (params: TokenValidationRequest) => Promise<
56
56
  * Transport.setAuthToken(accessToken);
57
57
  * ```
58
58
  */
59
- export declare const refreshTokens: () => Promise<IAuthenticateResponse>;
59
+ export declare const refreshTokens: (endpoint: VerdocsEndpoint) => Promise<IAuthenticateResponse>;
60
60
  /**
61
61
  * Update the caller's password. To help prevent CSRF attack vectors, the user's old password and email address are required.
62
62
  *
@@ -69,7 +69,7 @@ export declare const refreshTokens: () => Promise<IAuthenticateResponse>;
69
69
  * }
70
70
  * ```
71
71
  */
72
- export declare const updatePassword: (params: UpdatePasswordRequest) => Promise<UpdatePasswordResponse>;
72
+ export declare const updatePassword: (endpoint: VerdocsEndpoint, params: UpdatePasswordRequest) => Promise<UpdatePasswordResponse>;
73
73
  /**
74
74
  * Update the caller's email address.
75
75
  *
@@ -79,17 +79,4 @@ export declare const updatePassword: (params: UpdatePasswordRequest) => Promise<
79
79
  * const {profiles} = await Auth.updateEmail({ email: newEmail });
80
80
  * ```
81
81
  */
82
- export declare const updateEmail: (params: UpdateEmailRequest) => Promise<UpdateEmailResponse>;
83
- export declare type TSession = IActiveSession | ISigningSession | null;
84
- /**
85
- * Parses and sets the active session, optionally persisting (brower-only, persists to localStorage).
86
- */
87
- export declare const setSession: (source: string, token: string | null, persist?: boolean) => TSession;
88
- /**
89
- * Load a session from localStorage
90
- */
91
- export declare const loadSession: (source: string) => IActiveSession | ISigningSession | null;
92
- /**
93
- * End the active session.
94
- */
95
- export declare const endSession: (source: string, persist?: boolean) => null;
82
+ export declare const updateEmail: (endpoint: VerdocsEndpoint, params: UpdateEmailRequest) => Promise<UpdateEmailResponse>;
package/Users/Auth.js CHANGED
@@ -1,5 +1,3 @@
1
- import { getEndpoint } from '../HTTP/Transport';
2
- import { decodeAccessTokenBody } from '../Utils/Token';
3
1
  /**
4
2
  * Authenticate to Verdocs via user/password authentication
5
3
  *
@@ -11,9 +9,9 @@ import { decodeAccessTokenBody } from '../Utils/Token';
11
9
  * Transport.setAuthToken(accessToken);
12
10
  * ```
13
11
  */
14
- export var authenticateUser = function (params) {
15
- return getEndpoint()
16
- .api.post('/authentication/login', params)
12
+ export var authenticateUser = function (endpoint, params) {
13
+ return endpoint.api //
14
+ .post('/authentication/login', params)
17
15
  .then(function (r) { return r.data; });
18
16
  };
19
17
  /**
@@ -31,9 +29,9 @@ export var authenticateUser = function (params) {
31
29
  * Transport.setAuthToken(accessToken);
32
30
  * ```
33
31
  */
34
- export var authenticateApp = function (params) {
35
- return getEndpoint()
36
- .api.post('/authentication/login_client', {}, { headers: params })
32
+ export var authenticateApp = function (endpoint, params) {
33
+ return endpoint.api //
34
+ .post('/authentication/login_client', {}, { headers: params })
37
35
  .then(function (r) { return r.data; });
38
36
  };
39
37
  /**
@@ -50,9 +48,9 @@ export var authenticateApp = function (params) {
50
48
  * }
51
49
  * ```
52
50
  */
53
- export var validateToken = function (params) {
54
- return getEndpoint()
55
- .api.post('/token/isValid', params)
51
+ export var validateToken = function (endpoint, params) {
52
+ return endpoint.api //
53
+ .post('/token/isValid', params)
56
54
  .then(function (r) { return r.data; });
57
55
  };
58
56
  /**
@@ -66,9 +64,9 @@ export var validateToken = function (params) {
66
64
  * Transport.setAuthToken(accessToken);
67
65
  * ```
68
66
  */
69
- export var refreshTokens = function () {
70
- return getEndpoint()
71
- .api.get('/token')
67
+ export var refreshTokens = function (endpoint) {
68
+ return endpoint.api //
69
+ .get('/token')
72
70
  .then(function (r) { return r.data; });
73
71
  };
74
72
  /**
@@ -83,9 +81,9 @@ export var refreshTokens = function () {
83
81
  * }
84
82
  * ```
85
83
  */
86
- export var updatePassword = function (params) {
87
- return getEndpoint()
88
- .api.put('/user/update_password', params)
84
+ export var updatePassword = function (endpoint, params) {
85
+ return endpoint.api //
86
+ .put('/user/update_password', params)
89
87
  .then(function (r) { return r.data; });
90
88
  };
91
89
  /**
@@ -97,59 +95,8 @@ export var updatePassword = function (params) {
97
95
  * const {profiles} = await Auth.updateEmail({ email: newEmail });
98
96
  * ```
99
97
  */
100
- export var updateEmail = function (params) {
101
- return getEndpoint()
102
- .api.put('/user/update_email', params)
98
+ export var updateEmail = function (endpoint, params) {
99
+ return endpoint.api //
100
+ .put('/user/update_email', params)
103
101
  .then(function (r) { return r.data; });
104
102
  };
105
- var clearSession = function (source, persist) {
106
- getEndpoint().setAuthorization(null);
107
- if (persist) {
108
- localStorage.removeItem(source);
109
- }
110
- return null;
111
- };
112
- /**
113
- * Parses and sets the active session, optionally persisting (brower-only, persists to localStorage).
114
- */
115
- export var setSession = function (source, token, persist) {
116
- if (persist === void 0) { persist = false; }
117
- if (token === null) {
118
- return clearSession(source, persist);
119
- }
120
- var session = decodeAccessTokenBody(token || '');
121
- if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
122
- return clearSession(source, persist);
123
- }
124
- if (persist) {
125
- localStorage.setItem(source, token);
126
- }
127
- getEndpoint().setAuthorization(token);
128
- return session;
129
- };
130
- /**
131
- * Load a session from localStorage
132
- */
133
- export var loadSession = function (source) {
134
- var token = localStorage.getItem(source);
135
- if (!token) {
136
- return null;
137
- }
138
- var session = decodeAccessTokenBody(token);
139
- if (!session) {
140
- return null;
141
- }
142
- if (session.exp && session.exp * 1000 < new Date().getTime()) {
143
- localStorage.removeItem(source);
144
- return null;
145
- }
146
- getEndpoint().setAuthorization(token);
147
- return session;
148
- };
149
- /**
150
- * End the active session.
151
- */
152
- export var endSession = function (source, persist) {
153
- if (persist === void 0) { persist = false; }
154
- return clearSession(source, persist);
155
- };
@@ -1 +1 @@
1
- export {};
1
+ export declare const billingPlaceholder: {};
package/Users/Billing.js CHANGED
@@ -1,2 +1,2 @@
1
- export {};
2
1
  // TODO
2
+ export var billingPlaceholder = {};
@@ -1 +1,2 @@
1
- export declare const getNotifications: () => Promise<any>;
1
+ import { VerdocsEndpoint } from '../VerdocsEndpoint';
2
+ export declare const getNotifications: (endpoint: VerdocsEndpoint) => Promise<any>;