@internxt/sdk 1.4.76 → 1.4.77
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 +42 -1
- package/dist/auth/index.js +82 -5
- package/dist/auth/types.d.ts +11 -0
- package/dist/drive/payments/index.d.ts +16 -3
- package/dist/drive/payments/index.js +66 -4
- package/dist/drive/payments/types.d.ts +10 -0
- package/dist/drive/referrals/index.js +2 -3
- package/dist/drive/share/index.d.ts +246 -1
- package/dist/drive/share/index.js +386 -3
- package/dist/drive/share/types.d.ts +280 -0
- package/dist/drive/storage/index.d.ts +107 -5
- package/dist/drive/storage/index.js +198 -7
- package/dist/drive/storage/types.d.ts +221 -1
- package/dist/drive/storage/types.js +7 -1
- package/dist/drive/trash/index.d.ts +13 -2
- package/dist/drive/trash/index.js +18 -1
- package/dist/drive/trash/types.d.ts +2 -1
- package/dist/drive/users/index.d.ts +44 -3
- package/dist/drive/users/index.js +53 -2
- package/dist/drive/users/types.d.ts +23 -1
- package/dist/shared/headers/index.d.ts +13 -40
- package/dist/shared/headers/index.js +12 -14
- package/dist/shared/http/client.d.ts +7 -0
- package/dist/shared/http/client.js +16 -1
- package/dist/shared/types/apiConnection.d.ts +0 -1
- package/package.json +1 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
|
|
2
|
-
import { ChangePasswordPayload, FriendInvite, InitializeUserResponse, UpdateProfilePayload } from './types';
|
|
2
|
+
import { ChangePasswordPayload, CheckChangeEmailExpirationResponse, FriendInvite, InitializeUserResponse, PreCreateUserResponse, UpdateProfilePayload, UserPublicKeyResponse, VerifyEmailChangeResponse } from './types';
|
|
3
3
|
import { UserSettings } from '../../shared/types/userSettings';
|
|
4
4
|
export * as UserTypes from './types';
|
|
5
5
|
export declare class Users {
|
|
@@ -27,10 +27,21 @@ export declare class Users {
|
|
|
27
27
|
token: string;
|
|
28
28
|
}>;
|
|
29
29
|
/**
|
|
30
|
-
* Updates the authentication credentials
|
|
30
|
+
* Updates the authentication credentials and invalidates previous tokens
|
|
31
31
|
* @param payload
|
|
32
|
+
*
|
|
33
|
+
* @returns {Promise<{token: string, newToken: string}>} A promise that returns new tokens for this user.
|
|
32
34
|
*/
|
|
33
|
-
changePassword(payload: ChangePasswordPayload): Promise<
|
|
35
|
+
changePassword(payload: ChangePasswordPayload): Promise<{
|
|
36
|
+
token: string;
|
|
37
|
+
newToken: string;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Pre registers an email
|
|
41
|
+
* @param email
|
|
42
|
+
* @returns {Promise<PreCreateUserResponse>} A promise that returns a public key for this user.
|
|
43
|
+
*/
|
|
44
|
+
preRegister(email: string): Promise<PreCreateUserResponse>;
|
|
34
45
|
/**
|
|
35
46
|
* Updates a user profile
|
|
36
47
|
* @param payload
|
|
@@ -63,5 +74,35 @@ export declare class Users {
|
|
|
63
74
|
verifyEmail(payload: {
|
|
64
75
|
verificationToken: string;
|
|
65
76
|
}): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Change user email by new email
|
|
79
|
+
*
|
|
80
|
+
* @param {string} newEmail
|
|
81
|
+
*
|
|
82
|
+
* @returns {Promise<void>}
|
|
83
|
+
*/
|
|
84
|
+
changeUserEmail(newEmail: string): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Verify user email change
|
|
87
|
+
*
|
|
88
|
+
* @param {string} encryptedAttemptChangeEmailId
|
|
89
|
+
*
|
|
90
|
+
* @returns {Promise<VerifyEmailChangeResponse>}
|
|
91
|
+
*/
|
|
92
|
+
verifyEmailChange(encryptedAttemptChangeEmailId: string): Promise<VerifyEmailChangeResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* Check if user email change verification link is expired
|
|
95
|
+
*
|
|
96
|
+
* @param {string} encryptedAttemptChangeEmailId
|
|
97
|
+
*
|
|
98
|
+
* @returns {Promise<CheckChangeEmailExpirationResponse>}
|
|
99
|
+
*/
|
|
100
|
+
checkChangeEmailExpiration(encryptedAttemptChangeEmailId: string): Promise<CheckChangeEmailExpirationResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* Get public key of given email
|
|
103
|
+
*/
|
|
104
|
+
getPublicKeyByEmail({ email }: {
|
|
105
|
+
email: string;
|
|
106
|
+
}): Promise<UserPublicKeyResponse>;
|
|
66
107
|
private headers;
|
|
67
108
|
}
|
|
@@ -63,8 +63,10 @@ var Users = /** @class */ (function () {
|
|
|
63
63
|
return this.client.get('/user/refresh', this.headers());
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
66
|
-
* Updates the authentication credentials
|
|
66
|
+
* Updates the authentication credentials and invalidates previous tokens
|
|
67
67
|
* @param payload
|
|
68
|
+
*
|
|
69
|
+
* @returns {Promise<{token: string, newToken: string}>} A promise that returns new tokens for this user.
|
|
68
70
|
*/
|
|
69
71
|
Users.prototype.changePassword = function (payload) {
|
|
70
72
|
return this.client.patch('/user/password', {
|
|
@@ -75,6 +77,16 @@ var Users = /** @class */ (function () {
|
|
|
75
77
|
privateKey: payload.encryptedPrivateKey,
|
|
76
78
|
}, this.headers());
|
|
77
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* Pre registers an email
|
|
82
|
+
* @param email
|
|
83
|
+
* @returns {Promise<PreCreateUserResponse>} A promise that returns a public key for this user.
|
|
84
|
+
*/
|
|
85
|
+
Users.prototype.preRegister = function (email) {
|
|
86
|
+
return this.client.post('/users/pre-create', {
|
|
87
|
+
email: email,
|
|
88
|
+
}, this.headers());
|
|
89
|
+
};
|
|
78
90
|
/**
|
|
79
91
|
* Updates a user profile
|
|
80
92
|
* @param payload
|
|
@@ -115,8 +127,47 @@ var Users = /** @class */ (function () {
|
|
|
115
127
|
Users.prototype.verifyEmail = function (payload) {
|
|
116
128
|
return this.client.post('/user/verifyEmail', payload, this.headers());
|
|
117
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* Change user email by new email
|
|
132
|
+
*
|
|
133
|
+
* @param {string} newEmail
|
|
134
|
+
*
|
|
135
|
+
* @returns {Promise<void>}
|
|
136
|
+
*/
|
|
137
|
+
Users.prototype.changeUserEmail = function (newEmail) {
|
|
138
|
+
return this.client.post('users/attempt-change-email', {
|
|
139
|
+
newEmail: newEmail,
|
|
140
|
+
}, this.headers());
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Verify user email change
|
|
144
|
+
*
|
|
145
|
+
* @param {string} encryptedAttemptChangeEmailId
|
|
146
|
+
*
|
|
147
|
+
* @returns {Promise<VerifyEmailChangeResponse>}
|
|
148
|
+
*/
|
|
149
|
+
Users.prototype.verifyEmailChange = function (encryptedAttemptChangeEmailId) {
|
|
150
|
+
return this.client.post("users/attempt-change-email/" + encryptedAttemptChangeEmailId + "/accept", {}, this.headers());
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Check if user email change verification link is expired
|
|
154
|
+
*
|
|
155
|
+
* @param {string} encryptedAttemptChangeEmailId
|
|
156
|
+
*
|
|
157
|
+
* @returns {Promise<CheckChangeEmailExpirationResponse>}
|
|
158
|
+
*/
|
|
159
|
+
Users.prototype.checkChangeEmailExpiration = function (encryptedAttemptChangeEmailId) {
|
|
160
|
+
return this.client.get("users/attempt-change-email/" + encryptedAttemptChangeEmailId + "/verify-expiration", this.headers());
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Get public key of given email
|
|
164
|
+
*/
|
|
165
|
+
Users.prototype.getPublicKeyByEmail = function (_a) {
|
|
166
|
+
var email = _a.email;
|
|
167
|
+
return this.client.get("/users/public-key/" + email, this.headers());
|
|
168
|
+
};
|
|
118
169
|
Users.prototype.headers = function () {
|
|
119
|
-
return (0, headers_1.
|
|
170
|
+
return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token);
|
|
120
171
|
};
|
|
121
172
|
return Users;
|
|
122
173
|
}());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserSettings } from '../../shared/types/userSettings';
|
|
1
|
+
import { UUID, UserSettings } from '../../shared/types/userSettings';
|
|
2
2
|
export interface InitializeUserResponse {
|
|
3
3
|
email: string;
|
|
4
4
|
bucket: string;
|
|
@@ -13,9 +13,31 @@ export interface ChangePasswordPayload {
|
|
|
13
13
|
encryptedPrivateKey: string;
|
|
14
14
|
}
|
|
15
15
|
export declare type UpdateProfilePayload = Partial<Pick<UserSettings, 'name' | 'lastname'>>;
|
|
16
|
+
export declare type PreCreateUserResponse = {
|
|
17
|
+
publicKey: string;
|
|
18
|
+
user: {
|
|
19
|
+
uuid: UUID;
|
|
20
|
+
email: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
16
23
|
export declare type FriendInvite = {
|
|
17
24
|
guestEmail: string;
|
|
18
25
|
host: number;
|
|
19
26
|
accepted: boolean;
|
|
20
27
|
id: number;
|
|
21
28
|
};
|
|
29
|
+
export declare type UserPublicKeyResponse = {
|
|
30
|
+
publicKey: string;
|
|
31
|
+
};
|
|
32
|
+
export declare type VerifyEmailChangeResponse = {
|
|
33
|
+
oldEmail: string;
|
|
34
|
+
newEmail: string;
|
|
35
|
+
newAuthentication: {
|
|
36
|
+
user: UserSettings;
|
|
37
|
+
token: string;
|
|
38
|
+
newToken: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export declare type CheckChangeEmailExpirationResponse = {
|
|
42
|
+
isExpired: boolean;
|
|
43
|
+
};
|
|
@@ -1,45 +1,18 @@
|
|
|
1
1
|
import { BasicAuth, Token } from '../../auth';
|
|
2
|
-
|
|
3
|
-
'content-type': string;
|
|
4
|
-
'internxt-version': string;
|
|
5
|
-
'internxt-client': string;
|
|
6
|
-
};
|
|
7
|
-
export declare function basicHeadersWithPassword(clientName: string, clientVersion: string, password: string): {
|
|
8
|
-
'content-type': string;
|
|
9
|
-
'internxt-version': string;
|
|
10
|
-
'internxt-client': string;
|
|
11
|
-
'x-share-password': string;
|
|
12
|
-
};
|
|
13
|
-
export declare function headersWithToken(clientName: string, clientVersion: string, token: Token): {
|
|
14
|
-
Authorization: string;
|
|
15
|
-
'content-type': string;
|
|
16
|
-
'internxt-version': string;
|
|
17
|
-
'internxt-client': string;
|
|
18
|
-
};
|
|
19
|
-
export declare function headersWithTokenAndMnemonic(clientName: string, clientVersion: string, token: Token, mnemonic: string): {
|
|
20
|
-
'internxt-mnemonic': string;
|
|
21
|
-
Authorization: string;
|
|
22
|
-
'content-type': string;
|
|
23
|
-
'internxt-version': string;
|
|
24
|
-
'internxt-client': string;
|
|
25
|
-
};
|
|
26
|
-
export declare function headersWithTokenAndMnemonicAndPassword(clientName: string, clientVersion: string, token: Token, mnemonic: string, password: string): {
|
|
27
|
-
'internxt-mnemonic': string;
|
|
28
|
-
'x-share-password': string;
|
|
29
|
-
Authorization: string;
|
|
30
|
-
'content-type': string;
|
|
31
|
-
'internxt-version': string;
|
|
32
|
-
'internxt-client': string;
|
|
33
|
-
};
|
|
34
|
-
export declare function headersWithBasicAuth(clientName: string, clientVersion: string, auth: BasicAuth): {
|
|
35
|
-
Authorization: string;
|
|
36
|
-
'content-type': string;
|
|
37
|
-
'internxt-version': string;
|
|
38
|
-
'internxt-client': string;
|
|
39
|
-
};
|
|
40
|
-
export declare function headersWithAuthToken(clientName: string, clientVersion: string, token: string): {
|
|
41
|
-
'x-token': string;
|
|
2
|
+
declare type InternxtHeaders = {
|
|
42
3
|
'content-type': string;
|
|
43
4
|
'internxt-version': string;
|
|
44
5
|
'internxt-client': string;
|
|
6
|
+
'x-share-password'?: string;
|
|
7
|
+
'Authorization'?: string;
|
|
8
|
+
'x-token'?: string;
|
|
9
|
+
'internxt-resources-token'?: string;
|
|
45
10
|
};
|
|
11
|
+
export declare function basicHeaders(clientName: string, clientVersion: string): InternxtHeaders;
|
|
12
|
+
export declare function basicHeadersWithPassword(clientName: string, clientVersion: string, password: string): InternxtHeaders;
|
|
13
|
+
export declare function headersWithToken(clientName: string, clientVersion: string, token: Token): InternxtHeaders;
|
|
14
|
+
export declare function headersWithTokenAndPassword(clientName: string, clientVersion: string, token: Token, password: string): InternxtHeaders;
|
|
15
|
+
export declare function headersWithBasicAuth(clientName: string, clientVersion: string, auth: BasicAuth): InternxtHeaders;
|
|
16
|
+
export declare function headersWithAuthToken(clientName: string, clientVersion: string, token: Token): InternxtHeaders;
|
|
17
|
+
export declare function addResourcesTokenToHeaders(headers: InternxtHeaders, resourcesToken?: Token): InternxtHeaders;
|
|
18
|
+
export {};
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
14
|
+
exports.addResourcesTokenToHeaders = exports.headersWithAuthToken = exports.headersWithBasicAuth = exports.headersWithTokenAndPassword = exports.headersWithToken = exports.basicHeadersWithPassword = exports.basicHeaders = void 0;
|
|
15
15
|
function basicHeaders(clientName, clientVersion) {
|
|
16
16
|
return {
|
|
17
17
|
'content-type': 'application/json; charset=utf-8',
|
|
@@ -32,34 +32,25 @@ exports.basicHeadersWithPassword = basicHeadersWithPassword;
|
|
|
32
32
|
function headersWithToken(clientName, clientVersion, token) {
|
|
33
33
|
var headers = basicHeaders(clientName, clientVersion);
|
|
34
34
|
var extra = {
|
|
35
|
-
Authorization: 'Bearer ' + token,
|
|
35
|
+
'Authorization': 'Bearer ' + token,
|
|
36
36
|
};
|
|
37
37
|
return __assign(__assign({}, headers), extra);
|
|
38
38
|
}
|
|
39
39
|
exports.headersWithToken = headersWithToken;
|
|
40
|
-
function
|
|
40
|
+
function headersWithTokenAndPassword(clientName, clientVersion, token, password) {
|
|
41
41
|
var headers = headersWithToken(clientName, clientVersion, token);
|
|
42
42
|
var extra = {
|
|
43
|
-
'internxt-mnemonic': mnemonic,
|
|
44
|
-
};
|
|
45
|
-
return __assign(__assign({}, headers), extra);
|
|
46
|
-
}
|
|
47
|
-
exports.headersWithTokenAndMnemonic = headersWithTokenAndMnemonic;
|
|
48
|
-
function headersWithTokenAndMnemonicAndPassword(clientName, clientVersion, token, mnemonic, password) {
|
|
49
|
-
var headers = headersWithToken(clientName, clientVersion, token);
|
|
50
|
-
var extra = {
|
|
51
|
-
'internxt-mnemonic': mnemonic,
|
|
52
43
|
'x-share-password': password,
|
|
53
44
|
};
|
|
54
45
|
return __assign(__assign({}, headers), extra);
|
|
55
46
|
}
|
|
56
|
-
exports.
|
|
47
|
+
exports.headersWithTokenAndPassword = headersWithTokenAndPassword;
|
|
57
48
|
function headersWithBasicAuth(clientName, clientVersion, auth) {
|
|
58
49
|
var headers = basicHeaders(clientName, clientVersion);
|
|
59
50
|
var token = auth.username + ":" + auth.password;
|
|
60
51
|
var encodedToken = Buffer.from(token).toString('base64');
|
|
61
52
|
var extra = {
|
|
62
|
-
Authorization: 'Basic ' + encodedToken,
|
|
53
|
+
'Authorization': 'Basic ' + encodedToken,
|
|
63
54
|
};
|
|
64
55
|
return __assign(__assign({}, headers), extra);
|
|
65
56
|
}
|
|
@@ -69,3 +60,10 @@ function headersWithAuthToken(clientName, clientVersion, token) {
|
|
|
69
60
|
return __assign(__assign({}, headers), { 'x-token': token });
|
|
70
61
|
}
|
|
71
62
|
exports.headersWithAuthToken = headersWithAuthToken;
|
|
63
|
+
function addResourcesTokenToHeaders(headers, resourcesToken) {
|
|
64
|
+
if (resourcesToken && resourcesToken.length > 0) {
|
|
65
|
+
return __assign(__assign({}, headers), { 'internxt-resources-token': resourcesToken });
|
|
66
|
+
}
|
|
67
|
+
return headers;
|
|
68
|
+
}
|
|
69
|
+
exports.addResourcesTokenToHeaders = addResourcesTokenToHeaders;
|
|
@@ -11,6 +11,13 @@ export declare class HttpClient {
|
|
|
11
11
|
* @param headers
|
|
12
12
|
*/
|
|
13
13
|
get<Response>(url: URL, headers: Headers): Promise<Response>;
|
|
14
|
+
/**
|
|
15
|
+
* Requests a GET
|
|
16
|
+
* @param url
|
|
17
|
+
* @param params
|
|
18
|
+
* @param headers
|
|
19
|
+
*/
|
|
20
|
+
getWithParams<Response>(url: URL, params: Parameters, headers: Headers): Promise<Response>;
|
|
14
21
|
/**
|
|
15
22
|
* Requests a GET with option to cancel
|
|
16
23
|
* @param url
|
|
@@ -30,6 +30,18 @@ var HttpClient = /** @class */ (function () {
|
|
|
30
30
|
headers: headers,
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Requests a GET
|
|
35
|
+
* @param url
|
|
36
|
+
* @param params
|
|
37
|
+
* @param headers
|
|
38
|
+
*/
|
|
39
|
+
HttpClient.prototype.getWithParams = function (url, params, headers) {
|
|
40
|
+
return this.axios.get(url, {
|
|
41
|
+
params: params,
|
|
42
|
+
headers: headers,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
33
45
|
/**
|
|
34
46
|
* Requests a GET with option to cancel
|
|
35
47
|
* @param url
|
|
@@ -141,7 +153,10 @@ var HttpClient = /** @class */ (function () {
|
|
|
141
153
|
if (response.status === 401) {
|
|
142
154
|
this.unauthorizedCallback();
|
|
143
155
|
}
|
|
144
|
-
if (response.data.
|
|
156
|
+
if (response.data.message !== undefined) {
|
|
157
|
+
errorMessage = response.data.message;
|
|
158
|
+
}
|
|
159
|
+
else if (response.data.error !== undefined) {
|
|
145
160
|
errorMessage = response.data.error;
|
|
146
161
|
}
|
|
147
162
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internxt/sdk",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.77",
|
|
4
4
|
"description": "An sdk for interacting with Internxt's services",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,9 +15,6 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
-
"publishConfig": {
|
|
19
|
-
"access": "public"
|
|
20
|
-
},
|
|
21
18
|
"main": "dist/index.js",
|
|
22
19
|
"types": "dist/index.d.ts",
|
|
23
20
|
"scripts": {
|
|
@@ -46,8 +43,5 @@
|
|
|
46
43
|
"axios": "^0.24.0",
|
|
47
44
|
"query-string": "^7.1.0",
|
|
48
45
|
"uuid": "^8.3.2"
|
|
49
|
-
},
|
|
50
|
-
"directories": {
|
|
51
|
-
"test": "test"
|
|
52
46
|
}
|
|
53
47
|
}
|