@internxt/sdk 1.9.8 → 1.9.12

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';
@@ -121,8 +121,9 @@ export declare class Auth {
121
121
  * @param password
122
122
  * @param salt
123
123
  * @param mnemonic
124
+ * @param keys
124
125
  */
125
- 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>;
126
127
  /**
127
128
  * Reset account with token
128
129
  * @param token
@@ -355,12 +355,14 @@ var Auth = /** @class */ (function () {
355
355
  * @param password
356
356
  * @param salt
357
357
  * @param mnemonic
358
+ * @param keys
358
359
  */
359
- Auth.prototype.changePasswordWithLink = function (token, password, salt, mnemonic) {
360
+ Auth.prototype.changePasswordWithLink = function (token, password, salt, mnemonic, keys) {
360
361
  return this.client.put("/users/recover-account?token=".concat(token, "&reset=false"), {
361
362
  password: password,
362
363
  salt: salt,
363
364
  mnemonic: mnemonic,
365
+ privateKeys: keys,
364
366
  }, this.basicHeaders());
365
367
  };
366
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);
@@ -209,7 +209,11 @@ var Payments = /** @class */ (function () {
209
209
  * @private
210
210
  */
211
211
  Payments.prototype.headers = function () {
212
- return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token);
212
+ var additionalHeaders = {};
213
+ if (this.appDetails.desktopHeader) {
214
+ additionalHeaders['x-internxt-desktop-header'] = this.appDetails.desktopHeader;
215
+ }
216
+ return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token, undefined, additionalHeaders);
213
217
  };
214
218
  return Payments;
215
219
  }());
@@ -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
  };
@@ -67,4 +67,5 @@ export declare class Network {
67
67
  */
68
68
  private static headersWithBasicAuth;
69
69
  private static headersWithAuthToken;
70
+ private static mapAdditionalHeaders;
70
71
  }
@@ -305,10 +305,19 @@ var Network = /** @class */ (function () {
305
305
  * @param auth
306
306
  */
307
307
  Network.headersWithBasicAuth = function (appDetails, auth) {
308
- return (0, index_1.headersWithBasicAuth)(appDetails.clientName, appDetails.clientVersion, auth);
308
+ var additionalHeaders = this.mapAdditionalHeaders(appDetails);
309
+ return (0, index_1.headersWithBasicAuth)(appDetails.clientName, appDetails.clientVersion, auth, undefined, additionalHeaders);
309
310
  };
310
311
  Network.headersWithAuthToken = function (appDetails, token) {
311
- return (0, index_1.headersWithAuthToken)(appDetails.clientName, appDetails.clientVersion, token);
312
+ var additionalHeaders = this.mapAdditionalHeaders(appDetails);
313
+ return (0, index_1.headersWithAuthToken)(appDetails.clientName, appDetails.clientVersion, token, undefined, additionalHeaders);
314
+ };
315
+ Network.mapAdditionalHeaders = function (appDetails) {
316
+ var additionalHeaders = {};
317
+ if (appDetails.desktopHeader) {
318
+ additionalHeaders['x-internxt-desktop-header'] = appDetails.desktopHeader;
319
+ }
320
+ return additionalHeaders;
312
321
  };
313
322
  return Network;
314
323
  }());
@@ -15,7 +15,7 @@ export declare function basicHeaders(clientName: string, clientVersion: string):
15
15
  export declare function basicHeadersWithPassword(clientName: string, clientVersion: string, password: string): InternxtHeaders;
16
16
  export declare function headersWithToken(clientName: string, clientVersion: string, token: Token, workspaceToken?: Token, customHeaders?: CustomHeaders): InternxtHeaders;
17
17
  export declare function headersWithTokenAndPassword(clientName: string, clientVersion: string, token: Token, workspaceToken: Token | undefined, password: string): InternxtHeaders;
18
- export declare function headersWithBasicAuth(clientName: string, clientVersion: string, auth: BasicAuth, workspaceToken?: Token): InternxtHeaders;
19
- export declare function headersWithAuthToken(clientName: string, clientVersion: string, token: Token, workspaceToken?: Token): InternxtHeaders;
18
+ export declare function headersWithBasicAuth(clientName: string, clientVersion: string, auth: BasicAuth, workspaceToken?: Token, customHeaders?: CustomHeaders): InternxtHeaders;
19
+ export declare function headersWithAuthToken(clientName: string, clientVersion: string, token: Token, workspaceToken?: Token, customHeaders?: CustomHeaders): InternxtHeaders;
20
20
  export declare function addResourcesTokenToHeaders(headers: InternxtHeaders, resourcesToken?: Token): InternxtHeaders;
21
21
  export {};
@@ -48,7 +48,7 @@ function headersWithTokenAndPassword(clientName, clientVersion, token, workspace
48
48
  return __assign(__assign({}, headers), extra);
49
49
  }
50
50
  exports.headersWithTokenAndPassword = headersWithTokenAndPassword;
51
- function headersWithBasicAuth(clientName, clientVersion, auth, workspaceToken) {
51
+ function headersWithBasicAuth(clientName, clientVersion, auth, workspaceToken, customHeaders) {
52
52
  var headers = basicHeaders(clientName, clientVersion);
53
53
  var token = "".concat(auth.username, ":").concat(auth.password);
54
54
  var encodedToken = Buffer.from(token).toString('base64');
@@ -58,16 +58,16 @@ function headersWithBasicAuth(clientName, clientVersion, auth, workspaceToken) {
58
58
  if (workspaceToken !== undefined) {
59
59
  extra['x-internxt-workspace'] = workspaceToken;
60
60
  }
61
- return __assign(__assign({}, headers), extra);
61
+ return __assign(__assign(__assign({}, headers), extra), customHeaders);
62
62
  }
63
63
  exports.headersWithBasicAuth = headersWithBasicAuth;
64
- function headersWithAuthToken(clientName, clientVersion, token, workspaceToken) {
64
+ function headersWithAuthToken(clientName, clientVersion, token, workspaceToken, customHeaders) {
65
65
  var headers = basicHeaders(clientName, clientVersion);
66
66
  var extra = {};
67
67
  if (workspaceToken !== undefined) {
68
68
  extra['x-internxt-workspace'] = workspaceToken;
69
69
  }
70
- return __assign(__assign(__assign({}, headers), { 'x-token': token }), extra);
70
+ return __assign(__assign(__assign(__assign({}, headers), { 'x-token': token }), extra), customHeaders);
71
71
  }
72
72
  exports.headersWithAuthToken = headersWithAuthToken;
73
73
  function addResourcesTokenToHeaders(headers, resourcesToken) {
@@ -4,6 +4,7 @@ export type ApiUrl = string;
4
4
  export interface AppDetails {
5
5
  clientName: string;
6
6
  clientVersion: string;
7
+ desktopHeader?: string;
7
8
  }
8
9
  export interface ApiSecurity {
9
10
  token: Token;
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.8",
4
+ "version": "1.9.12",
5
5
  "description": "An sdk for interacting with Internxt's services",
6
6
  "repository": {
7
7
  "type": "git",