dpdp-erasure-cli 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example CHANGED
@@ -4,6 +4,9 @@
4
4
 
5
5
  LOG_LEVEL=info
6
6
 
7
+ # Mandatory Legal Acknowledgement: Sets liability shift and confirms Apache 2.0 terms
8
+ I_ACCEPT_APACHE2_AND_DPDP_OPERATIONAL_LIABILITY=true
9
+
7
10
  # Client application database. This is the database inside the client's VPC/VPS.
8
11
  DATABASE_URL=postgres://dpdp:dpdp@127.0.0.1:55432/dpdp_local
9
12
 
package/NOTICE ADDED
@@ -0,0 +1,56 @@
1
+ DPDP Erasure Engine
2
+ Copyright 2026 Dev Dhanadiya
3
+
4
+ This product includes software developed at
5
+ Dev Dhanadiya (https://github.com/devxdh)
6
+
7
+ =======================================================================
8
+ LEGAL AND ARCHITECTURAL DISCLAIMER (OPERATIONAL LIABILITY SHIFT)
9
+ =======================================================================
10
+
11
+ 1. FAIL-CLOSED ARCHITECTURE AND SYSTEM FREEZES
12
+ This software ("Engine for DPDP Workflows") is designed using an ACID
13
+ Fail-Closed orchestration pattern. As explicitly stated in our
14
+ documentation and marketing materials, the system relies on database
15
+ locks ("FOR UPDATE SKIP LOCKED"), strict cryptographic schema hashing,
16
+ and strict transaction boundaries.
17
+
18
+ If this Engine encounters ANY structural anomaly—including but not
19
+ limited to:
20
+ - A mismatch between the live database schema and the legal manifest
21
+ - Unresolved foreign key constraints
22
+ - API or Worker thread unhandled exceptions
23
+ - Transient network drops
24
+ - Unsigned or unauthorized configurations
25
+
26
+ The system is hard-coded to IMMEDIATELY AND PERMANENTLY HALT its execution
27
+ queues. It will not attempt dangerous roll-forwards. It will quarantine
28
+ itself.
29
+
30
+ 2. LIABILITY FOR COMPLIANCE TIMELINES (e.g. DPDP 30-DAY CLOCK)
31
+ Because the Licensor provides this software purely as an API and a local
32
+ Worker intended to be deployed on the Licensee's own infrastructure, the
33
+ Licensor has zero physical, operational, or logical control over the
34
+ deployment environment.
35
+
36
+ Consequently, by deploying this software, the Licensee (the Data Fiduciary)
37
+ expressly acknowledges and agrees that:
38
+ - They are solely responsible for monitoring worker health, API endpoint
39
+ uptime, and queue backlogs.
40
+ - If a system freeze, thread drop, or JSON payload parsing error causes
41
+ a delay in data erasure, the Licensee is solely liable for any resulting
42
+ breach of DPDP timelines (or any other regulatory mandate).
43
+ - The Licensor accepts ZERO liability for compliance failures resulting
44
+ from operational deployment bugs, configuration errors, or architectural
45
+ lockups.
46
+
47
+ 3. "AS-IS" DISTRIBUTION UNDER APACHE 2.0
48
+ In strict accordance with Sections 7 and 8 of the Apache 2.0 License:
49
+ This software is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR
50
+ CONDITIONS OF ANY KIND, either express or implied, including, without
51
+ limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
52
+ MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
53
+
54
+ You are solely responsible for determining the appropriateness of using
55
+ or redistributing the Work and assume any risks associated with Your
56
+ exercise of permissions under this License.
package/README.md CHANGED
@@ -1,67 +1,140 @@
1
- # DPDP Erasure Engine CLI (`dpdp-erasure-cli`)
1
+ # Operator CLI Reference Guide (`dpdp-erasure-cli`)
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/dpdp-erasure-cli.svg)](https://badge.fury.io/js/dpdp-erasure-cli)
4
4
 
5
- The **DPDP Erasure Engine Operator CLI** is an enterprise-grade utility designed to help data fiduciaries comply with modern privacy laws like the **Digital Personal Data Protection (DPDP) Act, 2023**.
5
+ The **Operator CLI** (`dpdp-erasure-cli`) is the primary interface for data engineers, DevOps, and privacy operators to manage the DPDP Erasure Engine.
6
6
 
7
- This CLI orchestrates the Data Plane, enabling you to inspect databases for Personally Identifiable Information (PII), generate privacy compliance manifests, sign them cryptographically, and execute safe erasure operations.
7
+ It is used to introspect databases, classify PII, manage compliance manifests, sign them cryptographically, and simulate safe erasure operations locally.
8
8
 
9
9
  ---
10
10
 
11
11
  ## 🚀 Installation
12
12
 
13
- This CLI relies on [Bun](https://bun.sh/) for native SQLite and cryptographic bindings. Ensure you have Bun installed, then install the package globally:
13
+ This CLI requires [Bun](https://bun.sh/) for native cryptographic bindings and high-performance execution. Ensure you have Bun installed, then install the package globally:
14
14
 
15
15
  ```bash
16
16
  npm install -g dpdp-erasure-cli
17
17
  ```
18
18
 
19
+ *Alternatively, if running from the monorepo root:*
20
+ ```bash
21
+ bun run --cwd ./apps/worker cli <command>
22
+ ```
23
+
19
24
  ---
20
25
 
21
- ## 🛠️ Usage
26
+ ## 🛠️ Interactive Console
27
+
28
+ If you run the CLI without any arguments, it will launch an interactive wizard to guide you through the available operations:
22
29
 
23
30
  ```bash
24
- dpdp-cli [command] [options]
31
+ dpdp-cli
25
32
  ```
26
33
 
27
- ### Core Commands
34
+ ---
28
35
 
29
- * `scan`: Run a metadata-only schema scan across your database to detect potential PII columns based on column names.
30
- * `introspect`: Safely analyze your database's Foreign Key (FK) DAG offline and draft a comprehensive PII mapping manifest (`compliance.worker.yml`).
31
- * `keygen`: Provision secure Ed25519 cryptographic keys required for configuration signing.
32
- * `sign`: Cryptographically sign your `compliance.worker.yml` manifest to lock in your legal attestation hash.
33
- * `verify`: Perform deep integrity checks to compute mandatory schema hashes and ensure nothing has drifted.
34
- * `check-integrity`: A CI/CD gate that fails closed unless the schema hash and compiled DAG match your live production database.
35
- * `verify-schema`: Similar to check-integrity, designed specifically to verify that the live schema matches the legal attestation hash.
36
- * `dry-run`: Simulate a full PII vault operation without mutating any production data.
37
- * `graph`: Visualize recursive table dependencies (FK DAG) for a specific root table.
38
- * `inspect`: Inspect an existing worker manifest and summarize the legal/configuration coverage.
39
- * `init`: Interactively provision a fresh legal compliance manifest for a new project.
36
+ ## 📚 Core Commands & Configuration Guide
40
37
 
41
- ### Example Workflow
38
+ ### 1. `introspect` (The Core Command)
39
+ Safely analyze your database's Foreign Key (FK) Directed Acyclic Graph (DAG) offline and draft a comprehensive PII mapping manifest (`compliance.worker.yml`). This is the first step in setting up the engine.
42
40
 
43
- **1. Introspect your database to detect PII:**
44
41
  ```bash
45
- dpdp-cli introspect -u postgres://user:pass@localhost:5432/app_db -r public.users -s public -o ./compliance.worker.yml
42
+ dpdp-cli introspect \
43
+ --url postgres://user:pass@localhost:5432/app_db \
44
+ --root public.users \
45
+ --schema public \
46
+ --output ./compliance.worker.yml.draft
46
47
  ```
47
48
 
48
- **2. Generate a secure keypair:**
49
+ **Options:**
50
+ * `-u, --url <url>`: PostgreSQL Connection DSN.
51
+ * `-r, --root <table>`: The root table containing the user/subject identifier (e.g., `public.users`).
52
+ * `-s, --schema <schema>`: The target PostgreSQL schema (defaults to `public`).
53
+ * `-o, --output <path>`: Where to write the generated YAML draft (defaults to `compliance.worker.yml.draft`).
54
+ * `-d, --max-depth <depth>`: Limit for recursive Foreign Key traversal (default: `32`).
55
+ * `--sample-percent <percent>`: Percentage of data to sample using `TABLESAMPLE` for PII detection (default: `1`).
56
+ * `--threshold <score>`: Confidence score required to flag a column as PII (default: `0.75`).
57
+ * `--report <path>`: Write a readable Markdown report of the findings.
58
+
59
+ ---
60
+
61
+ ### 2. `scan` (Quick PII Check)
62
+ A lightweight, metadata-only schema scan that looks for potential PII columns based purely on naming conventions, without the heavy block sampling used by `introspect`.
63
+
64
+ ```bash
65
+ dpdp-cli scan --url "postgres://user:pass@localhost:5432/app_db" --schema public
66
+ ```
67
+
68
+ ---
69
+
70
+ ### 3. `keygen` (Security Provisioning)
71
+ Provisions secure Ed25519 cryptographic keys required to sign your configuration manifest.
72
+
49
73
  ```bash
50
74
  dpdp-cli keygen
51
75
  ```
76
+ *This generates a private key file (e.g., `worker.pkcs8.key`) and a public key.*
77
+
78
+ ---
79
+
80
+ ### 4. `sign` (Cryptographic Manifest Lock)
81
+ To prevent unauthorized changes to data erasure rules in production, the manifest must be cryptographically signed by a Data Protection Officer (DPO) or Lead Engineer.
82
+
83
+ ```bash
84
+ dpdp-cli sign --config ./compliance.worker.yml --key ./worker.pkcs8.key
85
+ ```
86
+ *This generates a detached signature file (e.g., `compliance.worker.yml.sig`). The worker will fail to boot if this signature does not match the manifest.*
87
+
88
+ ---
89
+
90
+ ### 5. `check-integrity` & `verify-schema` (CI/CD Gates)
91
+ These commands are designed for CI/CD pipelines to ensure the live database schema matches the legal attestation hash stored in the signed manifest.
52
92
 
53
- **3. Cryptographically sign your manifest:**
54
93
  ```bash
55
- dpdp-cli sign -c ./compliance.worker.yml -k ./coe-private.key
94
+ # Verify the compiled DAG and live schema hash
95
+ dpdp-cli check-integrity --url "postgres://.../app_db" --config ./compliance.worker.yml
96
+
97
+ # Check only the live schema hash against the legal attestation
98
+ dpdp-cli verify-schema --url "postgres://.../app_db" --config ./compliance.worker.yml
56
99
  ```
100
+ *If a developer adds a new column to the database without updating and re-signing the manifest, these commands will exit with a non-zero status.*
101
+
102
+ ---
103
+
104
+ ### 6. `dry-run` (Safe Erasure Simulation)
105
+ Simulates a PII vault and redaction operation for a specific user. It runs inside an isolated transaction that is automatically rolled back.
57
106
 
58
- **4. Perform a dry-run to ensure safety:**
59
107
  ```bash
60
- dpdp-cli dry-run -u postgres://user:pass@localhost:5432/app_db -c ./compliance.worker.yml
108
+ dpdp-cli dry-run --id "user_12345" --url "postgres://.../app_db" --config ./compliance.worker.yml
61
109
  ```
110
+ *This is the recommended safety check to help ensure your configuration captures related PII without breaking foreign keys.*
62
111
 
63
112
  ---
64
113
 
65
- ## 📖 Complete Documentation
114
+ ### 7. `graph` (Dependency Visualization)
115
+ Visualizes the recursive table dependencies (FK DAG) for a specific root table, helping you understand how data cascades down from a user.
116
+
117
+ ```bash
118
+ dpdp-cli graph --table public.users --url "postgres://.../app_db"
119
+ ```
120
+
121
+ ---
122
+
123
+ ## ⚙️ Standard Workflow Example
124
+
125
+ Setting up the engine generally follows this workflow:
126
+
127
+ 1. **Introspect** the database to generate a draft manifest:
128
+ `dpdp-cli introspect -u postgres://... -r public.users -s public -o compliance.worker.yml`
129
+ 2. **Review & Tweak** the `compliance.worker.yml` manually (fix false positives, add missing logical links, select masking actions like `HMAC` or `SET NULL`).
130
+ 3. **Generate Keys** for signing:
131
+ `dpdp-cli keygen`
132
+ 4. **Sign** the finalized manifest:
133
+ `dpdp-cli sign -c compliance.worker.yml -k worker.pkcs8.key`
134
+ 5. **Dry-Run** an erasure to verify it behaves as expected:
135
+ `dpdp-cli dry-run -i "test_user_id" -u postgres://... -c compliance.worker.yml`
136
+ 6. **Deploy** the signed manifest and the detached `.sig` file to your production Worker.
137
+
138
+ ---
66
139
 
67
- For comprehensive instructions on how the entire Engine operates, including the Control Plane API and architectural overviews, please refer to the **[Official GitHub Repository](https://github.com/devxdh/dpdp-erasure-engine)**.
140
+ For architectural details and deep-dives into how the cryptographic shredding works, refer to the [Main Documentation](https://github.com/devxdh/dpdp-erasure-engine/tree/main/apps/docs).
package/package.json CHANGED
@@ -1,7 +1,18 @@
1
1
  {
2
2
  "name": "dpdp-erasure-cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "license": "Apache-2.0",
5
+ "keywords": [
6
+ "dpdp",
7
+ "dpdp-2023",
8
+ "data-privacy",
9
+ "data-erasure",
10
+ "privacy-compliance",
11
+ "cryptographic-shredding",
12
+ "gdpr",
13
+ "compliance",
14
+ "cli"
15
+ ],
5
16
  "module": "index.ts",
6
17
  "type": "module",
7
18
  "bin": {
@@ -39,4 +50,4 @@
39
50
  "postgres": "^3.4.9",
40
51
  "zod": "^4.4.2"
41
52
  }
42
- }
53
+ }
package/src/index.ts CHANGED
@@ -116,6 +116,24 @@ async function sendMailerWebhook(
116
116
 
117
117
  async function main() {
118
118
  registerProcessGuard(logger);
119
+
120
+ // Explicit Programmatic Legal Warning printed to standard output on boot
121
+ console.log("\n=======================================================================");
122
+ console.log("[ENGINE INIT] Copyright 2026 Dev Dhanadiya. Licensed under Apache 2.0.");
123
+ console.log("[ENGINE INIT] DESIGN PATTERN: ACID FAIL-CLOSED ORCHESTRATION ENGINE.");
124
+ console.log("[WARN] System will freeze execution queues upon any database conflict.");
125
+ console.log("[LEGAL] Under Apache 2.0 Sec 7 & 8, User assumes 100% liability for");
126
+ console.log(" monitoring API failures, worker drops, and DPDP timelines.");
127
+ console.log("=======================================================================\n");
128
+
129
+ if (process.env.I_ACCEPT_APACHE2_AND_DPDP_OPERATIONAL_LIABILITY !== "true") {
130
+ console.error("[CRITICAL ERROR] Engine initialization aborted.");
131
+ console.error("[CRITICAL ERROR] You must explicitly set 'I_ACCEPT_APACHE2_AND_DPDP_OPERATIONAL_LIABILITY=true'");
132
+ console.error(" in your environment variables to acknowledge the Apache 2.0 disclaimer");
133
+ console.error(" and assume full operational risk under the Indian DPDP Act 2023.");
134
+ process.exit(1);
135
+ }
136
+
119
137
  logger.info("Starting Compliance Worker");
120
138
 
121
139
  const configPath = new URL("../compliance.worker.yaml", import.meta.url)