@internxt/sdk 1.9.7 → 1.9.11

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.
@@ -1,4 +1,4 @@
1
- import { Token, CryptoProvider, Keys, LoginDetails, RegisterDetails, SecurityDetails, TwoFactorAuthQR, RegisterPreCreatedUser, RegisterPreCreatedUserResponse } from './types';
1
+ import { Token, CryptoProvider, Keys, LoginDetails, RegisterDetails, SecurityDetails, TwoFactorAuthQR, RegisterPreCreatedUser, RegisterPreCreatedUserResponse, PrivateKeys } from './types';
2
2
  import { UserSettings, UUID } from '../shared/types/userSettings';
3
3
  import { TeamsSettings } from '../shared/types/teams';
4
4
  import { ApiSecurity, ApiUrl, AppDetails } from '../shared';
@@ -84,15 +84,26 @@ export declare class Auth {
84
84
  */
85
85
  storeTwoFactorAuthKey(backupKey: string, code: string, token?: Token): Promise<void>;
86
86
  /**
87
+ * @deprecated Use `sendUserDeactivationEmail` instead.
87
88
  * Sends request to send the email to delete the account
88
89
  * @param email
89
90
  */
90
91
  sendDeactivationEmail(email: string): Promise<void>;
91
92
  /**
93
+ * Sends request to send the email to delete the account
94
+ */
95
+ sendUserDeactivationEmail(token?: Token): Promise<void>;
96
+ /**
97
+ * @deprecated Use `confirmUserDeactivation` instead.
92
98
  * Confirms the account deactivation
93
99
  * @param token
94
100
  */
95
101
  confirmDeactivation(token: string): Promise<void>;
102
+ /**
103
+ * Confirms the account deactivation
104
+ * @param token
105
+ */
106
+ confirmUserDeactivation(deactivationToken: string, token?: string): Promise<void>;
96
107
  /**
97
108
  * Check credentials
98
109
  * @param hashedPassword
@@ -110,8 +121,9 @@ export declare class Auth {
110
121
  * @param password
111
122
  * @param salt
112
123
  * @param mnemonic
124
+ * @param keys
113
125
  */
114
- changePasswordWithLink(token: string | undefined, password: string, salt: string, mnemonic: string): Promise<void>;
126
+ changePasswordWithLink(token: string | undefined, password: string, salt: string, mnemonic: string, keys?: PrivateKeys): Promise<void>;
115
127
  /**
116
128
  * Reset account with token
117
129
  * @param token
@@ -287,6 +287,7 @@ var Auth = /** @class */ (function () {
287
287
  }, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
288
288
  };
289
289
  /**
290
+ * @deprecated Use `sendUserDeactivationEmail` instead.
290
291
  * Sends request to send the email to delete the account
291
292
  * @param email
292
293
  */
@@ -294,12 +295,30 @@ var Auth = /** @class */ (function () {
294
295
  return this.client.get("/deactivate/".concat(email), this.basicHeaders());
295
296
  };
296
297
  /**
298
+ * Sends request to send the email to delete the account
299
+ */
300
+ Auth.prototype.sendUserDeactivationEmail = function (token) {
301
+ var _a;
302
+ return this.client.post('/users/deactivation/send', {}, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
303
+ };
304
+ /**
305
+ * @deprecated Use `confirmUserDeactivation` instead.
297
306
  * Confirms the account deactivation
298
307
  * @param token
299
308
  */
300
309
  Auth.prototype.confirmDeactivation = function (token) {
301
310
  return this.client.get("/confirmDeactivation/".concat(token), this.basicHeaders());
302
311
  };
312
+ /**
313
+ * Confirms the account deactivation
314
+ * @param token
315
+ */
316
+ Auth.prototype.confirmUserDeactivation = function (deactivationToken, token) {
317
+ var _a;
318
+ return this.client.post('/users/deactivation/confirm', {
319
+ token: deactivationToken,
320
+ }, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
321
+ };
303
322
  /**
304
323
  * Check credentials
305
324
  * @param hashedPassword
@@ -336,12 +355,14 @@ var Auth = /** @class */ (function () {
336
355
  * @param password
337
356
  * @param salt
338
357
  * @param mnemonic
358
+ * @param keys
339
359
  */
340
- Auth.prototype.changePasswordWithLink = function (token, password, salt, mnemonic) {
360
+ Auth.prototype.changePasswordWithLink = function (token, password, salt, mnemonic, keys) {
341
361
  return this.client.put("/users/recover-account?token=".concat(token, "&reset=false"), {
342
362
  password: password,
343
363
  salt: salt,
344
364
  mnemonic: mnemonic,
365
+ privateKeys: keys,
345
366
  }, this.basicHeaders());
346
367
  };
347
368
  /**
@@ -60,3 +60,7 @@ export interface BasicAuth {
60
60
  username: string;
61
61
  password: string;
62
62
  }
63
+ export interface PrivateKeys {
64
+ ecc?: string;
65
+ kyber?: string;
66
+ }
@@ -3,5 +3,6 @@ export * from './share';
3
3
  export * from './users';
4
4
  export * from './referrals';
5
5
  export * from './payments';
6
+ export * from './payments/object-storage';
6
7
  export * from './backups';
7
8
  export * from './trash';
@@ -19,5 +19,6 @@ __exportStar(require("./share"), exports);
19
19
  __exportStar(require("./users"), exports);
20
20
  __exportStar(require("./referrals"), exports);
21
21
  __exportStar(require("./payments"), exports);
22
+ __exportStar(require("./payments/object-storage"), exports);
22
23
  __exportStar(require("./backups"), exports);
23
24
  __exportStar(require("./trash"), exports);
@@ -0,0 +1,36 @@
1
+ import { ApiUrl, AppDetails } from '../../shared';
2
+ import { CreatedSubscriptionData } from './types';
3
+ interface ObjectStoragePlan {
4
+ id: string;
5
+ bytes: number;
6
+ interval: 'year' | 'month' | 'lifetime';
7
+ amount: number;
8
+ currency: string;
9
+ decimalAmount: number;
10
+ }
11
+ export declare class ObjectStorage {
12
+ private readonly client;
13
+ private readonly appDetails;
14
+ static client(apiUrl: ApiUrl, appDetails: AppDetails): ObjectStorage;
15
+ private constructor();
16
+ getObjectStoragePlanById(priceId: string, currency?: string): Promise<ObjectStoragePlan>;
17
+ createCustomerForObjectStorage({ name, email, country, companyVatId, }: {
18
+ name: string;
19
+ email: string;
20
+ country?: string;
21
+ companyVatId?: string;
22
+ }): Promise<{
23
+ customerId: string;
24
+ token: string;
25
+ }>;
26
+ createObjectStorageSubscription({ customerId, plan, token, companyName, vatId, promoCodeId, }: {
27
+ customerId: string;
28
+ plan: ObjectStoragePlan;
29
+ token: string;
30
+ companyName: string;
31
+ vatId: string;
32
+ promoCodeId?: string;
33
+ }): Promise<CreatedSubscriptionData>;
34
+ private headers;
35
+ }
36
+ export {};
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ObjectStorage = void 0;
4
+ var headers_1 = require("../../shared/headers");
5
+ var client_1 = require("../../shared/http/client");
6
+ var ObjectStorage = /** @class */ (function () {
7
+ function ObjectStorage(apiUrl, appDetails) {
8
+ this.client = client_1.HttpClient.create(apiUrl);
9
+ this.appDetails = appDetails;
10
+ }
11
+ ObjectStorage.client = function (apiUrl, appDetails) {
12
+ return new ObjectStorage(apiUrl, appDetails);
13
+ };
14
+ ObjectStorage.prototype.getObjectStoragePlanById = function (priceId, currency) {
15
+ var query = new URLSearchParams();
16
+ priceId !== undefined && query.set('planId', priceId);
17
+ currency !== undefined && query.set('currency', currency);
18
+ return this.client.get("/object-storage-plan-by-id?".concat(query.toString()), this.headers());
19
+ };
20
+ ObjectStorage.prototype.createCustomerForObjectStorage = function (_a) {
21
+ var name = _a.name, email = _a.email, country = _a.country, companyVatId = _a.companyVatId;
22
+ return this.client.post('/create-customer-for-object-storage', {
23
+ name: name,
24
+ email: email,
25
+ country: country,
26
+ companyVatId: companyVatId,
27
+ }, this.headers());
28
+ };
29
+ ObjectStorage.prototype.createObjectStorageSubscription = function (_a) {
30
+ var customerId = _a.customerId, plan = _a.plan, token = _a.token, companyName = _a.companyName, vatId = _a.vatId, promoCodeId = _a.promoCodeId;
31
+ var priceId = plan.id, currency = plan.currency;
32
+ return this.client.post('/create-subscription-for-object-storage', {
33
+ customerId: customerId,
34
+ priceId: priceId,
35
+ token: token,
36
+ currency: currency,
37
+ companyName: companyName,
38
+ companyVatId: vatId,
39
+ promoCodeId: promoCodeId,
40
+ }, this.headers());
41
+ };
42
+ ObjectStorage.prototype.headers = function () {
43
+ return (0, headers_1.basicHeaders)(this.appDetails.clientName, this.appDetails.clientVersion);
44
+ };
45
+ return ObjectStorage;
46
+ }());
47
+ exports.ObjectStorage = ObjectStorage;
@@ -127,7 +127,10 @@ export interface InvoicePayload {
127
127
  limit?: number;
128
128
  }
129
129
  export type UserSubscription = {
130
- type: 'free' | 'lifetime';
130
+ type: 'free';
131
+ } | {
132
+ type: 'lifetime';
133
+ productId?: string;
131
134
  } | {
132
135
  type: 'subscription';
133
136
  subscriptionId: string;
@@ -137,12 +140,13 @@ export type UserSubscription = {
137
140
  interval: 'year' | 'month';
138
141
  nextPayment: number;
139
142
  priceId: string;
143
+ productId?: string;
140
144
  userType?: UserType;
141
- planId?: string;
142
145
  plan?: StoragePlan;
143
146
  };
144
147
  export interface DisplayPrice {
145
148
  id: string;
149
+ productId?: string;
146
150
  bytes: number;
147
151
  interval: 'year' | 'month' | 'lifetime';
148
152
  amount: number;
@@ -182,5 +186,6 @@ export type CreatedSubscriptionData = {
182
186
  export type AvailableProducts = {
183
187
  featuresPerService: {
184
188
  antivirus: boolean;
189
+ backups: boolean;
185
190
  };
186
191
  };
@@ -70,11 +70,18 @@ export declare class Users {
70
70
  */
71
71
  preRegister(email: string): Promise<PreCreateUserResponse>;
72
72
  /**
73
+ * @deprecated Use `updateUserProfile` instead.
73
74
  * Updates a user profile
74
75
  * @param payload
75
76
  */
76
77
  updateProfile(payload: UpdateProfilePayload): Promise<void>;
77
78
  /**
79
+ * Updates a user profile
80
+ * @param payload
81
+ */
82
+ updateUserProfile(payload: UpdateProfilePayload, token?: Token): Promise<void>;
83
+ /**
84
+ * @deprecated Use `updateUserAvatar` instead.
78
85
  * Updates a user avatar
79
86
  * @param payload
80
87
  */
@@ -84,9 +91,23 @@ export declare class Users {
84
91
  avatar: string;
85
92
  }>;
86
93
  /**
94
+ * Updates a user avatar
95
+ * @param payload
96
+ */
97
+ updateUserAvatar(payload: {
98
+ avatar: Blob;
99
+ }, token?: Token): Promise<{
100
+ avatar: string;
101
+ }>;
102
+ /**
103
+ * @deprecated Use `deleteUserAvatar` instead.
87
104
  * Delete current user avatar
88
105
  */
89
106
  deleteAvatar(): Promise<void>;
107
+ /**
108
+ * Delete current user avatar
109
+ */
110
+ deleteUserAvatar(token?: Token): Promise<void>;
90
111
  /**
91
112
  * Gets all friend invites created by this user
92
113
  */
@@ -123,6 +123,7 @@ var Users = /** @class */ (function () {
123
123
  }, this.headers());
124
124
  };
125
125
  /**
126
+ * @deprecated Use `updateUserProfile` instead.
126
127
  * Updates a user profile
127
128
  * @param payload
128
129
  */
@@ -130,6 +131,15 @@ var Users = /** @class */ (function () {
130
131
  return this.client.patch('/user/profile', payload, this.headers());
131
132
  };
132
133
  /**
134
+ * Updates a user profile
135
+ * @param payload
136
+ */
137
+ Users.prototype.updateUserProfile = function (payload, token) {
138
+ var _a;
139
+ return this.client.patch('/users/profile', payload, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
140
+ };
141
+ /**
142
+ * @deprecated Use `updateUserAvatar` instead.
133
143
  * Updates a user avatar
134
144
  * @param payload
135
145
  */
@@ -139,11 +149,29 @@ var Users = /** @class */ (function () {
139
149
  return this.client.put('/user/avatar', formData, this.headers());
140
150
  };
141
151
  /**
152
+ * Updates a user avatar
153
+ * @param payload
154
+ */
155
+ Users.prototype.updateUserAvatar = function (payload, token) {
156
+ var _a;
157
+ var formData = new FormData();
158
+ formData.set('avatar', payload.avatar);
159
+ return this.client.put('/users/avatar', formData, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
160
+ };
161
+ /**
162
+ * @deprecated Use `deleteUserAvatar` instead.
142
163
  * Delete current user avatar
143
164
  */
144
165
  Users.prototype.deleteAvatar = function () {
145
166
  return this.client.delete('/user/avatar', this.headers());
146
167
  };
168
+ /**
169
+ * Delete current user avatar
170
+ */
171
+ Users.prototype.deleteUserAvatar = function (token) {
172
+ var _a;
173
+ return this.client.delete('/users/avatar', this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
174
+ };
147
175
  /**
148
176
  * Gets all friend invites created by this user
149
177
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@internxt/sdk",
3
3
  "author": "Internxt <hello@internxt.com>",
4
- "version": "1.9.7",
4
+ "version": "1.9.11",
5
5
  "description": "An sdk for interacting with Internxt's services",
6
6
  "repository": {
7
7
  "type": "git",