<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Yogesh Bansal]]></title><description><![CDATA[Yogesh Bansal]]></description><link>https://yogesh-dev.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 00:15:24 GMT</lastBuildDate><atom:link href="https://yogesh-dev.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[From the database to the consent screen: India's DPDP Act in React, Next.js and React Native (dpdp-kit 0.6)]]></title><description><![CDATA[dpdp-kit is an open-source toolkit for India's Digital Personal Data Protection Act. You declare why you hold each piece of personal data in one typed…]]></description><link>https://yogesh-dev.hashnode.dev/from-the-database-to-the-consent-screen-india-s-dpdp-act-in-react-next-js-and-react-native-dpdp-kit-0-6</link><guid isPermaLink="true">https://yogesh-dev.hashnode.dev/from-the-database-to-the-consent-screen-india-s-dpdp-act-in-react-next-js-and-react-native-dpdp-kit-0-6</guid><category><![CDATA[React]]></category><category><![CDATA[Next.js]]></category><category><![CDATA[React Native]]></category><category><![CDATA[privacy]]></category><category><![CDATA[Open Source]]></category><dc:creator><![CDATA[YOGESH BANSAL]]></dc:creator><pubDate>Wed, 25 Nov 2026 01:25:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6afef12229c4bc505b3f0816/905280ff-2059-4021-a364-d33c7e49ab02.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>dpdp-kit is an open-source toolkit for India's Digital Personal Data Protection Act. You declare why you hold each piece of personal data in one typed config. It then keeps consent records you can prove, carries out erasure on time, logs who reads what, and fails CI when your schema drifts.</p>
<p>Until now it stopped at the backend. Every app still had to hand-build the screens the law is really about: the consent notice and the place where people change their mind. <strong>0.6 ships those screens</strong>, for React, Next.js and React Native, on Postgres, MySQL, SQLite or MongoDB.</p>
<p>This post covers two releases, 0.5 and 0.6, because together they go from the database to the screen.</p>
<blockquote>
<p><strong>Not legal advice.</strong> dpdp-kit helps you put compliance into practice; it doesn't make an app compliant on its own.</p>
</blockquote>
<h2>The consent screen, in five lines</h2>
<pre><code class="language-tsx">"use client";
import { ConsentNotice, DpdpProvider } from "dpdp-kit/react";

&lt;DpdpProvider options={{ base: "/privacy" }}&gt;
  &lt;ConsentNotice onDone={() =&gt; router.push("/privacy")} /&gt;
&lt;/DpdpProvider&gt;
</code></pre>
<p>What it shows is decided by the law, not by a designer:</p>
<ul>
<li><strong>The notice's own text</strong> (Section 5, Rule 3): each purpose in plain words, the data it uses ("Mobile number", not <code>phone</code>), how to withdraw, how to make a request, and how to complain to the Board. It's built from your config, in each language you translate it into, and the exact version shown is saved as proof (Section 6(10)).</li>
<li><strong>Every switch starts off.</strong> Consent has to be a clear affirmative action, so nothing is pre-ticked.</li>
<li><strong>"Accept selected" and "Reject all" look the same.</strong> Neither is the big coloured button.</li>
<li><strong>The grant is recorded against the notice version and language</strong> the person actually saw.</li>
</ul>
<h2>The privacy centre</h2>
<pre><code class="language-tsx">&lt;DpdpProvider options={{ base: "/privacy" }}&gt;
  &lt;PrivacyCentre /&gt;
&lt;/DpdpProvider&gt;
</code></pre>
<ul>
<li><strong>Your choices</strong>: switch each consent off as easily as it was given (Section 6(4)), and object to a legitimate use under Section 7(a). Objecting asks for confirmation first.</li>
<li><strong>Your data</strong>: what's held and who it's shared with, in which country (Section 11), with a JSON download.</li>
<li><strong>Your requests</strong>: correction, erasure, access, grievance, with the reference and due date.</li>
<li><strong>Your nominee</strong> (Section 14), and <strong>how to reach us</strong> (Rule 14(1)).</li>
</ul>
<p>Each part works on its own (<code>&lt;ConsentSettings&gt;</code>, <code>&lt;MyData&gt;</code>, <code>&lt;Requests&gt;</code>, <code>&lt;Nominees&gt;</code>, <code>&lt;HowToReachUs&gt;</code>). The components are unstyled semantic HTML with <code>dpdp-*</code> classes, <code>role="switch"</code> and live regions, and checked with axe-core. If you want a default look, there's an optional stylesheet with dark mode, written with <code>:where()</code> so your own CSS always wins. Every string is in a <code>labels</code> prop.</p>
<p>If you'd rather build your own UI, the hooks are there: <code>useConsents</code> (changes show at once and are undone if the server refuses), <code>useNotice</code>, <code>useMyData</code>, <code>useRequests</code>, <code>useNominees</code>.</p>
<h2>The same screens on mobile</h2>
<pre><code class="language-tsx">import { ConsentNotice, DpdpProvider } from "dpdp-kit/react-native";

