@internxt/sdk 1.4.77 → 1.5.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.d.ts +122 -122
- package/dist/auth/index.js +310 -310
- package/dist/auth/types.d.ts +54 -54
- package/dist/auth/types.js +26 -26
- package/dist/drive/backups/index.d.ts +18 -18
- package/dist/drive/backups/index.js +40 -40
- package/dist/drive/backups/types.d.ts +27 -27
- package/dist/drive/backups/types.js +2 -2
- package/dist/drive/index.d.ts +7 -7
- package/dist/drive/index.js +19 -19
- package/dist/drive/payments/index.d.ts +71 -53
- package/dist/drive/payments/index.js +208 -153
- package/dist/drive/payments/types.d.ts +176 -114
- package/dist/drive/payments/types.js +37 -32
- package/dist/drive/referrals/index.d.ts +19 -19
- package/dist/drive/referrals/index.js +50 -50
- package/dist/drive/referrals/types.d.ts +21 -21
- package/dist/drive/referrals/types.js +18 -18
- package/dist/drive/share/index.d.ts +319 -319
- package/dist/drive/share/index.js +540 -539
- package/dist/drive/share/types.d.ts +360 -358
- package/dist/drive/share/types.js +2 -2
- package/dist/drive/storage/index.d.ts +315 -195
- package/dist/drive/storage/index.js +630 -434
- package/dist/drive/storage/types.d.ts +473 -394
- package/dist/drive/storage/types.js +13 -13
- package/dist/drive/trash/index.d.ts +75 -55
- package/dist/drive/trash/index.js +180 -149
- package/dist/drive/trash/types.d.ts +29 -20
- package/dist/drive/trash/types.js +2 -2
- package/dist/drive/users/index.d.ts +135 -108
- package/dist/drive/users/index.js +204 -174
- package/dist/drive/users/types.d.ts +51 -43
- package/dist/drive/users/types.js +2 -2
- package/dist/index.d.ts +6 -5
- package/dist/index.js +31 -30
- package/dist/network/download.d.ts +8 -8
- package/dist/network/download.js +123 -123
- package/dist/network/errors/codes.d.ts +24 -24
- package/dist/network/errors/codes.js +48 -48
- package/dist/network/errors/context.d.ts +35 -35
- package/dist/network/errors/context.js +39 -39
- package/dist/network/errors/download.d.ts +4 -4
- package/dist/network/errors/download.js +48 -48
- package/dist/network/errors/index.d.ts +3 -3
- package/dist/network/errors/index.js +15 -15
- package/dist/network/errors/upload.d.ts +13 -13
- package/dist/network/errors/upload.js +78 -78
- package/dist/network/index.d.ts +70 -71
- package/dist/network/index.js +311 -310
- package/dist/network/types.d.ts +102 -102
- package/dist/network/types.js +18 -18
- package/dist/network/upload.d.ts +4 -4
- package/dist/network/upload.js +159 -159
- package/dist/photos/devices/index.d.ts +10 -10
- package/dist/photos/devices/index.js +79 -79
- package/dist/photos/index.d.ts +17 -17
- package/dist/photos/index.js +52 -52
- package/dist/photos/photos/index.d.ts +60 -60
- package/dist/photos/photos/index.js +225 -225
- package/dist/photos/shares/index.d.ts +8 -8
- package/dist/photos/shares/index.js +34 -34
- package/dist/photos/types.d.ts +154 -154
- package/dist/photos/types.js +19 -19
- package/dist/photos/users/index.d.ts +7 -7
- package/dist/photos/users/index.js +46 -46
- package/dist/shared/headers/index.d.ts +21 -18
- package/dist/shared/headers/index.js +79 -69
- package/dist/shared/http/client.d.ts +85 -85
- package/dist/shared/http/client.js +172 -181
- package/dist/shared/http/types.d.ts +7 -7
- package/dist/shared/http/types.js +2 -2
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.js +13 -13
- package/dist/shared/types/apiConnection.d.ts +12 -11
- package/dist/shared/types/apiConnection.js +2 -2
- package/dist/shared/types/appsumo.d.ts +16 -16
- package/dist/shared/types/appsumo.js +12 -12
- package/dist/shared/types/errors.d.ts +5 -4
- package/dist/shared/types/errors.js +28 -27
- package/dist/shared/types/teams.d.ts +9 -9
- package/dist/shared/types/teams.js +2 -2
- package/dist/shared/types/userSettings.d.ts +29 -27
- package/dist/shared/types/userSettings.js +2 -2
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +25 -25
- package/dist/workspaces/index.d.ts +176 -0
- package/dist/workspaces/index.js +415 -0
- package/dist/workspaces/index.test.d.ts +1 -0
- package/dist/workspaces/index.test.js +903 -0
- package/dist/workspaces/types.d.ts +291 -0
- package/dist/workspaces/types.js +2 -0
- package/package.json +1 -1
|
@@ -1,108 +1,135 @@
|
|
|
1
|
-
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export * as UserTypes from './types';
|
|
5
|
-
export declare class Users {
|
|
6
|
-
private readonly client;
|
|
7
|
-
private readonly appDetails;
|
|
8
|
-
private readonly apiSecurity;
|
|
9
|
-
static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity): Users;
|
|
10
|
-
private constructor();
|
|
11
|
-
/**
|
|
12
|
-
* Sends an invitation to the specified email
|
|
13
|
-
* @param email
|
|
14
|
-
*/
|
|
15
|
-
sendInvitation(email: string): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Initialize basic state of user and returns data after registration process
|
|
18
|
-
* @param email
|
|
19
|
-
* @param mnemonic
|
|
20
|
-
*/
|
|
21
|
-
initialize(email: string, mnemonic: string): Promise<InitializeUserResponse>;
|
|
22
|
-
/**
|
|
23
|
-
* Returns fresh data of the user
|
|
24
|
-
*/
|
|
25
|
-
refreshUser(): Promise<{
|
|
26
|
-
user: UserSettings;
|
|
27
|
-
token: string;
|
|
28
|
-
}>;
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
*
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
*
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
1
|
+
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
|
|
2
|
+
import { UserSettings } from '../../shared/types/userSettings';
|
|
3
|
+
import { ChangePasswordPayload, ChangePasswordPayloadNew, CheckChangeEmailExpirationResponse, FriendInvite, InitializeUserResponse, PreCreateUserResponse, UpdateProfilePayload, UserPublicKeyResponse, VerifyEmailChangeResponse } from './types';
|
|
4
|
+
export * as UserTypes from './types';
|
|
5
|
+
export declare class Users {
|
|
6
|
+
private readonly client;
|
|
7
|
+
private readonly appDetails;
|
|
8
|
+
private readonly apiSecurity;
|
|
9
|
+
static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity): Users;
|
|
10
|
+
private constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Sends an invitation to the specified email
|
|
13
|
+
* @param email
|
|
14
|
+
*/
|
|
15
|
+
sendInvitation(email: string): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Initialize basic state of user and returns data after registration process
|
|
18
|
+
* @param email
|
|
19
|
+
* @param mnemonic
|
|
20
|
+
*/
|
|
21
|
+
initialize(email: string, mnemonic: string): Promise<InitializeUserResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns fresh data of the user
|
|
24
|
+
*/
|
|
25
|
+
refreshUser(): Promise<{
|
|
26
|
+
user: UserSettings;
|
|
27
|
+
token: string;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves the user data for a specific user identified by the uuid.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} params.userUuid - The UUID of the user.
|
|
33
|
+
* @return {Promise<Object>} A promise that resolves to an object containing the user data.
|
|
34
|
+
* The object has the following properties:
|
|
35
|
+
* - `newToken` (string): The new token of the user.
|
|
36
|
+
* - `oldToken` (string): The old drive token of the user.
|
|
37
|
+
* - `user` (UserSettings): The user data.
|
|
38
|
+
*/
|
|
39
|
+
getUserData({ userUuid }: {
|
|
40
|
+
userUuid: string;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
newToken: string;
|
|
43
|
+
oldToken: string;
|
|
44
|
+
user: UserSettings;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Updates the authentication credentials and invalidates previous tokens (Legacy backend (drive-server))
|
|
48
|
+
* @param payload
|
|
49
|
+
*
|
|
50
|
+
* @returns {Promise<{token: string, newToken: string}>} A promise that returns new tokens for this user.
|
|
51
|
+
*/
|
|
52
|
+
changePasswordLegacy(payload: ChangePasswordPayload): Promise<{
|
|
53
|
+
token: string;
|
|
54
|
+
newToken: string;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Updates the authentication credentials and invalidates previous tokens (New backend (drive-server-wip))
|
|
58
|
+
* @param payload
|
|
59
|
+
*
|
|
60
|
+
* @returns {Promise<{token: string, newToken: string}>} A promise that returns new tokens for this user.
|
|
61
|
+
*/
|
|
62
|
+
changePassword(payload: ChangePasswordPayloadNew): Promise<{
|
|
63
|
+
token: string;
|
|
64
|
+
newToken: string;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Pre registers an email
|
|
68
|
+
* @param email
|
|
69
|
+
* @returns {Promise<PreCreateUserResponse>} A promise that returns a public key for this user.
|
|
70
|
+
*/
|
|
71
|
+
preRegister(email: string): Promise<PreCreateUserResponse>;
|
|
72
|
+
/**
|
|
73
|
+
* Updates a user profile
|
|
74
|
+
* @param payload
|
|
75
|
+
*/
|
|
76
|
+
updateProfile(payload: UpdateProfilePayload): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Updates a user avatar
|
|
79
|
+
* @param payload
|
|
80
|
+
*/
|
|
81
|
+
updateAvatar(payload: {
|
|
82
|
+
avatar: Blob;
|
|
83
|
+
}): Promise<{
|
|
84
|
+
avatar: string;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Delete current user avatar
|
|
88
|
+
*/
|
|
89
|
+
deleteAvatar(): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Gets all friend invites created by this user
|
|
92
|
+
*/
|
|
93
|
+
getFriendInvites(): Promise<FriendInvite[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Sends verification email
|
|
96
|
+
*/
|
|
97
|
+
sendVerificationEmail(): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Verifies user email
|
|
100
|
+
*/
|
|
101
|
+
verifyEmail(payload: {
|
|
102
|
+
verificationToken: string;
|
|
103
|
+
}): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Change user email by new email
|
|
106
|
+
*
|
|
107
|
+
* @param {string} newEmail
|
|
108
|
+
*
|
|
109
|
+
* @returns {Promise<void>}
|
|
110
|
+
*/
|
|
111
|
+
changeUserEmail(newEmail: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Verify user email change
|
|
114
|
+
*
|
|
115
|
+
* @param {string} encryptedAttemptChangeEmailId
|
|
116
|
+
*
|
|
117
|
+
* @returns {Promise<VerifyEmailChangeResponse>}
|
|
118
|
+
*/
|
|
119
|
+
verifyEmailChange(encryptedAttemptChangeEmailId: string): Promise<VerifyEmailChangeResponse>;
|
|
120
|
+
/**
|
|
121
|
+
* Check if user email change verification link is expired
|
|
122
|
+
*
|
|
123
|
+
* @param {string} encryptedAttemptChangeEmailId
|
|
124
|
+
*
|
|
125
|
+
* @returns {Promise<CheckChangeEmailExpirationResponse>}
|
|
126
|
+
*/
|
|
127
|
+
checkChangeEmailExpiration(encryptedAttemptChangeEmailId: string): Promise<CheckChangeEmailExpirationResponse>;
|
|
128
|
+
/**
|
|
129
|
+
* Get public key of given email
|
|
130
|
+
*/
|
|
131
|
+
getPublicKeyByEmail({ email }: {
|
|
132
|
+
email: string;
|
|
133
|
+
}): Promise<UserPublicKeyResponse>;
|
|
134
|
+
private headers;
|
|
135
|
+
}
|
|
@@ -1,174 +1,204 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.Users = exports.UserTypes = void 0;
|
|
23
|
-
var headers_1 = require("../../shared/headers");
|
|
24
|
-
var client_1 = require("../../shared/http/client");
|
|
25
|
-
exports.UserTypes = __importStar(require("./types"));
|
|
26
|
-
var Users = /** @class */ (function () {
|
|
27
|
-
function Users(apiUrl, appDetails, apiSecurity) {
|
|
28
|
-
this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback);
|
|
29
|
-
this.appDetails = appDetails;
|
|
30
|
-
this.apiSecurity = apiSecurity;
|
|
31
|
-
}
|
|
32
|
-
Users.client = function (apiUrl, appDetails, apiSecurity) {
|
|
33
|
-
return new Users(apiUrl, appDetails, apiSecurity);
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Sends an invitation to the specified email
|
|
37
|
-
* @param email
|
|
38
|
-
*/
|
|
39
|
-
Users.prototype.sendInvitation = function (email) {
|
|
40
|
-
return this.client.post('/user/invite', {
|
|
41
|
-
email: email,
|
|
42
|
-
}, this.headers());
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Initialize basic state of user and returns data after registration process
|
|
46
|
-
* @param email
|
|
47
|
-
* @param mnemonic
|
|
48
|
-
*/
|
|
49
|
-
Users.prototype.initialize = function (email, mnemonic) {
|
|
50
|
-
return this.client
|
|
51
|
-
.post('/initialize', {
|
|
52
|
-
email: email,
|
|
53
|
-
mnemonic: mnemonic,
|
|
54
|
-
}, this.headers())
|
|
55
|
-
.then(function (data) {
|
|
56
|
-
return data.user;
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Returns fresh data of the user
|
|
61
|
-
*/
|
|
62
|
-
Users.prototype.refreshUser = function () {
|
|
63
|
-
return this.client.get('/user/refresh', this.headers());
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* @returns {Promise<
|
|
84
|
-
*/
|
|
85
|
-
Users.prototype.
|
|
86
|
-
return this.client.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
*
|
|
114
|
-
*/
|
|
115
|
-
Users.prototype.
|
|
116
|
-
return this.client.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
*
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
*
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
*
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.Users = exports.UserTypes = void 0;
|
|
23
|
+
var headers_1 = require("../../shared/headers");
|
|
24
|
+
var client_1 = require("../../shared/http/client");
|
|
25
|
+
exports.UserTypes = __importStar(require("./types"));
|
|
26
|
+
var Users = /** @class */ (function () {
|
|
27
|
+
function Users(apiUrl, appDetails, apiSecurity) {
|
|
28
|
+
this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback);
|
|
29
|
+
this.appDetails = appDetails;
|
|
30
|
+
this.apiSecurity = apiSecurity;
|
|
31
|
+
}
|
|
32
|
+
Users.client = function (apiUrl, appDetails, apiSecurity) {
|
|
33
|
+
return new Users(apiUrl, appDetails, apiSecurity);
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Sends an invitation to the specified email
|
|
37
|
+
* @param email
|
|
38
|
+
*/
|
|
39
|
+
Users.prototype.sendInvitation = function (email) {
|
|
40
|
+
return this.client.post('/user/invite', {
|
|
41
|
+
email: email,
|
|
42
|
+
}, this.headers());
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Initialize basic state of user and returns data after registration process
|
|
46
|
+
* @param email
|
|
47
|
+
* @param mnemonic
|
|
48
|
+
*/
|
|
49
|
+
Users.prototype.initialize = function (email, mnemonic) {
|
|
50
|
+
return this.client
|
|
51
|
+
.post('/initialize', {
|
|
52
|
+
email: email,
|
|
53
|
+
mnemonic: mnemonic,
|
|
54
|
+
}, this.headers())
|
|
55
|
+
.then(function (data) {
|
|
56
|
+
return data.user;
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Returns fresh data of the user
|
|
61
|
+
*/
|
|
62
|
+
Users.prototype.refreshUser = function () {
|
|
63
|
+
return this.client.get('/user/refresh', this.headers());
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves the user data for a specific user identified by the uuid.
|
|
67
|
+
*
|
|
68
|
+
* @param {string} params.userUuid - The UUID of the user.
|
|
69
|
+
* @return {Promise<Object>} A promise that resolves to an object containing the user data.
|
|
70
|
+
* The object has the following properties:
|
|
71
|
+
* - `newToken` (string): The new token of the user.
|
|
72
|
+
* - `oldToken` (string): The old drive token of the user.
|
|
73
|
+
* - `user` (UserSettings): The user data.
|
|
74
|
+
*/
|
|
75
|
+
Users.prototype.getUserData = function (_a) {
|
|
76
|
+
var userUuid = _a.userUuid;
|
|
77
|
+
return this.client.get("/users/c/" + userUuid, this.headers());
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Updates the authentication credentials and invalidates previous tokens (Legacy backend (drive-server))
|
|
81
|
+
* @param payload
|
|
82
|
+
*
|
|
83
|
+
* @returns {Promise<{token: string, newToken: string}>} A promise that returns new tokens for this user.
|
|
84
|
+
*/
|
|
85
|
+
Users.prototype.changePasswordLegacy = function (payload) {
|
|
86
|
+
return this.client.patch('/user/password', {
|
|
87
|
+
currentPassword: payload.currentEncryptedPassword,
|
|
88
|
+
newPassword: payload.newEncryptedPassword,
|
|
89
|
+
newSalt: payload.newEncryptedSalt,
|
|
90
|
+
mnemonic: payload.encryptedMnemonic,
|
|
91
|
+
privateKey: payload.encryptedPrivateKey,
|
|
92
|
+
}, this.headers());
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Updates the authentication credentials and invalidates previous tokens (New backend (drive-server-wip))
|
|
96
|
+
* @param payload
|
|
97
|
+
*
|
|
98
|
+
* @returns {Promise<{token: string, newToken: string}>} A promise that returns new tokens for this user.
|
|
99
|
+
*/
|
|
100
|
+
Users.prototype.changePassword = function (payload) {
|
|
101
|
+
return this.client.patch('/users/password', {
|
|
102
|
+
currentPassword: payload.currentEncryptedPassword,
|
|
103
|
+
newPassword: payload.newEncryptedPassword,
|
|
104
|
+
newSalt: payload.newEncryptedSalt,
|
|
105
|
+
mnemonic: payload.encryptedMnemonic,
|
|
106
|
+
privateKey: payload.encryptedPrivateKey,
|
|
107
|
+
encryptVersion: payload.encryptVersion,
|
|
108
|
+
}, this.headers());
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Pre registers an email
|
|
112
|
+
* @param email
|
|
113
|
+
* @returns {Promise<PreCreateUserResponse>} A promise that returns a public key for this user.
|
|
114
|
+
*/
|
|
115
|
+
Users.prototype.preRegister = function (email) {
|
|
116
|
+
return this.client.post('/users/pre-create', {
|
|
117
|
+
email: email,
|
|
118
|
+
}, this.headers());
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Updates a user profile
|
|
122
|
+
* @param payload
|
|
123
|
+
*/
|
|
124
|
+
Users.prototype.updateProfile = function (payload) {
|
|
125
|
+
return this.client.patch('/user/profile', payload, this.headers());
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Updates a user avatar
|
|
129
|
+
* @param payload
|
|
130
|
+
*/
|
|
131
|
+
Users.prototype.updateAvatar = function (payload) {
|
|
132
|
+
var formData = new FormData();
|
|
133
|
+
formData.set('avatar', payload.avatar);
|
|
134
|
+
return this.client.put('/user/avatar', formData, this.headers());
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Delete current user avatar
|
|
138
|
+
*/
|
|
139
|
+
Users.prototype.deleteAvatar = function () {
|
|
140
|
+
return this.client.delete('/user/avatar', this.headers());
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Gets all friend invites created by this user
|
|
144
|
+
*/
|
|
145
|
+
Users.prototype.getFriendInvites = function () {
|
|
146
|
+
return this.client.get('/user/invite', this.headers());
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Sends verification email
|
|
150
|
+
*/
|
|
151
|
+
Users.prototype.sendVerificationEmail = function () {
|
|
152
|
+
return this.client.post('/user/sendVerificationEmail', {}, this.headers());
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Verifies user email
|
|
156
|
+
*/
|
|
157
|
+
Users.prototype.verifyEmail = function (payload) {
|
|
158
|
+
return this.client.post('/user/verifyEmail', payload, this.headers());
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Change user email by new email
|
|
162
|
+
*
|
|
163
|
+
* @param {string} newEmail
|
|
164
|
+
*
|
|
165
|
+
* @returns {Promise<void>}
|
|
166
|
+
*/
|
|
167
|
+
Users.prototype.changeUserEmail = function (newEmail) {
|
|
168
|
+
return this.client.post('users/attempt-change-email', {
|
|
169
|
+
newEmail: newEmail,
|
|
170
|
+
}, this.headers());
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Verify user email change
|
|
174
|
+
*
|
|
175
|
+
* @param {string} encryptedAttemptChangeEmailId
|
|
176
|
+
*
|
|
177
|
+
* @returns {Promise<VerifyEmailChangeResponse>}
|
|
178
|
+
*/
|
|
179
|
+
Users.prototype.verifyEmailChange = function (encryptedAttemptChangeEmailId) {
|
|
180
|
+
return this.client.post("users/attempt-change-email/" + encryptedAttemptChangeEmailId + "/accept", {}, this.headers());
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Check if user email change verification link is expired
|
|
184
|
+
*
|
|
185
|
+
* @param {string} encryptedAttemptChangeEmailId
|
|
186
|
+
*
|
|
187
|
+
* @returns {Promise<CheckChangeEmailExpirationResponse>}
|
|
188
|
+
*/
|
|
189
|
+
Users.prototype.checkChangeEmailExpiration = function (encryptedAttemptChangeEmailId) {
|
|
190
|
+
return this.client.get("users/attempt-change-email/" + encryptedAttemptChangeEmailId + "/verify-expiration", this.headers());
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Get public key of given email
|
|
194
|
+
*/
|
|
195
|
+
Users.prototype.getPublicKeyByEmail = function (_a) {
|
|
196
|
+
var email = _a.email;
|
|
197
|
+
return this.client.get("/users/public-key/" + email, this.headers());
|
|
198
|
+
};
|
|
199
|
+
Users.prototype.headers = function () {
|
|
200
|
+
return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token);
|
|
201
|
+
};
|
|
202
|
+
return Users;
|
|
203
|
+
}());
|
|
204
|
+
exports.Users = Users;
|