@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.
@@ -1,4 +1,4 @@
1
- import { Token, CryptoProvider, Keys, LoginDetails, RegisterDetails, SecurityDetails, TwoFactorAuthQR } from './types';
1
+ import { Token, CryptoProvider, Keys, LoginDetails, RegisterDetails, SecurityDetails, TwoFactorAuthQR, RegisterPreCreatedUser, RegisterPreCreatedUserResponse } 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';
@@ -21,6 +21,26 @@ export declare class Auth {
21
21
  };
22
22
  uuid: UUID;
23
23
  }>;
24
+ /**
25
+ * Registers a precreated user
26
+ * @param registerDetails
27
+ * @returns {Promise<RegisterPreCreatedUserResponse>} Returns sign in token, user data and uuid.
28
+ */
29
+ registerPreCreatedUser(registerDetails: RegisterPreCreatedUser): Promise<RegisterPreCreatedUserResponse>;
30
+ /**
31
+ * Requests account unblock email
32
+ *
33
+ * @param {string} email - The email address associated with the account.
34
+ * @returns {Promise<void>} - Resolves when the email is sent.
35
+ */
36
+ requestUnblockAccount(email: string): Promise<void>;
37
+ /**
38
+ * Unblocks account with token
39
+ *
40
+ * @param {string} token - The token received via email to verify and unblock the account.
41
+ * @returns {Promise<void>} - Resolves successfuly when account is unblocked
42
+ */
43
+ unblockAccount(token: string): Promise<void>;
24
44
  /**
25
45
  * Tries to log in a user given its login details
26
46
  * @param details
@@ -76,6 +96,27 @@ export declare class Auth {
76
96
  * @returns
77
97
  */
78
98
  areCredentialsCorrect(email: string, hashedPassword: string): Promise<boolean>;
99
+ /**
100
+ * Send email to change password
101
+ * @param email
102
+ */
103
+ sendChangePasswordEmail(email: string): Promise<void>;
104
+ /**
105
+ * Restore password with email link
106
+ * @param token
107
+ * @param password
108
+ * @param salt
109
+ * @param mnemonic
110
+ */
111
+ changePasswordWithLink(token: string | undefined, password: string, salt: string, mnemonic: string): Promise<void>;
112
+ /**
113
+ * Reset account with token
114
+ * @param token
115
+ * @param password
116
+ * @param salt
117
+ * @param mnemonic
118
+ */
119
+ resetAccountWithToken(token: string | undefined, password: string, salt: string, mnemonic: string): Promise<void>;
79
120
  private basicHeaders;
80
121
  private headersWithToken;
81
122
  }
@@ -47,7 +47,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  Object.defineProperty(exports, "__esModule", { value: true });
49
49
  exports.Auth = void 0;
50
- var types_1 = require("./types");
51
50
  var headers_1 = require("../shared/headers");
52
51
  var client_1 = require("../shared/http/client");
53
52
  __exportStar(require("./types"), exports);
@@ -81,6 +80,48 @@ var Auth = /** @class */ (function () {
81
80
  referrer: registerDetails.referrer,
82
81
  }, this.basicHeaders());
83
82
  };
