ai-privacy-check 0.0.0-stage → 0.1.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (4 Dec 2026)
4
+
5
+ First release.
6
+
7
+ - Code scan (JS/TS/Python): personal-data fields in prompts and tool schemas (12 categories, owner-aware), whole-record serialisation, AI recipients (16 model providers, 4 gateways, 10 tracing/analytics tools, 9 vector databases, local models), OpenAI-compatible SDKs resolved to the real provider.
8
+ - Provider settings: OpenAI Responses `store` (including the Agents SDK default), objects kept until deleted, Chat Completions `store: true`, EU residency; Gemini API free-tier terms and Vertex AI; Anthropic `inference_geo`; gateway zero-data-retention settings; tracing off-switches, including names the SDK does not read.
9
+ - Retention and rights: stored chat history without an age-based delete, prompts in application logs, embeddings of customer content without a delete path, fine-tuning on customer data, AI-made significant decisions.
10
+ - Site scan: chat and AI personalisation scripts, privacy-policy discovery in 11 languages and on Shopify, GDPR Art. 13 checks, and a check that vendors found in code are named in the policy.
11
+ - Outputs: text, Markdown, JSON, CSV processing register (GDPR Art. 30 style), DPIA screening (WP248 nine criteria plus California triggers), draft privacy-notice section.
12
+ - Vendor facts and laws checked against primary sources on 4 Dec 2026.
13
+ - Evaluated on nine public AI apps; false positives found there were fixed and turned into tests.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ahmad Zia (https://www.ahmadzia.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,314 @@
1
- # Temporary Holding Version
1
+ # ai-privacy-check
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <!-- badges -->
4
+ [![npm](https://img.shields.io/npm/v/ai-privacy-check?color=3a7a4e&label=npm)](https://www.npmjs.com/package/ai-privacy-check) [![CI](https://github.com/MuhammadAhmadZia/ai-privacy-check/actions/workflows/ci.yml/badge.svg)](https://github.com/MuhammadAhmadZia/ai-privacy-check/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-0d2018)](LICENSE) [![Agent skill](https://img.shields.io/badge/agent%20skill-ai--privacy--check-c5dfc9)](skills/ai-privacy-check/SKILL.md) [![Guide](https://img.shields.io/badge/guide-ahmadzia.com-3a7a4e)](https://www.ahmadzia.com/tools/ai-privacy-check)
5
+
6
+ Find out where personal data goes when your store uses AI.
7
+
8
+ When a store adds an AI chatbot, search or product writer, customer data starts going to new places:
9
+
10
+ - the model provider;
11
+ - the tracing or analytics tool that copies every prompt;
12
+ - the vector database that keeps chat text "until deleted";
13
+ - the gateway that picks a provider for each request.
14
+
15
+ Each of these is a processor, so it belongs in your records, your contracts and your privacy notice. Most teams don't know they are there.
16
+
17
+ This tool reads your code (and, if you like, your live site and privacy policy). It tells you:
18
+
19
+ - **who** receives personal data;
20
+ - **which fields** reach a prompt;
21
+ - **how long** each recipient keeps it, and whether it is used for training;
22
+ - **what to change**.
23
+
24
+ It then drafts the paperwork a data protection officer asks for:
25
+
26
+ - a GDPR Article 30-style processing register (CSV);
27
+ - a DPIA screening against the nine WP248 criteria;
28
+ - the AI section of a privacy notice.
29
+
30
+ ```
31
+ [HIGH] Payment card or bank details sent to an AI model
32
+ lib/support_agent.py:7 Card on file: {order['card_number']}
33
+ why: Card and bank numbers never need to reach a model. Pass a masked form (last four digits) or nothing.
34
+ fix: Remove the field before the prompt is built.
35
+ rules: GDPR Art. 5(1)(c), GDPR Art. 25
36
+
37
+ [MEDIUM] OpenAI Agents SDK tracing is meant to be off, but the setting name is wrong
38
+ python-backend/main.py:31 os.environ.setdefault("OPENAI_TRACING_DISABLED", "1")
39
+ why: The code sets OPENAI_TRACING_DISABLED, which the SDK does not read, so tracing stays on ...
40
+ fix: Use the documented switch instead: OPENAI_AGENTS_DISABLE_TRACING=1, set_tracing_disabled(True) ...
41
+ ```
42
+
43
+ The second finding is real. It comes from OpenAI's own customer-service agents demo (see [Accuracy](#accuracy)).
44
+
45
+ The tool runs on your machine and reads only your files. Nothing is uploaded. **It is an engineering aid, not legal advice.**
46
+
47
+ ## Quick start
48
+
49
+ You need Node.js 18.17 or newer. Check your version with `node --version`.
50
+
51
+ To scan code, run this in your project folder:
52
+
53
+ ```bash
54
+ npx ai-privacy-check .
55
+ ```
56
+
57
+ To also check your live site and its privacy policy:
58
+
59
+ ```bash
60
+ npx ai-privacy-check . --site https://your-store.com
61
+ ```
62
+
63
+ To write all the outputs to files:
64
+
65
+ ```bash
66
+ npx ai-privacy-check . --site https://your-store.com \
67
+ --md ai-privacy.md --register register.csv --notice ai-notice.md \
68
+ --business "Your Store" --contact privacy@your-store.com
69
+ ```
70
+
71
+ What each file is for:
72
+
73
+ - `register.csv` opens in Excel or Google Sheets. It has one row per recipient. You fill in the `[brackets]`: lawful basis, contract status, and any purpose the tool could not guess.
74
+ - `ai-privacy.md` is the full report. It holds the findings, the register, the DPIA screening, the policy check and the notice draft.
75
+ - `ai-notice.md` is the draft "How we use AI" section for your privacy policy.
76
+
77
+ ## What it finds
78
+
79
+ ### Personal data in prompts
80
+
81
+ The tool reads the code that builds prompts: model-call arguments, plus variables such as `system`, `prompt`, `messages` and `context`. It also reads tool schemas the model fills in. In those places it looks at field names such as `customer.email`, `order['shipping_address']`, `user.get('phone')` and `${email}`.
82
+
83
+ A field counts only when it belongs to a person-like object:
84
+
85
+ - `customer.age` counts;
86
+ - `product.age` does not;
87
+ - `config.email` does not.
88
+
89
+ | Category | Examples | Severity |
90
+ |---|---|---|
91
+ | Payment card or bank details | `card_number`, `cvv`, `iban` | high |
92
+ | Passwords and login secrets | `password`, `otp` | high |
93
+ | Government ID numbers | `ssn`, `passport_number`, `cnic`, `aadhaar` | high |
94
+ | Special category data (GDPR Art. 9) | `allergies`, `medical_history`, `religion`, `ethnicity`, `biometrics` | high |
95
+ | Age, date of birth, children | `date_of_birth`, `child_name` | medium |
96
+ | Precise location, IP address | `ip_address`, `geolocation` | medium |
97
+ | Contact details | `email`, `phone` | medium |
98
+ | Postal address | `shipping_address`, `postcode` | medium |
99
+ | Partial card or ID numbers | `last_4_digits` | medium |
100
+ | Names | `first_name`, `passenger_name` | low |
101
+ | Order and purchase history | `order_history`, `cart_items` | low |
102
+ | Customer identifiers | `customer_id`, `confirmation_number` | low |
103
+
104
+ It also flags two other patterns:
105
+
106
+ - **Whole records serialised into prompts**, for example `JSON.stringify(order)`. You can't list what is shared, so the register would be wrong.
107
+ - **Tool schemas that make the AI collect data** from customers, for example an agent tool with `phone_number` and `date_of_birth` parameters.
108
+
109
+ ### Recipients and their settings
110
+
111
+ Each fact below was checked against the vendor's own documentation on 4 Dec 2026. The report prints the source link next to it.
112
+
113
+ **Model providers**
114
+
115
+ | Provider | What the tool checks |
116
+ |---|---|
117
+ | OpenAI | Responses API state is kept 30 days unless `store: false` (this includes the Agents SDK, which leaves `store` unset). Conversations, Assistants, Threads, Files, Vector stores and Batches are kept until deleted. `store: true` on Chat Completions. EU data residency (`eu.api.openai.com`) is recorded as a control. |
118
+ | Google Gemini API | With an API key and no billing, the free-tier terms apply: content can improve Google products and be read by human reviewers. People in the EEA, Switzerland and the UK may only be served through Paid Services. Logs are kept 55 days and are on by default in new projects. `vertexai: true` is recognised as Vertex AI. |
119
+ | Anthropic | Records `inference_geo`. |
120
+ | Azure OpenAI and Bedrock | Recorded as recipients with their region and retention facts. |
121
+ | DeepSeek API | Flagged as a transfer to China. |
122
+
123
+ It also recognises Vertex AI, Azure OpenAI (including `AzureOpenAI` from the `openai` package), Amazon Bedrock, Mistral, Groq, xAI, Cohere, Together, Fireworks, Perplexity, Replicate and Hugging Face. The `openai` SDK pointed at another provider's `baseURL` is counted as that provider.
124
+
125
+ **Gateways**
126
+
127
+ | Gateway | What the tool checks |
128
+ |---|---|
129
+ | Vercel AI Gateway | `zeroDataRetention` |
130
+ | OpenRouter | `data_collection: "deny"` |
131
+ | Helicone | the `Helicone-Omit-*` headers |
132
+ | Cloudflare AI Gateway | `cf-aig-collect-log-payload` (payload logs are on by default) |
133
+
134
+ **Tracing and analytics that copy prompts**
135
+
136
+ | Tool | How it is switched off |
137
+ |---|---|
138
+ | OpenAI Agents SDK tracing | on by default, with inputs |
139
+ | LangSmith | `LANGSMITH_HIDE_INPUTS` |
140
+ | Langfuse | `mask` |
141
+ | PostHog LLM analytics | `privacyMode` |
142
+ | Sentry AI monitoring | only when `recordInputs` or `sendDefaultPii` is on |
143
+ | Traceloop / OpenLLMetry | `TRACELOOP_TRACE_CONTENT` |
144
+ | Arize Phoenix | `OPENINFERENCE_HIDE_INPUTS` |
145
+ | Braintrust, W&B Weave, Datadog LLM Observability | recorded as recipients |
146
+ | Vercel AI SDK telemetry | records inputs by default once on |
147
+
148
+ If a tracing switch is set under a name the SDK does not read, the tool says so.
149
+
150
+ **Vector databases**
151
+
152
+ Pinecone, Qdrant, Weaviate, Chroma, Upstash Vector, Milvus, pgvector (Supabase, Neon), MongoDB Atlas Vector Search and turbopuffer.
153
+
154
+ The tool flags customer content that is embedded when no delete call exists for it. Without one, an erasure request (Art. 17) cannot be carried out.
155
+
156
+ **Local models**
157
+
158
+ Ollama, llama.cpp, vLLM and LM Studio are recorded as "no third party".
159
+
160
+ ### Retention, logs and decisions
161
+
162
+ - **Chat history.** It flags chats saved to a database with no expiry or age-based delete. It understands Prisma, Drizzle, Supabase, MongoDB and SQL. A paginated query on `createdAt` is not treated as a retention rule.
163
+ - **Application logs.** It flags prompts or replies written to logs. Counts and IDs are fine.
164
+ - **Fine-tuning and training.** It flags training on customer data. This is a new purpose, it is covered by EDPB Opinion 28/2024, and it is a California risk-assessment trigger.
165
+ - **Significant decisions.** It flags AI output used to decide credit, pay-later, financing, insurance or hiring. This touches GDPR Art. 22, the California ADMT rules (from 1 Jan 2027) and Colorado SB 26-189.
166
+
167
+ ### Live site and privacy policy (`--site`)
168
+
169
+ **Scripts on the home page.** The tool looks for chat and AI-agent scripts: Intercom, Tidio, Zendesk, Gorgias, Drift, HubSpot, Crisp, Freshchat, LiveChat, tawk.to, Re:amaze, Kommunicate, Ada, Chatbase, Voiceflow, Botpress and Shopify Inbox. It also looks for AI search and personalisation scripts: Klevu, Nosto, Rebuy, Constructor, Bloomreach and Algolia.
170
+
171
+ **Finding the policy.** It follows the footer link. That works in English, German, French, Spanish, Italian, Portuguese, Dutch, Swedish, Finnish, Polish and Turkish, and with Shopify's `/policies/privacy-policy`. If the policy is somewhere else, pass `--policy <url>`.
172
+
173
+ **Checking the policy.** It checks the policy against GDPR Art. 13. Does it:
174
+
175
+ - mention AI;
176
+ - name the recipients;
177
+ - give the purpose;
178
+ - give a retention period;
179
+ - say whether data is used for training;
180
+ - cover international transfers;
181
+ - mention automated decisions or profiling;
182
+ - explain people's rights?
183
+
184
+ When you scan code and site together, it also checks that every vendor in your code is named in the policy.
185
+
186
+ ### DPIA screening
187
+
188
+ The nine criteria come from the WP29 Guidelines on DPIA (WP248 rev.01, endorsed by the EDPB). Each criterion gets one of four results:
189
+
190
+ - **met**, with evidence from your code;
191
+ - **possible**, with the question to answer;
192
+ - **no sign**;
193
+ - **answer**, for things code cannot show, such as large scale or systematic monitoring.
194
+
195
+ Two or more criteria met means a DPIA is likely needed. The report also lists the California CCPA risk-assessment triggers that apply.
196
+
197
+ ## Accuracy
198
+
199
+ Two test projects come with the package:
200
+
201
+ - **A deliberately leaky store.** All 14 planted problem types are found.
202
+ - **The same store built carefully.** It has data minimisation, `store: false`, tracing off, privacy mode, Vertex AI in `europe-west4`, a 90-day chat purge and vector deletion. It produces 0 findings.
203
+
204
+ On 4 Dec 2026 I also ran the tool on nine public AI apps:
205
+
206
+ - `vercel/chatbot` (formerly `vercel/ai-chatbot`)
207
+ - `mckaywrigley/chatbot-ui`
208
+ - `openai/openai-agents-python`
209
+ - `openai/openai-realtime-agents`
210
+ - `openai/openai-cs-agents-demo`
211
+ - `Shopify/shop-chat-agent`
212
+ - `run-llama/create-llama`
213
+ - `langchain-ai/chat-langchain`
214
+ - `vercel-labs/ai-sdk-preview-rsc-genui`
215
+
216
+ **False positives the first run found.** Each one was fixed, and each is now a test:
217
+
218
+ - tool-approval states counted as decisions;
219
+ - a pagination query counted as a retention rule;
220
+ - a React "cleanup" comment counted as a retention rule;
221
+ - weather-tool coordinates counted as customer location;
222
+ - the word "candidate" in a tool-name helper.
223
+
224
+ **After the fixes, every finding was checked by hand against the code.** Some highlights:
225
+
226
+ - **OpenAI customer-service agents demo.** It sets `OPENAI_TRACING_DISABLED=1` to turn tracing off. The Agents SDK only reads `OPENAI_AGENTS_DISABLE_TRACING`. I checked this in the SDK source, `tracing/provider.py`. So tracing stays on for anyone who copies the demo.
227
+ - **OpenAI realtime agents demo.** Its retail agent asks callers for their phone number, date of birth and the last four digits of their SSN or card. The tool flags this, and flags that Agents SDK tracing, which is on by default, copies all of it to OpenAI.
228
+ - **Vercel's chatbot.** Telemetry is on in production with inputs recorded. Chats are stored with no age-based deletion. Gateway requests don't ask for zero data retention.
229
+ - **Shopify's chat agent.** Conversations are stored in Prisma with no deletion rule.
230
+ - **Agents SDK apps.** The SDK leaves `store` unset, so Responses state is kept for 30 days unless you set `ModelSettings(store=False)`.
231
+
232
+ Silence a reviewed line with a comment on it or on the line above:
233
+
234
+ ```js
235
+ // ai-privacy-check-ignore
236
+ ```
237
+
238
+ ## Options
239
+
240
+ | Option | What it does |
241
+ |---|---|
242
+ | `--site <url>` | Scan a live site and its privacy policy |
243
+ | `--policy <url>` | Privacy policy URL, if it cannot be found from the home page |
244
+ | `--md <file>` | Full Markdown report |
245
+ | `--register <file>` | Processing register as CSV |
246
+ | `--notice <file>` | Draft privacy-notice section |
247
+ | `--business <name>`, `--contact <email>` | Used in the notice draft |
248
+ | `--include-tests` | Also report tests, examples and docs (as info) |
249
+ | `--fail-on <level>` | `high`, `medium` or `low`: exit 1 for CI |
250
+ | `--json`, `--quiet` | Machine output, or one summary line |
251
+
252
+ You can also use it as a library:
253
+
254
+ ```js
255
+ import { privacyCheck, formatMarkdown, registerCsv } from 'ai-privacy-check';
256
+ const r = await privacyCheck({ code: './my-store', site: 'https://my-store.com' });
257
+ ```
258
+
259
+ ## What it does not do
260
+
261
+ - **It cannot see account settings.** These include Gemini billing, OpenAI Zero Data Retention approval, team-wide gateway settings and the retention plans of tracing tools. When a finding depends on one of these, it says so. Note the setting in your register.
262
+ - **It finds field names, not values.** A customer can type anything into a chat. Free text is listed in the register as "may contain any personal data".
263
+ - **It cannot decide your lawful basis or whether your processing is lawful.** It gives you the facts to decide with.
264
+ - **It does not check ad pixels.** Selling or sharing data for cross-context advertising is a separate California trigger.
265
+ - **The site check has only been tested on sample pages.** The machine I built it on cannot reach live stores, so try it on your own site.
266
+
267
+ ## Where the other tools fit
268
+
269
+ - **ai-disclosure-check:** tells people they are talking to AI (EU AI Act Art. 50).
270
+ - **llm-store-review:** security of the same AI code (OWASP LLM Top 10).
271
+ - **shopbot-shield:** blocks prompt injection at runtime.
272
+ - **rag-content-guard:** catches poisoned content before it reaches your index.
273
+
274
+ ## Laws and guidance referenced
275
+
276
+ - GDPR Art. 5, 9, 13, 17, 22, 25, 28, 30, 35 and 44–46.
277
+ - WP248 rev.01.
278
+ - EDPB Opinion 28/2024 on AI models.
279
+ - The EDPB Support Pool of Experts report *AI Privacy Risks & Mitigations: LLMs* (April 2025).
280
+ - The California CCPA regulations on risk assessments and ADMT (effective 1 Jan 2026; ADMT duties from 1 Jan 2027).
281
+ - Colorado SB 26-189 (signed 14 May 2026; duties from 1 Jan 2027).
282
+
283
+ **Pakistan:** there is still no comprehensive data protection law in force. The 2023 draft Personal Data Protection Bill has not been passed. So the tool uses GDPR-level practice as the baseline.
284
+
285
+ ## Sustainable Development Goals
286
+
287
+ This tool supports **SDG target 16.10**: ensure public access to information and protect fundamental freedoms. Privacy is one of those freedoms, under Article 12 of the Universal Declaration of Human Rights. People can only use their rights if a business can say where their data goes. Small stores that add AI rarely can. This tool turns their code into an honest list of recipients and a plain-language notice, so customers get accurate information and the business can answer access and erasure requests.
288
+
289
+ **What it does not do:** it does not make processing lawful. A clean report means no known patterns were found. It is not a compliance certificate.
290
+
291
+ ## License
292
+
293
+ MIT © Ahmad Zia
294
+
295
+ <!-- ahmadzia-links -->
296
+ ## Guide, help and author
297
+
298
+ - **Full guide with examples and FAQs:** [www.ahmadzia.com/tools/ai-privacy-check](https://www.ahmadzia.com/tools/ai-privacy-check)
299
+ - **Background reading:** [Agent skills explained: SKILL.md, Claude skills vs MCP](https://www.ahmadzia.com/blog/agent-skills-explained-ecommerce)
300
+ - **All 30 free tools and agent skills:** [ahmadzia.com/tools](https://www.ahmadzia.com/tools) · [ahmadzia.com/skills](https://www.ahmadzia.com/skills)
301
+ - **Want it set up, fixed or tuned for your store?** [Book a free call](https://www.ahmadzia.com/contact)
302
+
303
+ Built by **[Ahmad Zia](https://www.ahmadzia.com)** (Muhammad Ahmad Zia), an AI consultant for ecommerce since 2020 and green AI researcher at the University of Lahore. [Research](https://www.ahmadzia.com/research) · [Google Scholar](https://scholar.google.com/citations?user=sqjdX2EAAAAJ&hl=en) · [ORCID](https://orcid.org/0000-0002-3208-6246) · [LinkedIn](https://www.linkedin.com/in/muhammad-ahmadzia/) · [GitHub](https://github.com/MuhammadAhmadZia)
304
+ <!-- /ahmadzia-links -->
305
+
306
+ ## More AI and store security tools
307
+
308
+ - [shopbot-shield](https://github.com/MuhammadAhmadZia/shopbot-shield): Prompt injection protection for ecommerce chatbots and AI shopping assistants
309
+ - [model-file-guard](https://github.com/MuhammadAhmadZia/model-file-guard): Scan pickle, PyTorch, joblib and other ML model files for hidden code before you load them
310
+ - [llm-store-review](https://github.com/MuhammadAhmadZia/llm-store-review): Security review of AI chatbots and agents in your code, mapped to the OWASP LLM Top 10 2026
311
+ - [rag-content-guard](https://github.com/MuhammadAhmadZia/rag-content-guard): Find hidden instructions and poisoned documents before they reach your RAG index or AI agent
312
+ - [storeguard](https://github.com/MuhammadAhmadZia/storeguard): Free security scanner for vibe-coded online stores
313
+
314
+ All 30 tools and agent skills: [github.com/MuhammadAhmadZia](https://github.com/MuhammadAhmadZia) · [ahmadzia.com/tools](https://www.ahmadzia.com/tools)
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env node
2
+ import { writeFile } from 'node:fs/promises';
3
+ import { existsSync } from 'node:fs';
4
+ import { privacyCheck, formatText, formatMarkdown, registerCsv, DISCLAIMER } from '../src/index.js';
5
+
6
+ const HELP = `ai-privacy-check: where does personal data go when your store uses AI?
7
+
8
+ Usage
9
+ ai-privacy-check <project-folder> scan code
10
+ ai-privacy-check --site <url> scan a live site and its privacy policy
11
+ ai-privacy-check <project-folder> --site <url> both (checks the policy names what the code uses)
12
+
13
+ Options
14
+ --policy <url> privacy policy URL, if the tool cannot find it from the home page
15
+ --md <file> write the full Markdown report (register, DPIA screening, notice draft)
16
+ --register <file> write the processing register as CSV (opens in Excel or Google Sheets)
17
+ --notice <file> write the draft privacy-notice section as Markdown
18
+ --json print JSON instead of text
19
+ --business <name> your business name, used in the notice draft
20
+ --contact <email> privacy contact, used in the notice draft
21
+ --include-tests also report findings in tests, examples and docs
22
+ --fail-on <level> exit 1 if any finding is at or above high | medium | low (for CI)
23
+ --quiet only the summary line
24
+ -h, --help this help
25
+
26
+ Silence a reviewed line with a comment on it or the line above: // ai-privacy-check-ignore
27
+
28
+ ${DISCLAIMER}
29
+ More: https://www.ahmadzia.com/tools/ai-privacy-check
30
+ `;
31
+
32
+ function parse(argv) {
33
+ const o = { _: [] };
34
+ for (let i = 0; i < argv.length; i++) {
35
+ const a = argv[i];
36
+ const val = () => { const v = argv[++i]; if (v === undefined || v.startsWith('--')) throw new Error(`${a} needs a value`); return v; };
37
+ if (a === '-h' || a === '--help') o.help = true;
38
+ else if (a === '--site') o.site = val();
39
+ else if (a === '--policy') o.policy = val();
40
+ else if (a === '--md') o.md = val();
41
+ else if (a === '--register') o.register = val();
42
+ else if (a === '--notice') o.notice = val();
43
+ else if (a === '--business') o.business = val();
44
+ else if (a === '--contact') o.contact = val();
45
+ else if (a === '--fail-on') { o.failOn = val(); if (!['high', 'medium', 'low'].includes(o.failOn)) throw new Error('--fail-on takes high, medium or low'); }
46
+ else if (a === '--json') o.json = true;
47
+ else if (a === '--include-tests') o.includeTests = true;
48
+ else if (a === '--quiet') o.quiet = true;
49
+ else if (a.startsWith('-')) throw new Error(`Unknown option ${a}`);
50
+ else o._.push(a);
51
+ }
52
+ return o;
53
+ }
54
+
55
+ async function main() {
56
+ let o;
57
+ try { o = parse(process.argv.slice(2)); } catch (e) { process.stderr.write(`${e.message}\n\n${HELP}`); return 2; }
58
+ if (o.help || (!o._.length && !o.site)) { process.stdout.write(HELP); return o.help ? 0 : 2; }
59
+ let code = o._[0];
60
+ let site = o.site;
61
+ if (code && /^https?:\/\//i.test(code) && !site) { site = code; code = undefined; }
62
+ if (code && !existsSync(code)) { process.stderr.write(`Folder not found: ${code}\n`); return 2; }
63
+ const log = o.quiet || o.json ? () => {} : (m) => process.stderr.write(`${m}\n`);
64
+ let r;
65
+ try { r = await privacyCheck({ code, site, policyUrl: o.policy, includeTests: o.includeTests, business: o.business, contact: o.contact, log }); }
66
+ catch (e) { process.stderr.write(`Error: ${e.message}\n`); return 2; }
67
+ if (o.md) await writeFile(o.md, formatMarkdown(r));
68
+ if (o.register) await writeFile(o.register, registerCsv(r.register));
69
+ if (o.notice) await writeFile(o.notice, r.notice);
70
+ const counts = ['high', 'medium', 'low'].map((s) => `${r.findings.filter((f) => f.severity === s).length} ${s}`).join(', ');
71
+ if (o.json) process.stdout.write(JSON.stringify(r, (k, v) => (v instanceof RegExp ? v.source : v), 2) + '\n');
72
+ else if (o.quiet) process.stdout.write(`ai-privacy-check: ${counts}; ${r.recipients.length} recipients; ${r.dpia.verdict.text}\n`);
73
+ else process.stdout.write(formatText(r));
74
+ if (!o.json && !o.quiet) for (const [flag, file] of [['md', o.md], ['register', o.register], ['notice', o.notice]]) if (file) process.stderr.write(`Wrote ${file} (--${flag})\n`);
75
+ if (o.failOn) {
76
+ const rank = { high: 1, medium: 2, low: 3 };
77
+ if (r.findings.some((f) => (rank[f.severity] || 9) <= rank[o.failOn])) return 1;
78
+ }
79
+ return 0;
80
+ }
81
+
82
+ main().then((c) => { process.exitCode = c; });
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "ai-privacy-check",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Find where personal data goes when your store uses AI: which providers, trackers and vector databases receive it, what fields reach prompts, retention and training settings. Drafts a GDPR Art. 30 register, a DPIA screening and a privacy-notice section.",
5
+ "type": "module",
6
+ "bin": {
7
+ "ai-privacy-check": "bin/ai-privacy-check.js"
8
+ },
9
+ "main": "src/index.js",
10
+ "exports": {
11
+ ".": "./src/index.js"
12
+ },
13
+ "files": [
14
+ "bin",
15
+ "src",
16
+ "README.md",
17
+ "LICENSE",
18
+ "CHANGELOG.md"
19
+ ],
20
+ "scripts": {
21
+ "test": "node --test test/*.test.js"
22
+ },
23
+ "engines": {
24
+ "node": ">=18.17"
25
+ },
26
+ "keywords": [
27
+ "gdpr",
28
+ "privacy",
29
+ "ai-privacy",
30
+ "dpia",
31
+ "data-protection",
32
+ "ropa",
33
+ "article-30",
34
+ "llm",
35
+ "openai",
36
+ "gemini",
37
+ "anthropic",
38
+ "pii",
39
+ "data-minimisation",
40
+ "ccpa",
41
+ "ecommerce",
42
+ "privacy-policy"
43
+ ],
44
+ "author": {
45
+ "name": "Ahmad Zia (Muhammad Ahmad Zia)",
46
+ "url": "https://www.ahmadzia.com"
47
+ },
48
+ "license": "MIT",
49
+ "homepage": "https://www.ahmadzia.com/tools/ai-privacy-check",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/MuhammadAhmadZia/ai-privacy-check.git"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/MuhammadAhmadZia/ai-privacy-check/issues"
56
+ }
57
+ }