@internxt/sdk 1.4.79 → 1.6.3

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.
Files changed (64) hide show
  1. package/dist/auth/index.d.ts +5 -0
  2. package/dist/auth/index.js +80 -12
  3. package/dist/auth/types.d.ts +17 -4
  4. package/dist/drive/backups/index.js +3 -3
  5. package/dist/drive/index.js +5 -1
  6. package/dist/drive/payments/index.d.ts +30 -17
  7. package/dist/drive/payments/index.js +78 -25
  8. package/dist/drive/payments/types.d.ts +67 -1
  9. package/dist/drive/payments/types.js +11 -6
  10. package/dist/drive/referrals/index.js +5 -1
  11. package/dist/drive/referrals/types.js +2 -2
  12. package/dist/drive/share/index.d.ts +1 -1
  13. package/dist/drive/share/index.js +49 -44
  14. package/dist/drive/share/types.d.ts +31 -29
  15. package/dist/drive/storage/index.d.ts +130 -10
  16. package/dist/drive/storage/index.js +253 -53
  17. package/dist/drive/storage/types.d.ts +107 -21
  18. package/dist/drive/storage/types.js +2 -2
  19. package/dist/drive/trash/index.d.ts +22 -2
  20. package/dist/drive/trash/index.js +44 -9
  21. package/dist/drive/trash/types.d.ts +9 -0
  22. package/dist/drive/users/index.d.ts +30 -3
  23. package/dist/drive/users/index.js +40 -6
  24. package/dist/drive/users/types.d.ts +16 -6
  25. package/dist/index.d.ts +3 -2
  26. package/dist/index.js +12 -7
  27. package/dist/network/download.js +5 -5
  28. package/dist/network/errors/codes.d.ts +1 -1
  29. package/dist/network/errors/context.d.ts +4 -4
  30. package/dist/network/errors/context.js +2 -2
  31. package/dist/network/errors/download.js +5 -1
  32. package/dist/network/errors/index.js +5 -1
  33. package/dist/network/errors/upload.js +5 -1
  34. package/dist/network/index.d.ts +2 -3
  35. package/dist/network/index.js +14 -9
  36. package/dist/network/types.d.ts +16 -16
  37. package/dist/network/types.js +2 -2
  38. package/dist/network/upload.js +8 -9
  39. package/dist/photos/devices/index.js +8 -8
  40. package/dist/photos/index.js +5 -1
  41. package/dist/photos/photos/index.js +26 -26
  42. package/dist/photos/shares/index.js +3 -3
  43. package/dist/photos/types.d.ts +14 -14
  44. package/dist/photos/types.js +3 -3
  45. package/dist/photos/users/index.js +2 -2
  46. package/dist/shared/headers/index.d.ts +9 -6
  47. package/dist/shared/headers/index.js +27 -18
  48. package/dist/shared/http/client.d.ts +1 -1
  49. package/dist/shared/http/client.js +4 -13
  50. package/dist/shared/http/types.d.ts +4 -4
  51. package/dist/shared/index.js +5 -1
  52. package/dist/shared/types/apiConnection.d.ts +2 -1
  53. package/dist/shared/types/appsumo.js +1 -1
  54. package/dist/shared/types/errors.d.ts +2 -1
  55. package/dist/shared/types/errors.js +2 -1
  56. package/dist/shared/types/userSettings.d.ts +17 -1
  57. package/dist/utils.js +2 -3
  58. package/dist/workspaces/index.d.ts +176 -0
  59. package/dist/workspaces/index.js +419 -0
  60. package/dist/workspaces/index.test.d.ts +1 -0
  61. package/dist/workspaces/index.test.js +908 -0
  62. package/dist/workspaces/types.d.ts +294 -0
  63. package/dist/workspaces/types.js +2 -0
  64. package/package.json +13 -13
