Repository navigation
dpdp-kit 0.4.0
Prisma, MongoDB and Mongoose, and breach records (Section 8(6), Rule 7). dpdp-kit now runs on the database you already have, and it records a personal data breach against the Board's 72-hour deadline.
Added
- Breach records (Section 8(6), Rule 7):
dpdp.breach.open()starts the 72-hour clock from when you became aware.- Record who is affected (
addAffected), or everyone a compromised account read (addAffectedFromAccessLog). notice()drafts the message to each person, Rule 7(1)(a)–(e), with your DPO as the contact.markNotified(),boardNotified(),updateReport()andboardReport()cover the detailed report to the Board, Rule 7(2)(b)(i)–(vi).reportSent()records sending it, andextend()records the Board's written extension.status()says what's left to do.daily()includes every open breach.- New events:
breach.opened,breach.reportedandbreach.closed. - Changes made at the same time are all kept, and a closed breach can't change.
- Record who is affected (
dpdp-kit/prisma:prismaStore(prisma)keeps consent, requests, tasks, the access log and breaches.prismaData(prisma, { schema })reaches your own tables.prismaSchema(text)readsschema.prisma: models,@mapand@@map, native types, enums and lists.PRISMA_MODELSholds dpdp-kit's tables as Prisma models.prisma migrate difffinds no difference fromDPDP_DDL.- Works inside
prisma.$transactionwithprismaStore(tx). Tested on Prisma 7 with@prisma/adapter-pg.
dpdp-kit/postgres: the same store and data access for any client that runs a$1-parameterised query: node-postgres, postgres.js, Kysely, Knex. Also exportsDPDP_DDLwithout needingdrizzle-orm.dpdp-kit/mongodb:mongoStore(db)keeps dpdp-kit's records indpdp_*collections and creates its indexes itself.mongoData(db, { schema, ObjectId })reaches your own collections, including nested fields and fields inside arrays of subdocuments.mongooseSchema(models)feeds the drift check.- Accepts the driver's
Db, or() => mongoose.connection.dbso dpdp can be created before Mongoose connects.
audit --schemareads Prisma and Mongoose:--schema prisma/schema.prisma, or a folder of.prismafiles.--schema src/models.tsfor a file that exports Mongoose models.- The data map and
notPersonalcan use model and field names (User,phoneNumber) as well as the database's names.
- Foreign keys that break a legal hold (
audit --schema, Drizzle and Prisma). A link from a held table, like invoices kept for GST, to the users table:ON DELETE CASCADEwould delete the invoices with the account: errorheld-rows-cascade.SET NULLon the subject column would lose whose they are: errorheld-link-lost.RESTRICT, Prisma's default for a required relation, makes the deletion fail: warningheld-rows-block-delete.
- A
contact-missingaudit warning whenfiduciary.dpoisn't set. Section 8(9) requires publishing it, and every breach notice needs it (Rule 7(1)(e)). - Example apps in
examples/: the same shop on Express + Prisma + Postgres and on Express + Mongoose + MongoDB.examples/journey.mjstakes them through a year: consent, a blocked promo, access logs, a data request, withdrawal, a grievance, deletion, a breach and erasure. CI runs the journey on every change.
Fixed
- Timestamps on a server in IST. Prisma's pg adapter shifts
timestamptzvalues by the server's time zone. The SQL store reads timestamps back as UTC text, so consent records, deadlines and summaries are exact on a server set toAsia/Kolkata. CI now runs its Postgres in IST.
Upgrading from 0.3.x
- New tables.
- Drizzle: add
breachesandbreachNoticesto your schema and generate a migration, or runBREACH_DDL. - Prisma: add
PRISMA_MODELS. - MongoDB: nothing to do; the collections are created on first use.
- Drizzle: add
- New audit checks.
- If you run
dpdp-kit audit --strict, setfiduciary.dpo(your Data Protection Officer, or a contact person, with their business contact) first. - With
--schema, a foreign key from a table with alegalHoldto a table whose rows account deletion removes is now reported. Keep that link as a plain, indexed column (see the messages).
- If you run
- Custom stores.
- Breach records need
BreachStore. Without it,dpdp.breachthrowsstore-unsupportedanddaily()skips breaches. updateBreachmust save only over the version it read, and returnfalseotherwise (seeBreachStore).AccessLogStore.accessSubjectsis optional and new.
- Breach records need
Install
npm i dpdp-kit@0.4.0