UNPKG

@1mill/sops

Version:

```bash npm install @1mill/sops ```

3 lines (2 loc) 817 B
!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){var e=require("crypto"),r=Object.freeze("_unencrypted");module.exports={decryptScalar:function(t){var a=t.aad,f=t.key,o=t.value;if(a.endsWith(r+":"))return o;var n=o.match(/^ENC\[AES256_GCM,data:(.+),iv:(.+),tag:(.+),type:(.+)\]/),c=n[1],u=n[3],s=n[4];decryptor=e.createDecipheriv("aes-256-gcm",f,Buffer.from(n[2],"base64")),decryptor.setAAD(Buffer.from(a)),decryptor.setAuthTag(Buffer.from(u,"base64"));var d=decryptor.update(Buffer.from(c,"base64"),void 0,"utf-8")+decryptor.final("utf-8");switch(s){case"bool":return"true"===d.toLowerCase();case"bytes":case"str":return d;case"float":return parseFloat(d);case"int":return parseInt(d,10);default:throw new Error('Unknown type "'+s+'"')}}}}); //# sourceMappingURL=decryptScalar.umd.js.map