Skip to content

Commit

Permalink
fix(deps): bump @relaycorp/relaynet-core from 1.81.7 to 1.81.10 (#66)
Browse files Browse the repository at this point in the history
* fix(deps): bump @relaycorp/relaynet-core from 1.81.7 to 1.81.10

Bumps [@relaycorp/relaynet-core](https://github.com/relaycorp/relaynet-core-js) from 1.81.7 to 1.81.10.
- [Release notes](https://github.com/relaycorp/relaynet-core-js/releases)
- [Commits](relaycorp/relaynet-core-js@v1.81.7...v1.81.10)

---
updated-dependencies:
- dependency-name: "@relaycorp/relaynet-core"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix

* fix

* fix func tests

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gus Narea <[email protected]>
  • Loading branch information
dependabot[bot] and gnarea authored Aug 2, 2022
1 parent 001fc00 commit 7a2bf66
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 57 deletions.
45 changes: 23 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions src/functional_tests/gcp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,24 @@ describe('Private key store', () => {
test('Generate identity key pair', async () => {
const store = new GCPPrivateKeyStore(kmsClient, getDBConnection(), getKMSConfig());

const { privateKey, privateAddress } = await store.generateIdentityKeyPair();
const { privateKey, id } = await store.generateIdentityKeyPair();

const privateKeyRetrieved = await store.retrieveIdentityKey(privateAddress);
const privateKeyRetrieved = await store.retrieveIdentityKey(id);

expect(privateKeyRetrieved?.kmsKeyVersionPath).toEqual(
(privateKey as GcpKmsRsaPssPrivateKey).kmsKeyVersionPath,
);
});

test('Save and retrieve session key', async () => {
const privateAddress = '0deadbeef';
const peerPrivateAddress = '0deadc0de';
const id = '0deadbeef';
const peerId = '0deadc0de';
const store = new GCPPrivateKeyStore(kmsClient, getDBConnection(), getKMSConfig());
const { privateKey, sessionKey } = await SessionKeyPair.generate();

await store.saveSessionKey(privateKey, sessionKey.keyId, privateAddress, peerPrivateAddress);
await store.saveSessionKey(privateKey, sessionKey.keyId, id, peerId);

const privateKeyRetrieved = await store.retrieveSessionKey(
sessionKey.keyId,
privateAddress,
peerPrivateAddress,
);
const privateKeyRetrieved = await store.retrieveSessionKey(sessionKey.keyId, id, peerId);
await expect(derSerializePrivateKey(privateKeyRetrieved)).resolves.toEqual(
await derSerializePrivateKey(privateKey),
);
Expand Down
24 changes: 12 additions & 12 deletions src/lib/gcp/GCPPrivateKeyStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
derDeserializeRSAPublicKey,
derSerializePrivateKey,
derSerializePublicKey,
getPrivateAddressFromIdentityKey,
getIdFromIdentityKey,
KeyStoreError,
SessionKeyPair,
UnknownKeyError,
Expand Down Expand Up @@ -77,7 +77,7 @@ describe('Identity keys', () => {
beforeAll(async () => {
stubPublicKey = await derDeserializeRSAPublicKey(STUB_KMS_PUBLIC_KEY);
stubPublicKeySerialized = bufferToArrayBuffer(STUB_KMS_PUBLIC_KEY);
stubPrivateAddress = await getPrivateAddressFromIdentityKey(stubPublicKey);
stubPrivateAddress = await getIdFromIdentityKey(stubPublicKey);
});

const mockRetrieveKMSPublicKey = mockSpy(
Expand Down Expand Up @@ -200,26 +200,26 @@ describe('Identity keys', () => {
test('Private address should be stored', async () => {
const store = new GCPPrivateKeyStore(makeKmsClient(), getDBConnection(), KMS_CONFIG);

const { privateAddress } = await store.generateIdentityKeyPair();
const { id } = await store.generateIdentityKeyPair();

await expect(getDocument(privateAddress)).resolves.toBeTruthy();
await expect(getDocument(id)).resolves.toBeTruthy();
});

test('Public key should be stored', async () => {
const store = new GCPPrivateKeyStore(makeKmsClient(), getDBConnection(), KMS_CONFIG);

const { privateAddress, publicKey } = await store.generateIdentityKeyPair();
const { id, publicKey } = await store.generateIdentityKeyPair();

const document = await getDocument(privateAddress);
const document = await getDocument(id);
expect(document!.publicKey.equals(await derSerializePublicKey(publicKey))).toBeTrue();
});

test('KMS key should be stored', async () => {
const store = new GCPPrivateKeyStore(makeKmsClient(), getDBConnection(), KMS_CONFIG);

const { privateAddress } = await store.generateIdentityKeyPair();
const { id } = await store.generateIdentityKeyPair();

const document = await getDocument(privateAddress);
const document = await getDocument(id);
expect(document!.kmsKey).toEqual(KMS_CONFIG.identityKeyId);
});

Expand All @@ -231,9 +231,9 @@ describe('Identity keys', () => {
KMS_CONFIG,
);

const { privateAddress } = await store.generateIdentityKeyPair();
const { id } = await store.generateIdentityKeyPair();

const document = await getDocument(privateAddress);
const document = await getDocument(id);
expect(document?.kmsKeyVersion).toEqual(kmsKeyVersion);
});

Expand Down Expand Up @@ -278,9 +278,9 @@ describe('Identity keys', () => {
test('Private address should match public key', async () => {
const store = new GCPPrivateKeyStore(makeKmsClient(), getDBConnection(), KMS_CONFIG);

const { privateAddress } = await store.generateIdentityKeyPair();
const { id } = await store.generateIdentityKeyPair();

expect(privateAddress).toEqual(stubPrivateAddress);
expect(id).toEqual(stubPrivateAddress);
});
});

Expand Down
10 changes: 5 additions & 5 deletions src/lib/gcp/GCPPrivateKeyStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { KeyManagementServiceClient } from '@google-cloud/kms';
import {
derDeserializeRSAPublicKey,
derSerializePublicKey,
getPrivateAddressFromIdentityKey,
getIdFromIdentityKey,
IdentityKeyPair,
RSAKeyGenOptions,
SessionPrivateKeyData,
Expand Down Expand Up @@ -67,11 +67,11 @@ export class GCPPrivateKeyStore extends CloudPrivateKeystore {
const publicKeySerialized = await retrieveKMSPublicKey(kmsKeyVersionPath, this.kmsClient);
const publicKey = await derDeserializeRSAPublicKey(publicKeySerialized);
const privateKey = new GcpKmsRsaPssPrivateKey(kmsKeyVersionPath, publicKey, this.idKeyProvider);
const privateAddress = await getPrivateAddressFromIdentityKey(publicKey);
const id = await getIdFromIdentityKey(publicKey);

await this.linkKMSKeyVersion(kmsKeyVersionPath, privateAddress, publicKey);
await this.linkKMSKeyVersion(kmsKeyVersionPath, id, publicKey);

return { privateAddress, privateKey, publicKey };
return { id, privateKey, publicKey };
}

public async retrieveIdentityKey(privateAddress: string): Promise<GcpKmsRsaPssPrivateKey | null> {
Expand Down Expand Up @@ -129,7 +129,7 @@ export class GCPPrivateKeyStore extends CloudPrivateKeystore {
privateAddress,
peerPrivateAddress,
);
return { keySerialized, peerPrivateAddress, privateAddress };
return { keySerialized, peerId: peerPrivateAddress, nodeId: privateAddress };
}

//region Identity key utilities
Expand Down
12 changes: 6 additions & 6 deletions src/lib/vault/VaultPrivateKeyStore.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
derSerializePrivateKey,
generateRSAKeyPair,
getPrivateAddressFromIdentityKey,
getIdFromIdentityKey,
KeyStoreError,
SessionKeyPair,
UnknownKeyError,
Expand Down Expand Up @@ -129,11 +129,11 @@ describe('VaultPrivateKeyStore', () => {
test('Identity key should be generated', async () => {
const store = new VaultPrivateKeyStore(stubVaultUrl, stubVaultToken, stubKvPath);

const { privateKey, privateAddress } = await store.generateIdentityKeyPair();
const { privateKey, id } = await store.generateIdentityKeyPair();

expect(mockAxiosClient.post).toBeCalledTimes(1);
const postCallArgs = mockAxiosClient.post.mock.calls[0];
expect(postCallArgs[0]).toEqual(`/i-${privateAddress}`);
expect(postCallArgs[0]).toEqual(`/i-${id}`);
expect(postCallArgs[1]).toHaveProperty(
'data.privateKey',
base64Encode(await derSerializePrivateKey(privateKey)),
Expand Down Expand Up @@ -234,7 +234,7 @@ describe('VaultPrivateKeyStore', () => {
test('Existing identity key should be returned', async () => {
const senderKeyPair = await generateRSAKeyPair();
const identityPrivateKey = senderKeyPair.privateKey;
const privateAddress = await getPrivateAddressFromIdentityKey(senderKeyPair.publicKey);
const nodeId = await getIdFromIdentityKey(senderKeyPair.publicKey);
mockAxiosClient.get.mockResolvedValue(
makeVaultGETResponse(
{
Expand All @@ -245,11 +245,11 @@ describe('VaultPrivateKeyStore', () => {
);
const store = new VaultPrivateKeyStore(stubVaultUrl, stubVaultToken, stubKvPath);

const privateKey = await store.retrieveIdentityKey(privateAddress);
const privateKey = await store.retrieveIdentityKey(nodeId);

expect(mockAxiosClient.get).toBeCalledTimes(1);
const getCallArgs = mockAxiosClient.get.mock.calls[0];
expect(getCallArgs[0]).toEqual(`/i-${privateAddress}`);
expect(getCallArgs[0]).toEqual(`/i-${nodeId}`);
await expect(derSerializePrivateKey(privateKey!)).resolves.toEqual(
await derSerializePrivateKey(identityPrivateKey),
);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/vault/VaultPrivateKeyStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export class VaultPrivateKeyStore extends CloudPrivateKeystore {
}
return {
keySerialized: keyData.privateKey,
peerPrivateAddress: (keyData as SessionKeyDataDecoded).peerPrivateAddress,
privateAddress: (keyData as SessionKeyDataDecoded).privateAddress,
peerId: (keyData as SessionKeyDataDecoded).peerPrivateAddress,
nodeId: (keyData as SessionKeyDataDecoded).privateAddress,
};
}

Expand Down

0 comments on commit 7a2bf66

Please sign in to comment.