@internxt/sdk 1.11.11 → 1.11.13

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,7 +1,8 @@
1
1
  import { ApiSecurity, ApiUrl, AppDetails } from '../shared';
2
2
  import { TeamsSettings } from '../shared/types/teams';
3
3
  import { UserSettings, UUID } from '../shared/types/userSettings';
4
- import { ChangePasswordWithLinkPayload, CryptoProvider, Keys, LoginDetails, PrivateKeys, RegisterDetails, RegisterPreCreatedUser, RegisterPreCreatedUserResponse, SecurityDetails, Token, TwoFactorAuthQR } from './types';
4
+ import { ChangePasswordWithLinkPayload, CryptoProvider, Keys, LoginDetails, PrivateKeys, RegisterDetails, RegisterOpaqueDetails, RegisterPreCreatedUser, RegisterPreCreatedUserResponse, SecurityDetails, Token, TwoFactorAuthQR } from './types';
5
+ import { paths } from '../schema';
5
6
  export * from './types';
6
7
  export declare class Auth {
7
8
  private readonly client;
@@ -10,6 +11,25 @@ export declare class Auth {
10
11
  private readonly apiUrl;
11
12
  static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity?: ApiSecurity): Auth;
12
13
  private constructor();
14
+ /**
15
+ * Runs the first phase (out of 2) of opaque registation of a new user
16
+ * @param email - The user email.
17
+ * @param registrationRequest - The opaque registration request.
18
+ * @returns The opaque sign up response.
19
+ */
20
+ registerOpaqueStart(email: string, registrationRequest: string): Promise<{
21
+ signUpResponse: string;
22
+ }>;
23
+ /**
24
+ * Runs the second phase (out of 2) of opaque registation of a new user
25
+ * @param registrationRecord - The opaque registration record.
26
+ * @param registerDetails - The user registration details.
27
+ * @param startLoginRequest - The opaque start login request.
28
+ * @returns The opaque login response.
29
+ */
30
+ registerOpaqueFinish(registrationRecord: string, registerDetails: RegisterOpaqueDetails, startLoginRequest: string): Promise<{
31
+ loginResponse: string;
32
+ }>;
13
33
  /**
14
34
  * Tries to register a new user
15
35
  * @param registerDetails
@@ -60,6 +80,25 @@ export declare class Auth {
60
80
  * @returns {Promise<void>} - Resolves successfuly when account is unblocked
61
81
  */
62
82
  unblockAccount(token: string): Promise<void>;
83
+ /**
84
+ * Runs the first phase (out of 2) of opaque log for the given user
85
+ * @param email - The user email.
86
+ * @param startLoginRequest - The opaque start login request.
87
+ * @param tfa - The two factor auth code.
88
+ * @returns The opaque login response.
89
+ */
90
+ loginOpaqueStart(email: string, startLoginRequest: string, tfa: string | undefined): Promise<{
91
+ loginResponse: string;
92
+ }>;
93
+ /**
94
+ * Runs the second phase (out of 2) of opaque log for the given user
95
+ * @param email
96
+ * @param finishLoginRequest
97
+ */
98
+ loginOpaqueFinish(email: string, finishLoginRequest: string): Promise<{
99
+ sessionID: string;
100
+ user: UserSettings;
101
+ }>;
63
102
  /**
64
103
  * Tries to log in a user given its login details
65
104
  * @param details
@@ -71,6 +110,12 @@ export declare class Auth {
71
110
  user: UserSettings;
72
111
  userTeam: TeamsSettings | null;
73
112
  }>;
113
+ /**
114
+ * Tries to log in a user given its cli login details
115
+ * @param details
116
+ * @param cryptoProvider
117
+ */
118
+ loginAccess(details: LoginDetails, cryptoProvider: CryptoProvider): Promise<paths['/auth/cli/login/access']['post']['responses']['200']['content']['application/json']>;
74
119
  /**
75
120
  * Tries to log in a user given its login details without sending keys
76
121
  * @param details
@@ -64,6 +64,44 @@ var Auth = /** @class */ (function () {
64
64
  Auth.client = function (apiUrl, appDetails, apiSecurity) {
65
65
  return new Auth(apiUrl, appDetails, apiSecurity);
66
66
  };
67
+ /**
68
+ * Runs the first phase (out of 2) of opaque registation of a new user
69
+ * @param email - The user email.
70
+ * @param registrationRequest - The opaque registration request.
71
+ * @returns The opaque sign up response.
72
+ */
73
+ Auth.prototype.registerOpaqueStart = function (email, registrationRequest) {
74
+ return this.client.post('/register-opaque/start', {
75
+ email: email,
76
+ registrationRequest: registrationRequest,
77
+ }, this.basicHeaders());
78
+ };
79
+ /**
80
+ * Runs the second phase (out of 2) of opaque registation of a new user
81
+ * @param registrationRecord - The opaque registration record.
82
+ * @param registerDetails - The user registration details.
83
+ * @param startLoginRequest - The opaque start login request.
84
+ * @returns The opaque login response.
85
+ */
86
+ Auth.prototype.registerOpaqueFinish = function (registrationRecord, registerDetails, startLoginRequest) {
87
+ return this.client.post('/register-opaque/finish', {
88
+ name: registerDetails.name,
89
+ lastname: registerDetails.lastname,
90
+ email: registerDetails.email,
91
+ registrationRecord: registrationRecord,
92
+ keys: {
93
+ ecc: {
94
+ publicKey: registerDetails.keys.ecc.publicKey,
95
+ privateKey: registerDetails.keys.ecc.privateKey,
96
+ },
97
+ kyber: {
98
+ publicKey: registerDetails.keys.kyber.publicKey,
99
+ privateKey: registerDetails.keys.kyber.privateKey,
100
+ },
101
+ },
102
+ startLoginRequest: startLoginRequest,
103
+ }, this.basicHeaders());
104
+ };
67
105
  /**
68
106
  * Tries to register a new user
69
107
  * @param registerDetails
@@ -189,6 +227,39 @@ var Auth = /** @class */ (function () {
189
227
  Auth.prototype.unblockAccount = function (token) {
190
228
  return this.client.put('users/unblock-account', { token: token }, this.basicHeaders());
191
229
  };
230
+ /**
231
+ * Runs the first phase (out of 2) of opaque log for the given user
232
+ * @param email - The user email.
233
+ * @param startLoginRequest - The opaque start login request.
234
+ * @param tfa - The two factor auth code.
235
+ * @returns The opaque login response.
236
+ */
237
+ Auth.prototype.loginOpaqueStart = function (email, startLoginRequest, tfa) {
238
+ return __awaiter(this, void 0, void 0, function () {
239
+ return __generator(this, function (_a) {
240
+ return [2 /*return*/, this.client.post('/auth/login-opaque/start', {
241
+ email: email,
242
+ startLoginRequest: startLoginRequest,
243
+ tfa: tfa,
244
+ }, this.basicHeaders())];
245
+ });
246
+ });
247
+ };
248
+ /**
249
+ * Runs the second phase (out of 2) of opaque log for the given user
250
+ * @param email
251
+ * @param finishLoginRequest
252
+ */
253
+ Auth.prototype.loginOpaqueFinish = function (email, finishLoginRequest) {
254
+ return __awaiter(this, void 0, void 0, function () {
255
+ return __generator(this, function (_a) {
256
+ return [2 /*return*/, this.client.post('/auth/login-opaque/finish', {
257
+ email: email,
258
+ finishLoginRequest: finishLoginRequest,
259
+ }, this.basicHeaders())];
260
+ });
261
+ });
262
+ };
192
263
  /**
193
264
  * Tries to log in a user given its login details
194
265
  * @param details
@@ -239,6 +310,43 @@ var Auth = /** @class */ (function () {
239
310
  });
240
311
  });
241
312
  };
313
+ /**
314
+ * Tries to log in a user given its cli login details
315
+ * @param details
316
+ * @param cryptoProvider
317
+ */
318
+ Auth.prototype.loginAccess = function (details, cryptoProvider) {
319
+ return __awaiter(this, void 0, void 0, function () {
320
+ var securityDetails, encryptedSalt, encryptedPasswordHash, keys;
321
+ return __generator(this, function (_a) {
322
+ switch (_a.label) {
323
+ case 0: return [4 /*yield*/, this.securityDetails(details.email)];
324
+ case 1:
325
+ securityDetails = _a.sent();
326
+ encryptedSalt = securityDetails.encryptedSalt;
327
+ encryptedPasswordHash = cryptoProvider.encryptPasswordHash(details.password, encryptedSalt);
328
+ return [4 /*yield*/, cryptoProvider.generateKeys(details.password)];
329
+ case 2:
330
+ keys = _a.sent();
331
+ return [2 /*return*/, this.client.post('/auth/cli/login/access', {
332
+ email: details.email,
333
+ password: encryptedPasswordHash,
334
+ tfa: details.tfaCode,
335
+ keys: {
336
+ ecc: {
337
+ publicKey: keys.ecc.publicKey,
338
+ privateKey: keys.ecc.privateKeyEncrypted,
339
+ },
340
+ kyber: {
341
+ publicKey: keys.kyber.publicKey,
342
+ privateKey: keys.kyber.privateKeyEncrypted,
343
+ },
344
+ },
345
+ }, this.basicHeaders())];
346
+ }
347
+ });
348
+ });
349
+ };
242
350
  /**
243
351
  * Tries to log in a user given its login details without sending keys
244
352
  * @param details
@@ -306,6 +414,7 @@ var Auth = /** @class */ (function () {
306
414
  return {
307
415
  encryptedSalt: data.sKey,
308
416
  tfaEnabled: data.tfa === true,
417
+ useOpaqueLogin: data.useOpaqueLogin === true,
309
418
  };
310
419
  });
311
420
  };
@@ -7,6 +7,26 @@ export interface LoginDetails {
7
7
  password: Password;
8
8
  tfaCode: string | undefined;
9
9
  }
10
+ export type UserKeys = {
11
+ ecc: {
12
+ publicKey: string;
13
+ privateKey: string;
14
+ };
15
+ kyber: {
16
+ publicKey: string;
17
+ privateKey: string;
18
+ };
19
+ };
20
+ export interface RegisterOpaqueDetails {
21
+ name: string;
22
+ lastname: string;
23
+ email: Email;
24
+ mnemonic: string;
25
+ keys: UserKeys;
26
+ captcha: string;
27
+ referrer?: string;
28
+ referral?: string;
29
+ }
10
30
  export interface RegisterDetails {
11
31
  name: string;
12
32
  lastname: string;
@@ -52,6 +72,7 @@ export declare class UserAccessError extends Error {
52
72
  export interface SecurityDetails {
53
73
  encryptedSalt: string;
54
74
  tfaEnabled: boolean;
75
+ useOpaqueLogin: boolean;
55
76
  }
56
77
  export interface TwoFactorAuthQR {
57
78
  qr: string;
@@ -2,6 +2,7 @@ import { paths } from '../../schema';
2
2
  import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
3
3
  import { UserSettings } from '../../shared/types/userSettings';
4
4
  import { ChangePasswordPayload, ChangePasswordPayloadNew, CheckChangeEmailExpirationResponse, FriendInvite, InitializeUserResponse, PreCreateUserResponse, Token, UpdateProfilePayload, UserPublicKeyResponse, UserPublicKeyWithCreationResponse, VerifyEmailChangeResponse } from './types';
5
+ import { UserKeys } from '../../auth/types';
5
6
  export * as UserTypes from './types';
6
7
  export declare class Users {
7
8
  private readonly client;
@@ -67,6 +68,29 @@ export declare class Users {
67
68
  token: string;
68
69
  newToken: string;
69
70
  }>;
71
+ /**
72
+ * Runs the first phase (out of 2) of the password change.
73
+ * @param hmac - The HMAC to authenticate request.
74
+ * @param sessionID - The current session ID.
75
+ * @param registrationRequest - The opaque registration request.
76
+ * @returns {Promise<string>} A promise that returns opaque registration response.
77
+ */
78
+ changePwdOpaqueStart(hmac: string, sessionID: string, registrationRequest: string): Promise<{
79
+ registrationResponse: string;
80
+ }>;
81
+ /**
82
+ * Runs the second phase (out of 2) of the password change.
83
+ * @param hmac - The HMAC to authenticate request.
84
+ * @param sessionID - The current session ID.
85
+ * @param registrationRecord - The opaque registration record.
86
+ * @param mnemonic - The user's encrypted mnemonic.
87
+ * @param keys - The user's encrypted keys.
88
+ * @param startLoginRequest - The opaque start login request.
89
+ * @returns {Promise<string>} A promise that returns opaque login response.
90
+ */
91
+ changePwdOpaqueFinish(hmac: string, sessionID: string, registrationRecord: string, mnemonic: string, keys: UserKeys, startLoginRequest: string): Promise<{
92
+ loginResponse: string;
93
+ }>;
70
94
  /**
71
95
  * Pre registers an email
72
96
  * @param email
@@ -164,6 +164,40 @@ var Users = /** @class */ (function () {
164
164
  encryptVersion: payload.encryptVersion,
165
165
  }, this.headers());
166
166
  };
167
+ /**
168
+ * Runs the first phase (out of 2) of the password change.
169
+ * @param hmac - The HMAC to authenticate request.
170
+ * @param sessionID - The current session ID.
171
+ * @param registrationRequest - The opaque registration request.
172
+ * @returns {Promise<string>} A promise that returns opaque registration response.
173
+ */
174
+ Users.prototype.changePwdOpaqueStart = function (hmac, sessionID, registrationRequest) {
175
+ return this.client.patch('/users/password-opaque/start', {
176
+ hmac: hmac,
177
+ sessionID: sessionID,
178
+ registrationRequest: registrationRequest,
179
+ }, this.headers());
180
+ };
181
+ /**
182
+ * Runs the second phase (out of 2) of the password change.
183
+ * @param hmac - The HMAC to authenticate request.
184
+ * @param sessionID - The current session ID.
185
+ * @param registrationRecord - The opaque registration record.
186
+ * @param mnemonic - The user's encrypted mnemonic.
187
+ * @param keys - The user's encrypted keys.
188
+ * @param startLoginRequest - The opaque start login request.
189
+ * @returns {Promise<string>} A promise that returns opaque login response.
190
+ */
191
+ Users.prototype.changePwdOpaqueFinish = function (hmac, sessionID, registrationRecord, mnemonic, keys, startLoginRequest) {
192
+ return this.client.patch('/users/password-opaque/finish', {
193
+ hmac: hmac,
194
+ sessionID: sessionID,
195
+ keys: keys,
196
+ mnemonic: mnemonic,
197
+ registrationRecord: registrationRecord,
198
+ startLoginRequest: startLoginRequest,
199
+ }, this.headers());
200
+ };
167
201
  /**
168
202
  * Pre registers an email
169
203
  * @param email
package/dist/schema.d.ts CHANGED
@@ -2668,6 +2668,23 @@ export interface paths {
2668
2668
  patch?: never;
2669
2669
  trace?: never;
2670
2670
  };
2671
+ '/auth/cli/login/access': {
2672
+ parameters: {
2673
+ query?: never;
2674
+ header?: never;
2675
+ path?: never;
2676
+ cookie?: never;
2677
+ };
2678
+ get?: never;
2679
+ put?: never;
2680
+ /** CLI platform login access */
2681
+ post: operations['AuthController_cliLoginAccess'];
2682
+ delete?: never;
2683
+ options?: never;
2684
+ head?: never;
2685
+ patch?: never;
2686
+ trace?: never;
2687
+ };
2671
2688
  '/links': {
2672
2689
  parameters: {
2673
2690
  query?: never;
@@ -3105,12 +3122,27 @@ export interface components {
3105
3122
  */
3106
3123
  plainNames: string[];
3107
3124
  };
3108
- ExistingFoldersDto: {
3125
+ ExistentFoldersDto: {
3109
3126
  existentFolders: components['schemas']['FolderDto'][];
3110
3127
  };
3128
+ FilesNameAndType: {
3129
+ /**
3130
+ * @description Type of file
3131
+ * @example pdf
3132
+ */
3133
+ type?: string;
3134
+ /**
3135
+ * @description Plain name of file
3136
+ * @example example
3137
+ */
3138
+ plainName: string;
3139
+ };
3111
3140
  CheckFileExistenceInFolderDto: {
3112
3141
  /** @description Array of files with names and types */
3113
- files: string[];
3142
+ files: components['schemas']['FilesNameAndType'][];
3143
+ };
3144
+ ExistentFilesDto: {
3145
+ existentFiles: components['schemas']['FileDto'][];
3114
3146
  };
3115
3147
  GetFolderContentDto: {
3116
3148
  type: string;
@@ -4699,6 +4731,11 @@ export interface components {
4699
4731
  * @example 123456
4700
4732
  */
4701
4733
  maxSpaceBytes: number;
4734
+ /**
4735
+ * @description Tier ID to update user tier (optional)
4736
+ * @example a1b2c3d4-e5f6-7890-abcd-ef1234567890
4737
+ */
4738
+ tierId?: string;
4702
4739
  };
4703
4740
  };
4704
4741
  responses: never;
@@ -5204,7 +5241,7 @@ export interface operations {
5204
5241
  [name: string]: unknown;
5205
5242
  };
5206
5243
  content: {
5207
- 'application/json': components['schemas']['ExistingFoldersDto'];
5244
+ 'application/json': components['schemas']['ExistentFoldersDto'];
5208
5245
  };
5209
5246
  };
5210
5247
  };
@@ -5224,11 +5261,13 @@ export interface operations {
5224
5261
  };
5225
5262
  };
5226
5263
  responses: {
5227
- 201: {
5264
+ 200: {
5228
5265
  headers: {
5229
5266
  [name: string]: unknown;
5230
5267
  };
5231
- content?: never;
5268
+ content: {
5269
+ 'application/json': components['schemas']['ExistentFilesDto'];
5270
+ };
5232
5271
  };
5233
5272
  };
5234
5273
  };
@@ -6433,12 +6472,12 @@ export interface operations {
6433
6472
  };
6434
6473
  WorkspacesController_getFiles: {
6435
6474
  parameters: {
6436
- query: {
6475
+ query?: {
6437
6476
  /** @description Items per page */
6438
6477
  limit?: number;
6439
6478
  /** @description Offset for pagination */
6440
6479
  offset?: number;
6441
- status: string;
6480
+ status?: 'EXISTS' | 'TRASHED' | 'DELETED' | 'ALL';
6442
6481
  bucket?: string;
6443
6482
  sort?: string;
6444
6483
  order?: string;
@@ -6495,6 +6534,7 @@ export interface operations {
6495
6534
  limit?: number;
6496
6535
  /** @description Offset for pagination */
6497
6536
  offset?: number;
6537
+ status?: 'EXISTS' | 'TRASHED' | 'DELETED' | 'ALL';
6498
6538
  };
6499
6539
  header?: never;
6500
6540
  path: {
@@ -8869,6 +8909,37 @@ export interface operations {
8869
8909
  };
8870
8910
  };
8871
8911
  };
8912
+ AuthController_cliLoginAccess: {
8913
+ parameters: {
8914
+ query?: never;
8915
+ header?: never;
8916
+ path?: never;
8917
+ cookie?: never;
8918
+ };
8919
+ requestBody: {
8920
+ content: {
8921
+ 'application/json': components['schemas']['LoginAccessDto'];
8922
+ };
8923
+ };
8924
+ responses: {
8925
+ /** @description CLI user successfully accessed their account */
8926
+ 200: {
8927
+ headers: {
8928
+ [name: string]: unknown;
8929
+ };
8930
+ content: {
8931
+ 'application/json': components['schemas']['LoginAccessResponseDto'];
8932
+ };
8933
+ };
8934
+ /** @description This user current tier does not allow CLI access */
8935
+ 402: {
8936
+ headers: {
8937
+ [name: string]: unknown;
8938
+ };
8939
+ content?: never;
8940
+ };
8941
+ };
8942
+ };
8872
8943
  SendController_createLinks: {
8873
8944
  parameters: {
8874
8945
  query?: never;
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.11.11",
4
+ "version": "1.11.13",
5
5
  "description": "An sdk for interacting with Internxt's services",
6
6
  "repository": {
7
7
  "type": "git",
@@ -32,15 +32,15 @@
32
32
  "@types/jest": "30.0.0",
33
33
  "@types/sinon": "17.0.4",
34
34
  "@types/uuid": "10.0.0",
35
- "eslint": "9.35.0",
35
+ "eslint": "9.36.0",
36
36
  "husky": "9.1.7",
37
- "jest": "30.1.3",
38
- "lint-staged": "16.1.6",
37
+ "jest": "30.2.0",
38
+ "lint-staged": "16.2.3",
39
39
  "openapi-typescript": "^7.9.1",
40
40
  "prettier": "3.6.2",
41
41
  "sinon": "21.0.0",
42
- "ts-jest": "29.4.1",
43
- "typescript": "5.9.2"
42
+ "ts-jest": "29.4.4",
43
+ "typescript": "5.9.3"
44
44
  },
45
45
  "dependencies": {
46
46
  "axios": "^1.12.2",