@verdocs/js-sdk 1.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.
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/dist/Api/Auth.d.ts +71 -0
- package/dist/Api/Auth.js +24 -0
- package/dist/Api/Documents.d.ts +124 -0
- package/dist/Api/Documents.js +47 -0
- package/dist/Api/Endpoint.d.ts +2 -0
- package/dist/Api/Endpoint.js +9 -0
- package/dist/Api/Notifications.d.ts +1 -0
- package/dist/Api/Notifications.js +40 -0
- package/dist/Api/Templates.d.ts +33 -0
- package/dist/Api/Templates.js +55 -0
- package/dist/Api/Types.d.ts +182 -0
- package/dist/Api/Types.js +1 -0
- package/dist/Api/index.d.ts +2 -0
- package/dist/Api/index.js +2 -0
- package/dist/AuthManager.d.ts +14 -0
- package/dist/AuthManager.js +53 -0
- package/dist/Documents/Documents.d.ts +129 -0
- package/dist/Documents/Documents.js +52 -0
- package/dist/Documents/Stars.d.ts +2 -0
- package/dist/Documents/Stars.js +40 -0
- package/dist/Documents/Templates.d.ts +4 -0
- package/dist/Documents/Templates.js +46 -0
- package/dist/Documents/Types.d.ts +23 -0
- package/dist/Documents/Types.js +1 -0
- package/dist/Documents/index.d.ts +4 -0
- package/dist/Documents/index.js +4 -0
- package/dist/HTTP/Endpoint.d.ts +4 -0
- package/dist/HTTP/Endpoint.js +12 -0
- package/dist/HTTP/Transport.d.ts +3 -0
- package/dist/HTTP/Transport.js +12 -0
- package/dist/HTTP/Types.d.ts +1 -0
- package/dist/HTTP/Types.js +1 -0
- package/dist/HTTP/index.d.ts +2 -0
- package/dist/HTTP/index.js +2 -0
- package/dist/Organizations/ApiKeys.d.ts +5 -0
- package/dist/Organizations/ApiKeys.js +16 -0
- package/dist/Organizations/Groups.d.ts +7 -0
- package/dist/Organizations/Groups.js +22 -0
- package/dist/Organizations/Invitations.d.ts +7 -0
- package/dist/Organizations/Invitations.js +22 -0
- package/dist/Organizations/Members.d.ts +5 -0
- package/dist/Organizations/Members.js +16 -0
- package/dist/Organizations/Organizations.d.ts +7 -0
- package/dist/Organizations/Organizations.js +13 -0
- package/dist/Organizations/Types.d.ts +16 -0
- package/dist/Organizations/Types.js +1 -0
- package/dist/Organizations/Webhooks.d.ts +2 -0
- package/dist/Organizations/Webhooks.js +7 -0
- package/dist/Organizations/index.d.ts +7 -0
- package/dist/Organizations/index.js +7 -0
- package/dist/Users/Auth.d.ts +79 -0
- package/dist/Users/Auth.js +89 -0
- package/dist/Users/Billing.d.ts +1 -0
- package/dist/Users/Billing.js +2 -0
- package/dist/Users/Notifications.d.ts +1 -0
- package/dist/Users/Notifications.js +40 -0
- package/dist/Users/Profiles.d.ts +104 -0
- package/dist/Users/Profiles.js +114 -0
- package/dist/Users/Types.d.ts +106 -0
- package/dist/Users/Types.js +1 -0
- package/dist/Users/index.d.ts +5 -0
- package/dist/Users/index.js +5 -0
- package/dist/Utils/DateTime.d.ts +1 -0
- package/dist/Utils/DateTime.js +41 -0
- package/dist/Utils/index.d.ts +1 -0
- package/dist/Utils/index.js +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/package.json +52 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Endpoint } from '../HTTP/Transport';
|
|
2
|
+
/**
|
|
3
|
+
* Authenticate to Verdocs via user/password authentication
|
|
4
|
+
*
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import {Auth} from '@verdocs/js-sdk/Auth';
|
|
7
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
8
|
+
*
|
|
9
|
+
* const {accessToken} = await Auth.authenticateUser({ username: 'test@test.com', password: 'PASSWORD' });
|
|
10
|
+
* Endpoint.setAuthToken(accessToken);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export var authenticateUser = function (params) {
|
|
14
|
+
return Endpoint.post('/authentication/login', params).then(function (r) { return r.data; });
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Authenticate to Verdocs via client ID / Secret authentication. **NOTE: This is only suitable for
|
|
18
|
+
* NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
|
|
19
|
+
* that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
|
|
20
|
+
* hours. This expiration may change based on future security needs. Application developers are encouraged
|
|
21
|
+
* to check the `exp` expiration field in the response accessToken and renew tokens after they expire.
|
|
22
|
+
*
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import {Auth} from '@verdocs/js-sdk/Auth';
|
|
25
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
26
|
+
*
|
|
27
|
+
* const {accessToken} = await Auth.authenticateApp({ client_id: 'CLIENTID', client_secret: 'SECRET' });
|
|
28
|
+
* Endpoint.setAuthToken(accessToken);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export var authenticateApp = function (params) {
|
|
32
|
+
return Endpoint.post('/authentication/login_client', {}, { headers: params }).then(function (r) { return r.data; });
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Validate a token. Only Verdocs tokens will be accepted. Most applications can decode tokens locally,
|
|
36
|
+
* because tokens will be validated when API calls are made anyway. However, high-security applications
|
|
37
|
+
* may use this endpoint to check if a token has been revoked.
|
|
38
|
+
*
|
|
39
|
+
* ```typescript
|
|
40
|
+
* import {Auth} from '@verdocs/js-sdk/Auth';
|
|
41
|
+
*
|
|
42
|
+
* const {valid} = await Auth.validateToken({ token });
|
|
43
|
+
* if (!valid) {
|
|
44
|
+
* window.alert('Session invalid or expired. Please re-authenticate.');
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export var validateToken = function (params) {
|
|
49
|
+
return Endpoint.post('/token/isValid', params).then(function (r) { return r.data; });
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* If called before the session expires, this will refresh the caller's session and tokens.
|
|
53
|
+
*
|
|
54
|
+
* ```typescript
|
|
55
|
+
* import {Auth} from '@verdocs/js-sdk/Auth';
|
|
56
|
+
* import {Endpoint} from '@verdocs/js-sdk/HTTP';
|
|
57
|
+
*
|
|
58
|
+
* const {accessToken} = await Auth.refreshTokens();
|
|
59
|
+
* Auth.Endpoint.setAuthToken(accessToken);
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export var refreshTokens = function () { return Endpoint.get('/token').then(function (r) { return r.data; }); };
|
|
63
|
+
/**
|
|
64
|
+
* Update the caller's password. To help prevent CSRF attack vectors, the user's old password and email address are required.
|
|
65
|
+
*
|
|
66
|
+
* ```typescript
|
|
67
|
+
* import {Auth} from '@verdocs/js-sdk/Auth';
|
|
68
|
+
*
|
|
69
|
+
* const {status, message} = await Auth.updatePassword({ email, oldPassword, newPassword });
|
|
70
|
+
* if (status !== 'OK') {
|
|
71
|
+
* window.alert(`Password reset error: ${message}`);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export var updatePassword = function (params) {
|
|
76
|
+
return Endpoint.put('/user/update_password', params).then(function (r) { return r.data; });
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Update the caller's email address.
|
|
80
|
+
*
|
|
81
|
+
* ```typescript
|
|
82
|
+
* import {Auth} from '@verdocs/js-sdk/Auth';
|
|
83
|
+
*
|
|
84
|
+
* const {profiles} = await Auth.updateEmail({ email: newEmail });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export var updateEmail = function (params) {
|
|
88
|
+
return Endpoint.put('/user/update_email', params).then(function (r) { return r.data; });
|
|
89
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getNotifications: () => Promise<any>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { Endpoint } from '../HTTP/Transport';
|
|
38
|
+
export var getNotifications = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
39
|
+
return [2 /*return*/, Endpoint.get('/notifications').then(function (r) { return r.data; })];
|
|
40
|
+
}); }); };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ICreateProfileRequest, IGroup, IPermission, IProfile, IRole, ISwitchProfileResponse, IUpdateProfileRequest } from './Types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the user's available profiles. The current profile will be marked with `current: true`.
|
|
4
|
+
*
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
7
|
+
*
|
|
8
|
+
* const profiles = await Profiles.getProfiles()
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare const getProfiles: () => Promise<IProfile[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Get a list of system roles.
|
|
14
|
+
*
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
17
|
+
*
|
|
18
|
+
* const roles = await Profiles.getRoles();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const getRoles: () => Promise<IRole[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Get a list of system roles.
|
|
24
|
+
*
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
27
|
+
*
|
|
28
|
+
* const permissions = await Profiles.getPermissions();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const getPermissions: () => Promise<IPermission[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Create a profile. If the caller does not have a "current" profile set, the new profile will be made current.
|
|
34
|
+
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
37
|
+
*
|
|
38
|
+
* const newProfile = await Profiles.createProfile({ first_name: 'FIRST', last_name: 'LAST', email: 'EMAIL' });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const createProfile: (params: ICreateProfileRequest) => Promise<IProfile>;
|
|
42
|
+
/**
|
|
43
|
+
* Get a profile. The caller must have admin access to the given profile.
|
|
44
|
+
* TODO: Add a "public" profile endpoint for public pages
|
|
45
|
+
*
|
|
46
|
+
* ```typescript
|
|
47
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
48
|
+
*
|
|
49
|
+
* const profile = await Profiles.getProfile('PROFILEID');
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare const getProfile: (profileId: string) => Promise<IProfile>;
|
|
53
|
+
/**
|
|
54
|
+
* Get a profile's permissions. The caller must have admin access to the given profile.
|
|
55
|
+
*
|
|
56
|
+
* ```typescript
|
|
57
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
58
|
+
*
|
|
59
|
+
* const permissions = await Profiles.getProfilePermissions('PROFILEID');
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare const getProfilePermissions: (profileId: string) => Promise<IPermission[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Get a profile's groups.
|
|
65
|
+
*
|
|
66
|
+
* ```typescript
|
|
67
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
68
|
+
*
|
|
69
|
+
* const groups = await Profiles.getProfileGroups('PROFILEID');
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare const getProfileGroups: (profileId: string) => Promise<IGroup[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Switch the caller's "current" profile. The current profile is used for permissions checking and profile_id field settings
|
|
75
|
+
* for most operations in Verdocs. It is important to select the appropropriate profile before calling other API functions.
|
|
76
|
+
*
|
|
77
|
+
* ```typescript
|
|
78
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
79
|
+
*
|
|
80
|
+
* const newProfile = await Profiles.switchProfile('PROFILEID');
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare const switchProfile: (profileId: string) => Promise<ISwitchProfileResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Update a profile. For future expansion, the profile ID to update is required, but currently this must also be the
|
|
86
|
+
* "current" profile for the caller.
|
|
87
|
+
*
|
|
88
|
+
* ```typescript
|
|
89
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
90
|
+
*
|
|
91
|
+
* const newProfile = await Profiles.updateProfile('PROFILEID');
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare const updateProfile: (profileId: string, params: IUpdateProfileRequest) => Promise<IProfile>;
|
|
95
|
+
/**
|
|
96
|
+
* Delete a profile. If the requested profile is the caller's curent profile, the next available profile will be selected.
|
|
97
|
+
*
|
|
98
|
+
* ```typescript
|
|
99
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
100
|
+
*
|
|
101
|
+
* await Profiles.deleteProfile('PROFILEID');
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare const deleteProfile: (profileId: string) => Promise<any>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Endpoint } from '../HTTP/Transport';
|
|
2
|
+
/**
|
|
3
|
+
* Get the user's available profiles. The current profile will be marked with `current: true`.
|
|
4
|
+
*
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
7
|
+
*
|
|
8
|
+
* const profiles = await Profiles.getProfiles()
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export var getProfiles = function () { return Endpoint.get('/profiles').then(function (r) { return r.data; }); };
|
|
12
|
+
/**
|
|
13
|
+
* Get a list of system roles.
|
|
14
|
+
*
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
17
|
+
*
|
|
18
|
+
* const roles = await Profiles.getRoles();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export var getRoles = function () { return Endpoint.get('/roles').then(function (r) { return r.data; }); };
|
|
22
|
+
/**
|
|
23
|
+
* Get a list of system roles.
|
|
24
|
+
*
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
27
|
+
*
|
|
28
|
+
* const permissions = await Profiles.getPermissions();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export var getPermissions = function () { return Endpoint.get('/permissions').then(function (r) { return r.data; }); };
|
|
32
|
+
/**
|
|
33
|
+
* Create a profile. If the caller does not have a "current" profile set, the new profile will be made current.
|
|
34
|
+
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
37
|
+
*
|
|
38
|
+
* const newProfile = await Profiles.createProfile({ first_name: 'FIRST', last_name: 'LAST', email: 'EMAIL' });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export var createProfile = function (params) {
|
|
42
|
+
return Endpoint.post('/profiles', params).then(function (r) { return r.data; });
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Get a profile. The caller must have admin access to the given profile.
|
|
46
|
+
* TODO: Add a "public" profile endpoint for public pages
|
|
47
|
+
*
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
50
|
+
*
|
|
51
|
+
* const profile = await Profiles.getProfile('PROFILEID');
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export var getProfile = function (profileId) { return Endpoint.get("/profiles/" + profileId).then(function (r) { return r.data; }); };
|
|
55
|
+
/**
|
|
56
|
+
* Get a profile's permissions. The caller must have admin access to the given profile.
|
|
57
|
+
*
|
|
58
|
+
* ```typescript
|
|
59
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
60
|
+
*
|
|
61
|
+
* const permissions = await Profiles.getProfilePermissions('PROFILEID');
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export var getProfilePermissions = function (profileId) {
|
|
65
|
+
return Endpoint.get("/profiles/" + profileId + "/permissions").then(function (r) { return r.data; });
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Get a profile's groups.
|
|
69
|
+
*
|
|
70
|
+
* ```typescript
|
|
71
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
72
|
+
*
|
|
73
|
+
* const groups = await Profiles.getProfileGroups('PROFILEID');
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export var getProfileGroups = function (profileId) {
|
|
77
|
+
return Endpoint.get("/profiles/" + profileId + "/groups").then(function (r) { return r.data; });
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Switch the caller's "current" profile. The current profile is used for permissions checking and profile_id field settings
|
|
81
|
+
* for most operations in Verdocs. It is important to select the appropropriate profile before calling other API functions.
|
|
82
|
+
*
|
|
83
|
+
* ```typescript
|
|
84
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
85
|
+
*
|
|
86
|
+
* const newProfile = await Profiles.switchProfile('PROFILEID');
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export var switchProfile = function (profileId) {
|
|
90
|
+
return Endpoint.post("/profiles/" + profileId + "/switch").then(function (r) { return r.data; });
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Update a profile. For future expansion, the profile ID to update is required, but currently this must also be the
|
|
94
|
+
* "current" profile for the caller.
|
|
95
|
+
*
|
|
96
|
+
* ```typescript
|
|
97
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
98
|
+
*
|
|
99
|
+
* const newProfile = await Profiles.updateProfile('PROFILEID');
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export var updateProfile = function (profileId, params) {
|
|
103
|
+
return Endpoint.put("/profiles/" + profileId, params).then(function (r) { return r.data; });
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Delete a profile. If the requested profile is the caller's curent profile, the next available profile will be selected.
|
|
107
|
+
*
|
|
108
|
+
* ```typescript
|
|
109
|
+
* import {Profiles} from '@verdocs/js-sdk/Users';
|
|
110
|
+
*
|
|
111
|
+
* await Profiles.deleteProfile('PROFILEID');
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export var deleteProfile = function (profileId) { return Endpoint.delete("/profiles/" + profileId).then(function (r) { return r.data; }); };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { IOrganization } from '../Organizations/Types';
|
|
2
|
+
import { TRequestStatus } from '../HTTP/Types';
|
|
3
|
+
export declare type TPermission = 'org:view' | 'member:view' | 'org:update' | 'member:add' | 'member:remove' | 'admin:add' | 'admin:remove' | 'org:delete' | 'org:transfer' | 'owner:add' | 'owner:remove' | 'template:creator:create:personal' | 'template:creator:visibility' | 'template:creator:create:org' | 'template:member:read' | 'template:member:write' | 'template:member:visibility' | 'template:creator:delete' | 'template:member:delete' | 'template:creator:create:public' | 'rform:access' | 'rcommon:access' | 'org:list' | 'org:create';
|
|
4
|
+
export declare type TPlan = 'env:essential' | 'org:standard';
|
|
5
|
+
export declare type TRole = 'owner' | 'basic_user' | 'member';
|
|
6
|
+
export interface IGroup {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
organization_id: string;
|
|
10
|
+
parent_id: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface IProfile {
|
|
13
|
+
/** The unique ID of the profile */
|
|
14
|
+
id: string;
|
|
15
|
+
/**
|
|
16
|
+
* The Verdocs back-end currently uses Auth0 for authentication. This value is a unique ID assigned by Auth0 to the
|
|
17
|
+
* user. This is typically used to identify multiple profiles owned by a single user, but its implementation may
|
|
18
|
+
* change in the future and developers should not develop code based on this field at this time.
|
|
19
|
+
*/
|
|
20
|
+
user_id: string;
|
|
21
|
+
/** The profile's organization ID, or a global "Realster" organization that all personal profiles are members of. */
|
|
22
|
+
organization_id: string;
|
|
23
|
+
first_name: string;
|
|
24
|
+
last_name: string;
|
|
25
|
+
email: string;
|
|
26
|
+
phone: string | null;
|
|
27
|
+
/** If true, this is the caller's "currently selected" profile. All operations will performed "as" this profile. */
|
|
28
|
+
current: boolean;
|
|
29
|
+
/** The organization */
|
|
30
|
+
organization: IOrganization;
|
|
31
|
+
/** The permissions assigned to the profilel _NOTE: Only present in the "current" profile._ */
|
|
32
|
+
permissions?: TPermission[];
|
|
33
|
+
/** The roles assigned to the profilel _NOTE: Only present in the "current" profile._ */
|
|
34
|
+
roles?: TRole[];
|
|
35
|
+
/** The plans assigned to the profilel _NOTE: Only present in the "current" profile._ */
|
|
36
|
+
plans?: TPlan[];
|
|
37
|
+
/** The plans assigned to the profilel _NOTE: Only present in the "current" profile._ */
|
|
38
|
+
groups?: IGroup[];
|
|
39
|
+
}
|
|
40
|
+
export interface IRole {
|
|
41
|
+
/** Unique identifier for the role. */
|
|
42
|
+
id: string;
|
|
43
|
+
/** Display name for the role. */
|
|
44
|
+
name: string;
|
|
45
|
+
}
|
|
46
|
+
export interface IPermission {
|
|
47
|
+
/** Unique identifier for the permission. */
|
|
48
|
+
id: string;
|
|
49
|
+
/** Display name for the permission. */
|
|
50
|
+
name: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ICreateProfileRequest {
|
|
53
|
+
first_name: string;
|
|
54
|
+
last_name: string;
|
|
55
|
+
email: string;
|
|
56
|
+
phone?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface ISwitchProfileResponse {
|
|
59
|
+
profile: IProfile;
|
|
60
|
+
idToken: string;
|
|
61
|
+
accessToken: string;
|
|
62
|
+
refreshToken: string;
|
|
63
|
+
}
|
|
64
|
+
export interface IUpdateProfileRequest {
|
|
65
|
+
first_name?: string;
|
|
66
|
+
last_name?: string;
|
|
67
|
+
phone?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface IAuthenticateUserRequest {
|
|
70
|
+
username: string;
|
|
71
|
+
password: string;
|
|
72
|
+
}
|
|
73
|
+
export interface IAuthenticateAppRequest {
|
|
74
|
+
client_id: string;
|
|
75
|
+
client_secret: string;
|
|
76
|
+
}
|
|
77
|
+
export interface IAuthenticateResponse {
|
|
78
|
+
idToken: string;
|
|
79
|
+
accessToken: string;
|
|
80
|
+
refreshToken: string;
|
|
81
|
+
}
|
|
82
|
+
export interface TokenValidationRequest {
|
|
83
|
+
token: string;
|
|
84
|
+
}
|
|
85
|
+
export interface TokenValidationResponse {
|
|
86
|
+
/** True if the token is valid */
|
|
87
|
+
valid: boolean;
|
|
88
|
+
/** The decoded and validated body of the JWT */
|
|
89
|
+
payload: any;
|
|
90
|
+
}
|
|
91
|
+
export interface UpdatePasswordRequest {
|
|
92
|
+
email: string;
|
|
93
|
+
oldPassword: string;
|
|
94
|
+
newPassword: string;
|
|
95
|
+
}
|
|
96
|
+
export interface UpdatePasswordResponse {
|
|
97
|
+
status: TRequestStatus;
|
|
98
|
+
/** Success or failure message */
|
|
99
|
+
message: string;
|
|
100
|
+
}
|
|
101
|
+
export interface UpdateEmailRequest {
|
|
102
|
+
email: string;
|
|
103
|
+
}
|
|
104
|
+
export interface UpdateEmailResponse {
|
|
105
|
+
profiles: IProfile[];
|
|
106
|
+
}
|