Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@internxt/sdk",
"author": "Internxt <hello@internxt.com>",
"version": "1.20.1",
"version": "1.20.2",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
116 changes: 0 additions & 116 deletions src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
PrivateKeys,
RecoveryKeys,
RegisterDetails,
RegisterOpaqueDetails,
RegisterPreCreatedUser,
RegisterPreCreatedUserResponse,
SecurityDetails,
Expand Down Expand Up @@ -39,65 +38,6 @@ export class Auth {
this.apiUrl = apiUrl;
}

/**
* Runs the first phase (out of 2) of opaque registation of a new user
* @param email - The user email.
* @param registrationRequest - The opaque registration request.
* @returns The opaque sign up response.
*/
public registerOpaqueStart(
email: string,
registrationRequest: string,
): Promise<{
signUpResponse: string;
}> {
return this.client.post(
'/register-opaque/start',
{
email,
registrationRequest,
},
this.basicHeaders(),
);
}

/**
* Runs the second phase (out of 2) of opaque registation of a new user
* @param registrationRecord - The opaque registration record.
* @param registerDetails - The user registration details.
* @param startLoginRequest - The opaque start login request.
* @returns The opaque login response.
*/
public registerOpaqueFinish(
registrationRecord: string,
registerDetails: RegisterOpaqueDetails,
startLoginRequest: string,
): Promise<{
loginResponse: string;
}> {
return this.client.post(
'/register-opaque/finish',
{
name: registerDetails.name,
lastname: registerDetails.lastname,
email: registerDetails.email,
registrationRecord,
keys: {
ecc: {
publicKey: registerDetails.keys.ecc.publicKey,
privateKey: registerDetails.keys.ecc.privateKey,
},
kyber: {
publicKey: registerDetails.keys.kyber.publicKey,
privateKey: registerDetails.keys.kyber.privateKey,
},
},
startLoginRequest,
},
this.basicHeaders(),
);
}

/**
* Tries to register a new user
* @param registerDetails
Expand Down Expand Up @@ -245,60 +185,6 @@ export class Auth {
return this.client.put('users/unblock-account', { token }, this.basicHeaders());
}

/**
* Runs the first phase (out of 2) of opaque log for the given user
* @param email - The user email.
* @param startLoginRequest - The opaque start login request.
* @param tfa - The two factor auth code.
* @returns The opaque login response.
*/
public async loginOpaqueStart(
email: string,
startLoginRequest: string,
): Promise<{
loginResponse: string;
}> {
return this.client.post<{
loginResponse: string;
}>(
'/auth/login-opaque/start',
{
email,
startLoginRequest,
},
this.basicHeaders(),
);
}

/**
* Runs the second phase (out of 2) of opaque log for the given user
* @param email
* @param finishLoginRequest
*/
public async loginOpaqueFinish(
email: string,
finishLoginRequest: string,
tfa: string | undefined,
): Promise<{
sessionID: string;
user: UserSettings;
token: string;
}> {
return this.client.post<{
sessionID: string;
user: UserSettings;
token: string;
}>(
'/auth/login-opaque/finish',
{
email,
finishLoginRequest,
tfa,
},
this.basicHeaders(),
);
}

/**
* Tries to log in a user given its login details
* @param details
Expand Down Expand Up @@ -444,7 +330,6 @@ export class Auth {
.post<{
sKey: string;
tfa: boolean | null;
useOpaqueLogin: boolean | null;
}>(
'/auth/login',
{
Expand All @@ -456,7 +341,6 @@ export class Auth {
return {
encryptedSalt: data.sKey,
tfaEnabled: data.tfa === true,
useOpaqueLogin: data.useOpaqueLogin === true,
};
});
}
Expand Down
12 changes: 0 additions & 12 deletions src/auth/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@ export type UserKeys = {
};
};

export interface RegisterOpaqueDetails {
name: string;
lastname: string;
email: Email;
mnemonic: string;
keys: UserKeys;
captcha: string;
referrer?: string;
referral?: string;
}

export interface RegisterDetails {
name: string;
lastname: string;
Expand Down Expand Up @@ -76,7 +65,6 @@ export class UserAccessError extends Error {}
export interface SecurityDetails {
encryptedSalt: string;
tfaEnabled: boolean;
useOpaqueLogin: boolean;
}

export interface TwoFactorAuthQR {
Expand Down
55 changes: 0 additions & 55 deletions src/drive/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
VerifyEmailChangeResponse,
} from './types';

import { UserKeys } from '../../auth/types';
export * as UserTypes from './types';

export class Users {
Expand Down Expand Up @@ -160,60 +159,6 @@ export class Users {
);
}

/**
* Runs the first phase (out of 2) of the password change.
* @param hmac - The HMAC to authenticate request.
* @param sessionID - The current session ID.
* @param registrationRequest - The opaque registration request.
* @returns {Promise<string>} A promise that returns opaque registration response.
*/
public changePwdOpaqueStart(
hmac: string,
sessionID: string,
registrationRequest: string,
): Promise<{ registrationResponse: string }> {
return this.client.patch(
'/users/password-opaque/start',
{
hmac,
sessionID,
registrationRequest,
},
this.headers(),
);
}