83
+ /**
84
+ * Registers a precreated user
85
+ * @param registerDetails
86
+ * @returns {Promise<RegisterPreCreatedUserResponse>} Returns sign in token, user data and uuid.
87
+ */
88
+ Auth.prototype.registerPreCreatedUser = function (registerDetails) {
89
+ return this.client.post('users/pre-created-users/register', {
90
+ name: registerDetails.name,
91
+ captcha: registerDetails.captcha,
92
+ lastname: registerDetails.lastname,
93
+ email: registerDetails.email,
94
+ password: registerDetails.password,
95
+ mnemonic: registerDetails.mnemonic,
96
+ salt: registerDetails.salt,
97
+ privateKey: registerDetails.keys.privateKeyEncrypted,
98
+ publicKey: registerDetails.keys.publicKey,
99
+ revocationKey: registerDetails.keys.revocationCertificate,
100
+ referral: registerDetails.referral,
101
+ referrer: registerDetails.referrer,
102
+ invitationId: registerDetails.invitationId,
103
+ }, this.basicHeaders());
104
+ };
105
+ /**
106
+ * Requests account unblock email
107
+ *
108
+ * @param {string} email - The email address associated with the account.
109
+ * @returns {Promise<void>} - Resolves when the email is sent.
110
+ */
111
+ Auth.prototype.requestUnblockAccount = function (email) {
112
+ return this.client.post('users/unblock-account', {
113
+ email: email,
114
+ }, this.basicHeaders());
115
+ };
116
+ /**
117
+ * Unblocks account with token
118
+ *
119
+ * @param {string} token - The token received via email to verify and unblock the account.
120
+ * @returns {Promise<void>} - Resolves successfuly when account is unblocked
121
+ */
122
+ Auth.prototype.unblockAccount = function (token) {
123
+ return this.client.put('users/unblock-account', { token: token }, this.basicHeaders());
124
+ };
84
125
  /**
85
126
  * Tries to log in a user given its login details
86
127
  * @param details
@@ -113,9 +154,6 @@ var Auth = /** @class */ (function () {
113
154
  // @ts-ignore
114
155
  data.user.revocationKey = data.user.revocateKey; // TODO : remove when all projects use SDK
115
156
  return data;
116
- })
117
- .catch(function (error) {
118
- throw new types_1.UserAccessError(error.message);
119
157
  })];
120
158
  }
121
159
  });