&lt;DpdpProvider options={{ base: `${API}/privacy`, headers: () =&gt; ({ authorization: `Bearer ${token}` }) }}&gt;
  &lt;ConsentNotice theme="auto" onDone={next} /&gt;
&lt;/DpdpProvider&gt;
</code></pre>
<p>Built from <code>View</code>, <code>Text</code>, <code>Switch</code> and <code>Pressable</code>, with VoiceOver and TalkBack labels and a share sheet for the data copy. The server can record whether consent came from <code>ios</code>, <code>android</code> or <code>web</code>.</p>
<h2>What's behind them (0.5)</h2>
<p>The screens talk to an HTTP API that 0.5 added to your own server. One line in Next.js:</p>
<pre><code class="language-ts">// app/privacy/[...path]/route.ts
export const { GET, POST, DELETE } = createHandlers(dpdp, { base: "/privacy", subject: userId });
</code></pre>
<p>Express (<code>dpdpRouter</code>) and Hono (<code>dpdpRoutes</code>) work the same way. The person comes only from your authentication, and paths it doesn't serve go on to your own handlers.</p>
<p>0.5 also brought the parts of the law the screens show:</p>
<ul>
<li><strong>Privacy notices</strong> built from the config, versioned by content and saved the first time they're shown.</li>
<li><strong>Objections</strong> to legitimate uses (Section 7(a)), in the same hash chain as consent.</li>
<li><strong>Complete rights requests</strong>: corrections written to your tables, identity checks, acknowledgements with due dates, nominees.</li>
<li><strong>Cross-border transfers</strong> (Section 16): the audit errors on a processor in a restricted country.</li>
<li><strong>An evidence report</strong>: the data map, processors and countries, notices shown, consent counts, requests, erasure and breaches, ending with what needs attention.</li>
</ul>
<h2>MySQL and SQLite (0.6)</h2>
<p><code>dpdp-kit/mysql</code> (MySQL 8, mysql2 or Prisma) and <code>dpdp-kit/sqlite</code> (<code>node:sqlite</code>, better-sqlite3, libsql/Turso) each provide a store for dpdp-kit's records and data access for your own tables, so erasure and corrections run there too:</p>
<pre><code class="language-ts">import { sqliteData, sqliteStore } from "dpdp-kit/sqlite";

