New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prisma-field-encryption

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-field-encryption - npm Package Compare versions

Comparing version 1.2.0-beta.2 to 1.2.0

19

dist/dmmf.js

@@ -6,2 +6,3 @@ "use strict";

const errors_1 = require("./errors");
const supportedCursorTypes = ['Int', 'String'];
function analyseDMMF(dmmf = client_1.Prisma.dmmf) {

@@ -15,7 +16,19 @@ // todo: Make it robust against changes in the DMMF structure

return allModels.reduce((output, model) => {
var _a;
const idField = model.fields.find(field => field.isId && ['Int', 'String'].includes(String(field.type)));
var _a, _b;
const idField = model.fields.find(field => field.isId && supportedCursorTypes.includes(String(field.type)));
const cursorField = model.fields.find(field => { var _a; return (_a = field.documentation) === null || _a === void 0 ? void 0 : _a.includes('@encryption:cursor'); });
if (cursorField) {
// Make sure custom cursor field is valid
if (!cursorField.isUnique) {
throw new Error(errors_1.errors.nonUniqueCursor(model.name, cursorField.name));
}
if (!supportedCursorTypes.includes(String(cursorField.type))) {
throw new Error(errors_1.errors.unsupportedCursorType(model.name, cursorField.name, String(cursorField.type)));
}
if ((_a = cursorField.documentation) === null || _a === void 0 ? void 0 : _a.includes('@encrypted')) {
throw new Error(errors_1.errors.encryptedCursor(model.name, cursorField.name));
}
}
const modelDescriptor = {
cursor: (_a = cursorField === null || cursorField === void 0 ? void 0 : cursorField.name) !== null && _a !== void 0 ? _a : idField === null || idField === void 0 ? void 0 : idField.name,
cursor: (_b = cursorField === null || cursorField === void 0 ? void 0 : cursorField.name) !== null && _b !== void 0 ? _b : idField === null || idField === void 0 ? void 0 : idField.name,
fields: model.fields.reduce((fields, field) => {

@@ -22,0 +35,0 @@ const fieldConfig = parseAnnotation(field.documentation, model.name, field.name);

@@ -9,2 +9,5 @@ import type { Prisma } from '@prisma/client';

decryptionErrorReport: (operation: string, errors: string[]) => string;
nonUniqueCursor: (model: string, field: string) => string;
unsupportedCursorType: (model: string, field: string, type: string) => string;
encryptedCursor: (model: string, field: string) => string;
noInteractiveTransactions: string;

@@ -11,0 +14,0 @@ };

@@ -19,2 +19,9 @@ "use strict";

// Generator errors
nonUniqueCursor: (model, field) => prefixError(`the cursor field ${model}.${field} should have a @unique attribute.
Read more: https://github.com/47ng/prisma-field-encryption#custom-cursors`),
unsupportedCursorType: (model, field, type) => prefixError(`the cursor field ${model}.${field} has an unsupported type ${type}.
Only String and Int cursors are supported.
Read more: https://github.com/47ng/prisma-field-encryption#custom-cursors`),
encryptedCursor: (model, field) => prefixError(`the field ${model}.${field} cannot be used as a cursor as it is encrypted.
Read more: https://github.com/47ng/prisma-field-encryption#custom-cursors`),
noInteractiveTransactions: prefixError(`this generator requires enabling the \`interactiveTransactions\` preview feature on \`prisma-client-js\`:

@@ -21,0 +28,0 @@

2

package.json
{
"name": "prisma-field-encryption",
"version": "1.2.0-beta.2",
"version": "1.2.0",
"description": "Transparent field-level encryption at rest for Prisma",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc