Sops decrypting library
npm install @figedi/sopsMinimal Sops re-implementation for decrypting sops files directly w/ node.js w/o any sops-dependencies
This library in no way supports all sops-versions and is only tested on 3.9.x. It does not implement encoding, although this could probably easily added. An example for encoding, but by all means not complete, is found in sops.spec-utils.ts
Use this at your own risk
I've used this in several production projects in a k8s-context in GCP (through GCP KMS).
Example to decrypt an encrypted file with a GCP-KMS keyring:
``typescript
import { readFile } from "node:fs/promises";
import { GoogleKmsKeyDecryptor } from "@figedi/sops/kms";
import { SopsClient } from "@figedi/sops";
import { KeyManagementServiceClient } from '@google-cloud/kms';
const run = async () => {
const decryptor = new GoogleKmsKeyDecryptor(new KeyManagementServiceClient({ projectId: '
const sopsClient = new SopsClient(decryptor);
const testFile = await readFile('
console.log(await sopsClient.decrypt(testFile))
}
run()
``