const dpdp = createDpdp({ config, store: sqliteStore(query), data: sqliteData(query) });
</code></pre>
<p>MySQL timestamps are stored in UTC and read back as text, so no driver or server time zone shifts them. 0.4 taught me that one: Prisma shifted every timestamp by 5½ hours on a server in IST. CI runs MySQL in IST for that reason.</p>
<p>Every built-in store now passes <strong>the same contract suite</strong>: memory, Postgres three ways, MongoDB, SQLite and MySQL. If you write a store for another database, you can run it too.</p>
<h2>Try it</h2>
<p>Two new example apps, in <a href="https://github.com/yogesh2902/dpdp-kit/tree/v0.6.0/examples"><code>examples/</code></a>:</p>
<ul>
<li><strong>next-app</strong>: Chai &amp; Co, a small tea shop, on the Next.js App Router and SQLite, with the consent screen and the privacy centre. A script drives it through a year of customers in CI.</li>
<li><strong>expo-app</strong>: the same shop on iOS and Android, talking to the Next.js example with a Bearer token.</li>
</ul>
<pre><code class="language-bash">npm i dpdp-kit
</code></pre>
<p>Upgrading from 0.5: the audit warnings added in 0.5 now fail <code>--strict</code>, as 0.5 announced. Everything else is opt-in.</p>
<ul>
<li>Docs: <a href="https://dpdp-kit.js.org/"><strong>https://dpdp-kit.js.org/</strong></a></li>
<li>GitHub: <a href="https://github.com/yogesh2902/dpdp-kit"><strong>https://github.com/yogesh2902/dpdp-kit</strong></a> (a star helps others find it)</li>
</ul>
<p>Next up is 0.7: children's data (Section 9, Rule 10) and erasure after a period of inactivity (Rule 8). If you're building on DPDP, I'd love to hear what you need.</p>
]]></content:encoded></item><item><title><![CDATA[I ran a fake tea shop for a year to test my DPDP Act library (dpdp-kit 0.4.0)]]></title><description><![CDATA[dpdp-kit is an open-source Node.js toolkit for India's Digital Personal Data Protection Act. You declare why you hold each piece of personal data in one…]]></description><link>https://yogesh-dev.hashnode.dev/i-ran-a-fake-tea-shop-for-a-year-to-test-my-dpdp-act-library-dpdp-kit-0-4-0</link><guid isPermaLink="true">https://yogesh-dev.hashnode.dev/i-ran-a-fake-tea-shop-for-a-year-to-test-my-dpdp-act-library-dpdp-kit-0-4-0</guid><category><![CDATA[Node.js]]></category><category><![CDATA[prisma]]></category><category><![CDATA[MongoDB]]></category><category><![CDATA[privacy]]></category><category><![CDATA[Open Source]]></category><dc:creator><![CDATA[YOGESH BANSAL]]></dc:creator><pubDate>Thu, 19 Nov 2026 13:14:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6afef12229c4bc505b3f0816/c0d5bc06-1326-4440-a9aa-7bfec17cca45.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>dpdp-kit is an open-source Node.js toolkit for India's Digital Personal Data Protection Act. You declare why you hold each piece of personal data in one typed config, and it keeps consent records you can prove, carries out erasure on time, logs who reads what, and fails CI when your schema drifts.</p>
<p>Until now it only spoke Drizzle. <strong>0.4.0 works with the database you already have</strong>: Prisma, MongoDB and Mongoose, or any Postgres client. It also adds <strong>breach records</strong> with the Board's 72-hour deadline.</p>
<p>But the part I want to write about is how I tested it, because that's where the surprises were.</p>
<blockquote>
<p><strong>Not legal advice.</strong> dpdp-kit helps you put compliance into practice; it doesn't make an app compliant on its own.</p>
</blockquote>
<h2>The test: a year of Chai &amp; Co</h2>
<p>Unit tests check functions. Compliance is about what happens over months: someone withdraws consent today, and the law says their data goes a year later. So I built a small online tea shop, Chai &amp; Co, twice (Express + Prisma + Postgres, and Express + Mongoose + MongoDB), and wrote a script that plays a customer, a support agent and the privacy team through a year of it, over HTTP:</p>
<ol>
<li>Asha signs up and agrees to promotional SMS, in Marathi. Ravi agrees to nothing.</li>
<li>A promo goes out: Asha gets it, Ravi gets a plain 403.</li>
<li>Support opens both records. Each read is logged with who, why and which fields.</li>
<li>Asha asks what data the shop holds on her (Section 11) and gets it, with who it's shared with.</li>
<li>Asha withdraws consent. Promos stop at once; the SMS vendor is told to stop.</li>
<li>Ravi raises a grievance (due in 90 days) and deletes his account.</li>
<li>Three months on, the overdue grievance shows up in the daily report.</li>
<li>A support account is compromised. The two people it read are found from the access log, told, and the Board informed; the report is due in 72 hours.</li>
<li>A year later, erasure runs: Asha's interests are erased, her phone stays (the account still needs it), Ravi's profile is deleted, his invoice is kept for 8 years under GST.</li>
<li>Both consent records still verify.</li>
</ol>
<p>It runs in CI on every change, against the packed npm package. Here's what it caught.</p>
<h3>Surprise 1: Prisma shifted every timestamp by 5½ hours</h3>
<p>On a Postgres server set to <code>Asia/Kolkata</code>, raw queries through Prisma 7's pg adapter returned <code>timestamptz</code> values shifted by the server's offset: <code>00:00Z</code> came back as <code>05:30Z</code>. That broke the consent hash chain (each event's hash covers its timestamp) and every deadline. CI ran Postgres in UTC, so it would never have shown up there.</p>
<p>The fix: the SQL store reads timestamps back as UTC text (<code>to_char(at AT TIME ZONE 'UTC', …)</code>), so no driver can shift them. CI now runs its Postgres in IST. If your servers are in India, they probably are too.</p>
<h3>Surprise 2: my own config would have failed a year later</h3>
<p>The audit refused my first Chai &amp; Co config: four <code>NOT NULL</code> columns that erasure would set to <code>NULL</code>. That failure would have shown up a year after the withdrawal, when the erasure task runs. The config now says what to write instead:</p>
<pre><code class="language-ts">email: { category: "contact", purposes: ["account"], erase: { value: ({ subjectId }) =&gt; `erased-${subjectId}@invalid` } },
name:  { category: "identity", purposes: ["account"], erase: "redact" },
</code></pre>
<h3>Surprise 3: a normal foreign key breaks a legal hold</h3>
<p>Account deletion deletes the person's rows but keeps the ones under a legal hold, like invoices. With an ordinary Prisma relation from <code>Order</code> to <code>User</code>:</p>
<ul>
<li>the default (<code>Restrict</code>) makes the deletion fail, forever;</li>
<li><code>SetNull</code> keeps the invoice but loses whose it is, so it's never anonymised;</li>
<li><code>Cascade</code> silently deletes the invoices the law says to keep.</li>
</ul>
<p><code>dpdp-kit audit --schema</code> now reads the relations in your Prisma or Drizzle schema and says so, with the fix: keep <code>user_id</code> as a plain, indexed column.</p>
<h2>What's new in 0.4.0</h2>
<p><strong>Prisma</strong></p>
<pre><code class="language-ts">import { prismaData, prismaSchema, prismaStore } from "dpdp-kit/prisma";

const schema = prismaSchema(readFileSync("prisma/schema.prisma", "utf8"));
const dpdp = createDpdp({ config, store: prismaStore(prisma), data: prismaData(prisma, { schema }) });
</code></pre>
<p>dpdp-kit's tables come as Prisma models (<code>PRISMA_MODELS</code>), so <code>prisma migrate</code> creates them. The data map can use model and field names (<code>User</code>, <code>phoneNumber</code>). It works inside <code>prisma.$transaction</code>, so a consent record can commit or roll back with your own writes.</p>
<p><strong>MongoDB and Mongoose</strong></p>
<pre><code class="language-ts">import { mongoData, mongooseSchema, mongoStore } from "dpdp-kit/mongodb";

const db = () =&gt; mongoose.connection.db; // so dpdp can be created before connect()
const dpdp = createDpdp({
  config,
  store: mongoStore(db),
  data: mongoData(db, { schema: mongooseSchema(mongoose), ObjectId: mongoose.Types.ObjectId }),
});
</code></pre>
<p>Nested fields and arrays of subdocuments work, for the drift check and for erasure (<code>addresses.$[].phone</code>).</p>
<p><strong>Any other Postgres client</strong>: <code>dpdp-kit/postgres</code> needs only a function that runs a <code>$1</code>-parameterised query, so node-postgres, postgres.js, Kysely and Knex all work.</p>
<p><strong>Drift checks everywhere</strong>:</p>
<pre><code class="language-bash">npx dpdp-kit audit --schema prisma/schema.prisma
npx dpdp-kit audit --schema src/models.ts   # Mongoose models
</code></pre>
<p>Add an <code>aadhaarNumber</code> field without saying what it's for, and the build fails. It's also a GitHub Action, now on the <a href="https://github.com/marketplace/actions/dpdp-kit-audit">Marketplace</a>.</p>
<p><strong>Breach records</strong> (Section 8(6), Rule 7): record a breach, find who's affected (including everyone a compromised account read), draft the notice to each person, and build the Board's detailed report against the 72-hour clock. <code>dpdp.daily()</code> reminds you of every open deadline.</p>
<h2>Try it</h2>
<p>The two example apps are in <a href="https://github.com/yogesh2902/dpdp-kit/tree/v0.4.1/examples"><code>examples/</code></a>, about 150 lines each. Copy whichever matches your stack.</p>
<pre><code class="language-bash">npm i dpdp-kit
</code></pre>
<ul>
<li>Docs: <strong><a href="https://dpdp-kit.js.org/">https://dpdp-kit.js.org/</a></strong></li>
<li>GitHub: <strong><a href="https://github.com/yogesh2902/dpdp-kit">https://github.com/yogesh2902/dpdp-kit</a></strong> (a star helps others find it)</li>
</ul>
<p>Next is 0.5: notices built from the config, in each language you offer, recording objections to a legitimate use, and an HTTP API. If you're building on DPDP, I'd love to hear what you need.</p>
]]></content:encoded></item></channel></rss>