@verdocs/js-sdk 3.1.2 → 3.1.4
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/Envelopes/Envelopes.d.ts +3 -1
- package/Envelopes/Permissions.d.ts +23 -0
- package/Envelopes/Permissions.js +33 -0
- package/Envelopes/Types.d.ts +45 -19
- package/Envelopes/Types.js +45 -1
- package/Envelopes/index.d.ts +1 -0
- package/Envelopes/index.js +1 -0
- package/Sessions/Types.d.ts +13 -2
- package/Sessions/index.d.ts +5 -1
- package/Sessions/index.js +6 -1
- package/Templates/Permissions.d.ts +73 -0
- package/Templates/Permissions.js +124 -0
- package/Templates/Types.d.ts +2 -12
- package/Templates/Types.js +0 -12
- package/Users/Types.d.ts +39 -4
- package/Users/Types.js +47 -1
- package/Utils/Strings.d.ts +4 -0
- package/Utils/Strings.js +4 -0
- package/Utils/Token.d.ts +2 -3
- package/Utils/index.d.ts +1 -0
- package/Utils/index.js +1 -0
- package/package.json +1 -1
package/Envelopes/Envelopes.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { IEnvelope, IEnvelopesSummary, IRecipient,
|
|
1
|
+
import { IEnvelope, IEnvelopesSummary, IRecipient, IDocumentFieldSettings, IEnvelopeDocument } from './Types';
|
|
2
2
|
import { ICreateEnvelopeRole, IEnvelopesSearchResult, ISigningSessionRequest } from './Types';
|
|
3
|
+
import { TEnvelopeUpdateResult, TEnvelopeStatus, TRecipientStatus } from './Types';
|
|
3
4
|
import { VerdocsEndpoint } from '../VerdocsEndpoint';
|
|
5
|
+
import { ISigningSession } from '../Sessions/Types';
|
|
4
6
|
export interface ICreateEnvelopeRequest {
|
|
5
7
|
template_id: string;
|
|
6
8
|
roles: ICreateEnvelopeRole[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Various helpers to identify available operations for an envelope by a user.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { IEnvelope } from './Types';
|
|
7
|
+
import { TSession } from '../Sessions/Types';
|
|
8
|
+
/**
|
|
9
|
+
* Check to see if the user owns the envelope.
|
|
10
|
+
*/
|
|
11
|
+
export declare const userIsEnvelopeOwner: (session: TSession, envelope: IEnvelope) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Check to see if the user owns the envelope.
|
|
14
|
+
*/
|
|
15
|
+
export declare const userIsEnvelopeRecipient: (session: TSession, envelope: IEnvelope) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Check to see if the user owns the envelope.
|
|
18
|
+
*/
|
|
19
|
+
export declare const userCanCancelEnvelope: (session: TSession, envelope: IEnvelope) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Check to see if the user owns the envelope.
|
|
22
|
+
*/
|
|
23
|
+
export declare const userCanFinishEnvelope: (session: TSession, envelope: IEnvelope) => boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Various helpers to identify available operations for an envelope by a user.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { EnvelopeStates } from './Types';
|
|
7
|
+
/**
|
|
8
|
+
* Check to see if the user owns the envelope.
|
|
9
|
+
*/
|
|
10
|
+
export var userIsEnvelopeOwner = function (session, envelope) { return envelope.profile_id === (session === null || session === void 0 ? void 0 : session.profile_id); };
|
|
11
|
+
/**
|
|
12
|
+
* Check to see if the user owns the envelope.
|
|
13
|
+
*/
|
|
14
|
+
export var userIsEnvelopeRecipient = function (session, envelope) { return envelope.profile_id === (session === null || session === void 0 ? void 0 : session.profile_id); };
|
|
15
|
+
/**
|
|
16
|
+
* Check to see if the user owns the envelope.
|
|
17
|
+
*/
|
|
18
|
+
export var userCanCancelEnvelope = function (session, envelope) {
|
|
19
|
+
return userIsEnvelopeOwner(session, envelope) &&
|
|
20
|
+
envelope.status !== EnvelopeStates.COMPLETE &&
|
|
21
|
+
envelope.status !== EnvelopeStates.DECLINED &&
|
|
22
|
+
envelope.status !== EnvelopeStates.CANCELED;
|
|
23
|
+
};
|
|
24
|
+
// export type TEnvelopeStatus = 'complete' | 'pending' | 'in progress' | 'declined' | 'canceled';
|
|
25
|
+
/**
|
|
26
|
+
* Check to see if the user owns the envelope.
|
|
27
|
+
*/
|
|
28
|
+
export var userCanFinishEnvelope = function (session, envelope) {
|
|
29
|
+
return userIsEnvelopeOwner(session, envelope) &&
|
|
30
|
+
envelope.status !== EnvelopeStates.COMPLETE &&
|
|
31
|
+
envelope.status !== EnvelopeStates.DECLINED &&
|
|
32
|
+
envelope.status !== EnvelopeStates.CANCELED;
|
|
33
|
+
};
|
package/Envelopes/Types.d.ts
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
import { IProfile } from '../Users/Types';
|
|
2
2
|
import { IPage } from '../Templates/Types';
|
|
3
|
-
export type TRecipientAction = 'submit' | 'decline' | 'prepare' | 'update';
|
|
4
3
|
export interface ISigningSessionRequest {
|
|
5
4
|
envelopeId: string;
|
|
6
5
|
roleId: string;
|
|
7
6
|
inviteCode: string;
|
|
8
7
|
}
|
|
9
|
-
export interface ISigningSession {
|
|
10
|
-
profile_id: string;
|
|
11
|
-
envelope_id: string;
|
|
12
|
-
role: string;
|
|
13
|
-
email: string;
|
|
14
|
-
access_key: {
|
|
15
|
-
id: string;
|
|
16
|
-
type: string;
|
|
17
|
-
};
|
|
18
|
-
iss: string;
|
|
19
|
-
aud: string;
|
|
20
|
-
exp: number;
|
|
21
|
-
iat: number;
|
|
22
|
-
}
|
|
23
8
|
export interface IInPersonAccessKey {
|
|
24
9
|
id: string;
|
|
25
10
|
created_at: string;
|
|
@@ -31,9 +16,37 @@ export interface IInPersonAccessKey {
|
|
|
31
16
|
first_used: string | null;
|
|
32
17
|
last_used: string | null;
|
|
33
18
|
}
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
19
|
+
export declare enum RecipientActions {
|
|
20
|
+
SUBMIT = "submit",
|
|
21
|
+
DECLINE = "decline",
|
|
22
|
+
PREPARE = "prepare",
|
|
23
|
+
UPDATE = "update"
|
|
24
|
+
}
|
|
25
|
+
export type TRecipientAction = `${RecipientActions}`;
|
|
26
|
+
export declare enum EnvelopeStates {
|
|
27
|
+
COMPLETE = "complete",
|
|
28
|
+
PENDING = "pending",
|
|
29
|
+
IN_PROGRESS = "in progress",
|
|
30
|
+
DECLINED = "declined",
|
|
31
|
+
CANCELED = "canceled"
|
|
32
|
+
}
|
|
33
|
+
export type TEnvelopeStatus = `${EnvelopeStates}`;
|
|
34
|
+
export declare enum RecipientStates {
|
|
35
|
+
INVITED = "invited",
|
|
36
|
+
OPENED = "opened",
|
|
37
|
+
SIGNED = "signed",
|
|
38
|
+
SUBMITTED = "submitted",
|
|
39
|
+
CANCELED = "canceled",
|
|
40
|
+
PENDING = "pending",
|
|
41
|
+
DECLINED = "declined"
|
|
42
|
+
}
|
|
43
|
+
export type TRecipientStatus = `${RecipientStates}`;
|
|
44
|
+
export declare enum RecipientTypes {
|
|
45
|
+
SIGNER = "signer",
|
|
46
|
+
CC = "cc",
|
|
47
|
+
APPROVER = "approver"
|
|
48
|
+
}
|
|
49
|
+
export type TRecipientType = `${RecipientTypes}`;
|
|
37
50
|
/**
|
|
38
51
|
* One entry in an envelope search result.
|
|
39
52
|
* NOTE: Many of the fields here are undefined unless "summary=true" is included in the search terms
|
|
@@ -176,7 +189,20 @@ export interface IDocumentFieldSettings {
|
|
|
176
189
|
maximum_checked?: number;
|
|
177
190
|
[key: string]: any;
|
|
178
191
|
}
|
|
179
|
-
export
|
|
192
|
+
export declare enum DocumentFieldTypes {
|
|
193
|
+
SIGNATURE = "signature",
|
|
194
|
+
INITIAL = "initial",
|
|
195
|
+
CHECKBOX_GROUP = "checkbox_group",
|
|
196
|
+
RADIO_BUTTON_GROUP = "radio_button_group",
|
|
197
|
+
TEXTBOX = "textbox",
|
|
198
|
+
TIMESTAMP = "timestamp",
|
|
199
|
+
DATE = "date",
|
|
200
|
+
DROPDOWN = "dropdown",
|
|
201
|
+
TEXTAREA = "textarea",
|
|
202
|
+
ATTACHMENT = "attachment",
|
|
203
|
+
PAYMENT = "payment"
|
|
204
|
+
}
|
|
205
|
+
export type TDocumentFieldType = `${DocumentFieldTypes}`;
|
|
180
206
|
export interface IDocumentField {
|
|
181
207
|
/**
|
|
182
208
|
* The ID of the document the field is for. For historical reasons, this is called `envelope_id` because documents
|
package/Envelopes/Types.js
CHANGED
|
@@ -1 +1,45 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var RecipientActions;
|
|
2
|
+
(function (RecipientActions) {
|
|
3
|
+
RecipientActions["SUBMIT"] = "submit";
|
|
4
|
+
RecipientActions["DECLINE"] = "decline";
|
|
5
|
+
RecipientActions["PREPARE"] = "prepare";
|
|
6
|
+
RecipientActions["UPDATE"] = "update";
|
|
7
|
+
})(RecipientActions || (RecipientActions = {}));
|
|
8
|
+
export var EnvelopeStates;
|
|
9
|
+
(function (EnvelopeStates) {
|
|
10
|
+
EnvelopeStates["COMPLETE"] = "complete";
|
|
11
|
+
EnvelopeStates["PENDING"] = "pending";
|
|
12
|
+
EnvelopeStates["IN_PROGRESS"] = "in progress";
|
|
13
|
+
EnvelopeStates["DECLINED"] = "declined";
|
|
14
|
+
EnvelopeStates["CANCELED"] = "canceled";
|
|
15
|
+
})(EnvelopeStates || (EnvelopeStates = {}));
|
|
16
|
+
export var RecipientStates;
|
|
17
|
+
(function (RecipientStates) {
|
|
18
|
+
RecipientStates["INVITED"] = "invited";
|
|
19
|
+
RecipientStates["OPENED"] = "opened";
|
|
20
|
+
RecipientStates["SIGNED"] = "signed";
|
|
21
|
+
RecipientStates["SUBMITTED"] = "submitted";
|
|
22
|
+
RecipientStates["CANCELED"] = "canceled";
|
|
23
|
+
RecipientStates["PENDING"] = "pending";
|
|
24
|
+
RecipientStates["DECLINED"] = "declined";
|
|
25
|
+
})(RecipientStates || (RecipientStates = {}));
|
|
26
|
+
export var RecipientTypes;
|
|
27
|
+
(function (RecipientTypes) {
|
|
28
|
+
RecipientTypes["SIGNER"] = "signer";
|
|
29
|
+
RecipientTypes["CC"] = "cc";
|
|
30
|
+
RecipientTypes["APPROVER"] = "approver";
|
|
31
|
+
})(RecipientTypes || (RecipientTypes = {}));
|
|
32
|
+
export var DocumentFieldTypes;
|
|
33
|
+
(function (DocumentFieldTypes) {
|
|
34
|
+
DocumentFieldTypes["SIGNATURE"] = "signature";
|
|
35
|
+
DocumentFieldTypes["INITIAL"] = "initial";
|
|
36
|
+
DocumentFieldTypes["CHECKBOX_GROUP"] = "checkbox_group";
|
|
37
|
+
DocumentFieldTypes["RADIO_BUTTON_GROUP"] = "radio_button_group";
|
|
38
|
+
DocumentFieldTypes["TEXTBOX"] = "textbox";
|
|
39
|
+
DocumentFieldTypes["TIMESTAMP"] = "timestamp";
|
|
40
|
+
DocumentFieldTypes["DATE"] = "date";
|
|
41
|
+
DocumentFieldTypes["DROPDOWN"] = "dropdown";
|
|
42
|
+
DocumentFieldTypes["TEXTAREA"] = "textarea";
|
|
43
|
+
DocumentFieldTypes["ATTACHMENT"] = "attachment";
|
|
44
|
+
DocumentFieldTypes["PAYMENT"] = "payment";
|
|
45
|
+
})(DocumentFieldTypes || (DocumentFieldTypes = {}));
|
package/Envelopes/index.d.ts
CHANGED
package/Envelopes/index.js
CHANGED
package/Sessions/Types.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ export interface ISigningSessionRequest {
|
|
|
4
4
|
roleId: string;
|
|
5
5
|
inviteCode: string;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* A Signing Session connects a caller to a role within an envelope, and can be used only for calls related to signing that envelope.
|
|
9
|
+
*/
|
|
8
10
|
export interface ISigningSession {
|
|
9
11
|
profile_id: string;
|
|
10
12
|
envelope_id: string;
|
|
@@ -20,7 +22,9 @@ export interface ISigningSession {
|
|
|
20
22
|
iat: number;
|
|
21
23
|
[key: string]: any;
|
|
22
24
|
}
|
|
23
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* A User Session connects a caller to a Verdocs profile, and can be used for any operations that profile may perform.
|
|
27
|
+
*/
|
|
24
28
|
export interface IUserSession {
|
|
25
29
|
sub: string;
|
|
26
30
|
email: string;
|
|
@@ -35,5 +39,12 @@ export interface IUserSession {
|
|
|
35
39
|
plans?: TPlan[];
|
|
36
40
|
[key: string]: any;
|
|
37
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Verdocs supports two types of authenticated sessions: User and Signing. Both behave similarly and have similar
|
|
44
|
+
* properties, but signing sessions only have access to a small set of signing-related functions.
|
|
45
|
+
*/
|
|
38
46
|
export type TSessionType = 'user' | 'signing';
|
|
47
|
+
/**
|
|
48
|
+
* An authenticated session within Verdocs, either for signing or regular user-based operations.
|
|
49
|
+
*/
|
|
39
50
|
export type TSession = IUserSession | ISigningSession | null;
|
package/Sessions/index.d.ts
CHANGED
package/Sessions/index.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Confirm whether the user has all of the specified permissions.
|
|
3
|
+
*/
|
|
4
|
+
export var userHasPermissions = function (session, permissions) {
|
|
5
|
+
return permissions.every(function (perm) { return ((session === null || session === void 0 ? void 0 : session.permissions) || []).includes(perm); });
|
|
6
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Various helpers to identify available operations for a template by a user.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { ITemplate, ITemplateSummaryEntry } from './Types';
|
|
7
|
+
import { TSession } from '../Sessions/Types';
|
|
8
|
+
/**
|
|
9
|
+
* Check to see if the user created the template.
|
|
10
|
+
*/
|
|
11
|
+
export declare const userIsTemplateCreator: (session: TSession, template: ITemplate | ITemplateSummaryEntry) => boolean | null;
|
|
12
|
+
/**
|
|
13
|
+
* Check to see if a template is "shared" with the user.
|
|
14
|
+
*/
|
|
15
|
+
export declare const userHasSharedTemplate: (session: TSession, template: ITemplate | ITemplateSummaryEntry) => boolean | null;
|
|
16
|
+
/**
|
|
17
|
+
* Check to see if the user can create a personal/private template.
|
|
18
|
+
*/
|
|
19
|
+
export declare const userCanCreatePersonalTemplate: (session: TSession) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Check to see if the user can create an org-shared template.
|
|
22
|
+
*/
|
|
23
|
+
export declare const userCanCreateOrgTemplate: (session: TSession) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Check to see if the user can create a public template.
|
|
26
|
+
*/
|
|
27
|
+
export declare const userCanCreatePublicTemplate: (session: TSession) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Check to see if the user can read/view a template.
|
|
30
|
+
*/
|
|
31
|
+
export declare const userCanReadTemplate: (session: TSession, template: ITemplate | ITemplateSummaryEntry) => boolean | null;
|
|
32
|
+
/**
|
|
33
|
+
* Check to see if the user can update a tempate.
|
|
34
|
+
*/
|
|
35
|
+
export declare const userCanUpdateTemplate: (session: TSession, template: ITemplate | ITemplateSummaryEntry) => boolean | null;
|
|
36
|
+
/**
|
|
37
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
38
|
+
*/
|
|
39
|
+
export declare const userCanMakeTemplatePrivate: (session: TSession, template: ITemplate | ITemplateSummaryEntry) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
42
|
+
*/
|
|
43
|
+
export declare const userCanMakeTemplateShared: (session: TSession, template: ITemplate | ITemplateSummaryEntry) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
46
|
+
*/
|
|
47
|
+
export declare const userCanMakeTemplatePublic: (session: TSession, template: ITemplate | ITemplateSummaryEntry) => boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
50
|
+
*/
|
|
51
|
+
export declare const userCanChangeOrgVisibility: (session: TSession, template: ITemplate | ITemplateSummaryEntry) => boolean | null;
|
|
52
|
+
/**
|
|
53
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
54
|
+
*/
|
|
55
|
+
export declare const userCanDeleteTemplate: (session: TSession, template: ITemplate | ITemplateSummaryEntry) => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Confirm whether the user can create an envelope using the specified template.
|
|
58
|
+
*/
|
|
59
|
+
export declare const userCanSendTemplate: (session: TSession, template: ITemplate | ITemplateSummaryEntry) => boolean | null;
|
|
60
|
+
/**
|
|
61
|
+
* Confirm whether the user can create a new template.
|
|
62
|
+
*/
|
|
63
|
+
export declare const userCanCreateTemplate: (session: TSession) => boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Check to see if the user can "build" the template (use the field builder). The user must have write access to the
|
|
66
|
+
* template, and the template must have at least one signer role.
|
|
67
|
+
*/
|
|
68
|
+
export declare const userCanBuildTemplate: (session: TSession, template: ITemplate) => boolean | null;
|
|
69
|
+
/**
|
|
70
|
+
* Check to see if the user can preview the template. The user must have read access to the template, the template must
|
|
71
|
+
* have at least one signer, and every signer must have at least one field.
|
|
72
|
+
*/
|
|
73
|
+
export declare const userCanPreviewTemplate: (session: TSession, template: ITemplate) => boolean | null;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Various helpers to identify available operations for a template by a user.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { TemplateSenderTypes } from './Types';
|
|
7
|
+
import { userHasPermissions } from '../Sessions';
|
|
8
|
+
import { Permissions } from '../Users/Types';
|
|
9
|
+
/**
|
|
10
|
+
* Check to see if the user created the template.
|
|
11
|
+
*/
|
|
12
|
+
export var userIsTemplateCreator = function (session, template) {
|
|
13
|
+
return session && template && session.profile_id === template.profile_id;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Check to see if a template is "shared" with the user.
|
|
17
|
+
*/
|
|
18
|
+
export var userHasSharedTemplate = function (session, template) {
|
|
19
|
+
return session && template && !template.is_personal && session.organization_id === template.organization_id;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Check to see if the user can create a personal/private template.
|
|
23
|
+
*/
|
|
24
|
+
export var userCanCreatePersonalTemplate = function (session) {
|
|
25
|
+
return userHasPermissions(session, [Permissions.TEMPLATE_CREATOR_CREATE_PERSONAL]);
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Check to see if the user can create an org-shared template.
|
|
29
|
+
*/
|
|
30
|
+
export var userCanCreateOrgTemplate = function (session) { return userHasPermissions(session, [Permissions.TEMPLATE_CREATOR_CREATE_ORG]); };
|
|
31
|
+
/**
|
|
32
|
+
* Check to see if the user can create a public template.
|
|
33
|
+
*/
|
|
34
|
+
export var userCanCreatePublicTemplate = function (session) { return userHasPermissions(session, [Permissions.TEMPLATE_CREATOR_CREATE_PUBLIC]); };
|
|
35
|
+
/**
|
|
36
|
+
* Check to see if the user can read/view a template.
|
|
37
|
+
*/
|
|
38
|
+
export var userCanReadTemplate = function (session, template) {
|
|
39
|
+
return template.is_public ||
|
|
40
|
+
userIsTemplateCreator(session, template) ||
|
|
41
|
+
(userHasSharedTemplate(session, template) && userHasPermissions(session, [Permissions.TEMPLATE_MEMBER_READ]));
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Check to see if the user can update a tempate.
|
|
45
|
+
*/
|
|
46
|
+
export var userCanUpdateTemplate = function (session, template) {
|
|
47
|
+
return userIsTemplateCreator(session, template) ||
|
|
48
|
+
(userHasSharedTemplate(session, template) &&
|
|
49
|
+
userHasPermissions(session, [Permissions.TEMPLATE_MEMBER_READ, Permissions.TEMPLATE_MEMBER_WRITE]));
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
53
|
+
*/
|
|
54
|
+
export var userCanMakeTemplatePrivate = function (session, template) {
|
|
55
|
+
return userIsTemplateCreator(session, template)
|
|
56
|
+
? userHasPermissions(session, [Permissions.TEMPLATE_CREATOR_CREATE_PERSONAL])
|
|
57
|
+
: userHasPermissions(session, [Permissions.TEMPLATE_MEMBER_VISIBILITY]);
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
61
|
+
*/
|
|
62
|
+
export var userCanMakeTemplateShared = function (session, template) {
|
|
63
|
+
return userIsTemplateCreator(session, template)
|
|
64
|
+
? userHasPermissions(session, [Permissions.TEMPLATE_CREATOR_CREATE_ORG])
|
|
65
|
+
: userHasPermissions(session, [Permissions.TEMPLATE_MEMBER_VISIBILITY]);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
69
|
+
*/
|
|
70
|
+
export var userCanMakeTemplatePublic = function (session, template) {
|
|
71
|
+
return userIsTemplateCreator(session, template)
|
|
72
|
+
? userHasPermissions(session, [Permissions.TEMPLATE_CREATOR_CREATE_PUBLIC])
|
|
73
|
+
: userHasPermissions(session, [Permissions.TEMPLATE_MEMBER_VISIBILITY]);
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
77
|
+
*/
|
|
78
|
+
export var userCanChangeOrgVisibility = function (session, template) {
|
|
79
|
+
return userIsTemplateCreator(session, template) && userHasPermissions(session, [Permissions.TEMPLATE_CREATOR_CREATE_PERSONAL]);
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
83
|
+
*/
|
|
84
|
+
export var userCanDeleteTemplate = function (session, template) {
|
|
85
|
+
return userIsTemplateCreator(session, template)
|
|
86
|
+
? userHasPermissions(session, [Permissions.TEMPLATE_CREATOR_DELETE])
|
|
87
|
+
: userHasPermissions(session, [Permissions.TEMPLATE_MEMBER_DELETE]);
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Confirm whether the user can create an envelope using the specified template.
|
|
91
|
+
*/
|
|
92
|
+
export var userCanSendTemplate = function (session, template) {
|
|
93
|
+
switch (template.sender) {
|
|
94
|
+
case TemplateSenderTypes.CREATOR:
|
|
95
|
+
return userIsTemplateCreator(session, template);
|
|
96
|
+
case TemplateSenderTypes.ORGANIZATION_MEMBER:
|
|
97
|
+
case TemplateSenderTypes.ORGANIZATION_MEMBER_AS_CREATOR:
|
|
98
|
+
return userIsTemplateCreator(session, template) || template.organization_id === (session === null || session === void 0 ? void 0 : session.organization_id);
|
|
99
|
+
default:
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Confirm whether the user can create a new template.
|
|
105
|
+
*/
|
|
106
|
+
export var userCanCreateTemplate = function (session) {
|
|
107
|
+
return userCanCreatePersonalTemplate(session) || userCanCreateOrgTemplate(session) || userCanCreatePublicTemplate(session);
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Check to see if the user can "build" the template (use the field builder). The user must have write access to the
|
|
111
|
+
* template, and the template must have at least one signer role.
|
|
112
|
+
*/
|
|
113
|
+
export var userCanBuildTemplate = function (session, template) {
|
|
114
|
+
return userCanUpdateTemplate(session, template) && (template.roles || []).filter(function (role) { return role.type === 'signer'; }).length > 0;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Check to see if the user can preview the template. The user must have read access to the template, the template must
|
|
118
|
+
* have at least one signer, and every signer must have at least one field.
|
|
119
|
+
*/
|
|
120
|
+
export var userCanPreviewTemplate = function (session, template) {
|
|
121
|
+
var hasPermission = userCanReadTemplate(session, template);
|
|
122
|
+
var signers = (template.roles || []).filter(function (role) { return role.type === 'signer'; });
|
|
123
|
+
return hasPermission && signers.length > 0 && signers.every(function (signer) { return (signer.fields || []).length > 0; });
|
|
124
|
+
};
|
package/Templates/Types.d.ts
CHANGED
|
@@ -124,18 +124,6 @@ export interface ITemplateSummaryEntry {
|
|
|
124
124
|
tag_name: string | null;
|
|
125
125
|
is_starred: boolean;
|
|
126
126
|
}
|
|
127
|
-
export type TTemplateSender = 'creator' | 'organization_member' | 'organization_member_as_creator' | 'everyone' | 'everyone_as_creator';
|
|
128
|
-
export declare enum TemplatePermissions {
|
|
129
|
-
TEMPLATE_CREATOR_CREATE_PUBLIC = "template:creator:create:public",
|
|
130
|
-
TEMPLATE_CREATOR_CREATE_ORG = "template:creator:create:org",
|
|
131
|
-
TEMPLATE_CREATOR_CREATE_PERSONAL = "template:creator:create:personal",
|
|
132
|
-
TEMPLATE_CREATOR_DELETE = "template:creator:delete",
|
|
133
|
-
TEMPLATE_CREATOR_VISIBILITY = "template:creator:visibility",
|
|
134
|
-
TEMPLATE_MEMBER_READ = "template:member:read",
|
|
135
|
-
TEMPLATE_MEMBER_WRITE = "template:member:write",
|
|
136
|
-
TEMPLATE_MEMBER_DELETE = "template:member:delete",
|
|
137
|
-
TEMPLATE_MEMBER_VISIBILITY = "template:member:visibility"
|
|
138
|
-
}
|
|
139
127
|
export declare enum TemplateSenderTypes {
|
|
140
128
|
CREATOR = "creator",
|
|
141
129
|
ORGANIZATION_MEMBER = "organization_member",
|
|
@@ -143,6 +131,7 @@ export declare enum TemplateSenderTypes {
|
|
|
143
131
|
EVERYONE = "everyone",
|
|
144
132
|
EVERYONE_AS_CREATOR = "everyone_as_creator"
|
|
145
133
|
}
|
|
134
|
+
export type TTemplateSender = `${TemplateSenderTypes}`;
|
|
146
135
|
export declare enum TemplateActions {
|
|
147
136
|
CREATE_PERSONAL = "create_personal",
|
|
148
137
|
CREATE_ORG = "create_org",
|
|
@@ -154,6 +143,7 @@ export declare enum TemplateActions {
|
|
|
154
143
|
CHANGE_VISIBILITY_ORG = "change_visibility_org",
|
|
155
144
|
CHANGE_VISIBILITY_PUBLIC = "change_visibility_public"
|
|
156
145
|
}
|
|
146
|
+
export type TTemplateAction = `${TemplateActions}`;
|
|
157
147
|
export interface ITemplateSearchParams {
|
|
158
148
|
id?: string;
|
|
159
149
|
name?: string;
|
package/Templates/Types.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
export var TemplatePermissions;
|
|
2
|
-
(function (TemplatePermissions) {
|
|
3
|
-
TemplatePermissions["TEMPLATE_CREATOR_CREATE_PUBLIC"] = "template:creator:create:public";
|
|
4
|
-
TemplatePermissions["TEMPLATE_CREATOR_CREATE_ORG"] = "template:creator:create:org";
|
|
5
|
-
TemplatePermissions["TEMPLATE_CREATOR_CREATE_PERSONAL"] = "template:creator:create:personal";
|
|
6
|
-
TemplatePermissions["TEMPLATE_CREATOR_DELETE"] = "template:creator:delete";
|
|
7
|
-
TemplatePermissions["TEMPLATE_CREATOR_VISIBILITY"] = "template:creator:visibility";
|
|
8
|
-
TemplatePermissions["TEMPLATE_MEMBER_READ"] = "template:member:read";
|
|
9
|
-
TemplatePermissions["TEMPLATE_MEMBER_WRITE"] = "template:member:write";
|
|
10
|
-
TemplatePermissions["TEMPLATE_MEMBER_DELETE"] = "template:member:delete";
|
|
11
|
-
TemplatePermissions["TEMPLATE_MEMBER_VISIBILITY"] = "template:member:visibility";
|
|
12
|
-
})(TemplatePermissions || (TemplatePermissions = {}));
|
|
13
1
|
export var TemplateSenderTypes;
|
|
14
2
|
(function (TemplateSenderTypes) {
|
|
15
3
|
TemplateSenderTypes["CREATOR"] = "creator";
|
package/Users/Types.d.ts
CHANGED
|
@@ -1,17 +1,52 @@
|
|
|
1
1
|
import { IGroup, IOrganization } from '../Organizations/Types';
|
|
2
2
|
export type TRequestStatus = 'OK' | 'ERROR';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Operation within Verdocs that users may perform.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export declare enum Permissions {
|
|
7
|
+
RCOMMON = "rcommon:access",
|
|
8
|
+
RFORM_ACCESS = "rform:access",
|
|
9
|
+
ORG_CREATE = "org:create",
|
|
10
|
+
ORG_VIEW = "org:view",
|
|
11
|
+
ORG_UPDATE = "org:update",
|
|
12
|
+
ORG_DELETE = "org:delete",
|
|
13
|
+
ORG_TRANSFER = "org:transfer",
|
|
14
|
+
ORG_LIST = "org:list",
|
|
15
|
+
OWNER_ADD = "owner:add",
|
|
16
|
+
OWNER_REMOVE = "owner:remove",
|
|
17
|
+
ADMIN_ADD = "admin:add",
|
|
18
|
+
ADMIN_REMOVE = "admin:remove",
|
|
19
|
+
MEMBER_VIEW = "member:view",
|
|
20
|
+
MEMBER_ADD = "member:add",
|
|
21
|
+
MEMBER_REMOVE = "member:remove",
|
|
22
|
+
TEMPLATE_CREATOR_DELETE = "template:creator:delete",
|
|
23
|
+
TEMPLATE_CREATOR_VISIBILITY = "template:creator:visibility",
|
|
24
|
+
TEMPLATE_CREATOR_CREATE_ORG = "template:creator:create:org",
|
|
25
|
+
TEMPLATE_CREATOR_CREATE_PUBLIC = "template:creator:create:public",
|
|
26
|
+
TEMPLATE_CREATOR_CREATE_PERSONAL = "template:creator:create:personal",
|
|
27
|
+
TEMPLATE_MEMBER_READ = "template:member:read",
|
|
28
|
+
TEMPLATE_MEMBER_WRITE = "template:member:write",
|
|
29
|
+
TEMPLATE_MEMBER_DELETE = "template:member:delete",
|
|
30
|
+
TEMPLATE_MEMBER_VISIBILITY = "template:member:visibility"
|
|
31
|
+
}
|
|
32
|
+
export type TPermission = `${Permissions}`;
|
|
7
33
|
/**
|
|
8
34
|
* Plans provide access to Verdocs product features.
|
|
9
35
|
*/
|
|
10
|
-
export
|
|
36
|
+
export declare enum Plans {
|
|
37
|
+
ENV_ESSENTIAL = "env:essential",
|
|
38
|
+
ORG_STANDARD = "org:standard"
|
|
39
|
+
}
|
|
40
|
+
export type TPlan = `${Plans}`;
|
|
11
41
|
/**
|
|
12
42
|
* Roles provide access to groups of permissions.
|
|
13
43
|
*/
|
|
14
|
-
export
|
|
44
|
+
export declare enum Roles {
|
|
45
|
+
OWNER = "owner",
|
|
46
|
+
BASIC_USER = "basic_user",
|
|
47
|
+
MEMBER = "member"
|
|
48
|
+
}
|
|
49
|
+
export type TRole = `${Roles}`;
|
|
15
50
|
export interface IProfile {
|
|
16
51
|
/** The unique ID of the profile */
|
|
17
52
|
id: string;
|
package/Users/Types.js
CHANGED
|
@@ -1 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Operation within Verdocs that users may perform.
|
|
3
|
+
*/
|
|
4
|
+
export var Permissions;
|
|
5
|
+
(function (Permissions) {
|
|
6
|
+
Permissions["RCOMMON"] = "rcommon:access";
|
|
7
|
+
Permissions["RFORM_ACCESS"] = "rform:access";
|
|
8
|
+
Permissions["ORG_CREATE"] = "org:create";
|
|
9
|
+
Permissions["ORG_VIEW"] = "org:view";
|
|
10
|
+
Permissions["ORG_UPDATE"] = "org:update";
|
|
11
|
+
Permissions["ORG_DELETE"] = "org:delete";
|
|
12
|
+
Permissions["ORG_TRANSFER"] = "org:transfer";
|
|
13
|
+
Permissions["ORG_LIST"] = "org:list";
|
|
14
|
+
Permissions["OWNER_ADD"] = "owner:add";
|
|
15
|
+
Permissions["OWNER_REMOVE"] = "owner:remove";
|
|
16
|
+
Permissions["ADMIN_ADD"] = "admin:add";
|
|
17
|
+
Permissions["ADMIN_REMOVE"] = "admin:remove";
|
|
18
|
+
Permissions["MEMBER_VIEW"] = "member:view";
|
|
19
|
+
Permissions["MEMBER_ADD"] = "member:add";
|
|
20
|
+
Permissions["MEMBER_REMOVE"] = "member:remove";
|
|
21
|
+
Permissions["TEMPLATE_CREATOR_DELETE"] = "template:creator:delete";
|
|
22
|
+
Permissions["TEMPLATE_CREATOR_VISIBILITY"] = "template:creator:visibility";
|
|
23
|
+
Permissions["TEMPLATE_CREATOR_CREATE_ORG"] = "template:creator:create:org";
|
|
24
|
+
Permissions["TEMPLATE_CREATOR_CREATE_PUBLIC"] = "template:creator:create:public";
|
|
25
|
+
Permissions["TEMPLATE_CREATOR_CREATE_PERSONAL"] = "template:creator:create:personal";
|
|
26
|
+
Permissions["TEMPLATE_MEMBER_READ"] = "template:member:read";
|
|
27
|
+
Permissions["TEMPLATE_MEMBER_WRITE"] = "template:member:write";
|
|
28
|
+
Permissions["TEMPLATE_MEMBER_DELETE"] = "template:member:delete";
|
|
29
|
+
Permissions["TEMPLATE_MEMBER_VISIBILITY"] = "template:member:visibility";
|
|
30
|
+
})(Permissions || (Permissions = {}));
|
|
31
|
+
/**
|
|
32
|
+
* Plans provide access to Verdocs product features.
|
|
33
|
+
*/
|
|
34
|
+
export var Plans;
|
|
35
|
+
(function (Plans) {
|
|
36
|
+
Plans["ENV_ESSENTIAL"] = "env:essential";
|
|
37
|
+
Plans["ORG_STANDARD"] = "org:standard";
|
|
38
|
+
})(Plans || (Plans = {}));
|
|
39
|
+
/**
|
|
40
|
+
* Roles provide access to groups of permissions.
|
|
41
|
+
*/
|
|
42
|
+
export var Roles;
|
|
43
|
+
(function (Roles) {
|
|
44
|
+
Roles["OWNER"] = "owner";
|
|
45
|
+
Roles["BASIC_USER"] = "basic_user";
|
|
46
|
+
Roles["MEMBER"] = "member";
|
|
47
|
+
})(Roles || (Roles = {}));
|
package/Utils/Strings.js
ADDED
package/Utils/Token.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IUserSession } from '../Sessions/Types';
|
|
1
|
+
import { TSession } from '../Sessions/Types';
|
|
3
2
|
/**
|
|
4
3
|
* Simplified, Node/Browser-safe alternative to atob() for base64 decoding.
|
|
5
4
|
* Modified from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
|
|
@@ -17,4 +16,4 @@ export declare const decodeJWTBody: (token: string) => any;
|
|
|
17
16
|
* application should distinguish between the two based on the context of the authenticated session, or by
|
|
18
17
|
* the presence of the `document_id` field, which will only be present for signing sessions.
|
|
19
18
|
*/
|
|
20
|
-
export declare const decodeAccessTokenBody: (token: string) =>
|
|
19
|
+
export declare const decodeAccessTokenBody: (token: string) => TSession;
|
package/Utils/index.d.ts
CHANGED
package/Utils/index.js
CHANGED