/**
* Runs the second phase (out of 2) of the password change.
* @param hmac - The HMAC to authenticate request.
* @param sessionID - The current session ID.
* @param registrationRecord - The opaque registration record.
* @param mnemonic - The user's encrypted mnemonic.
* @param keys - The user's encrypted keys.
* @param startLoginRequest - The opaque start login request.
* @returns {Promise<string>} A promise that returns opaque login response.
*/
public changePwdOpaqueFinish(
hmac: string,
sessionID: string,
registrationRecord: string,
mnemonic: string,
keys: UserKeys,
startLoginRequest: string,
): Promise<{ loginResponse: string }> {
return this.client.patch(
'/users/password-opaque/finish',
{
hmac,
sessionID,
keys,
mnemonic,
registrationRecord,
startLoginRequest,
},
this.headers(),
);
}
/**
* Pre registers an email
* @param email
Expand Down
33 changes: 10 additions & 23 deletions test/auth/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { emptyRegisterDetails } from './registerDetails.mother';
import { basicHeaders, headersWithToken } from '../../src/shared/headers';
import { ApiSecurity, AppDetails } from '../../src/shared';
import { HttpClient } from '../../src/shared/http/client';
import { Auth, CryptoProvider, Keys, LoginDetails, Password, RegisterDetails, Token } from '../../src';
import { Auth, CryptoProvider, Keys, LoginDetails, RegisterDetails, Token } from '../../src';

describe('# auth service tests', () => {
beforeEach(() => {
Expand All @@ -24,8 +24,7 @@ describe('# auth service tests', () => {
registerDetails.keys.ecc.publicKey = '8';
registerDetails.keys.kyber.privateKeyEncrypted = '9';
registerDetails.keys.kyber.publicKey = '10';
registerDetails.keys.revocationCertificate = '11';
registerDetails.captcha = '12';
registerDetails.captcha = '11';

const postCall = vi.spyOn(HttpClient.prototype, 'post').mockResolvedValue({});
const { client, headers } = clientAndHeaders();
Expand Down Expand Up @@ -93,8 +92,7 @@ describe('# auth service tests', () => {
registerDetails.keys.ecc.publicKey = '8';
registerDetails.keys.kyber.privateKeyEncrypted = '9';
registerDetails.keys.kyber.publicKey = '10';
registerDetails.keys.revocationCertificate = '11';
registerDetails.captcha = '12';
registerDetails.captcha = '11';

const postCall = vi.spyOn(HttpClient.prototype, 'post').mockResolvedValue({});
const { client, headers } = clientAndHeaders();
Expand Down Expand Up @@ -152,8 +150,7 @@ describe('# auth service tests', () => {
registerDetails.keys.ecc.publicKey = '8';
registerDetails.keys.kyber.privateKeyEncrypted = '9';
registerDetails.keys.kyber.publicKey = '10';
registerDetails.keys.revocationCertificate = '11';
registerDetails.captcha = '12';
registerDetails.captcha = '11';

const mockInvitatioId = 'invitationId';

Expand Down Expand Up @@ -224,8 +221,7 @@ describe('# auth service tests', () => {
registerDetails.keys.ecc.publicKey = '8';
registerDetails.keys.kyber.privateKeyEncrypted = '9';
registerDetails.keys.kyber.publicKey = '10';
registerDetails.keys.revocationCertificate = '11';
registerDetails.captcha = '12';
registerDetails.captcha = '11';

const mockInvitatioId = 'invitationId';

Expand Down Expand Up @@ -289,11 +285,8 @@ describe('# auth service tests', () => {
};
const cryptoProvider: CryptoProvider = {
encryptPasswordHash: () => '',
generateKeys: (password: Password) => {
generateKeys: () => {
const keys: Keys = {
privateKeyEncrypted: '',
publicKey: '',
revocationCertificate: '',
ecc: {
publicKey: '',
privateKeyEncrypted: '',
Expand Down Expand Up @@ -325,11 +318,8 @@ describe('# auth service tests', () => {
};
const cryptoProvider: CryptoProvider = {
encryptPasswordHash: () => '',
generateKeys: (password: Password) => {
generateKeys: () => {
const keys: Keys = {
privateKeyEncrypted: '',
publicKey: '',
revocationCertificate: '',
ecc: {
publicKey: '',
privateKeyEncrypted: '',
Expand Down Expand Up @@ -366,7 +356,7 @@ describe('# auth service tests', () => {
};
const cryptoProvider: CryptoProvider = {
encryptPasswordHash: (password, encryptedSalt) => password + '-' + encryptedSalt,
generateKeys: (password: Password) => {
generateKeys: () => {
const keys: Keys = {
ecc: {
publicKey: 'pub',
Expand Down Expand Up @@ -434,7 +424,7 @@ describe('# auth service tests', () => {
};
const cryptoProvider: CryptoProvider = {
encryptPasswordHash: (password, encryptedSalt) => password + '-' + encryptedSalt,
generateKeys: (password: Password) => {
generateKeys: () => {
const keys: Keys = {
ecc: {
publicKey: 'pub',
Expand Down Expand Up @@ -492,7 +482,7 @@ describe('# auth service tests', () => {
};
const cryptoProvider: CryptoProvider = {
encryptPasswordHash: () => '',
generateKeys: (password: Password) => {
generateKeys: () => {
const keys: Keys = {
ecc: {
publicKey: '',
Expand Down Expand Up @@ -560,7 +550,6 @@ describe('# auth service tests', () => {
hasKeys: true,
sKey: 'gibberish',
tfa: true,
useOpaqueLogin: true,
});
const { client, headers } = clientAndHeaders();
const email = 'my@email.com';
Expand All @@ -579,7 +568,6 @@ describe('# auth service tests', () => {
expect(body).toEqual({
encryptedSalt: 'gibberish',
tfaEnabled: true,
useOpaqueLogin: true,
});
});

Expand All @@ -600,7 +588,6 @@ describe('# auth service tests', () => {
expect(body).toEqual({
encryptedSalt: 'gibberish',
tfaEnabled: false,
useOpaqueLogin: false,
});
});
});
Expand Down
Loading