@@ -211,7 +249,9 @@ var Auth = /** @class */ (function () {
211
249
  var _a;
212
250
  // Uses fetch instead of httpClient since a 401 response
213
251
  // would log out the user
214
- return fetch(this.apiUrl + "/are-credentials-correct?email=" + email + "&hashedPassword=" + hashedPassword, { headers: this.headersWithToken((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token) }).then(function (res) {
252
+ return fetch(this.apiUrl + "/are-credentials-correct?email=" + email + "&hashedPassword=" + hashedPassword, {
253
+ headers: this.headersWithToken((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token),
254
+ }).then(function (res) {
215
255
  if (res.ok) {
216
256
  return true;
217
257
  }
@@ -222,6 +262,43 @@ var Auth = /** @class */ (function () {
222
262
  throw new Error("Request failed with error " + res.status);
223
263
  });
224
264
  };
265
+ /**
266
+ * Send email to change password
267
+ * @param email
268
+ */
269
+ Auth.prototype.sendChangePasswordEmail = function (email) {
270
+ return this.client.post('/users/recover-account', {
271
+ email: email,
272
+ }, this.basicHeaders());
273
+ };
274
+ /**
275
+ * Restore password with email link
276
+ * @param token
277
+ * @param password
278
+ * @param salt
279
+ * @param mnemonic
280
+ */
281
+ Auth.prototype.changePasswordWithLink = function (token, password, salt, mnemonic) {
282
+ return this.client.put("/users/recover-account?token=" + token + "&reset=false", {
283
+ password: password,
284
+ salt: salt,
285
+ mnemonic: mnemonic,
286
+ }, this.basicHeaders());
287
+ };
288
+ /**
289
+ * Reset account with token
290
+ * @param token
291
+ * @param password
292
+ * @param salt
293
+ * @param mnemonic
294
+ */
295
+ Auth.prototype.resetAccountWithToken = function (token, password, salt, mnemonic) {
296
+ return this.client.put("/users/recover-account?token=" + token + "&reset=true", {
297
+ password: password,
298
+ salt: salt,
299
+ mnemonic: mnemonic,
300
+ }, this.basicHeaders());
301
+ };
225
302
  Auth.prototype.basicHeaders = function () {
226
303
  return (0, headers_1.basicHeaders)(this.appDetails.clientName, this.appDetails.clientVersion);
227
304
  };
@@ -1,3 +1,4 @@
1
+ import { UUID, UserSettings } from '../shared/types/userSettings';
1
2
  export declare type Password = string;
2
3
  export declare type Email = string;
3
4
  export declare type Token = string;
@@ -18,6 +19,16 @@ export interface RegisterDetails {
18
19
  referrer?: string;
19
20
  referral?: string;
20
21
  }
22
+ export interface RegisterPreCreatedUser extends RegisterDetails {
23
+ invitationId: string;
24
+ }
25
+ export interface RegisterPreCreatedUserResponse {
26
+ token: Token;
27
+ user: UserSettings & {
28
+ referralCode: string;
29
+ };
30
+ uuid: UUID;
31
+ }
21
32
  export interface Keys {
22
33
  privateKeyEncrypted: string;
23
34
  publicKey: string;
@@ -1,5 +1,5 @@
1
1
  import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
2
- import { CreateCheckoutSessionPayload, CreatePaymentSessionPayload, DisplayPrice, Invoice, PaymentMethod, ProductData, UserSubscription } from './types';
2
+ import { CreateCheckoutSessionPayload, CreatePaymentSessionPayload, DisplayPrice, Invoice, PaymentMethod, ProductData, UserSubscription, FreeTrialAvailable, RedeemCodePayload } from './types';
3
3
  export declare class Payments {
4
4
  private readonly client;
5
5
  private readonly appDetails;
@@ -26,12 +26,25 @@ export declare class Payments {
26
26
  limit?: number;
27
27
  }): Promise<Invoice[]>;
28
28
  getUserSubscription(): Promise<UserSubscription>;
29
- getPrices(): Promise<DisplayPrice[]>;
30
- updateSubscriptionPrice(priceId: string): Promise<UserSubscription>;
29
+ getPrices(currency?: string): Promise<DisplayPrice[]>;
30
+ requestPreventCancellation(): Promise<FreeTrialAvailable>;
31
+ preventCancellation(): Promise<void>;
32
+ applyRedeemCode(payload: RedeemCodePayload): Promise<void>;
33
+ updateSubscriptionPrice(priceId: string, couponCode?: string): Promise<{
34
+ userSubscription: UserSubscription;
35
+ request3DSecure: boolean;
36
+ clientSecret: string;
37
+ }>;
31
38
  cancelSubscription(): Promise<void>;
32
39
  createCheckoutSession(payload: CreateCheckoutSessionPayload): Promise<{
33
40
  sessionId: string;
34
41
  }>;
42
+ getPaypalSetupIntent({ priceId, coupon, }: {
43
+ priceId: string;
44
+ coupon?: string;
45
+ }): Promise<{
46
+ client_secret: string;
47
+ }>;
35
48
  /**
36
49
  * Returns the needed headers for the module requests
37
50
  * @private
@@ -10,6 +10,42 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
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;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
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
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
13
49
  Object.defineProperty(exports, "__esModule", { value: true });
14
50
  exports.Payments = void 0;
15
51
  var headers_1 = require("../../shared/headers");
@@ -67,11 +103,28 @@ var Payments = /** @class */ (function () {
67
103
  throw err;
68
104
  });
69
105
  };
70
- Payments.prototype.getPrices = function () {
71
- return this.client.get('/prices', this.headers());
106
+ Payments.prototype.getPrices = function (currency) {
107
+ return __awaiter(this, void 0, void 0, function () {
108
+ var query;
109
+ return __generator(this, function (_a) {
110
+ query = new URLSearchParams();
111
+ if (currency !== undefined)
112
+ query.set('currency', currency);
113
+ return [2 /*return*/, this.client.get("/prices?" + query.toString(), this.headers())];
114
+ });
115
+ });
116
+ };
117
+ Payments.prototype.requestPreventCancellation = function () {
118
+ return this.client.get('/request-prevent-cancellation', this.headers());
72
119
  };
73
- Payments.prototype.updateSubscriptionPrice = function (priceId) {
74
- return this.client.put('/subscriptions', { price_id: priceId }, this.headers());
120
+ Payments.prototype.preventCancellation = function () {
121
+ return this.client.put('/prevent-cancellation', {}, this.headers());
122
+ };
123
+ Payments.prototype.applyRedeemCode = function (payload) {
124
+ return this.client.post('/licenses', { code: payload.code, provider: payload.provider }, this.headers());
125
+ };
126
+ Payments.prototype.updateSubscriptionPrice = function (priceId, couponCode) {
127
+ return this.client.put('/subscriptions', { price_id: priceId, couponCode: couponCode }, this.headers());
75
128
  };
76
129
  Payments.prototype.cancelSubscription = function () {
77
130
  return this.client.delete('/subscriptions', this.headers());
@@ -79,6 +132,15 @@ var Payments = /** @class */ (function () {
79
132
  Payments.prototype.createCheckoutSession = function (payload) {
80
133
  return this.client.post('/checkout-session', __assign({}, payload), this.headers());
81
134
  };
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());
143
+ };
82
144
  /**
83
145
  * Returns the needed headers for the module requests
84
146
  * @private
@@ -94,11 +94,21 @@ export interface DisplayPrice {
94
94
  bytes: number;
95
95
  interval: 'year' | 'month' | 'lifetime';
96
96
  amount: number;
97
+ currency: string;
97
98
  }
98
99
  export interface CreateCheckoutSessionPayload {
99
100
  price_id: string;
100
101
  coupon_code?: string;
102
+ trial_days?: number;
101
103
  success_url: string;
102
104
  cancel_url: string;
103
105
  customer_email: string;
106
+ currency?: string;
107
+ }
108
+ export interface FreeTrialAvailable {
109
+ elegible: boolean;
110
+ }
111
+ export interface RedeemCodePayload {
112
+ code: string;
113
+ provider: string;
104
114
  }
@@ -36,15 +36,14 @@ var Referrals = /** @class */ (function () {
36
36
  * Returns a list of referrals of this user
37
37
  */
38
38
  Referrals.prototype.getReferrals = function () {
39
- return this.client
40
- .get('/users-referrals', this.headers());
39
+ return this.client.get('/users-referrals', this.headers());
41
40
  };
42
41
  /**
43
42
  * Returns the needed headers for the module requests
44
43
  * @private
45
44
  */
46
45
  Referrals.prototype.headers = function () {
47
- return (0, headers_1.headersWithTokenAndMnemonic)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token, this.apiSecurity.mnemonic);
46
+ return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token);
48
47
  };
49
48
  return Referrals;
50
49
  }());
@@ -1,4 +1,4 @@
1
- import { GenerateShareLinkPayload, GetSharedDirectoryPayload, GetShareLinkFolderSizePayload, ListShareLinksResponse, ShareLink, UpdateShareLinkPayload } from './types';
1
+ import { GenerateShareLinkPayload, GetSharedDirectoryPayload, GetShareLinkFolderSizePayload, ListAllSharedFoldersResponse, ListPrivateSharedFoldersResponse, ListShareLinksResponse, SharedFolderUser, ShareDomainsResponse, ShareLink, ShareFolderWithUserPayload, UpdateUserRolePayload, UpdateUserRoleResponse, UpdateShareLinkPayload, ListSharedItemsResponse, AcceptInvitationToSharedFolderPayload, RemoveUserRolePayload, Role, SharingInvite, SharedFoldersInvitationsAsInvitedUserResponse, CreateSharingPayload, SharingMeta, PublicSharedItemInfo, SharedFolderSize } from './types';
2
2
  import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
3
3
  export * as ShareTypes from './types';
4
4
  export declare class Share {
@@ -51,11 +51,242 @@ export declare class Share {
51
51
  * @param payload
52
52
  */
53
53
  getShareLinkDirectory(payload: GetSharedDirectoryPayload): Promise<any>;
54
+ getShareDomains(): Promise<ShareDomainsResponse>;
54
55
  /**
55
56
  * Get size of folder in share links
56
57
  * @param payload
57
58
  */
58
59
  getShareLinkFolderSize(payload: GetShareLinkFolderSizePayload): Promise<any>;
60
+ /**
61
+ * Fetches all folders shared by a user.
62
+ *
63
+ * @param {number} page - The page number for pagination.
64
+ * @param {number} perPage - The number of items per page for pagination.
65
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
66
+ * @returns {Promise<ListPrivateSharedFoldersResponse>} A promise containing the list of shared folders.
67
+ */
68
+ getSentSharedFolders(page?: number, perPage?: number, orderBy?: 'views:ASC' | 'views:DESC' | 'createdAt:ASC' | 'createdAt:DESC'): Promise<ListPrivateSharedFoldersResponse>;
69
+ /**
70
+ * Fetches folders shared with a user.
71
+ *
72
+ * @param {number} page - The page number for pagination.
73
+ * @param {number} perPage - The number of items per page for pagination.
74
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
75
+ * @returns {Promise<ListPrivateSharedFoldersResponse>} A promise containing the list of shared folders.
76
+ */
77
+ getReceivedSharedFolders(page?: number, perPage?: number, orderBy?: 'views:ASC' | 'views:DESC' | 'createdAt:ASC' | 'createdAt:DESC'): Promise<ListPrivateSharedFoldersResponse>;
78
+ /**
79
+ * Fetches all shared folders.
80
+ *
81
+ * @param {number} page - The page number for pagination.
82
+ * @param {number} perPage - The number of items per page for pagination.
83
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
84
+ * @returns {Promise<ListAllSharedFoldersResponse>} A promise containing the list of shared folders.
85
+ */
86
+ getAllSharedFolders(page?: number, perPage?: number, orderBy?: 'views:ASC' | 'views:DESC' | 'createdAt:ASC' | 'createdAt:DESC'): Promise<ListAllSharedFoldersResponse>;
87
+ /**
88
+ * Fetches all shared files.
89
+ *
90
+ * @param {number} page - The page number for pagination.
91
+ * @param {number} perPage - The number of items per page for pagination.
92
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
93
+ * @returns {Promise<ListAllSharedFoldersResponse>} A promise containing the list of shared folders.
94
+ */
95
+ getAllSharedFiles(page?: number, perPage?: number, orderBy?: 'views:ASC' | 'views:DESC' | 'createdAt:ASC' | 'createdAt:DESC'): Promise<ListAllSharedFoldersResponse>;
96
+ /**
97
+ * Get all users with access to a shared folder.
98
+ *
99
+ * @param {string} folderUUID - The UUID of the folder.
100
+ * @param {number} page - The page number for pagination.
101
+ * @param {number} perPage - The number of items per page for pagination.
102
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
103
+ * @returns {Promise<{ users: SharedFolderUser[] }>} A promise containing the list of users with access to the folder.
104
+ */
105
+ getSharedFolderUsers(folderUUID: string, page?: number, perPage?: number, orderBy?: 'views:ASC' | 'views:DESC' | 'createdAt:ASC' | 'createdAt:DESC'): Promise<{
106
+ users: SharedFolderUser[];
107
+ }>;
108
+ /**
109
+ * Get shared folder content
110
+ * @param {string} sharedFolderId - The UUID of the shared folder.
111
+ * @param {string} type - The item type for the query folders/files
112
+ * @param {string} token - Key that enables invited users to navigate the folders
113
+ * @param {number} page - The page number for pagination.
114
+ * @param {number} perPage - The number of items per page for pagination.
115
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
116
+ */
117
+ getSharedFolderContent(sharedFolderId: string, type: 'folders' | 'files', token: string | null, page?: number, perPage?: number, orderBy?: 'views:ASC' | 'views:DESC' | 'createdAt:ASC' | 'createdAt:DESC'): Promise<ListSharedItemsResponse>;
118
+ /**
119
+ * Get public shared folder content
120
+ * @param {string} sharedFolderId - The UUID of the shared folder.
121
+ * @param {string} type - The item type for the query folders/files
122
+ * @param {string} token - Key that enables invited users to navigate the folders
123
+ * @param {number} page - The page number for pagination.
124
+ * @param {number} perPage - The number of items per page for pagination.
125
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
126
+ */
127
+ getPublicSharedFolderContent(sharedFolderId: string, type: 'folders' | 'files', token: string | null, page?: number, perPage?: number, code?: string, orderBy?: 'views:ASC' | 'views:DESC' | 'createdAt:ASC' | 'createdAt:DESC'): Promise<ListSharedItemsResponse>;
128
+ /**
129
+ * Get the role of a user on a folder.
130
+ *
131
+ * @param {string} options.sharingId - The unique identifier of the sharing.
132
+ * @returns {Promise<Role>} A promise containing the role of the current user in the sharing.
133
+ */
134
+ getUserRole(sharingId: string): Promise<Role>;
135
+ /**
136
+ * Update the role of a user on a folder.
137
+ *
138
+ * @param {UpdateUserRolePayload} options - The options for updating the user's role on the folder.
139
+ * @param {string} options.sharingId - The unique identifier of the user to whom we will update the role.
140
+ * @param {string} options.newRoleId - The new role Id.
141
+ * @returns {Promise<UpdateRoleFolderResponse>} A promise that resolves when the user's role is updated.
142
+ */
143
+ updateUserRole({ sharingId, newRoleId }: UpdateUserRolePayload): Promise<UpdateUserRoleResponse>;
144
+ /**
145
+ * Remove user from shared folder.
146
+ *
147
+ * @param {UpdateUserRolePayload} options - The options for updating the user's role on the folder.
148
+ * @param {string} options.itemType - The unique identifier of the folder.
149
+ * @param {string} options.itemId - The identifier of the role to assign to the user.
150
+ * @param {string} options.userId - The role Id how we want to delete.
151
+ * @returns {Promise<UpdateRoleFolderResponse>} A promise that resolves when the user's role is updated.
152
+ */
153
+ removeUserRole({ itemType, itemId, userId }: RemoveUserRolePayload): Promise<UpdateUserRoleResponse>;
154
+ /**
155
+ * Get private folder data.
156
+ *
157
+ * @param {string} itemId - The itemId of the folder.
158
+ * @param {string} itemType - The itemType of the folder (file | folder).
159
+ * @returns {Promise<{ data: SharingInvite[] }>} A promise containing the private folder data.
160
+ */
161
+ getSharedFolderInvitations({ itemId, itemType, }: {
162
+ itemId: string;
163
+ itemType: 'folder' | 'file';
164
+ }): Promise<any[]>;
165
+ /**
166
+ * Get all invitations for a user.
167
+ * @param limit - The number of items per page for pagination.
168
+ * @param offset - The page number for pagination.
169
+ * @returns {Promise<invites: any>} A promise containing the list of invitations.
170
+ */
171
+ getSharedFolderInvitationsAsInvitedUser({ limit, offset, }: {
172
+ limit?: number;
173
+ offset?: number;
174
+ }): Promise<{
175
+ invites: SharedFoldersInvitationsAsInvitedUserResponse[];
176
+ }>;
177
+ /**
178
+ * Share a private folder with a user.
179
+ *
180
+ * @param {ShareFolderWithUserPayload} options - The options for sharing the private folder with a user.
181
+ * @param {string} options.itemId - The id of the item to share.
182
+ * @param {string} options.itemType - The type of the item to share (folder | file).
183
+ * @param {string} options.sharedWith - The email address of the user to share the folder with.
184
+ * @param {string} options.encryptionKey - Owner\'s encryption key encrypted with the invited user\'s public key. This field should not be empty if the invitation type is "OWNER".
185
+ * @param {string} options.encryptionAlgorithm - Encryption algorithm used to encrypt the encryption key. This field should not be empty if the invitation type is "OWNER".
186
+ * @param {string} options.type - Owner's encryption key encrypted with the invited user's public key.
187
+ * @param {string} options.roleId - The id of the role to assign to the user.
188
+ * @param {string} options.notifyUser - If it has to notify the users
189
+ * @param {string} options.notificationMessage - Message of the notificacion
190
+ *
191
+ *
192
+ * @returns {Promise<SharingInvite>} A promise that resolves when the folder is shared with the user.
193
+ */
194
+ inviteUserToSharedFolder(createInviteDto: ShareFolderWithUserPayload): Promise<SharingInvite>;
195
+ /**
196
+ * Create a sharing.
197
+ */
198
+ createSharing(createSharingPayload: CreateSharingPayload): Promise<SharingMeta>;
199
+ /**
200
+ * Get sharing meta with code
201
+ */
202
+ getSharingMeta(sharingId: string, code: string, password?: string): Promise<SharingMeta>;
203
+ /**
204
+ * Add/edit sharing Password
205
+ * @param {string} sharingId - id of sharing.
206
+ * @param {string} encryptedPassword - password encrypted with CODE as key
207
+ * @returns {Promise<SharingMeta>} A promise that returns the sharing info with the new encrypted password
208
+ */
209
+ saveSharingPassword(sharingId: string, encryptedPassword: string): Promise<SharingMeta>;
210
+ /**
211
+ * Remove password protection from sharing
212
+ * @param {string} sharingId - id of sharing.
213
+ * @returns {Promise<void>} A promise that resolves when password was successfully deleted.
214
+ */
215
+ removeSharingPassword(sharingId: string): Promise<void>;
216
+ /**
217
+ * Get public information of the item shared.
218
+ * @param {string} sharingId - id of sharing.
219
+ * @returns {Promise<PublicSharedItemInfo>} A promise that returns data of the public shared item.
220
+ */
221
+ getPublicSharedItemInfo(sharingId: string): Promise<PublicSharedItemInfo>;
222
+ /**
223
+ * Request access to shared folder.
224
+ */
225
+ requestUserToSharedFolder(createInviteDto: ShareFolderWithUserPayload): Promise<void>;
226
+ /**
227
+ * Check if the expirationDate of invite is valid.
228
+ * @param {string} invitationId - The id of the invitation.
229
+
230
+ * @returns {Promise<{uuid: string}>} A promise returning the uuid of the invitation if valid.
231
+ */
232
+ validateInviteExpiration(invitationId: string): Promise<{
233
+ uuid: string;
234
+ }>;
235
+ /**
236
+ * Share a private folder with a user.
237
+ * @param {string} invitationId - The id of the invitation.
238
+ * @param {ShareFolderWithUserPayload} options - The options for sharing the private folder with a user.
239
+ * @param {string} options.encryptionKey - The encryption key (just in case the invitation is a request).
240
+ * @param {string} options.itemType - The encryption algorithm (just in case the invitation is a request).
241
+
242
+ * @returns {Promise<void>} A promise that resolves when the folder is shared with the user.
243
+ */
244
+ acceptSharedFolderInvite({ invitationId, acceptInvite, token, }: {
245
+ invitationId: string;
246
+ acceptInvite?: AcceptInvitationToSharedFolderPayload;
247
+ token?: string;
248
+ }): Promise<void>;
249
+ /**
250
+ * Change Sharing Mode.
251
+ * @param {string} options.itemType - folder | file
252
+ * @param {string} options.itemId - id of folder or file
253
+ * @param {string} options.sharingType - New Sharing type.
254
+
255
+ * @returns {Promise<void>} A promise that resolves when sharing mode has been updated.
256
+ */
257
+ updateSharingType({ itemId, itemType, sharingType, }: {
258
+ itemId: string;
259
+ itemType: string;
260
+ sharingType: string;
261
+ }): Promise<void>;
262
+ /**
263
+ * Get Sharing type
264
+ * @param {string} options.itemType - folder | file
265
+ * @param {string} options.itemId - id of folder or file
266
+ * @returns {Promise<SharingMeta>} A promise that returns the sharing data.
267
+ */
268
+ getSharingType({ itemId, itemType }: {
269
+ itemId: string;
270
+ itemType: string;
271
+ }): Promise<SharingMeta>;
272
+ declineSharedFolderInvite(invitationId: string, token?: string): Promise<void>;
273
+ /**
274
+ * Fetches roles for sharing items.
275
+ *
276
+ * @returns {Promise<PrivateSharingRolesResponse>} A promise containing the list of sharing roles.
277
+ */
278
+ getSharingRoles(): Promise<Role[]>;
279
+ getAllAccessUsers({ itemType, folderId, }: {
280
+ itemType: string;
281
+ folderId: string;
282
+ }): Promise<Record<'users', any[]> | Record<'error', string>>;
283
+ /**
284
+ * Stop sharing folder
285
+ * @param {string} itemType - Type of the sharing to delete
286
+ * @param {string} itemId - Id of the sharing to delete
287
+ * @returns
288
+ */
289
+ stopSharingFolder(itemType: string, itemId: string): Promise<void>;
59
290
  /**
60
291
  * Returns the needed headers for the module requests
61
292
  * @private
@@ -71,4 +302,18 @@ export declare class Share {
71
302
  * @private
72
303
  */
73
304
  private basicHeadersWithPassword;
305
+ /**
306
+ * Get request headers with optional authorization token.
307
+ *
308
+ * @param {string} [token] - Optional authorization token.
309
+ * @returns {Object} - Request headers object.
310
+ */
311
+ private getRequestHeaders;
312
+ /**
313
+ * Gets the size of a shared folder given sharing id
314
+ *
315
+ * @param {string} sharingId - Sharing ID.
316
+ * @returns {Promise<SharedFolderSize>}
317
+ */
318
+ getSharedFolderSize(id: string): Promise<SharedFolderSize>;
74
319
  }