Skip to content

Commit 1449baa

Browse files
committed
Bump to Internxt SDK 1.6.4 by:
- Adjusting `plain_name` field to `plainName` - Adding missing crypto keys making the login fail - Making `encryptPasswordHash` asynchronous - Consdering the new fields of the folder entity: `deleted`, `removed`, `modificationTime`, `creationTime`, `encryptVersion` in the tests
1 parent eef38ee commit 1449baa

9 files changed

Lines changed: 91 additions & 25 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"dependencies": {
3838
"@internxt/inxt-js": "^2.0.11",
3939
"@internxt/lib": "^1.2.1",
40-
"@internxt/sdk": "^1.5.25",
40+
"@internxt/sdk": "1.6.4",
4141
"@oclif/core": "^3",
4242
"axios": "^1.7.7",
4343
"bip39": "^3.1.0",

src/commands/create-folder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default class CreateFolder extends Command {
5757
const newFolder = await createNewFolder;
5858
CLIUtils.done();
5959
CLIUtils.success(
60-
`Folder ${newFolder.plain_name} created successfully, view it at view it at ${ConfigService.instance.get('DRIVE_URL')}/folder/${newFolder.uuid}`,
60+
`Folder ${newFolder.plainName} created successfully, view it at view it at ${ConfigService.instance.get('DRIVE_URL')}/folder/${newFolder.uuid}`,
6161
);
6262
}
6363
}