@@ -101,6 +101,11 @@ export declare class Auth {
101
101
  * @param email
102
102
  */
103
103
  sendChangePasswordEmail(email: string): Promise<void>;
104
+ /**
105
+ * Upgrade hash in the database
106
+ * @param newHash
107
+ */
108
+ upgradeHash(newHash: string): Promise<void>;
104
109
  /**
105
110
  * Restore password with email link
106
111
  * @param token
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -19,12 +23,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
23
  });
20
24
  };
21
25
  var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
28
  function verb(n) { return function (v) { return step([n, v]); }; }
25
29
  function step(op) {
26
30
  if (f) throw new TypeError("Generator is already executing.");
27
- while (_) try {
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
32
  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;
29
33
  if (y = 0, t) op = [op[0] & 2, t.value];
30
34
  switch (op[0]) {
@@ -73,9 +77,22 @@ var Auth = /** @class */ (function () {
73
77
  password: registerDetails.password,
74
78
  mnemonic: registerDetails.mnemonic,
75
79
  salt: registerDetails.salt,
80
+ /**
81
+ / @deprecated The individual fields for keys should not be used
82
+ */
76
83
  privateKey: registerDetails.keys.privateKeyEncrypted,
77
84
  publicKey: registerDetails.keys.publicKey,
78
85
  revocationKey: registerDetails.keys.revocationCertificate,
86
+ keys: {
87
+ ecc: {
88
+ privateKey: registerDetails.keys.keys.ecc.privateKeyEncrypted,
89
+ publicKey: registerDetails.keys.keys.ecc.publicKey,
90
+ },
91
+ kyber: {
92
+ privateKey: registerDetails.keys.keys.kyber.privateKeyEncrypted,
93
+ publicKey: registerDetails.keys.keys.kyber.publicKey,
94
+ }
95
+ },
79
96
  referral: registerDetails.referral,
80
97
  referrer: registerDetails.referrer,
81
98
  }, this.basicHeaders());
@@ -94,9 +111,22 @@ var Auth = /** @class */ (function () {
94
111
  password: registerDetails.password,
95
112
  mnemonic: registerDetails.mnemonic,
96
113
  salt: registerDetails.salt,
114
+ /**
115
+ / @deprecated The individual fields for keys should not be used
116
+ */
97
117
  privateKey: registerDetails.keys.privateKeyEncrypted,
98
118
  publicKey: registerDetails.keys.publicKey,
99
119
  revocationKey: registerDetails.keys.revocationCertificate,
120
+ keys: {
121
+ ecc: {
122
+ privateKey: registerDetails.keys.keys.ecc.privateKeyEncrypted,
123
+ publicKey: registerDetails.keys.keys.ecc.publicKey,
124
+ },
125
+ kyber: {
126
+ privateKey: registerDetails.keys.keys.kyber.privateKeyEncrypted,
127
+ publicKey: registerDetails.keys.keys.kyber.publicKey,
128
+ }
129
+ },
100
130
  referral: registerDetails.referral,
101
131
  referrer: registerDetails.referrer,
102
132
  invitationId: registerDetails.invitationId,
@@ -136,18 +166,33 @@ var Auth = /** @class */ (function () {
136
166
  case 1:
137
167
  securityDetails = _a.sent();
138
168
  encryptedSalt = securityDetails.encryptedSalt;
139
- encryptedPasswordHash = cryptoProvider.encryptPasswordHash(details.password, encryptedSalt);
140
- return [4 /*yield*/, cryptoProvider.generateKeys(details.password)];
169
+ return [4 /*yield*/, cryptoProvider.encryptPasswordHash(details.password, encryptedSalt)];
141
170
  case 2:
171
+ encryptedPasswordHash = _a.sent();
172
+ return [4 /*yield*/, cryptoProvider.generateKeys(details.password)];
173
+ case 3:
142
174
  keys = _a.sent();
143
175
  return [2 /*return*/, this.client
144
176
  .post('/access', {
145
177
  email: details.email,
146
178
  password: encryptedPasswordHash,
147
179
  tfa: details.tfaCode,
180
+ /**
181
+ / @deprecated The individual fields for keys should not be used
182
+ */
148
183
  privateKey: keys.privateKeyEncrypted,
149
184
  publicKey: keys.publicKey,
150
185
  revocateKey: keys.revocationCertificate,
186
+ keys: {
187
+ ecc: {
188
+ privateKey: keys.keys.ecc.privateKeyEncrypted,
189
+ publicKey: keys.keys.ecc.publicKey,
190
+ },
191
+ kyber: {
192
+ privateKey: keys.keys.kyber.privateKeyEncrypted,
193
+ publicKey: keys.keys.kyber.publicKey,
194
+ }
195
+ },
151
196
  }, this.basicHeaders())
152
197
  .then(function (data) {
153
198
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -166,9 +211,22 @@ var Auth = /** @class */ (function () {
166
211
  */
167
212
  Auth.prototype.updateKeys = function (keys, token) {
168
213
  return this.client.patch('/user/keys', {
214
+ /**
215
+ / @deprecated The individual fields for keys should not be used
216
+ */
169
217
  publicKey: keys.publicKey,
170
218
  privateKey: keys.privateKeyEncrypted,
171
219
  revocationKey: keys.revocationCertificate,
220
+ keys: {
221
+ ecc: {
222
+ privateKey: keys.keys.ecc.privateKeyEncrypted,
223
+ publicKey: keys.keys.ecc.publicKey,
224
+ },
225
+ kyber: {
226
+ privateKey: keys.keys.kyber.privateKeyEncrypted,
227
+ publicKey: keys.keys.kyber.publicKey,
228
+ }
229
+ },
172
230
  }, this.headersWithToken(token));
173
231
  };
174
232
  /**
@@ -230,14 +288,14 @@ var Auth = /** @class */ (function () {
230
288
  * @param email
231
289
  */
232
290
  Auth.prototype.sendDeactivationEmail = function (email) {
233
- return this.client.get("/deactivate/" + email, this.basicHeaders());
291
+ return this.client.get("/deactivate/".concat(email), this.basicHeaders());
234
292
  };
235
293
  /**
236
294
  * Confirms the account deactivation
237
295
  * @param token
238
296
  */
239
297
  Auth.prototype.confirmDeactivation = function (token) {
240
- return this.client.get("/confirmDeactivation/" + token, this.basicHeaders());
298
+ return this.client.get("/confirmDeactivation/".concat(token), this.basicHeaders());
241
299
  };
242
300
  /**
243
301
  * Checks if the password is correct for this email
@@ -249,7 +307,7 @@ var Auth = /** @class */ (function () {
249
307
  var _a;
250
308
  // Uses fetch instead of httpClient since a 401 response
251
309
  // would log out the user
252
- return fetch(this.apiUrl + "/are-credentials-correct?email=" + email + "&hashedPassword=" + hashedPassword, {
310
+ return fetch("".concat(this.apiUrl, "/are-credentials-correct?email=").concat(email, "&hashedPassword=").concat(hashedPassword), {
253
311
  headers: this.headersWithToken((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token),
254
312
  }).then(function (res) {
255
313
  if (res.ok) {
@@ -259,7 +317,7 @@ var Auth = /** @class */ (function () {
259
317
  return false;
260
318
  }
261
319
  else
262
- throw new Error("Request failed with error " + res.status);
320
+ throw new Error("Request failed with error ".concat(res.status));
263
321
  });
264
322
  };
265
323
  /**
@@ -271,6 +329,16 @@ var Auth = /** @class */ (function () {
271
329
  email: email,
272
330
  }, this.basicHeaders());
273
331
  };
332
+ /**
333
+ * Upgrade hash in the database
334
+ * @param newHash
335
+ */
336
+ Auth.prototype.upgradeHash = function (newHash) {
337
+ return this.client.patch('/users/:id', {
338
+ newPassword: newHash,
339
+ newSalt: '',
340
+ }, this.basicHeaders());
341
+ };
274
342
  /**
275
343
  * Restore password with email link
276
344
  * @param token
@@ -279,7 +347,7 @@ var Auth = /** @class */ (function () {
279
347
  * @param mnemonic
280
348
  */
281
349
  Auth.prototype.changePasswordWithLink = function (token, password, salt, mnemonic) {
282
- return this.client.put("/users/recover-account?token=" + token + "&reset=false", {
350
+ return this.client.put("/users/recover-account?token=".concat(token, "&reset=false"), {
283
351
  password: password,
284
352
  salt: salt,
285
353
  mnemonic: mnemonic,
@@ -293,7 +361,7 @@ var Auth = /** @class */ (function () {
293
361
  * @param mnemonic
294
362
  */
295
363
  Auth.prototype.resetAccountWithToken = function (token, password, salt, mnemonic) {
296
- return this.client.put("/users/recover-account?token=" + token + "&reset=true", {
364
+ return this.client.put("/users/recover-account?token=".concat(token, "&reset=true"), {
297
365
  password: password,
298
366
  salt: salt,
299
367
  mnemonic: mnemonic,
@@ -1,7 +1,7 @@
1
1
  import { UUID, UserSettings } from '../shared/types/userSettings';
2
- export declare type Password = string;
3
- export declare type Email = string;
4
- export declare type Token = string;
2
+ export type Password = string;
3
+ export type Email = string;
4
+ export type Token = string;
5
5
  export interface LoginDetails {
6
6
  email: Email;
7
7
  password: Password;
@@ -30,12 +30,25 @@ export interface RegisterPreCreatedUserResponse {
30
30
  uuid: UUID;
31
31
  }
32
32
  export interface Keys {
33
+ /**
34
+ / @deprecated The individual fields for keys should not be used
35
+ */
33
36
  privateKeyEncrypted: string;
34
37
  publicKey: string;
35
38
  revocationCertificate: string;
39
+ keys: {
40
+ ecc: {
41
+ privateKeyEncrypted: string;
42
+ publicKey: string;
43
+ };
44
+ kyber: {
45
+ publicKey: string;
46
+ privateKeyEncrypted: string;
47
+ };
48
+ };
36
49
  }
37
50
  export interface CryptoProvider {
38
- encryptPasswordHash: (password: Password, encryptedSalt: string) => string;
51
+ encryptPasswordHash: (password: Password, encryptedSalt: string) => Promise<string>;
39
52
  generateKeys: (password: Password) => Promise<Keys>;
40
53
  }
41
54
  export declare class UserAccessError extends Error {
@@ -18,15 +18,15 @@ var Backups = /** @class */ (function () {
18
18
  };
19
19
  Backups.prototype.getAllBackups = function (mac) {
20
20
  return this.client
21
- .get("/backup/" + mac, this.headers());
21
+ .get("/backup/".concat(mac), this.headers());
22
22
  };
23
23
  Backups.prototype.deleteBackup = function (backupId) {
24
24
  return this.client
25
- .delete("/backup/" + backupId, this.headers());
25
+ .delete("/backup/".concat(backupId), this.headers());
26
26
  };
27
27
  Backups.prototype.deleteDevice = function (deviceId) {
28
28
  return this.client
29
- .delete("/backup/device/" + deviceId, this.headers());
29
+ .delete("/backup/device/".concat(deviceId), this.headers());
30
30
  };
31
31
  /**
32
32
  * Returns the needed headers for the module requests
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,11 +1,21 @@
1
1
  import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
2
- import { CreateCheckoutSessionPayload, CreatePaymentSessionPayload, DisplayPrice, Invoice, PaymentMethod, ProductData, UserSubscription, FreeTrialAvailable, RedeemCodePayload } from './types';
2
+ import { CreateCheckoutSessionPayload, CreatedSubscriptionData, CreatePaymentSessionPayload, CustomerBillingInfo, DisplayPrice, FreeTrialAvailable, Invoice, InvoicePayload, PaymentMethod, ProductData, RedeemCodePayload, UpdateSubscriptionPaymentMethod, UserSubscription, UserType } from './types';
3
3
  export declare class Payments {
4
4
  private readonly client;
5
5
  private readonly appDetails;
6
6
  private readonly apiSecurity;
7
7
  static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity): Payments;
8
8
  private constructor();
9
+ createCustomer(name: string, email: string, country?: string, companyVatId?: string): Promise<{
10
+ customerId: string;
11
+ token: string;
12
+ }>;
13
+ createSubscription(customerId: string, priceId: string, token: string, quantity: number, currency?: string, promoCodeId?: string): Promise<CreatedSubscriptionData>;
14
+ createPaymentIntent(customerId: string, amount: number, planId: string, token: string, currency?: string, promoCodeName?: string): Promise<{
15
+ clientSecret: string;
16
+ id: string;
17
+ invoiceStatus?: string;
18
+ }>;
9
19
  /**
10
20
  * Fetches the existing products and its details
11
21
  */
@@ -17,34 +27,37 @@ export declare class Payments {
17
27
  createSession(payload: CreatePaymentSessionPayload): Promise<{
18
28
  id: string;
19
29
  }>;
20
- getSetupIntent(): Promise<{
30
+ getSetupIntent(userType?: UserType): Promise<{
21
31
  clientSecret: string;
22
32
  }>;
23
- getDefaultPaymentMethod(): Promise<PaymentMethod>;
24
- getInvoices({ startingAfter, limit }: {
25
- startingAfter?: string;
26
- limit?: number;
27
- }): Promise<Invoice[]>;
28
- getUserSubscription(): Promise<UserSubscription>;
29
- getPrices(currency?: string): Promise<DisplayPrice[]>;
33
+ getDefaultPaymentMethod(userType?: UserType): Promise<PaymentMethod>;
34
+ getInvoices({ subscriptionId, startingAfter, limit }: InvoicePayload): Promise<Invoice[]>;
35
+ isCouponUsedByUser({ couponCode }: {
36
+ couponCode: string;
37
+ }): Promise<{
38
+ couponUsed: boolean;
39
+ }>;
40
+ getUserSubscription(userType?: UserType): Promise<UserSubscription>;
41
+ getPrices(currency?: string, userType?: UserType): Promise<DisplayPrice[]>;
30
42
  requestPreventCancellation(): Promise<FreeTrialAvailable>;
31
43
  preventCancellation(): Promise<void>;
32
44
  applyRedeemCode(payload: RedeemCodePayload): Promise<void>;
33
- updateSubscriptionPrice(priceId: string, couponCode?: string): Promise<{
45
+ updateSubscriptionPaymentMethod(payload: UpdateSubscriptionPaymentMethod): Promise<void | Error>;
46
+ updateSubscriptionPrice({ priceId, couponCode, userType, }: {
47
+ priceId: string;
48
+ couponCode?: string;
49
+ userType: UserType;
50
+ }): Promise<{
34
51
  userSubscription: UserSubscription;
35
52
  request3DSecure: boolean;
36
53
  clientSecret: string;
37
54
  }>;
38
- cancelSubscription(): Promise<void>;
55
+ updateWorkspaceMembers(workspaceId: string, subscriptionId: string, updatedSeats: number): Promise<unknown>;
56
+ cancelSubscription(userType?: UserType): Promise<void>;
39
57
  createCheckoutSession(payload: CreateCheckoutSessionPayload): Promise<{
40
58
  sessionId: string;
41
59
  }>;
42
- getPaypalSetupIntent({ priceId, coupon, }: {
43
- priceId: string;
44
- coupon?: string;
45
- }): Promise<{
46
- client_secret: string;
47
- }>;
60
+ updateCustomerBillingInfo(payload: CustomerBillingInfo): Promise<void>;
48
61
  /**
49
62
  * Returns the needed headers for the module requests
50
63
  * @private
@@ -20,12 +20,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  });
21
21
  };
22
22
  var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  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;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -59,6 +59,31 @@ var Payments = /** @class */ (function () {
59
59
  Payments.client = function (apiUrl, appDetails, apiSecurity) {
60
60
  return new Payments(apiUrl, appDetails, apiSecurity);
61
61
  };
62
+ Payments.prototype.createCustomer = function (name, email, country, companyVatId) {
63
+ return this.client.post('/create-customer', { name: name, email: email, country: country, companyVatId: companyVatId }, this.headers());
64
+ };
65
+ Payments.prototype.createSubscription = function (customerId, priceId, token, quantity, currency, promoCodeId) {
66
+ return this.client.post('/create-subscription', {
67
+ customerId: customerId,
68
+ priceId: priceId,
69
+ token: token,
70
+ quantity: quantity,
71
+ currency: currency,
72
+ promoCodeId: promoCodeId,
73
+ }, this.headers());
74
+ };
75
+ Payments.prototype.createPaymentIntent = function (customerId, amount, planId, token, currency, promoCodeName) {
76
+ var query = new URLSearchParams();
77
+ query.set('customerId', customerId);
78
+ query.set('amount', String(amount));
79
+ query.set('planId', planId);
80
+ query.set('token', token);
81
+ if (currency !== undefined)
82
+ query.set('currency', currency);
83
+ if (promoCodeName !== undefined)
84
+ query.set('promoCodeName', promoCodeName);
85
+ return this.client.get("/payment-intent?".concat(query.toString()), this.headers());
86
+ };
62
87
  /**
63
88
  * Fetches the existing products and its details
64
89
  */
@@ -79,23 +104,41 @@ var Payments = /** @class */ (function () {
79
104
  canceledUrl: payload.canceledUrl,
80
105
  }, this.headers());
81
106
  };
82
- Payments.prototype.getSetupIntent = function () {
83
- return this.client.get('/setup-intent', this.headers());
107
+ Payments.prototype.getSetupIntent = function (userType) {
108
+ var query = new URLSearchParams();
109
+ if (userType)
110
+ query.set('userType', userType);
111
+ return this.client.get("/setup-intent?".concat(query.toString()), this.headers());
84
112
  };
85
- Payments.prototype.getDefaultPaymentMethod = function () {
86
- return this.client.get('/default-payment-method', this.headers());
113
+ Payments.prototype.getDefaultPaymentMethod = function (userType) {
114
+ var query = new URLSearchParams();
115
+ if (userType)
116
+ query.set('userType', userType);
117
+ return this.client.get("/default-payment-method?".concat(query.toString()), this.headers());
87
118
  };
88
119
  Payments.prototype.getInvoices = function (_a) {
89
- var startingAfter = _a.startingAfter, limit = _a.limit;
120
+ var subscriptionId = _a.subscriptionId, startingAfter = _a.startingAfter, limit = _a.limit;
90
121
  var query = new URLSearchParams();
122
+ if (subscriptionId)
123
+ query.set('subscription', subscriptionId);
91
124
  if (startingAfter !== undefined)
92
125
  query.set('starting_after', startingAfter);
93
126
  if (limit !== undefined)
94
127
  query.set('limit', limit.toString());
95
- return this.client.get("/invoices?" + query.toString(), this.headers());
128
+ return this.client.get("/invoices?".concat(query.toString()), this.headers());
129
+ };
130
+ Payments.prototype.isCouponUsedByUser = function (_a) {
131
+ var couponCode = _a.couponCode;
132
+ var query = new URLSearchParams();
133
+ if (couponCode !== undefined)
134
+ query.set('code', couponCode);
135
+ return this.client.get("/coupon-in-use?".concat(query.toString()), this.headers());
96
136
  };
97
- Payments.prototype.getUserSubscription = function () {
98
- return this.client.get('/subscriptions', this.headers()).catch(function (err) {
137
+ Payments.prototype.getUserSubscription = function (userType) {
138
+ var query = new URLSearchParams();
139
+ if (userType)
140
+ query.set('userType', userType);
141
+ return this.client.get("/subscriptions?".concat(query.toString()), this.headers()).catch(function (err) {
99
142
  var error = err;
100
143
  if (error.status === 404)
101
144
  return { type: 'free' };
@@ -103,14 +146,16 @@ var Payments = /** @class */ (function () {
103
146
  throw err;
104
147
  });
105
148
  };
106
- Payments.prototype.getPrices = function (currency) {
149
+ Payments.prototype.getPrices = function (currency, userType) {
107
150
  return __awaiter(this, void 0, void 0, function () {
108
151
  var query;
109
152
  return __generator(this, function (_a) {
110
153
  query = new URLSearchParams();
111
154
  if (currency !== undefined)
112
155
  query.set('currency', currency);
113
- return [2 /*return*/, this.client.get("/prices?" + query.toString(), this.headers())];
156
+ if (userType)
157
+ query.set('userType', userType);
158
+ return [2 /*return*/, this.client.get("/prices?".concat(query.toString()), this.headers())];
114
159
  });
115
160
  });
116
161
  };
@@ -123,23 +168,31 @@ var Payments = /** @class */ (function () {
123
168
  Payments.prototype.applyRedeemCode = function (payload) {
124
169
  return this.client.post('/licenses', { code: payload.code, provider: payload.provider }, this.headers());
125
170
  };
126
- Payments.prototype.updateSubscriptionPrice = function (priceId, couponCode) {
127
- return this.client.put('/subscriptions', { price_id: priceId, couponCode: couponCode }, this.headers());
171
+ Payments.prototype.updateSubscriptionPaymentMethod = function (payload) {
172
+ return this.client.post('/subscriptions/update-payment-method', __assign({}, payload), this.headers());
128
173
  };
129
- Payments.prototype.cancelSubscription = function () {
130
- return this.client.delete('/subscriptions', this.headers());
174
+ Payments.prototype.updateSubscriptionPrice = function (_a) {
175
+ var priceId = _a.priceId, couponCode = _a.couponCode, userType = _a.userType;
176
+ return this.client.put('/subscriptions', { price_id: priceId, couponCode: couponCode, userType: userType }, this.headers());
177
+ };
178
+ Payments.prototype.updateWorkspaceMembers = function (workspaceId, subscriptionId, updatedSeats) {
179
+ return this.client.patch('/business/subscription', {
180
+ workspaceId: workspaceId,
181
+ subscriptionId: subscriptionId,
182
+ workspaceUpdatedSeats: updatedSeats,
183
+ }, this.headers());
184
+ };
185
+ Payments.prototype.cancelSubscription = function (userType) {
186
+ var query = new URLSearchParams();
187
+ if (userType)
188
+ query.set('userType', userType);
189
+ return this.client.delete("/subscriptions?".concat(query.toString()), this.headers());
131
190
  };
132
191
  Payments.prototype.createCheckoutSession = function (payload) {
133
192
  return this.client.post('/checkout-session', __assign({}, payload), this.headers());
134
193
  };
135
- Payments.prototype.getPaypalSetupIntent = function (_a) {
136
- var priceId = _a.priceId, coupon = _a.coupon;
137
- var query = new URLSearchParams();
138
- if (priceId !== undefined)
139
- query.set('priceId', priceId);
140
- if (coupon !== undefined)
141
- query.set('coupon', coupon);
142
- return this.client.get("/paypal-setup-intent?" + query.toString(), this.headers());
194
+ Payments.prototype.updateCustomerBillingInfo = function (payload) {
195
+ return this.client.patch('/billing', __assign({}, payload), this.headers());
143
196
  };
144
197
  /**
145
198
  * Returns the needed headers for the module requests
@@ -1,3 +1,4 @@
1
+ import { AppSumoDetails } from './../../shared/types/appsumo';
1
2
  export interface ProductData {
2
3
  id: string;
3
4
  name: string;
@@ -54,6 +55,31 @@ export declare enum ProductPriceType {
54
55
  Recurring = "recurring",
55
56
  OneTime = "one_time"
56
57
  }
58
+ export declare enum UserType {
59
+ Individual = "individual",
60
+ Business = "business"
61
+ }
62
+ export type StoragePlan = {
63
+ planId: string;
64
+ productId: string;
65
+ name: string;
66
+ simpleName: string;
67
+ paymentInterval: RenewalPeriod;
68
+ price: number;
69
+ monthlyPrice: number;
70
+ currency: string;
71
+ isTeam: boolean;
72
+ isLifetime: boolean;
73
+ renewalPeriod: RenewalPeriod;
74
+ storageLimit: number;
75
+ amountOfSeats: number;
76
+ isAppSumo?: boolean;
77
+ details?: AppSumoDetails;
78
+ seats?: {
79
+ minimumSeats: number;
80
+ maximumSeats: number;
81
+ };
82
+ };
57
83
  export interface CreatePaymentSessionPayload {
58
84
  test?: boolean;
59
85
  lifetime_tier?: LifetimeTier;
@@ -62,8 +88,22 @@ export interface CreatePaymentSessionPayload {
62
88
  successUrl?: string;
63
89
  canceledUrl?: string;
64
90
  }
91
+ export interface StripeAddress {
92
+ city: string | null;
93
+ country: string | null;
94
+ line1: string | null;
95
+ line2: string | null;
96
+ postal_code: string | null;
97
+ state: string | null;
98
+ }
65
99
  export interface PaymentMethod {
66
100
  id: string;
101
+ billing_details?: {
102
+ address: StripeAddress | null;
103
+ email: string | null;
104
+ name: string | null;
105
+ phone: string | null;
106
+ };
67
107
  card: {
68
108
  brand: 'amex' | 'diners' | 'discover' | 'jcb' | 'mastercard' | 'unionpay' | 'visa' | 'unknown';
69
109
  exp_month: number;
@@ -77,17 +117,28 @@ export interface Invoice {
77
117
  created: number;
78
118
  bytesInPlan: number;
79
119
  pdf: string;
120
+ total: number;
121
+ currency: string;
122
+ }
123
+ export interface InvoicePayload {
124
+ subscriptionId: string;
125
+ startingAfter?: string;
126
+ limit?: number;
80
127
  }
81
- export declare type UserSubscription = {
128
+ export type UserSubscription = {
82
129
  type: 'free' | 'lifetime';
83
130
  } | {
84
131
  type: 'subscription';
132
+ subscriptionId: string;
85
133
  amount: number;
86
134
  currency: string;
87
135
  amountAfterCoupon?: number;
88
136
  interval: 'year' | 'month';
89
137
  nextPayment: number;
90
138
  priceId: string;
139
+ userType?: UserType;
140
+ planId?: string;
141
+ plan?: StoragePlan;
91
142
  };
92
143
  export interface DisplayPrice {
93
144
  id: string;
@@ -95,6 +146,7 @@ export interface DisplayPrice {
95
146
  interval: 'year' | 'month' | 'lifetime';
96
147
  amount: number;
97
148
  currency: string;
149
+ userType: UserType;
98
150
  }
99
151
  export interface CreateCheckoutSessionPayload {
100
152
  price_id: string;
@@ -112,3 +164,17 @@ export interface RedeemCodePayload {
112
164
  code: string;
113
165
  provider: string;
114
166
  }
167
+ export interface UpdateSubscriptionPaymentMethod {
168
+ userType: UserType;
169
+ paymentMethodId: string;
170
+ }
171
+ export interface CustomerBillingInfo {
172
+ address?: string;
173
+ phoneNumber?: string;
174
+ }
175
+ export type CreatedSubscriptionData = {
176
+ type: 'setup' | 'payment';
177
+ clientSecret: string;
178
+ subscriptionId?: string;
179
+ paymentIntentId?: string;
180
+ };