@internxt/sdk 1.9.3 → 1.9.4

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.
@@ -94,12 +94,11 @@ export declare class Auth {
94
94
  */
95
95
  confirmDeactivation(token: string): Promise<void>;
96
96
  /**
97
- * Checks if the password is correct for this email
98
- * @param email
97
+ * Check credentials
99
98
  * @param hashedPassword
100
99
  * @returns
101
100
  */
102
- areCredentialsCorrect(email: string, hashedPassword: string): Promise<boolean>;
101
+ areCredentialsCorrect(hashedPassword: string, token?: Token): Promise<boolean>;
103
102
  /**
104
103
  * Send email to change password
105
104
  * @param email
@@ -91,7 +91,7 @@ var Auth = /** @class */ (function () {
91
91
  kyber: {
92
92
  publicKey: registerDetails.keys.kyber.publicKey,
93
93
  privateKeyEncrypted: registerDetails.keys.kyber.privateKeyEncrypted,
94
- }
94
+ },
95
95
  },
96
96
  referral: registerDetails.referral,
97
97
  referrer: registerDetails.referrer,
@@ -189,7 +189,7 @@ var Auth = /** @class */ (function () {
189
189
  kyber: {
190
190
  publicKey: keys.kyber.publicKey,
191
191
  privateKeyEncrypted: keys.kyber.privateKeyEncrypted,
192
- }
192
+ },
193
193
  },
194
194
  }, this.basicHeaders())
195
195
  .then(function (data) {
@@ -222,7 +222,7 @@ var Auth = /** @class */ (function () {
222
222
  kyber: {
223
223
  publicKey: keys.kyber.publicKey,
224
224
  privateKeyEncrypted: keys.kyber.privateKeyEncrypted,
225
- }
225
+ },
226
226
  }, this.headersWithToken(token));
227
227
  };
228
228
  /**
@@ -301,26 +301,24 @@ var Auth = /** @class */ (function () {
301
301
  return this.client.get("/confirmDeactivation/".concat(token), this.basicHeaders());
302
302
  };
303
303
  /**
304
- * Checks if the password is correct for this email
305
- * @param email
304
+ * Check credentials
306
305
  * @param hashedPassword
307
306
  * @returns
308
307
  */
309
- Auth.prototype.areCredentialsCorrect = function (email, hashedPassword) {
308
+ Auth.prototype.areCredentialsCorrect = function (hashedPassword, token) {
310
309
  var _a;
311
- // Uses fetch instead of httpClient since a 401 response
312
- // would log out the user
313
- return fetch("".concat(this.apiUrl, "/are-credentials-correct?email=").concat(email, "&hashedPassword=").concat(hashedPassword), {
314
- headers: this.headersWithToken((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token),
315
- }).then(function (res) {
316
- if (res.ok) {
317
- return true;
318
- }
319
- else if (res.status === 401) {
310
+ var url = '/auth/are-credentials-correct';
311
+ return this.client
312
+ .getWithParams(url, { hashedPassword: hashedPassword }, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token))
313
+ .then(function (res) {
314
+ return res;
315
+ })
316
+ .catch(function (error) {
317
+ var _a, _b, _c;
318
+ if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
320
319
  return false;
321
320
  }
322
- else
323
- throw new Error("Request failed with error ".concat(res.status));
321
+ throw new Error("Request failed with status ".concat((_b = error.response) === null || _b === void 0 ? void 0 : _b.status, ": ").concat((_c = error.response) === null || _c === void 0 ? void 0 : _c.data));
324
322
  });
325
323
  };
326
324
  /**
@@ -1,6 +1,6 @@
1
1
  import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
2
2
  import { UserSettings } from '../../shared/types/userSettings';
3
- import { ChangePasswordPayload, ChangePasswordPayloadNew, CheckChangeEmailExpirationResponse, FriendInvite, InitializeUserResponse, PreCreateUserResponse, UpdateProfilePayload, UserPublicKeyResponse, VerifyEmailChangeResponse } from './types';
3
+ import { ChangePasswordPayload, ChangePasswordPayloadNew, CheckChangeEmailExpirationResponse, FriendInvite, InitializeUserResponse, PreCreateUserResponse, Token, UpdateProfilePayload, UserPublicKeyResponse, VerifyEmailChangeResponse } from './types';
4
4
  export * as UserTypes from './types';
5
5
  export declare class Users {
6
6
  private readonly client;
@@ -94,7 +94,7 @@ export declare class Users {
94
94
  /**
95
95
  * Sends verification email
96
96
  */
97
- sendVerificationEmail(): Promise<void>;
97
+ sendVerificationEmail(token?: Token): Promise<void>;
98
98
  /**
99
99
  * Verifies user email
100
100
  */
@@ -132,4 +132,5 @@ export declare class Users {
132
132
  email: string;
133
133
  }): Promise<UserPublicKeyResponse>;
134
134
  private headers;
135
+ private headersWithToken;
135
136
  }
@@ -153,14 +153,15 @@ var Users = /** @class */ (function () {
153
153
  /**
154
154
  * Sends verification email
155
155
  */
156
- Users.prototype.sendVerificationEmail = function () {
157
- return this.client.post('/user/sendVerificationEmail', {}, this.headers());
156
+ Users.prototype.sendVerificationEmail = function (token) {
157
+ var _a;
158
+ return this.client.post('/users/email-verification/send', {}, this.headersWithToken(token !== null && token !== void 0 ? token : (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token));
158
159
  };
159
160
  /**
160
161
  * Verifies user email
161
162
  */
162
163
  Users.prototype.verifyEmail = function (payload) {
163
- return this.client.post('/user/verifyEmail', payload, this.headers());
164
+ return this.client.post('/users/email-verification', payload, this.headers());
164
165
  };
165
166
  /**
166
167
  * Change user email by new email
@@ -204,6 +205,9 @@ var Users = /** @class */ (function () {
204
205
  Users.prototype.headers = function () {
205
206
  return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token);
206
207
  };
208
+ Users.prototype.headersWithToken = function (token) {
209
+ return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, token);
210
+ };
207
211
  return Users;
208
212
  }());
209
213
  exports.Users = Users;
@@ -1,4 +1,5 @@
1
1
  import { UUID, UserSettings } from '../../shared/types/userSettings';
2
+ export type Token = string;
2
3
  export interface InitializeUserResponse {
3
4
  email: string;
4
5
  bucket: string;
@@ -18,8 +19,8 @@ export interface ChangePasswordPayloadNew {
18
19
  newEncryptedSalt: string;
19
20
  encryptedMnemonic: string;
20
21
  /**
21
- * @deprecated encryptedPrivateKey field is depercated, use keys.encryptedPrivateKey instead
22
- */
22
+ * @deprecated encryptedPrivateKey field is depercated, use keys.encryptedPrivateKey instead
23
+ */
23
24
  encryptedPrivateKey: string;
24
25
  keys: {
25
26
  encryptedPrivateKey: string;
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.3",
4
+ "version": "1.9.4",
5
5
  "description": "An sdk for interacting with Internxt's services",
6
6
  "repository": {
7
7
  "type": "git",