Skip to content

Commit

Permalink
Merge branch 'quentin/ID' into 'master'
Browse files Browse the repository at this point in the history
chore: rename ID -> Id when part a variable name for consistency

See merge request TankerHQ/sdk-js!1025
  • Loading branch information
quentinvernot committed Jun 7, 2024
2 parents a4d6182 + 50dbe1c commit 251a829
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/DataProtection/DataProtector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class DataProtector {
const clearSize = encryption.getClearSize(encryptedSize);
const progressHandler = new ProgressHandler(progressOptions).start(clearSize);

const keyMapper = (keyID: Uint8Array) => this._resourceManager.findKeyFromResourceId(keyID);
const keyMapper = (keyId: Uint8Array) => this._resourceManager.findKeyFromResourceId(keyId);

const clearData = await encryption.decrypt(keyMapper, encryption.unserialize(castEncryptedData));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('provisional identity serialization: payload test vectors', () => {
};

const payload = new Uint8Array([
// UserID
// UserId
0x74, 0x68, 0x65, 0x20, 0x75, 0x73, 0x65, 0x72, 0x20, 0x69, 0x64, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/__tests__/Tanker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ describe('Tanker', () => {
}
});

it('updating group members should throw if invalid GroupID argument given', async () => {
it('updating group members should throw if invalid GroupId argument given', async () => {
const badGroupIdArgs = [
undefined,
null,
Expand Down Expand Up @@ -587,7 +587,7 @@ describe('Tanker', () => {
});

describe('download\'s return type', () => {
const resourceID = 'AAAAAAAAAAAAAAAAAAAAAA==';
const resourceId = 'AAAAAAAAAAAAAAAAAAAAAA==';

if (isBrowser()) {
// @ts-expect-error only used as destination
Expand All @@ -596,12 +596,12 @@ describe('Tanker', () => {
let blob: Blob;

it('is File | Uint8Array by default', async () => {
const downloadedResource = await tanker.download(resourceID);
const downloadedResource = await tanker.download(resourceId);
fileOrArray = downloadedResource;
});

it('is overriden by FormatOptions', async () => {
const downloadedBlob = await tanker.download(resourceID, { type: Blob });
const downloadedBlob = await tanker.download(resourceId, { type: Blob });
blob = downloadedBlob;
});
} else {
Expand All @@ -611,12 +611,12 @@ describe('Tanker', () => {
let buffer: Buffer;

it('is File | Uint8Array by default', async () => {
const downloadedResource = await tanker.download(resourceID);
const downloadedResource = await tanker.download(resourceId);
fileOrArray = downloadedResource;
});

it('is overriden by FormatOptions', async () => {
const downloadedBuffer = await tanker.download(resourceID, { type: Buffer });
const downloadedBuffer = await tanker.download(resourceId, { type: Buffer });
buffer = downloadedBuffer;
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/src/EncryptionFormats/KeyMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import type { Key } from '../aliases';

type MaybePromise<T> = T | Promise<T>;

export type KeyMapper = (keyID: Uint8Array) => MaybePromise<Key | null>;
export type KeyMapper = (keyId: Uint8Array) => MaybePromise<Key | null>;
20 changes: 10 additions & 10 deletions packages/functional-tests/src/concurrency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ export const generateConcurrencyTests = (args: TestArgs) => {

it('decrypt resource shared through group concurrently [RO6DP7]', async () => {
const clearData = 'a beautiful word';
const groupID = await aliceLaptop.createGroup([bobPublicIdentity]);
const encryptedData = await aliceLaptop.encrypt(clearData, { shareWithGroups: [groupID] });
const groupId = await aliceLaptop.createGroup([bobPublicIdentity]);
const encryptedData = await aliceLaptop.encrypt(clearData, { shareWithGroups: [groupId] });

const decryptedDataArray = await expect(Promise.all(
bobSessions.map((session) => session.decrypt(encryptedData)),
Expand All @@ -154,10 +154,10 @@ export const generateConcurrencyTests = (args: TestArgs) => {
it('share concurrently [HNWFV3]', async () => {
const clearData = 'an unexpected response';
const encryptedData = await bobSessions[0]!.encrypt(clearData);
const resourceID = await bobSessions[0]!.getResourceId(encryptedData);
const resourceId = await bobSessions[0]!.getResourceId(encryptedData);

await expect(Promise.all(
bobSessions.map((session) => session.share([resourceID], { shareWithUsers: [alicePublicIdentity] })),
bobSessions.map((session) => session.share([resourceId], { shareWithUsers: [alicePublicIdentity] })),
), 'failed to share from both sessions').to.be.fulfilled;

await expectDecrypt([aliceLaptop], clearData, encryptedData);
Expand All @@ -166,12 +166,12 @@ export const generateConcurrencyTests = (args: TestArgs) => {
describe('handling group', () => {
let clearData: string;
let encryptedData: Uint8Array;
let resourceID: b64string;
let resourceId: b64string;

beforeEach(async () => {
clearData = 'whining to the group';
encryptedData = await bobSessions[0]!.encrypt(clearData);
resourceID = await bobSessions[0]!.getResourceId(encryptedData);
resourceId = await bobSessions[0]!.getResourceId(encryptedData);
});

it('create group concurrently [WX3H50]', async () => {
Expand All @@ -180,19 +180,19 @@ export const generateConcurrencyTests = (args: TestArgs) => {
), 'failed to createGroup from both sessions').to.be.fulfilled as Array<b64string>;

await Promise.all(
groups.map((groupID, index) => bobSessions[index]!.share([resourceID], { shareWithGroups: [groupID] })),
groups.map((groupId, index) => bobSessions[index]!.share([resourceId], { shareWithGroups: [groupId] })),
);

await expectDecrypt([aliceLaptop], clearData, encryptedData);
});

it('add member to a group concurrently [BXA5BC]', async () => {
const groupID = await bobSessions[0]!.createGroup([bobPublicIdentity]);
await bobSessions[0]!.share([resourceID], { shareWithGroups: [groupID] });
const groupId = await bobSessions[0]!.createGroup([bobPublicIdentity]);
await bobSessions[0]!.share([resourceId], { shareWithGroups: [groupId] });

await expect(Promise.all(
bobSessions.map(session => retry(
() => session.updateGroupMembers(groupID, { usersToAdd: [alicePublicIdentity] }),
() => session.updateGroupMembers(groupId, { usersToAdd: [alicePublicIdentity] }),
bobSessions.length,
'There was a conflict with a concurrent operation',
)),
Expand Down
6 changes: 3 additions & 3 deletions packages/functional-tests/src/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,9 @@ export const generateGroupsTests = (args: TestArgs) => {
const alice = await UserSession.create(appHelper);
await expect(alice.session.updateGroupMembers('', { usersToAdd: [alice.spublicIdentity] }))
.to.be.rejectedWith(errors.InvalidArgument);
const badGroupID = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=';
await expect(alice.session.updateGroupMembers(badGroupID, { usersToAdd: [alice.spublicIdentity] }))
.to.be.rejectedWith(errors.InvalidArgument, badGroupID);
const badGroupId = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=';
await expect(alice.session.updateGroupMembers(badGroupId, { usersToAdd: [alice.spublicIdentity] }))
.to.be.rejectedWith(errors.InvalidArgument, badGroupId);
});

it('update group members with an attached provisional identity', async () => {
Expand Down

0 comments on commit 251a829

Please sign in to comment.