Skip to content

Commit

Permalink
fix: aligns dynamic kms import w/ typings
Browse files Browse the repository at this point in the history
  • Loading branch information
Figedi committed Jun 8, 2023
1 parent 427d89b commit 8233a59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/kms-addon/kmsKeyDecryptor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import type { v1 } from "@google-cloud/kms";
import type { KeyManagementServiceClient } from "@google-cloud/kms";

import { setupStubbedKms } from "./shared.specFiles/kmsStubs";
import { encryptJson } from "../shared.specFiles/sopsUtils";
Expand Down Expand Up @@ -56,7 +56,7 @@ describe("SopsClient with KmsKeyDecryptor", () => {
describe("decryptSopsJson", () => {
let key: Buffer;
let iv: Buffer;
let kms: v1.KeyManagementServiceClient;
let kms: KeyManagementServiceClient;
let keyDecryptor: IKeyDecryptor;
let sopsClient: SopsClient;

Expand Down
6 changes: 3 additions & 3 deletions src/kms-addon/kmsKeyDecryptor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { statSync } from "fs";
import type { v1 } from "@google-cloud/kms";
import type { KeyManagementServiceClient } from "@google-cloud/kms";
import { IKeyDecryptor, ISopsEncryptedJSON } from "../types";

export class KmsKeyDecryptor implements IKeyDecryptor {
private constructor(private client: v1.KeyManagementServiceClient) {}
private constructor(private client: KeyManagementServiceClient) {}

public static async create(projectId?: string, serviceAccountPath?: string) {
// eslint-disable-next-line import/no-extraneous-dependencies
Expand All @@ -26,7 +26,7 @@ export class KmsKeyDecryptor implements IKeyDecryptor {
return new KmsKeyDecryptor(new mod.KeyManagementServiceClient({ projectId }));
}

public static createWithKmsClient(client: v1.KeyManagementServiceClient): IKeyDecryptor {
public static createWithKmsClient(client: KeyManagementServiceClient): IKeyDecryptor {
return new KmsKeyDecryptor(client);
}

Expand Down
6 changes: 3 additions & 3 deletions src/kms-addon/shared.specFiles/kmsStubs.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { v1 } from "@google-cloud/kms";
import type { KeyManagementServiceClient } from "@google-cloud/kms";
import { scryptSync } from "crypto";

export const createStubbedKeyManagementClient = (key: Buffer): v1.KeyManagementServiceClient => {
export const createStubbedKeyManagementClient = (key: Buffer): KeyManagementServiceClient => {
return {
decrypt: async () => [
{
plaintext: key,
},
],
} as unknown as v1.KeyManagementServiceClient;
} as unknown as KeyManagementServiceClient;
};

export const setupStubbedKms = (password: string): any => {
Expand Down

0 comments on commit 8233a59

Please sign in to comment.