shelfready 0.1.0 → 0.1.1
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/README.md +1 -4
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +272 -0
- package/dist/core/appPrivacy.d.ts +20 -0
- package/dist/core/appPrivacy.js +73 -0
- package/dist/core/check.d.ts +15 -0
- package/dist/core/check.js +151 -0
- package/dist/core/checklist.d.ts +44 -0
- package/dist/core/checklist.js +176 -0
- package/dist/core/facts.d.ts +103 -0
- package/dist/core/facts.js +97 -0
- package/dist/core/knowledge.d.ts +29 -0
- package/dist/core/knowledge.js +35 -0
- package/dist/core/legalView.d.ts +6 -0
- package/dist/core/legalView.js +39 -0
- package/dist/core/migrate.d.ts +24 -0
- package/dist/core/migrate.js +66 -0
- package/dist/core/online.d.ts +20 -0
- package/dist/core/online.js +76 -0
- package/dist/core/pages.d.ts +17 -0
- package/dist/core/pages.js +124 -0
- package/dist/core/scan.d.ts +55 -0
- package/dist/core/scan.js +215 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +11 -0
- package/package.json +4 -3
- package/knowledge/README.md +0 -26
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { needsImpressum, pageURL } from "./facts.js";
|
|
2
|
+
/** Visible text of an HTML page, normalised so typographic quotes and entities compare equal. */
|
|
3
|
+
export function pageText(html) {
|
|
4
|
+
return html
|
|
5
|
+
.replace(/<(script|style)[\s\S]*?<\/\1>/gi, " ")
|
|
6
|
+
.replace(/<[^>]+>/g, " ")
|
|
7
|
+
.replace(/ /g, " ")
|
|
8
|
+
.replace(/&/g, "&")
|
|
9
|
+
.replace(/"/g, '"')
|
|
10
|
+
.replace(/'|'|’|‘|[‘’]/g, "'")
|
|
11
|
+
.replace(/“|”|[“”]/g, '"')
|
|
12
|
+
.replace(/›|›/g, "›")
|
|
13
|
+
.replace(/…|…/g, "…")
|
|
14
|
+
.replace(/&[a-z]+;|&#\d+;/gi, " ")
|
|
15
|
+
.replace(/\s+/g, " ")
|
|
16
|
+
.trim()
|
|
17
|
+
.toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
/** Markdown inline formatting removed, for matching against rendered text. */
|
|
20
|
+
const plain = (md) => pageText(md.replace(/[*_`]/g, "").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1"));
|
|
21
|
+
/**
|
|
22
|
+
* `shelf check --online`: are the pages live, and do they show what shelfready.yaml says?
|
|
23
|
+
* Catches dead URLs (App Review rejects them) and stale deployments.
|
|
24
|
+
*/
|
|
25
|
+
export async function checkOnline(facts, fetchFn = fetch, timeoutMs = 10_000) {
|
|
26
|
+
const findings = [];
|
|
27
|
+
const add = (level, rule, message) => findings.push({ level, rule, message });
|
|
28
|
+
if (!facts.pages.baseURL) {
|
|
29
|
+
add("error", "online.baseURL", "pages.baseURL is empty, so there is nothing to check online.");
|
|
30
|
+
return findings;
|
|
31
|
+
}
|
|
32
|
+
const pages = [
|
|
33
|
+
{
|
|
34
|
+
name: "privacy",
|
|
35
|
+
expect: [
|
|
36
|
+
{ text: facts.app.name, what: "the app name" },
|
|
37
|
+
{ text: facts.pages.policyUpdated, what: `the policy date ${facts.pages.policyUpdated}` },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "support",
|
|
42
|
+
expect: [
|
|
43
|
+
{ text: facts.publisher.email, what: "the contact email" },
|
|
44
|
+
...facts.support.faq.map((f) => ({ text: f.q, what: `FAQ "${f.q}"` })),
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
if (needsImpressum(facts))
|
|
49
|
+
pages.push({ name: "impressum", expect: [{ text: facts.publisher.email, what: "the contact email" }] });
|
|
50
|
+
await Promise.all(pages.map(async ({ name, expect }) => {
|
|
51
|
+
const url = pageURL(facts, name);
|
|
52
|
+
if (!/^https:\/\//.test(url))
|
|
53
|
+
return add("error", `online.${name}`, `${name} URL must be absolute https, got "${url}".`);
|
|
54
|
+
const controller = new AbortController();
|
|
55
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
56
|
+
try {
|
|
57
|
+
const res = await fetchFn(url, { signal: controller.signal, redirect: "follow", headers: { "user-agent": "shelfready-check" } });
|
|
58
|
+
if (!res.ok)
|
|
59
|
+
return add("error", `online.${name}`, `${url} returned HTTP ${res.status}.`);
|
|
60
|
+
const text = pageText(await res.text());
|
|
61
|
+
const missing = expect.filter((e) => !text.includes(plain(e.text))).map((e) => e.what);
|
|
62
|
+
if (missing.length)
|
|
63
|
+
add("warn", `online.${name}.stale`, `${url} is live but doesn't show ${missing.join(", ")}. Redeploy the generated page?`);
|
|
64
|
+
else
|
|
65
|
+
add("ok", `online.${name}`, `${url} is live and up to date.`);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
const reason = e.name === "AbortError" ? `no response within ${timeoutMs / 1000}s` : e.message;
|
|
69
|
+
add("error", `online.${name}`, `${url} unreachable: ${reason}.`);
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
clearTimeout(timer);
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
return findings.sort((a, b) => a.rule.localeCompare(b.rule));
|
|
76
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Facts } from "./facts.js";
|
|
2
|
+
/**
|
|
3
|
+
* Page templates. Draft wording, generalised from the Half Batch site (kipple).
|
|
4
|
+
* Must be reviewed by a lawyer before ShelfReady is offered to others; output is not legal advice.
|
|
5
|
+
*/
|
|
6
|
+
export interface Page {
|
|
7
|
+
file: string;
|
|
8
|
+
title: string;
|
|
9
|
+
/** Path relative to the app's base URL, e.g. "privacy/". */
|
|
10
|
+
path: string;
|
|
11
|
+
markdown: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function renderPages(facts: Facts): Page[];
|
|
14
|
+
export declare function privacyPolicy(facts: Facts): Page;
|
|
15
|
+
export declare function supportPage(facts: Facts): Page;
|
|
16
|
+
/** German-language Impressum (§ 5 DDG for DE, § 5 ECG for AT), with an English notice. */
|
|
17
|
+
export declare function impressum(facts: Facts): Page;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { CATEGORY, PURPOSE } from "./appPrivacy.js";
|
|
2
|
+
import { impressumLines, needsImpressum, pageURL } from "./facts.js";
|
|
3
|
+
import { lookup, sdkCollects } from "./knowledge.js";
|
|
4
|
+
const CATEGORY_LABEL = {
|
|
5
|
+
NAME: "Name", EMAIL_ADDRESS: "Email address", PHONE_NUMBER: "Phone number", PHYSICAL_ADDRESS: "Physical address",
|
|
6
|
+
OTHER_CONTACT_INFO: "Other contact info", HEALTH: "Health", FITNESS: "Fitness", PAYMENT_INFORMATION: "Payment info",
|
|
7
|
+
CREDIT_AND_FRAUD: "Credit info", OTHER_FINANCIAL_INFO: "Other financial info", PRECISE_LOCATION: "Precise location",
|
|
8
|
+
COARSE_LOCATION: "Coarse location", SENSITIVE_INFO: "Sensitive info", CONTACTS: "Contacts",
|
|
9
|
+
EMAILS_OR_TEXT_MESSAGES: "Emails or text messages", PHOTOS_OR_VIDEOS: "Photos or videos", AUDIO: "Audio data",
|
|
10
|
+
GAMEPLAY_CONTENT: "Gameplay content", CUSTOMER_SUPPORT: "Customer support", OTHER_USER_CONTENT: "Other user content",
|
|
11
|
+
BROWSING_HISTORY: "Browsing history", SEARCH_HISTORY: "Search history", USER_ID: "User ID", DEVICE_ID: "Device ID",
|
|
12
|
+
PURCHASE_HISTORY: "Purchase history", PRODUCT_INTERACTION: "Product interaction", ADVERTISING_DATA: "Advertising data",
|
|
13
|
+
OTHER_USAGE_DATA: "Other usage data", CRASH_DATA: "Crash data", PERFORMANCE_DATA: "Performance data",
|
|
14
|
+
OTHER_DIAGNOSTIC_DATA: "Other diagnostic data", OTHER_DATA: "Other data",
|
|
15
|
+
};
|
|
16
|
+
const PURPOSE_LABEL = {
|
|
17
|
+
THIRD_PARTY_ADVERTISING: "third-party advertising", DEVELOPERS_ADVERTISING: "the developer's own advertising",
|
|
18
|
+
ANALYTICS: "analytics", PRODUCT_PERSONALIZATION: "personalisation", APP_FUNCTIONALITY: "making the app work",
|
|
19
|
+
OTHER_PURPOSES: "other purposes",
|
|
20
|
+
};
|
|
21
|
+
/** First-person words for the publisher's voice. */
|
|
22
|
+
function voice(facts) {
|
|
23
|
+
return facts.publisher.voice === "I"
|
|
24
|
+
? { We: "I", we: "I", us: "me", our: "my" }
|
|
25
|
+
: { We: "We", we: "we", us: "us", our: "our" };
|
|
26
|
+
}
|
|
27
|
+
export function renderPages(facts) {
|
|
28
|
+
const pages = [privacyPolicy(facts), supportPage(facts)];
|
|
29
|
+
// A shared Impressum (impressumURL) lives elsewhere, e.g. on the studio site.
|
|
30
|
+
if (needsImpressum(facts) && !facts.pages.impressumURL)
|
|
31
|
+
pages.push(impressum(facts));
|
|
32
|
+
return pages;
|
|
33
|
+
}
|
|
34
|
+
function by(facts) {
|
|
35
|
+
return facts.publisher.brand || facts.publisher.name || "the developer";
|
|
36
|
+
}
|
|
37
|
+
function contactLine(facts) {
|
|
38
|
+
const p = facts.publisher;
|
|
39
|
+
const who = p.trader && p.name ? `${p.name}${p.brand ? ` (${p.brand})` : ""}` : by(facts);
|
|
40
|
+
const impressumLink = needsImpressum(facts) ? `, see the [Impressum](${pageURL(facts, "impressum")})` : "";
|
|
41
|
+
return `${who}, [${p.email}](mailto:${p.email})${impressumLink}`;
|
|
42
|
+
}
|
|
43
|
+
export function privacyPolicy(facts) {
|
|
44
|
+
const { app, data } = facts;
|
|
45
|
+
const w = voice(facts);
|
|
46
|
+
const none = data.collected.length === 0 && !data.tracking;
|
|
47
|
+
const lines = [`# ${app.name} privacy policy`, "", `_Last updated: ${facts.pages.policyUpdated}_`, ""];
|
|
48
|
+
lines.push(app.tagline ? `${app.name} is ${app.tagline}, made by ${by(facts)}.` : `${app.name} is an app by ${by(facts)}.`, "");
|
|
49
|
+
lines.push("## The short version", "");
|
|
50
|
+
if (none) {
|
|
51
|
+
lines.push(`${app.name} doesn't collect, store or share any of your data. There are no accounts, no analytics, no ads and no tracking.`, "");
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
lines.push(`${app.name} collects the data listed below${data.tracking ? ", and some of it is used to track you across apps and websites owned by other companies" : ", and none of it is used to track you"}.`, "");
|
|
55
|
+
}
|
|
56
|
+
for (const note of facts.privacyNotes)
|
|
57
|
+
lines.push(`## ${note.heading}`, "", note.body.trim(), "");
|
|
58
|
+
lines.push(`## Data ${w.we} collect`, "");
|
|
59
|
+
if (data.collected.length === 0) {
|
|
60
|
+
const noSDKs = data.packages.length === 0 ? ` ${app.name} contains no third-party SDKs, analytics or crash-reporting services.` : "";
|
|
61
|
+
lines.push(`None.${noSDKs || ` ${app.name} doesn't collect personal data.`}`);
|
|
62
|
+
lines.push("If you've agreed to share analytics with app developers in iOS Settings, Apple may give the developer anonymous crash reports.", "");
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
lines.push("| Data | Used for | Linked to you | Used to track you |", "|---|---|---|---|");
|
|
66
|
+
for (const item of data.collected) {
|
|
67
|
+
const category = CATEGORY[item.type];
|
|
68
|
+
const label = (category && CATEGORY_LABEL[category]) ?? item.type;
|
|
69
|
+
const purposes = item.purposes.map((p) => PURPOSE_LABEL[PURPOSE[p] ?? ""] ?? p).join(", ") || "—";
|
|
70
|
+
lines.push(`| ${label} | ${purposes} | ${item.linked ? "Yes" : "No"} | ${item.tracking ? "Yes" : "No"} |`);
|
|
71
|
+
}
|
|
72
|
+
lines.push("");
|
|
73
|
+
}
|
|
74
|
+
const services = data.packages.map((p) => lookup(p)).filter((e) => e !== undefined && sdkCollects(e).length > 0);
|
|
75
|
+
if (services.length) {
|
|
76
|
+
lines.push("## Third-party services", "", `${app.name} includes these services, which collect data as described in their own privacy manifests:`, "");
|
|
77
|
+
for (const s of services) {
|
|
78
|
+
const labels = [...new Set(sdkCollects(s).map((c) => CATEGORY_LABEL[CATEGORY[c.type] ?? ""] ?? c.type))];
|
|
79
|
+
lines.push(`- **${s.name}** (${s.vendor}): ${labels.join(", ").toLowerCase()}`);
|
|
80
|
+
}
|
|
81
|
+
lines.push("");
|
|
82
|
+
}
|
|
83
|
+
if (facts.pages.sitePrivacyURL) {
|
|
84
|
+
lines.push("## This website", "", `For the website itself, see the [website privacy notice](${facts.pages.sitePrivacyURL}).`, "");
|
|
85
|
+
}
|
|
86
|
+
lines.push("## Your rights", "", none
|
|
87
|
+
? `Because ${app.name} doesn't collect personal data, there's nothing held about you to access, correct or delete. If you have questions about your rights under the GDPR, contact ${w.us} below.`
|
|
88
|
+
: `Under the GDPR you can ask to access, correct or delete your personal data, restrict or object to its use, and complain to a data protection authority. Contact ${w.us} below to make a request.`, "", "## Children", "", none ? `${app.name} doesn't collect data from anyone, including children.` : `${app.name} isn't directed at children under 13, and ${w.we} don't knowingly collect their data.`, "", "## Changes", "", "If this policy changes, the new version will be posted at this address, with a new date above.", "", "## Contact", "", contactLine(facts), "");
|
|
89
|
+
return { file: "privacy.md", title: `${app.name} privacy policy`, path: "privacy/", markdown: lines.join("\n") };
|
|
90
|
+
}
|
|
91
|
+
export function supportPage(facts) {
|
|
92
|
+
const { app, publisher, support } = facts;
|
|
93
|
+
const w = voice(facts);
|
|
94
|
+
const lines = [
|
|
95
|
+
`# ${app.name} support`,
|
|
96
|
+
"",
|
|
97
|
+
`Questions, bugs or ideas: email **[${publisher.email}](mailto:${publisher.email})**. ${w.We} usually reply ${support.replyTime}.`,
|
|
98
|
+
"",
|
|
99
|
+
`Please include ${support.askFor || "your device model and iOS version"}, and what you expected to happen.`,
|
|
100
|
+
"",
|
|
101
|
+
];
|
|
102
|
+
if (support.faq.length > 0) {
|
|
103
|
+
lines.push("## Frequently asked questions", "");
|
|
104
|
+
for (const { q, a } of support.faq)
|
|
105
|
+
lines.push(`**${q}**`, a.trim(), "");
|
|
106
|
+
}
|
|
107
|
+
lines.push("## Privacy", "", `See the [${app.name} privacy policy](${pageURL(facts, "privacy")}).`, "");
|
|
108
|
+
return { file: "support.md", title: `${app.name} support`, path: "support/", markdown: lines.join("\n") };
|
|
109
|
+
}
|
|
110
|
+
/** German-language Impressum (§ 5 DDG for DE, § 5 ECG for AT), with an English notice. */
|
|
111
|
+
export function impressum(facts) {
|
|
112
|
+
const p = facts.publisher;
|
|
113
|
+
const law = p.country.toUpperCase() === "AT" ? "§ 5 ECG" : "§ 5 DDG";
|
|
114
|
+
const lines = [];
|
|
115
|
+
if (p.trader) {
|
|
116
|
+
lines.push("# Impressum", "", `## Angaben gemäß ${law}`, "", impressumLines(facts)
|
|
117
|
+
.map(({ label, value }) => (label ? `${label}: ${value.includes("@") ? `[${value}](mailto:${value})` : value}` : value))
|
|
118
|
+
.join(" \n"), "", "## Verantwortlich für den Inhalt", "", `${p.representative || p.name}, Anschrift wie oben.`, "", "---", "", "## Legal notice (English)", "", `${facts.app.name} is provided by ${[p.name, p.address.street, p.address.city, p.address.country].filter(Boolean).join(", ")}. Contact: ${p.email}.`, "");
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
lines.push("# Contact", "", `${by(facts)} is a private, non-commercial project. ${facts.app.name} is free, with no in-app purchases, ads or tracking.`, "", `Email: [${p.email}](mailto:${p.email})`, "", "## Impressum", "", `${by(facts)} ist ein privates, nicht-kommerzielles Projekt ohne Gewinnabsicht. ${facts.app.name} ist kostenlos, ohne In-App-Käufe, Werbung oder Tracking.`, "", `Kontakt: [${p.email}](mailto:${p.email})`, "");
|
|
122
|
+
}
|
|
123
|
+
return { file: "impressum.md", title: "Impressum", path: "impressum/", markdown: lines.join("\n") };
|
|
124
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** What `shelf scan` finds in an app repository. Everything comes from files on disk. */
|
|
2
|
+
export interface ScanResult {
|
|
3
|
+
root: string;
|
|
4
|
+
xcodeProjects: string[];
|
|
5
|
+
bundleIdentifiers: string[];
|
|
6
|
+
displayNames: string[];
|
|
7
|
+
/** Purpose strings (e.g. NSCameraUsageDescription) from Info.plist files and build settings. */
|
|
8
|
+
purposeStrings: Record<string, string>;
|
|
9
|
+
privacyManifests: PrivacyManifest[];
|
|
10
|
+
packages: ResolvedPackage[];
|
|
11
|
+
/** ITSAppUsesNonExemptEncryption from Info.plist or build settings; undefined if not declared. */
|
|
12
|
+
usesNonExemptEncryption?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface PrivacyManifest {
|
|
15
|
+
path: string;
|
|
16
|
+
tracking: boolean;
|
|
17
|
+
trackingDomains: string[];
|
|
18
|
+
collectedDataTypes: CollectedDataType[];
|
|
19
|
+
accessedAPIs: AccessedAPI[];
|
|
20
|
+
}
|
|
21
|
+
export interface CollectedDataType {
|
|
22
|
+
type: string;
|
|
23
|
+
linked: boolean;
|
|
24
|
+
tracking: boolean;
|
|
25
|
+
purposes: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface AccessedAPI {
|
|
28
|
+
category: string;
|
|
29
|
+
reasons: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface ResolvedPackage {
|
|
32
|
+
identity: string;
|
|
33
|
+
location: string;
|
|
34
|
+
version?: string;
|
|
35
|
+
}
|
|
36
|
+
type Dict = Record<string, unknown>;
|
|
37
|
+
export declare function scan(rootPath: string): ScanResult;
|
|
38
|
+
export declare function privacyManifest(dict: Dict, path: string): PrivacyManifest;
|
|
39
|
+
/** Supports Package.resolved v1 (`object.pins`) and v2/v3 (`pins`). */
|
|
40
|
+
export declare function readResolvedPackages(file: string): ResolvedPackage[];
|
|
41
|
+
/** CocoaPods: top-level entries under PODS, e.g. " - FirebaseAnalytics (10.0.0):". */
|
|
42
|
+
export declare function readPodfileLock(file: string): ResolvedPackage[];
|
|
43
|
+
/** Carthage: lines like `github "Alamofire/Alamofire" "5.8.0"`. */
|
|
44
|
+
export declare function readCartfileResolved(file: string): ResolvedPackage[];
|
|
45
|
+
/**
|
|
46
|
+
* Minimal reader for the build settings that matter in `project.pbxproj`.
|
|
47
|
+
* Projects with GENERATE_INFOPLIST_FILE keep purpose strings here as INFOPLIST_KEY_*.
|
|
48
|
+
*/
|
|
49
|
+
export declare function parseBuildSettings(text: string): {
|
|
50
|
+
bundleIdentifiers: Set<string>;
|
|
51
|
+
displayNames: Set<string>;
|
|
52
|
+
purposeStrings: Record<string, string>;
|
|
53
|
+
usesNonExemptEncryption: boolean | undefined;
|
|
54
|
+
};
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { readdirSync, readFileSync, existsSync, statSync } from "node:fs";
|
|
2
|
+
import { join, relative, resolve } from "node:path";
|
|
3
|
+
import { parse as parsePlist, parseBinary } from "plist";
|
|
4
|
+
/** Folders that never hold source of truth. */
|
|
5
|
+
const SKIPPED = new Set([".git", ".build", "build", "DerivedData", "Pods", "Carthage", "node_modules", ".swiftpm"]);
|
|
6
|
+
export function scan(rootPath) {
|
|
7
|
+
const root = resolve(rootPath);
|
|
8
|
+
if (!existsSync(root) || !statSync(root).isDirectory())
|
|
9
|
+
throw new Error(`Not a directory: ${rootPath}`);
|
|
10
|
+
const result = {
|
|
11
|
+
root,
|
|
12
|
+
xcodeProjects: [],
|
|
13
|
+
bundleIdentifiers: [],
|
|
14
|
+
displayNames: [],
|
|
15
|
+
purposeStrings: {},
|
|
16
|
+
privacyManifests: [],
|
|
17
|
+
packages: [],
|
|
18
|
+
};
|
|
19
|
+
const bundleIDs = new Set();
|
|
20
|
+
const names = new Set();
|
|
21
|
+
const seenPackages = new Set();
|
|
22
|
+
for (const file of walk(root)) {
|
|
23
|
+
const name = file.split("/").pop() ?? "";
|
|
24
|
+
const rel = relative(root, file);
|
|
25
|
+
if (name.endsWith(".xcodeproj")) {
|
|
26
|
+
result.xcodeProjects.push(rel);
|
|
27
|
+
const pbx = join(file, "project.pbxproj");
|
|
28
|
+
if (existsSync(pbx)) {
|
|
29
|
+
const settings = parseBuildSettings(readFileSync(pbx, "utf8"));
|
|
30
|
+
settings.bundleIdentifiers.forEach((id) => bundleIDs.add(id));
|
|
31
|
+
settings.displayNames.forEach((n) => names.add(n));
|
|
32
|
+
for (const [k, v] of Object.entries(settings.purposeStrings))
|
|
33
|
+
result.purposeStrings[k] ??= v;
|
|
34
|
+
if (settings.usesNonExemptEncryption !== undefined)
|
|
35
|
+
result.usesNonExemptEncryption ||= settings.usesNonExemptEncryption;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (name === "Info.plist") {
|
|
39
|
+
const dict = readPlist(file);
|
|
40
|
+
if (!dict)
|
|
41
|
+
continue;
|
|
42
|
+
for (const [key, value] of Object.entries(dict)) {
|
|
43
|
+
if (key.endsWith("UsageDescription") && typeof value === "string")
|
|
44
|
+
result.purposeStrings[key] = value;
|
|
45
|
+
}
|
|
46
|
+
const id = dict.CFBundleIdentifier;
|
|
47
|
+
if (typeof id === "string" && !id.includes("$("))
|
|
48
|
+
bundleIDs.add(id);
|
|
49
|
+
if (typeof dict.ITSAppUsesNonExemptEncryption === "boolean")
|
|
50
|
+
result.usesNonExemptEncryption ||= dict.ITSAppUsesNonExemptEncryption;
|
|
51
|
+
const display = dict.CFBundleDisplayName;
|
|
52
|
+
if (typeof display === "string" && !display.includes("$("))
|
|
53
|
+
names.add(display);
|
|
54
|
+
}
|
|
55
|
+
else if (name === "PrivacyInfo.xcprivacy") {
|
|
56
|
+
const dict = readPlist(file);
|
|
57
|
+
if (dict)
|
|
58
|
+
result.privacyManifests.push(privacyManifest(dict, rel));
|
|
59
|
+
}
|
|
60
|
+
else if (name === "Package.resolved" || name === "Podfile.lock" || name === "Cartfile.resolved") {
|
|
61
|
+
const found = name === "Package.resolved" ? readResolvedPackages(file) : name === "Podfile.lock" ? readPodfileLock(file) : readCartfileResolved(file);
|
|
62
|
+
for (const pkg of found) {
|
|
63
|
+
if (!seenPackages.has(pkg.identity)) {
|
|
64
|
+
seenPackages.add(pkg.identity);
|
|
65
|
+
result.packages.push(pkg);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
result.xcodeProjects.sort();
|
|
71
|
+
result.bundleIdentifiers = [...bundleIDs].sort();
|
|
72
|
+
result.displayNames = [...names].sort();
|
|
73
|
+
result.privacyManifests.sort((a, b) => a.path.localeCompare(b.path));
|
|
74
|
+
result.packages.sort((a, b) => a.identity.localeCompare(b.identity));
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
/** Yields files and `.xcodeproj` bundles; doesn't descend into skipped folders or bundles. */
|
|
78
|
+
function* walk(dir) {
|
|
79
|
+
let entries;
|
|
80
|
+
try {
|
|
81
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
for (const entry of entries) {
|
|
87
|
+
if (entry.name.startsWith(".") && entry.name !== ".github")
|
|
88
|
+
continue;
|
|
89
|
+
const path = join(dir, entry.name);
|
|
90
|
+
if (entry.isDirectory()) {
|
|
91
|
+
if (entry.name.endsWith(".xcodeproj")) {
|
|
92
|
+
yield path;
|
|
93
|
+
// Package.resolved for Xcode projects lives inside the bundle.
|
|
94
|
+
const resolved = join(path, "project.xcworkspace/xcshareddata/swiftpm/Package.resolved");
|
|
95
|
+
if (existsSync(resolved))
|
|
96
|
+
yield resolved;
|
|
97
|
+
}
|
|
98
|
+
else if (!SKIPPED.has(entry.name) && !entry.name.endsWith(".xcworkspace")) {
|
|
99
|
+
yield* walk(path);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
yield path;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function readPlist(file) {
|
|
108
|
+
const isDict = (v) => !!v && typeof v === "object" && !Array.isArray(v) && !(v instanceof Date);
|
|
109
|
+
const bytes = readFileSync(file);
|
|
110
|
+
try {
|
|
111
|
+
const parsed = bytes.subarray(0, 6).toString("latin1") === "bplist" ? parseBinary(bytes) : parsePlist(bytes.toString("utf8"));
|
|
112
|
+
return isDict(parsed) ? parsed : undefined;
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return undefined; // malformed plist
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const strings = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === "string") : []);
|
|
119
|
+
const dicts = (v) => (Array.isArray(v) ? v.filter((x) => !!x && typeof x === "object") : []);
|
|
120
|
+
export function privacyManifest(dict, path) {
|
|
121
|
+
return {
|
|
122
|
+
path,
|
|
123
|
+
tracking: dict.NSPrivacyTracking === true,
|
|
124
|
+
trackingDomains: strings(dict.NSPrivacyTrackingDomains),
|
|
125
|
+
collectedDataTypes: dicts(dict.NSPrivacyCollectedDataTypes).map((d) => ({
|
|
126
|
+
type: typeof d.NSPrivacyCollectedDataType === "string" ? d.NSPrivacyCollectedDataType : "unknown",
|
|
127
|
+
linked: d.NSPrivacyCollectedDataTypeLinked === true,
|
|
128
|
+
tracking: d.NSPrivacyCollectedDataTypeTracking === true,
|
|
129
|
+
purposes: strings(d.NSPrivacyCollectedDataTypePurposes),
|
|
130
|
+
})),
|
|
131
|
+
accessedAPIs: dicts(dict.NSPrivacyAccessedAPITypes).map((d) => ({
|
|
132
|
+
category: typeof d.NSPrivacyAccessedAPIType === "string" ? d.NSPrivacyAccessedAPIType : "unknown",
|
|
133
|
+
reasons: strings(d.NSPrivacyAccessedAPITypeReasons),
|
|
134
|
+
})),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** Supports Package.resolved v1 (`object.pins`) and v2/v3 (`pins`). */
|
|
138
|
+
export function readResolvedPackages(file) {
|
|
139
|
+
let json;
|
|
140
|
+
try {
|
|
141
|
+
json = JSON.parse(readFileSync(file, "utf8"));
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
const pins = dicts(json.pins ?? json.object?.pins);
|
|
147
|
+
return pins.flatMap((pin) => {
|
|
148
|
+
const identity = typeof pin.identity === "string" ? pin.identity : typeof pin.package === "string" ? pin.package.toLowerCase() : undefined;
|
|
149
|
+
if (!identity)
|
|
150
|
+
return [];
|
|
151
|
+
const location = typeof pin.location === "string" ? pin.location : typeof pin.repositoryURL === "string" ? pin.repositoryURL : "";
|
|
152
|
+
const version = pin.state?.version;
|
|
153
|
+
return [{ identity, location, ...(typeof version === "string" ? { version } : {}) }];
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/** CocoaPods: top-level entries under PODS, e.g. " - FirebaseAnalytics (10.0.0):". */
|
|
157
|
+
export function readPodfileLock(file) {
|
|
158
|
+
const pods = [];
|
|
159
|
+
let inPods = false;
|
|
160
|
+
for (const line of readFileSync(file, "utf8").split("\n")) {
|
|
161
|
+
if (/^\S/.test(line))
|
|
162
|
+
inPods = line.startsWith("PODS:");
|
|
163
|
+
else if (inPods) {
|
|
164
|
+
const m = /^ - "?([^\s"(]+)"?(?: \(([^)]+)\))?/.exec(line);
|
|
165
|
+
if (m) {
|
|
166
|
+
const identity = m[1].split("/")[0].toLowerCase();
|
|
167
|
+
if (!pods.some((p) => p.identity === identity))
|
|
168
|
+
pods.push({ identity, location: "cocoapods", ...(m[2] ? { version: m[2] } : {}) });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return pods;
|
|
173
|
+
}
|
|
174
|
+
/** Carthage: lines like `github "Alamofire/Alamofire" "5.8.0"`. */
|
|
175
|
+
export function readCartfileResolved(file) {
|
|
176
|
+
return readFileSync(file, "utf8").split("\n").flatMap((line) => {
|
|
177
|
+
const m = /^(github|git|binary) "([^"]+)" "([^"]+)"/.exec(line.trim());
|
|
178
|
+
if (!m)
|
|
179
|
+
return [];
|
|
180
|
+
const identity = m[2].replace(/\.git$/, "").split("/").pop().toLowerCase();
|
|
181
|
+
return [{ identity, location: m[2], version: m[3] }];
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Minimal reader for the build settings that matter in `project.pbxproj`.
|
|
186
|
+
* Projects with GENERATE_INFOPLIST_FILE keep purpose strings here as INFOPLIST_KEY_*.
|
|
187
|
+
*/
|
|
188
|
+
export function parseBuildSettings(text) {
|
|
189
|
+
const bundleIdentifiers = new Set();
|
|
190
|
+
const displayNames = new Set();
|
|
191
|
+
const purposeStrings = {};
|
|
192
|
+
let usesNonExemptEncryption;
|
|
193
|
+
for (const raw of text.split("\n")) {
|
|
194
|
+
const line = raw.trim();
|
|
195
|
+
const eq = line.indexOf("=");
|
|
196
|
+
if (eq < 0 || !line.endsWith(";"))
|
|
197
|
+
continue;
|
|
198
|
+
const key = line.slice(0, eq).trim();
|
|
199
|
+
let value = line.slice(eq + 1, -1).trim();
|
|
200
|
+
if (value.length >= 2 && value.startsWith('"') && value.endsWith('"'))
|
|
201
|
+
value = value.slice(1, -1);
|
|
202
|
+
if (!value || value.includes("$("))
|
|
203
|
+
continue;
|
|
204
|
+
if (key === "PRODUCT_BUNDLE_IDENTIFIER")
|
|
205
|
+
bundleIdentifiers.add(value);
|
|
206
|
+
else if (key === "INFOPLIST_KEY_CFBundleDisplayName")
|
|
207
|
+
displayNames.add(value);
|
|
208
|
+
else if (key === "INFOPLIST_KEY_ITSAppUsesNonExemptEncryption")
|
|
209
|
+
usesNonExemptEncryption = (usesNonExemptEncryption ?? false) || /^(yes|true|1)$/i.test(value);
|
|
210
|
+
else if (key.startsWith("INFOPLIST_KEY_") && key.endsWith("UsageDescription")) {
|
|
211
|
+
purposeStrings[key.slice("INFOPLIST_KEY_".length)] = value;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return { bundleIdentifiers, displayNames, purposeStrings, usesNonExemptEncryption };
|
|
215
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./core/scan.js";
|
|
2
|
+
export * from "./core/facts.js";
|
|
3
|
+
export * from "./core/appPrivacy.js";
|
|
4
|
+
export * from "./core/pages.js";
|
|
5
|
+
export * from "./core/legalView.js";
|
|
6
|
+
export * from "./core/check.js";
|
|
7
|
+
export * from "./core/migrate.js";
|
|
8
|
+
export * from "./core/online.js";
|
|
9
|
+
export * from "./core/checklist.js";
|
|
10
|
+
export * from "./core/knowledge.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ShelfKit: the core shared by the CLI, the MCP server and the hosted Worker.
|
|
2
|
+
export * from "./core/scan.js";
|
|
3
|
+
export * from "./core/facts.js";
|
|
4
|
+
export * from "./core/appPrivacy.js";
|
|
5
|
+
export * from "./core/pages.js";
|
|
6
|
+
export * from "./core/legalView.js";
|
|
7
|
+
export * from "./core/check.js";
|
|
8
|
+
export * from "./core/migrate.js";
|
|
9
|
+
export * from "./core/online.js";
|
|
10
|
+
export * from "./core/checklist.js";
|
|
11
|
+
export * from "./core/knowledge.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shelfready",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Get an iOS app ready for the App Store shelf: legal pages, privacy truth, preflight.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
"test": "tsx --test test/*.test.ts",
|
|
26
26
|
"typecheck": "tsc -p . --noEmit",
|
|
27
27
|
"kb:import": "tsx scripts/kb-import.ts",
|
|
28
|
-
"prepack": "cp ../README.md ../LICENSE ../NOTICE .",
|
|
29
|
-
"postpack": "rm -f README.md LICENSE NOTICE"
|
|
28
|
+
"prepack": "npm run build && cp ../README.md ../LICENSE ../NOTICE .",
|
|
29
|
+
"postpack": "rm -f README.md LICENSE NOTICE",
|
|
30
|
+
"pack:check": "node scripts/pack-check.mjs"
|
|
30
31
|
},
|
|
31
32
|
"license": "Apache-2.0",
|
|
32
33
|
"dependencies": {
|
package/knowledge/README.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# SDK knowledge base
|
|
2
|
-
|
|
3
|
-
What common third-party SDKs collect, so `shelf init` can fill `data.collected`, `shelf pages` can name the services in the privacy policy, and `shelf check` can flag SDKs it doesn't know.
|
|
4
|
-
|
|
5
|
-
## Source of truth: the SDK's own privacy manifest
|
|
6
|
-
|
|
7
|
-
Each entry is generated from the `PrivacyInfo.xcprivacy` files in the SDK's public repository, never written from memory:
|
|
8
|
-
|
|
9
|
-
- `sources.yaml` lists the SDKs: Swift package identity, display name, vendor, GitHub repo, which manifest paths to read, CocoaPods/Carthage aliases and caveats.
|
|
10
|
-
- `npm run kb:import -- <clone folder>` clones each repo (metadata only), reads the manifests at `HEAD` and writes `sdks/<identity>.yaml` with the repository, commit, file links and date.
|
|
11
|
-
- Re-run it to refresh after SDK releases; the diff shows what changed.
|
|
12
|
-
|
|
13
|
-
## Reading an entry
|
|
14
|
-
|
|
15
|
-
- `products`: one per module with its own manifest (Firebase Crashlytics, Firestore, …). An app usually uses only some, so ShelfReady takes the union and you remove what you don't use from `data.collected`.
|
|
16
|
-
- `collects`: data type, linked to the user, used for tracking, purposes, exactly as the SDK declares them.
|
|
17
|
-
- `notes`: caveats. Analytics and backend SDKs (Mixpanel, Supabase, Segment, TelemetryDeck) often declare nothing or little because what they send depends on your code: `shelf check` warns so you declare it yourself.
|
|
18
|
-
|
|
19
|
-
## Not covered
|
|
20
|
-
|
|
21
|
-
- Binary-only SDKs without a manifest in their repo, e.g. Google Analytics for Firebase (GoogleAppMeasurement) and Google Mobile Ads. Check the vendor's data disclosure.
|
|
22
|
-
- Configuration: entries describe what the SDK declares by default; features you turn on or off can change it.
|
|
23
|
-
|
|
24
|
-
## Entries (2026-11-18)
|
|
25
|
-
|
|
26
|
-
Firebase, RevenueCat, Sentry, Mixpanel, Amplitude, PostHog, Facebook SDK, OneSignal, Bugsnag, Datadog, Segment, TelemetryDeck, Adapty, Superwall, Google Sign-In, Supabase, Alamofire, Kingfisher, SDWebImage, Lottie, Realm.
|