src/services/crypto.service.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ export class CryptoService {
1010
public static readonly instance: CryptoService = new CryptoService();
1111

1212
public static readonly cryptoProvider: CryptoProvider = {
13-
encryptPasswordHash(password: Password, encryptedSalt: string): string {
13+
encryptPasswordHash(password: Password, encryptedSalt: string): Promise<string> {
1414
const salt = CryptoService.instance.decryptText(encryptedSalt);
1515
const hashObj = CryptoService.instance.passToHash({ password, salt });
16-
return CryptoService.instance.encryptText(hashObj.hash);
16+
return Promise.resolve(CryptoService.instance.encryptText(hashObj.hash));
1717
},
1818
async generateKeys(password: Password): Promise<Keys> {
1919
const { privateKeyArmoredEncrypted, publicKeyArmored, revocationCertificate } =
@@ -22,6 +22,14 @@ export class CryptoService {
2222
privateKeyEncrypted: privateKeyArmoredEncrypted,
2323
publicKey: publicKeyArmored,
2424
revocationCertificate: revocationCertificate,
25+
ecc: {
26+
privateKeyEncrypted: privateKeyArmoredEncrypted,
27+
publicKey: publicKeyArmored,
28+
},
29+
kyber: {
30+
privateKeyEncrypted: null,
31+
publicKey: null
32+
}
2533
};
2634
return keys;
2735
},

src/webdav/handlers/MKCOL.handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class MKCOLRequestHandler implements WebDavMethodHandler {
4545

4646
await driveDatabaseManager.createFolder(
4747
{
48-
name: newFolder.plain_name,
48+
name: newFolder.plainName,
4949
status: 'EXISTS',
5050
encryptedName: newFolder.name,
5151
bucket: newFolder.bucket,

test/fixtures/auth.fixture.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { UserSettings } from '@internxt/sdk/dist/shared/types/userSettings';
22
import crypto from 'crypto';
33

4-
export const UserFixture = {
4+
export const UserFixture: UserSettings = {
55
userId: crypto.randomBytes(16).toString('hex'),
66
uuid: crypto.randomBytes(16).toString('hex'),
77
email: crypto.randomBytes(16).toString('hex'),
@@ -20,6 +20,17 @@ export const UserFixture = {
2020
privateKey: crypto.randomBytes(16).toString('hex'),
2121
publicKey: crypto.randomBytes(16).toString('hex'),
2222
revocationKey: crypto.randomBytes(16).toString('hex'),
23+
keys: {
24+
ecc: {
25+
privateKey: crypto.randomBytes(16).toString('hex'),
26+
publicKey: crypto.randomBytes(16).toString('hex'),
27+
revocationKey: crypto.randomBytes(16).toString('hex'),
28+
},
29+
kyber: {
30+
privateKyberKey: crypto.randomBytes(16).toString('hex'),
31+
publicKyberKey: crypto.randomBytes(16).toString('hex'),
32+
}
33+
},
2334
teams: false,
2435
appSumoDetails: null,
2536
registerCompleted: true,
@@ -47,6 +58,17 @@ export const UserSettingsFixture: UserSettings = {
4758
privateKey: UserFixture.privateKey,
4859
publicKey: UserFixture.publicKey,
4960
revocationKey: UserFixture.revocationKey,
61+
keys: {
62+
ecc: {
63+
privateKey: UserFixture.keys.ecc.privateKey,
64+
publicKey: UserFixture.keys.ecc.publicKey,
65+
revocationKey: UserFixture.revocationKey,
66+
},
67+
kyber: {
68+
privateKyberKey: UserFixture.keys.kyber.privateKyberKey,
69+
publicKyberKey: UserFixture.keys.kyber.publicKyberKey,
70+
}
71+
},
5072
teams: UserFixture.teams,
5173
appSumoDetails: UserFixture.appSumoDetails,
5274
registerCompleted: UserFixture.registerCompleted,

test/services/crypto.service.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('Crypto service', () => {
5757
expect(spyConfigService).to.be.calledWith(envEndpoint.key);
5858
});
5959

60-
it('When a password is hashed using CryptoProvider, then it is hashed correctly', () => {
60+
it('When a password is hashed using CryptoProvider, then it is hashed correctly', async () => {
6161
const envEndpoint: { key: keyof ConfigKeys; value: string } = {
6262
key: 'APP_CRYPTO_SECRET',
6363
value: crypto.randomBytes(16).toString('hex'),
@@ -74,7 +74,7 @@ describe('Crypto service', () => {
7474

7575
const encryptedSalt = CryptoService.instance.encryptText(password.salt);
7676
const hashedAndEncryptedPassword = CryptoService.cryptoProvider.encryptPasswordHash(password.value, encryptedSalt);
77-
const hashedPassword = CryptoService.instance.decryptText(hashedAndEncryptedPassword);
77+
const hashedPassword = CryptoService.instance.decryptText(await hashedAndEncryptedPassword);
7878

7979
const expectedHashedPassword = crypto
8080
.pbkdf2Sync(password.value, Buffer.from(password.salt, 'hex'), 10000, 256 / 8, 'sha1')
@@ -110,6 +110,14 @@ describe('Crypto service', () => {
110110
privateKeyEncrypted: keysReturned.privateKeyArmoredEncrypted,
111111
publicKey: keysReturned.publicKeyArmored,
112112
revocationCertificate: keysReturned.revocationCertificate,
113+
kyber: {
114+
privateKeyEncrypted: null,
115+
publicKey: null,
116+
},
117+
ecc: {
118+
privateKeyEncrypted: keysReturned.privateKeyArmoredEncrypted,
119+
publicKey: keysReturned.publicKeyArmored,
120+
}
113121
};
114122

115123
const resultedKeys = await CryptoService.cryptoProvider.generateKeys(password);

test/services/drive/drive-folder.service.test.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,19 @@ describe('Drive folder Service', () => {
8484
bucket: 'bucket1',
8585
id: 0,
8686
name: 'folder-1',
87-
plain_name: 'folder-1',
88-
createdAt: '',
89-
updatedAt: '',
87+
plainName: 'folder-1',
88+
createdAt: new Date(),
89+
updatedAt: new Date(),
9090
userId: 0,
9191
uuid: '1234-5678-9012-3456',
9292
parentUuid: '0123-5678-9012-3456',
93+
encryptVersion: 'aes-03',
94+
creationTime: new Date(),
95+
deleted: false,
96+
deletedAt: null,
97+
modificationTime: new Date(),
98+
removed: false,
99+
removedAt: null,
93100
};
94101
sandbox
95102
.stub(Storage.prototype, 'createFolder')
@@ -101,6 +108,6 @@ describe('Drive folder Service', () => {
101108
});
102109

103110
const newFolder = await createFolder;
104-
expect(newFolder.plain_name).to.be.eq('folder-1');
111+
expect(newFolder.plainName).to.be.eq('folder-1');
105112
});
106113
});

test/webdav/handlers/MKCOL.handler.test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,19 @@ describe('MKCOL request handler', () => {
5050
bucket: 'bucket1',
5151
id: 0,
5252
name: 'folder-1',
53-
plain_name: 'FolderA',
54-
createdAt: '',
55-
updatedAt: '',
53+
plainName: 'FolderA',
54+
createdAt: new Date(),
55+
updatedAt: new Date(),
5656
userId: 0,
5757
uuid: '1234-5678-9012-3456',
5858
parentUuid: '0123-5678-9012-3456',
59+
removed: false,
60+
removedAt: null,
61+
creationTime: new Date(),
62+
deleted: false,
63+
deletedAt: null,
64+
encryptVersion: 'aes-03',
65+
modificationTime: new Date(),
5966
};
6067

6168
const getRequestedResourceStub = sandbox

yarn.lock

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,15 @@
13341334
resolved "https://npm.pkg.github.com/download/@internxt/prettier-config/1.0.2/5bd220b8de76734448db5475b3e0c01f9d22c19b#5bd220b8de76734448db5475b3e0c01f9d22c19b"
13351335
integrity sha512-t4HiqvCbC7XgQepwWlIaFJe3iwW7HCf6xOSU9nKTV0tiGqOPz7xMtIgLEloQrDA34Cx4PkOYBXrvFPV6RxSFAA==
13361336

1337+
"@internxt/sdk@1.6.4":
1338+
version "1.6.4"
1339+
resolved "https://npm.pkg.github.com/download/@internxt/sdk/1.6.4/79720d5d4ff3a0f12da4dbd4094d666f6f8a1854#79720d5d4ff3a0f12da4dbd4094d666f6f8a1854"
1340+
integrity sha512-XMub1zcRwf6C/3fWlHDVrqUTRD7U4M279dUB4Z4f5dPPL7JdYdDlCe3nzZN56yLgHEty7CJJ9kWVJT9357/Q5A==
1341+
dependencies:
1342+
axios "^0.28.0"
1343+
query-string "^7.1.0"
1344+
uuid "^11.0.2"
1345+
13371346
"@internxt/sdk@^1.4.27":
13381347
version "1.4.70"
13391348
resolved "https://npm.pkg.github.com/download/@internxt/sdk/1.4.70/6e07263dbaa130269323d21b895ea8c0e7d1cc3c#6e07263dbaa130269323d21b895ea8c0e7d1cc3c"
@@ -1343,15 +1352,6 @@
13431352
query-string "^7.1.0"
13441353
uuid "^8.3.2"
13451354

1346-
"@internxt/sdk@^1.5.25":
1347-
version "1.5.25"
1348-
resolved "https://npm.pkg.github.com/download/@internxt/sdk/1.5.25/c0dc19d92b4002d897c5cc177168f36c9c34001f#c0dc19d92b4002d897c5cc177168f36c9c34001f"
1349-
integrity sha512-FTMGTv2p3ZKl91BMhBlig7CyZ45hTWoSUDf2cyM/iIZtdublGbMipG644tIlZbtrEDmQRA8XCO2NjkPV3IjXow==
1350-
dependencies:
1351-
axios "^0.24.0"
1352-
query-string "^7.1.0"
1353-
uuid "^8.3.2"
1354-
13551355
"@isaacs/string-locale-compare@^1.1.0":
13561356
version "1.1.0"
13571357
resolved "https://registry.yarnpkg.com/@isaacs/string-locale-compare/-/string-locale-compare-1.1.0.tgz#291c227e93fd407a96ecd59879a35809120e432b"
@@ -3614,6 +3614,15 @@ axios@^0.24.0:
36143614
dependencies:
36153615
follow-redirects "^1.14.4"
36163616

3617+
axios@^0.28.0:
3618+
version "0.28.1"
3619+
resolved "https://registry.yarnpkg.com/axios/-/axios-0.28.1.tgz#2a7bcd34a3837b71ee1a5ca3762214b86b703e70"
3620+
integrity sha512-iUcGA5a7p0mVb4Gm/sy+FSECNkPFT4y7wt6OM/CDpO/OnNCvSs3PoMG8ibrC9jRoGYU0gUK5pXVC4NPXq6lHRQ==
3621+
dependencies:
3622+
follow-redirects "^1.15.0"
3623+
form-data "^4.0.0"
3624+
proxy-from-env "^1.1.0"
3625+
36173626
axios@^1.7.7:
36183627
version "1.7.7"
36193628
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.7.tgz#2f554296f9892a72ac8d8e4c5b79c14a91d0a47f"
@@ -5621,7 +5630,7 @@ follow-redirects@^1.14.0, follow-redirects@^1.14.4:
56215630
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020"
56225631
integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==
56235632

5624-
follow-redirects@^1.15.6:
5633+
follow-redirects@^1.15.0, follow-redirects@^1.15.6:
56255634
version "1.15.9"
56265635
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1"
56275636
integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==
@@ -10135,6 +10144,11 @@ utils-merge@1.0.1:
1013510144
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
1013610145
integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==
1013710146

10147+
uuid@^11.0.2:
10148+
version "11.0.3"
10149+
resolved "https://registry.yarnpkg.com/uuid/-/uuid-11.0.3.tgz#248451cac9d1a4a4128033e765d137e2b2c49a3d"
10150+
integrity sha512-d0z310fCWv5dJwnX1Y/MncBAqGMKEzlBb1AOf7z9K8ALnd0utBX/msg/fA0+sbyN1ihbMsLhrBlnl1ak7Wa0rg==
10151+
1013810152
uuid@^8.3.2:
1013910153
version "8.3.2"
1014010154
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"

0 commit comments

Comments
 (0)