app privacy: one Apple purpose per Play purpose (advertising is Third-Party Advertising only; Developer's Advertising only from the owner), appPrivacy.types (owner answers per Apple type id: certain in console fill, proposed by scan without linked / tracking, compared by check with Info.plist and PrivacyInfo.xcprivacy)

This commit is contained in:
CRTkafa 2026-10-12 04:07:15 +08:00
parent 704231457f
commit 4533e3e1c4
17 changed files with 509 additions and 52 deletions

View file

@ -2,6 +2,26 @@
## Unreleased ## Unreleased
- App Privacy purposes (wrong answers in `console fill apple-app-privacy`, `project.declarations` and `scan`): Play
"advertising" became both Third-Party Advertising and Developer's Advertising or Marketing (Device ID, Coarse
Location, Product Interaction, Performance Data). Now one Apple purpose per Play purpose, following Apple's
definitions (developer.apple.com/app-store/app-privacy-details/): advertising -> Third-Party Advertising,
analytics -> Analytics, personalization -> Product Personalization, functionality / fraud / account /
communications -> App Functionality. Developer's Advertising or Marketing is No unless the owner says so; with a
Play "communications" purpose console fill asks.
- New `appPrivacy.types`: the owner's App Privacy answers per Apple data type id (all 35: USER_ID, DEVICE_ID,
GAMEPLAY_CONTENT, ADVERTISING_DATA, CUSTOMER_SUPPORT, ENVIRONMENT_SCANNING, HANDS, HEAD ...), each
`{ collected?, linked?, tracking?, purposes? }` (THIRD_PARTY_ADVERTISING, DEVELOPERS_ADVERTISING, ANALYTICS,
PRODUCT_PERSONALIZATION, APP_FUNCTIONALITY, OTHER_PURPOSES), validated against Apple's lists.
- `console fill apple-app-privacy` fills them as certain answers (they win over what dataSafety suggests); types
with no Play equivalent work from the block alone; anything unset stays "(you decide)".
- `scan --write` proposes `collected` + `purposes` for detected types the block does not answer; never `linked` /
`tracking` (the SDK disclosures do not prove them).
- `check` compares the block with the iOS project, both ways: a type used for tracking needs
`NSUserTrackingUsageDescription` and `NSPrivacyTracking` true (and the reverse is flagged), and the app's
`NSPrivacyCollectedDataTypes` (manifest keys mapped to App Privacy ids) must match the types marked collected.
- templates/app-privacy.md, the store-declarations, console-autofill and store-pitfalls skills document it.
- `console fill play-app-record`: Play Console's Create app form, the Play counterpart of `apple-app-record` (the - `console fill play-app-record`: Play Console's Create app form, the Play counterpart of `apple-app-record` (the
Play Developer API cannot create apps). Play Developer API cannot create apps).
- Account: `play.developerId`, the workspace account's id or the remembered one; else the only account the login - Account: `play.developerId`, the workspace account's id or the remembered one; else the only account the login

View file

@ -6,6 +6,7 @@
// --json structured result ({ ok, items, warnings, hints, problems } or { findings, errors }), exit 1 on problems // --json structured result ({ ok, items, warnings, hints, problems } or { findings, errors }), exit 1 on problems
import { existsSync, readFileSync } from 'node:fs'; import { existsSync, readFileSync } from 'node:fs';
import { relative } from 'node:path'; import { relative } from 'node:path';
import { appPrivacyMismatches } from './lib/app-privacy';
import { type AsoFinding, auditAso } from './lib/aso'; import { type AsoFinding, auditAso } from './lib/aso';
import { appleName, playCodes } from './lib/config'; import { appleName, playCodes } from './lib/config';
import { APPLE_IAP_LIMITS, appleNameIssues, len, parseAppStoreListing, parsePlayListing } from './lib/copy'; import { APPLE_IAP_LIMITS, appleNameIssues, len, parseAppStoreListing, parsePlayListing } from './lib/copy';
@ -14,6 +15,7 @@ import { dataSafetyRows } from './lib/data-safety';
import { reviewDemoAccount } from './lib/credentials'; import { reviewDemoAccount } from './lib/credentials';
import { log, printJson, warn } from './lib/log'; import { log, printJson, warn } from './lib/log';
import { profileIssues } from './lib/profile'; import { profileIssues } from './lib/profile';
import { detectProject } from './lib/scan/project';
import { reviewShotProblem } from './apple/iap-review'; import { reviewShotProblem } from './apple/iap-review';
import { allSubscriptions } from './lib/subscriptions'; import { allSubscriptions } from './lib/subscriptions';
import { type CopyFile, validateCopy } from './shots/lib'; import { type CopyFile, validateCopy } from './shots/lib';
@ -78,6 +80,19 @@ export async function run(ctx: Ctx): Promise<void> {
if (todo.length) note(`${relative(process.cwd(), f) || f}: not translated yet (status=translate): ${todo.join(', ')}`); if (todo.length) note(`${relative(process.cwd(), f) || f}: not translated yet (status=translate): ${todo.join(', ')}`);
if (drafts.length) note(`${relative(process.cwd(), f) || f}: machine-translated drafts not reviewed: ${drafts.join(', ')} (storebound listing check, then listing reviewed --lang <ids>)`); if (drafts.length) note(`${relative(process.cwd(), f) || f}: machine-translated drafts not reviewed: ${drafts.join(', ')} (storebound listing check, then listing reviewed --lang <ids>)`);
} }
// App Privacy answers (appPrivacy.types) against the iOS project: ATT string, PrivacyInfo.xcprivacy tracking and types
const apTypes = config.appPrivacy?.types;
if (config.apple && apTypes && Object.keys(apTypes).length) {
const facts = detectProject(ctx.loaded.root);
if (!facts.ios) hints.push('appPrivacy.types: no iOS project found here, so it is not compared with Info.plist / PrivacyInfo.xcprivacy');
else {
const own = facts.privacyManifests.find(m => !/(^|\/)(Pods|node_modules|SourcePackages|Carthage|\.build)\//.test(m.path)) ?? null;
const found = appPrivacyMismatches(apTypes, { attString: facts.plist.has('NSUserTrackingUsageDescription'), manifest: own });
for (const f of found) if (f.level === 'error') problems.push(f.msg); else note(f.msg);
items.push({ what: 'app privacy', detail: `${Object.keys(apTypes).length} types answered, ${found.length} mismatch(es) with the iOS project` });
log('check', `app privacy: ${Object.keys(apTypes).length} types answered, ${found.length} mismatch(es) with the iOS project`);
}
}
if (config.dataSafety) tryDo('data safety', () => `${dataSafetyRows(config.dataSafety!).length - 1} CSV rows`); if (config.dataSafety) tryDo('data safety', () => `${dataSafetyRows(config.dataSafety!).length - 1} CSV rows`);
for (const p of config.products ?? []) for (const [lang, l] of Object.entries(p.listings)) { for (const p of config.products ?? []) for (const [lang, l] of Object.entries(p.listings)) {
if (config.apple && len(l.description) > APPLE_IAP_LIMITS.description) problems.push(`product ${p.id} ${lang}: description ${len(l.description)} > ${APPLE_IAP_LIMITS.description} (App Store limit)`); if (config.apple && len(l.description) > APPLE_IAP_LIMITS.description) problems.push(`product ${p.id} ${lang}: description ${len(l.description)} > ${APPLE_IAP_LIMITS.description} (App Store limit)`);

144
cli/lib/app-privacy.ts Normal file
View file

@ -0,0 +1,144 @@
// Apple App Privacy ("privacy nutrition label") data types and purposes, and the config block `appPrivacy.types` that
// answers them per type. Pure, no imports from the config (config.ts imports this file).
// Sources (checked October 2026):
// https://developer.apple.com/app-store/app-privacy-details/ (data types, purposes and their definitions, tracking,
// linked to the user)
// https://developer.apple.com/documentation/bundleresources/describing-data-use-in-privacy-manifests
// (NSPrivacyCollectedDataTypes: the manifest's data type and purpose keys, one per App Privacy type / purpose)
// Purpose definitions on the App Privacy details page, which the Play purpose mapping (declarations.ts applePurpose)
// follows:
// Third-Party Advertising: displaying third-party ads in your app, or sharing data with entities who display
// third-party ads.
// Developer's Advertising or Marketing: displaying first-party ads in your app, sending marketing communications
// directly to your users, or sharing data with entities who will display your ads.
// Analytics: evaluating user behavior (effectiveness of features, planning features, audience size).
// Product Personalization: customizing what the user sees (recommendations, posts, suggestions).
// App Functionality: authenticating the user, enabling features, preventing fraud, security, server up-time,
// minimizing crashes, scalability and performance, customer support.
// Other Purposes: any other purpose not listed.
/** App Privacy data type id -> [category, the name App Store Connect shows, the privacy manifest key]. */
export const APPLE_PRIVACY_TYPES = {
NAME: ['Contact Info', 'Name', 'NSPrivacyCollectedDataTypeName'],
EMAIL_ADDRESS: ['Contact Info', 'Email Address', 'NSPrivacyCollectedDataTypeEmailAddress'],
PHONE_NUMBER: ['Contact Info', 'Phone Number', 'NSPrivacyCollectedDataTypePhoneNumber'],
PHYSICAL_ADDRESS: ['Contact Info', 'Physical Address', 'NSPrivacyCollectedDataTypePhysicalAddress'],
OTHER_USER_CONTACT_INFO: ['Contact Info', 'Other User Contact Info', 'NSPrivacyCollectedDataTypeOtherUserContactInfo'],
HEALTH: ['Health & Fitness', 'Health', 'NSPrivacyCollectedDataTypeHealth'],
FITNESS: ['Health & Fitness', 'Fitness', 'NSPrivacyCollectedDataTypeFitness'],
PAYMENT_INFO: ['Financial Info', 'Payment Info', 'NSPrivacyCollectedDataTypePaymentInfo'],
CREDIT_INFO: ['Financial Info', 'Credit Info', 'NSPrivacyCollectedDataTypeCreditInfo'],
OTHER_FINANCIAL_INFO: ['Financial Info', 'Other Financial Info', 'NSPrivacyCollectedDataTypeOtherFinancialInfo'],
PRECISE_LOCATION: ['Location', 'Precise Location', 'NSPrivacyCollectedDataTypePreciseLocation'],
COARSE_LOCATION: ['Location', 'Coarse Location', 'NSPrivacyCollectedDataTypeCoarseLocation'],
SENSITIVE_INFO: ['Sensitive Info', 'Sensitive Info', 'NSPrivacyCollectedDataTypeSensitiveInfo'],
CONTACTS: ['Contacts', 'Contacts', 'NSPrivacyCollectedDataTypeContacts'],
EMAILS_OR_TEXT_MESSAGES: ['User Content', 'Emails or Text Messages', 'NSPrivacyCollectedDataTypeEmailsOrTextMessages'],
PHOTOS_OR_VIDEOS: ['User Content', 'Photos or Videos', 'NSPrivacyCollectedDataTypePhotosorVideos'],
AUDIO_DATA: ['User Content', 'Audio Data', 'NSPrivacyCollectedDataTypeAudioData'],
GAMEPLAY_CONTENT: ['User Content', 'Gameplay Content', 'NSPrivacyCollectedDataTypeGameplayContent'],
CUSTOMER_SUPPORT: ['User Content', 'Customer Support', 'NSPrivacyCollectedDataTypeCustomerSupport'],
OTHER_USER_CONTENT: ['User Content', 'Other User Content', 'NSPrivacyCollectedDataTypeOtherUserContent'],
BROWSING_HISTORY: ['Browsing History', 'Browsing History', 'NSPrivacyCollectedDataTypeBrowsingHistory'],
SEARCH_HISTORY: ['Search History', 'Search History', 'NSPrivacyCollectedDataTypeSearchHistory'],
USER_ID: ['Identifiers', 'User ID', 'NSPrivacyCollectedDataTypeUserID'],
DEVICE_ID: ['Identifiers', 'Device ID', 'NSPrivacyCollectedDataTypeDeviceID'],
PURCHASE_HISTORY: ['Purchases', 'Purchase History', 'NSPrivacyCollectedDataTypePurchaseHistory'],
PRODUCT_INTERACTION: ['Usage Data', 'Product Interaction', 'NSPrivacyCollectedDataTypeProductInteraction'],
ADVERTISING_DATA: ['Usage Data', 'Advertising Data', 'NSPrivacyCollectedDataTypeAdvertisingData'],
OTHER_USAGE_DATA: ['Usage Data', 'Other Usage Data', 'NSPrivacyCollectedDataTypeOtherUsageData'],
CRASH_DATA: ['Diagnostics', 'Crash Data', 'NSPrivacyCollectedDataTypeCrashData'],
PERFORMANCE_DATA: ['Diagnostics', 'Performance Data', 'NSPrivacyCollectedDataTypePerformanceData'],
OTHER_DIAGNOSTIC_DATA: ['Diagnostics', 'Other Diagnostic Data', 'NSPrivacyCollectedDataTypeOtherDiagnosticData'],
ENVIRONMENT_SCANNING: ['Surroundings', 'Environment Scanning', 'NSPrivacyCollectedDataTypeEnvironmentScanning'],
HANDS: ['Body', 'Hands', 'NSPrivacyCollectedDataTypeHands'],
HEAD: ['Body', 'Head', 'NSPrivacyCollectedDataTypeHead'],
OTHER_DATA_TYPES: ['Other Data', 'Other Data Types', 'NSPrivacyCollectedDataTypeOtherDataTypes'],
} as const satisfies Record<string, readonly [string, string, string]>;
export type AppleDataTypeId = keyof typeof APPLE_PRIVACY_TYPES;
export const APPLE_DATA_TYPE_IDS = Object.keys(APPLE_PRIVACY_TYPES) as AppleDataTypeId[];
/** App Privacy purpose id -> [the name App Store Connect shows, the privacy manifest key]. */
export const APPLE_PRIVACY_PURPOSES = {
THIRD_PARTY_ADVERTISING: ['Third-Party Advertising', 'NSPrivacyCollectedDataTypePurposeThirdPartyAdvertising'],
DEVELOPERS_ADVERTISING: ['Developer\'s Advertising or Marketing', 'NSPrivacyCollectedDataTypePurposeDeveloperAdvertising'],
ANALYTICS: ['Analytics', 'NSPrivacyCollectedDataTypePurposeAnalytics'],
PRODUCT_PERSONALIZATION: ['Product Personalization', 'NSPrivacyCollectedDataTypePurposeProductPersonalization'],
APP_FUNCTIONALITY: ['App Functionality', 'NSPrivacyCollectedDataTypePurposeAppFunctionality'],
OTHER_PURPOSES: ['Other Purposes', 'NSPrivacyCollectedDataTypePurposeOther'],
} as const satisfies Record<string, readonly [string, string]>;
export type AppleAppPrivacyPurpose = keyof typeof APPLE_PRIVACY_PURPOSES;
export const APPLE_PURPOSE_IDS = Object.keys(APPLE_PRIVACY_PURPOSES) as AppleAppPrivacyPurpose[];
/** The owner's App Privacy answers for one data type (`appPrivacy.types.<ID>`). Unset fields stay questions. */
export interface AppleTypeAnswer {
collected?: boolean;
linked?: boolean;
tracking?: boolean;
/** The full purpose list of this type (replaces what storebound derives from dataSafety). */
purposes?: AppleAppPrivacyPurpose[];
}
export const typeName = (id: AppleDataTypeId): string => APPLE_PRIVACY_TYPES[id][1];
export const purposeName = (id: AppleAppPrivacyPurpose): string => APPLE_PRIVACY_PURPOSES[id][0];
/** The id of an App Store Connect type name ("Device ID" -> DEVICE_ID), or null. */
export const typeIdOf = (name: string): AppleDataTypeId | null => APPLE_DATA_TYPE_IDS.find(id => APPLE_PRIVACY_TYPES[id][1] === name) ?? null;
/** The id of an App Store Connect purpose name, or null. */
export const purposeIdOf = (name: string): AppleAppPrivacyPurpose | null => APPLE_PURPOSE_IDS.find(id => APPLE_PRIVACY_PURPOSES[id][0] === name) ?? null;
/** The App Privacy type of a privacy manifest data type key (NSPrivacyCollectedDataTypeDeviceID -> DEVICE_ID), or null. */
export const typeIdOfManifest = (key: string): AppleDataTypeId | null => APPLE_DATA_TYPE_IDS.find(id => APPLE_PRIVACY_TYPES[id][2] === key) ?? null;
/** Problems of `appPrivacy.types` (ids and purposes against Apple's lists). */
export function validateAppPrivacyTypes(types: unknown): string[] {
if (types === undefined) return [];
if (!types || typeof types !== 'object' || Array.isArray(types)) return ['appPrivacy.types: an object keyed by App Privacy data type id (DEVICE_ID, USER_ID ...)'];
const e: string[] = [];
for (const [id, v] of Object.entries(types as Record<string, unknown>)) {
if (!(id in APPLE_PRIVACY_TYPES)) { e.push(`appPrivacy.types.${id}: not an App Privacy data type id (one of ${APPLE_DATA_TYPE_IDS.join(', ')})`); continue; }
if (!v || typeof v !== 'object' || Array.isArray(v)) { e.push(`appPrivacy.types.${id}: { collected?, linked?, tracking?, purposes? }`); continue; }
const a = v as Record<string, unknown>;
for (const k of Object.keys(a)) if (!['collected', 'linked', 'tracking', 'purposes'].includes(k)) e.push(`appPrivacy.types.${id}.${k}: unknown (collected | linked | tracking | purposes)`);
for (const k of ['collected', 'linked', 'tracking'] as const) if (a[k] !== undefined && typeof a[k] !== 'boolean') e.push(`appPrivacy.types.${id}.${k}: true | false`);
if (a.purposes !== undefined) {
if (!Array.isArray(a.purposes)) e.push(`appPrivacy.types.${id}.purposes: a list of ${APPLE_PURPOSE_IDS.join(' | ')}`);
else for (const p of a.purposes) if (!(APPLE_PURPOSE_IDS as string[]).includes(p as string)) e.push(`appPrivacy.types.${id}.purposes: "${String(p)}" is not one of ${APPLE_PURPOSE_IDS.join(' | ')}`);
}
if (a.collected === false && (a.linked !== undefined || a.tracking !== undefined || (Array.isArray(a.purposes) && a.purposes.length)))
e.push(`appPrivacy.types.${id}: collected is false, so linked / tracking / purposes do not apply`);
}
return e;
}
export interface PrivacyMismatch { level: 'error' | 'warn'; msg: string }
/**
* `appPrivacy.types` against the iOS project (both ways): any type used for tracking <-> Info.plist
* NSUserTrackingUsageDescription and the app manifest's NSPrivacyTracking true; the app manifest's
* NSPrivacyCollectedDataTypes <-> the types marked collected. `manifest` null: no PrivacyInfo.xcprivacy found.
*/
export function appPrivacyMismatches(types: Partial<Record<AppleDataTypeId, AppleTypeAnswer>>, ios: { attString: boolean; manifest: { path: string; tracking: boolean | null; collectedTypes: string[] } | null }): PrivacyMismatch[] {
const out: PrivacyMismatch[] = [];
const entries = Object.entries(types) as [AppleDataTypeId, AppleTypeAnswer][];
const tracked = entries.filter(([, a]) => a.tracking === true).map(([id]) => id);
const m = ios.manifest;
if (tracked.length) {
if (!ios.attString) out.push({ level: 'error', msg: `appPrivacy.types says ${tracked.join(', ')} ${tracked.length === 1 ? 'is' : 'are'} used for tracking, but Info.plist has no NSUserTrackingUsageDescription (App Tracking Transparency is required before tracking)` });
if (m && m.tracking !== true) out.push({ level: 'error', msg: `appPrivacy.types says ${tracked.join(', ')} ${tracked.length === 1 ? 'is' : 'are'} used for tracking, but ${m.path} has NSPrivacyTracking ${m.tracking === false ? 'false' : 'missing'}` });
} else if (entries.some(([, a]) => a.tracking === false) && entries.every(([, a]) => a.collected === false || a.tracking === false)) {
if (ios.attString) out.push({ level: 'warn', msg: 'Info.plist has NSUserTrackingUsageDescription, but appPrivacy.types marks no collected type as used for tracking' });
if (m?.tracking === true) out.push({ level: 'warn', msg: `${m.path} has NSPrivacyTracking true, but appPrivacy.types marks no collected type as used for tracking` });
}
if (!m) return out;
const inManifest = new Set<AppleDataTypeId>();
for (const k of m.collectedTypes) {
const id = typeIdOfManifest(k);
if (!id) { out.push({ level: 'warn', msg: `${m.path}: unknown NSPrivacyCollectedDataType "${k}"` }); continue; }
inManifest.add(id);
const a = types[id];
if (a?.collected === false) out.push({ level: 'error', msg: `${m.path} declares ${k} (${typeName(id)}) as collected, but appPrivacy.types.${id}.collected is false` });
else if (!a || a.collected === undefined) out.push({ level: 'warn', msg: `${m.path} declares ${k} (${typeName(id)}) as collected, but appPrivacy.types has no answer for ${id}` });
}
for (const [id, a] of entries) if (a.collected === true && !inManifest.has(id))
out.push({ level: 'warn', msg: `appPrivacy.types.${id} is collected, but ${m.path} has no ${APPLE_PRIVACY_TYPES[id][2]} in NSPrivacyCollectedDataTypes (fine if only an SDK collects it and declares it in its own manifest)` });
return out;
}

View file

@ -3,6 +3,7 @@
import { existsSync } from 'node:fs'; import { existsSync } from 'node:fs';
import { dirname, isAbsolute, join, resolve } from 'node:path'; import { dirname, isAbsolute, join, resolve } from 'node:path';
import { validateCapture, validateRecord } from '../shots/devices'; import { validateCapture, validateRecord } from '../shots/devices';
import { type AppleDataTypeId, type AppleTypeAnswer, validateAppPrivacyTypes } from './app-privacy';
import { type AppEventDef, type CustomProductPageDef, validateCpp, validateEvents } from './cpp-events'; import { type AppEventDef, type CustomProductPageDef, validateCpp, validateEvents } from './cpp-events';
import { type IapOfferCodeDef, type PromotedConfig, validateIapOfferCodes, validatePromoted, validateWinBack, type WinBackDef } from './offers'; import { type IapOfferCodeDef, type PromotedConfig, validateIapOfferCodes, validatePromoted, validateWinBack, type WinBackDef } from './offers';
import { validateSubscriptions } from './subscriptions'; import { validateSubscriptions } from './subscriptions';
@ -332,6 +333,11 @@ export interface AppPrivacyConfig {
tracking?: boolean; tracking?: boolean;
/** Domains that receive tracking data (privacy manifest NSPrivacyTrackingDomains). */ /** Domains that receive tracking data (privacy manifest NSPrivacyTrackingDomains). */
trackingDomains?: string[]; trackingDomains?: string[];
/** The owner's App Store App Privacy answers per data type, keyed by Apple's type id (DEVICE_ID, USER_ID,
* GAMEPLAY_CONTENT, ADVERTISING_DATA ...; cli/lib/app-privacy.ts). `console fill apple-app-privacy` fills them as
* certain answers and they win over what storebound derives from dataSafety; types with no Play equivalent work
* from here alone. `check` compares them with the iOS project (ATT string, PrivacyInfo.xcprivacy). */
types?: Partial<Record<AppleDataTypeId, AppleTypeAnswer>>;
} }
export type SubscriptionPeriod = 'P1W' | 'P1M' | 'P2M' | 'P3M' | 'P6M' | 'P1Y'; export type SubscriptionPeriod = 'P1W' | 'P1M' | 'P2M' | 'P3M' | 'P6M' | 'P1Y';
@ -797,6 +803,7 @@ export function validateConfig(c: unknown): string[] {
if (cfg.appPrivacy.tracking !== undefined && typeof cfg.appPrivacy.tracking !== 'boolean') e.push('appPrivacy.tracking: true | false'); if (cfg.appPrivacy.tracking !== undefined && typeof cfg.appPrivacy.tracking !== 'boolean') e.push('appPrivacy.tracking: true | false');
if (cfg.appPrivacy.trackingDomains && !(Array.isArray(cfg.appPrivacy.trackingDomains) && cfg.appPrivacy.trackingDomains.every(d => typeof d === 'string' && /^[a-z0-9.-]+$/i.test(d)))) if (cfg.appPrivacy.trackingDomains && !(Array.isArray(cfg.appPrivacy.trackingDomains) && cfg.appPrivacy.trackingDomains.every(d => typeof d === 'string' && /^[a-z0-9.-]+$/i.test(d))))
e.push('appPrivacy.trackingDomains: a list of host names'); e.push('appPrivacy.trackingDomains: a list of host names');
e.push(...validateAppPrivacyTypes(cfg.appPrivacy.types));
} }
for (const [i, x] of (cfg.scan?.ignore ?? []).entries()) for (const [i, x] of (cfg.scan?.ignore ?? []).entries())
if (!x || typeof x.rule !== 'string' || !x.rule || typeof x.reason !== 'string' || !x.reason.trim() || (x.store !== undefined && x.store !== 'apple' && x.store !== 'play') || (x.match !== undefined && (typeof x.match !== 'string' || !x.match.trim()))) if (!x || typeof x.rule !== 'string' || !x.rule || typeof x.reason !== 'string' || !x.reason.trim() || (x.store !== undefined && x.store !== 'apple' && x.store !== 'play') || (x.match !== undefined && (typeof x.match !== 'string' || !x.match.trim())))

View file

@ -18,6 +18,7 @@
import { AGE_RATING_NONE } from '../apple/appinfo'; import { AGE_RATING_NONE } from '../apple/appinfo';
import { type AgeGroup, AGE_GROUPS, appleName, IARC_QUESTIONS, type IarcQuestion, profileOf, type ShipConfig } from './config'; import { type AgeGroup, AGE_GROUPS, appleName, IARC_QUESTIONS, type IarcQuestion, profileOf, type ShipConfig } from './config';
import { APPLE_PRIVACY, applePurpose } from './declarations'; import { APPLE_PRIVACY, applePurpose } from './declarations';
import { APPLE_DATA_TYPE_IDS, APPLE_PRIVACY_TYPES, APPLE_PURPOSE_IDS, type AppleDataTypeId, type AppleTypeAnswer, purposeName } from './app-privacy';
import { maskUser } from './credentials'; import { maskUser } from './credentials';
export const FORM_IDS = ['apple-app-record', 'apple-age-rating', 'apple-app-privacy', 'play-app-record', 'play-content-rating', 'play-target-audience'] as const; export const FORM_IDS = ['apple-app-record', 'apple-age-rating', 'apple-app-privacy', 'play-app-record', 'play-content-rating', 'play-target-audience'] as const;
@ -184,52 +185,65 @@ function ageRating(config: ShipConfig): Answer[] {
} }
/** App Privacy data types (App privacy details on the App Store), in Apple's order: [category, type]. */ /** App Privacy data types (App privacy details on the App Store), in Apple's order: [category, type]. */
export const APPLE_DATA_TYPES: [string, string][] = [ export const APPLE_DATA_TYPES: [string, string][] = APPLE_DATA_TYPE_IDS.map(id => [APPLE_PRIVACY_TYPES[id][0], APPLE_PRIVACY_TYPES[id][1]]);
['Contact Info', 'Name'], ['Contact Info', 'Email Address'], ['Contact Info', 'Phone Number'], ['Contact Info', 'Physical Address'], ['Contact Info', 'Other User Contact Info'], export const APPLE_PURPOSES: string[] = APPLE_PURPOSE_IDS.map(purposeName);
['Health & Fitness', 'Health'], ['Health & Fitness', 'Fitness'], ['Financial Info', 'Payment Info'], ['Financial Info', 'Credit Info'], ['Financial Info', 'Other Financial Info'], const DEV_ADS = purposeName('DEVELOPERS_ADVERTISING');
['Location', 'Precise Location'], ['Location', 'Coarse Location'], ['Sensitive Info', 'Sensitive Info'], ['Contacts', 'Contacts'],
['User Content', 'Emails or Text Messages'], ['User Content', 'Photos or Videos'], ['User Content', 'Audio Data'], ['User Content', 'Gameplay Content'],
['User Content', 'Customer Support'], ['User Content', 'Other User Content'], ['Browsing History', 'Browsing History'], ['Search History', 'Search History'],
['Identifiers', 'User ID'], ['Identifiers', 'Device ID'], ['Purchases', 'Purchase History'], ['Usage Data', 'Product Interaction'], ['Usage Data', 'Advertising Data'],
['Usage Data', 'Other Usage Data'], ['Diagnostics', 'Crash Data'], ['Diagnostics', 'Performance Data'], ['Diagnostics', 'Other Diagnostic Data'],
['Surroundings', 'Environment Scanning'], ['Body', 'Hands'], ['Body', 'Head'], ['Other Data', 'Other Data Types'],
];
export const APPLE_PURPOSES = ['Third-Party Advertising', 'Developer\'s Advertising or Marketing', 'Analytics', 'Product Personalization', 'App Functionality', 'Other Purposes'];
/** Apple data types the config's Data safety answers say are collected: type -> { from, purposes }. */ /** Apple data types the config's Data safety answers say are collected: type -> { from, purposes, comms (a Play
export function privacyTypes(config: ShipConfig): Map<string, { from: string[]; purposes: Set<string> }> { * "communications" purpose: maybe marketing) }. One App Privacy purpose per Play purpose (applePurpose). */
const m = new Map<string, { from: string[]; purposes: Set<string> }>(); export function privacyTypes(config: ShipConfig): Map<string, { from: string[]; purposes: Set<string>; comms: boolean }> {
const m = new Map<string, { from: string[]; purposes: Set<string>; comms: boolean }>();
for (const [id, u] of Object.entries(config.dataSafety?.data ?? {})) { for (const [id, u] of Object.entries(config.dataSafety?.data ?? {})) {
const name = APPLE_PRIVACY[id]?.[1] ?? 'Other Data Types'; const name = APPLE_PRIVACY[id]?.[1] ?? 'Other Data Types';
const e = m.get(name) ?? { from: [], purposes: new Set<string>() }; const e = m.get(name) ?? { from: [], purposes: new Set<string>(), comms: false };
e.from.push(id); e.from.push(id);
for (const p of u.collect) e.purposes.add(applePurpose(p, false)); const all = [...u.collect, ...(u.shared ? u.share ?? [] : [])];
for (const p of u.shared ? u.share ?? [] : []) e.purposes.add(applePurpose(p, true)); for (const p of all) e.purposes.add(applePurpose(p));
e.comms ||= all.includes('communications');
m.set(name, e); m.set(name, e);
} }
return m; return m;
} }
function appPrivacy(config: ShipConfig): Answer[] { function appPrivacy(config: ShipConfig): Answer[] {
const ds = config.dataSafety; const ds = config.dataSafety, ov: Partial<Record<AppleDataTypeId, AppleTypeAnswer>> = config.appPrivacy?.types ?? {};
const label = 'Do you or your third-party partners collect data from this app?'; const label = 'Do you or your third-party partners collect data from this app?';
if (!ds) return [ask('collects', label, 'dataSafety', 'The config has no dataSafety answers: answer what the app and every SDK collect (store-declarations skill), then rerun.')]; const ovIds = Object.keys(ov) as AppleDataTypeId[];
const out: Answer[] = [ok('collects', label, ds.collectsData, 'dataSafety.collectsData')]; if (!ds && !ovIds.length) return [ask('collects', label, 'dataSafety', 'The config has no dataSafety answers and no appPrivacy.types: answer what the app and every SDK collect (store-declarations skill), then rerun.')];
if (!ds.collectsData) return out; const ovYes = ovIds.filter(id => ov[id]?.collected === true);
const got = privacyTypes(config); const out: Answer[] = [];
if (ovYes.length) out.push(ok('collects', label, true, `appPrivacy.types (${ovYes.join(', ')})`));
else if (ds) out.push(ok('collects', label, ds.collectsData, 'dataSafety.collectsData'));
else if (APPLE_DATA_TYPE_IDS.every(id => ov[id]?.collected === false)) out.push(ok('collects', label, false, 'appPrivacy.types'));
else out.push(ask('collects', label, 'appPrivacy.types', 'No type is marked collected, but not every type is answered: answer the rest, or add dataSafety.'));
if (out[0]!.value === false) return out;
const got = ds?.collectsData ? privacyTypes(config) : new Map<string, { from: string[]; purposes: Set<string>; comms: boolean }>();
const mapped = new Set(Object.values(APPLE_PRIVACY).map(([, n]) => n)); const mapped = new Set(Object.values(APPLE_PRIVACY).map(([, n]) => n));
for (const [cat, name] of APPLE_DATA_TYPES) { const collected: AppleDataTypeId[] = [];
const g = got.get(name), id = `type:${name}`, l = `Data type: ${cat} > ${name}`; for (const id of APPLE_DATA_TYPE_IDS) {
if (g && name === 'Other Data Types') out.push(ask(id, l, `dataSafety.data.${g.from.join(', ')}`, `${g.from.join(', ')} has no exact App Store type: decide where it belongs.`)); const [cat, name] = APPLE_PRIVACY_TYPES[id];
else if (g) out.push(ok(id, l, true, `dataSafety.data.${g.from.join(', ')}`)); const g = got.get(name), o = ov[id], aid = `type:${name}`, l = `Data type: ${cat} > ${name}`;
else if (mapped.has(name)) out.push(ok(id, l, false, 'dataSafety.data (not listed)')); if (o?.collected !== undefined) { out.push(ok(aid, l, o.collected, `appPrivacy.types.${id}.collected`)); if (o.collected) collected.push(id); continue; }
else out.push(ask(id, l, 'none', name === 'Advertising Data' ? 'No Play Data safety equivalent; ad SDKs usually collect it: check each SDK\'s privacy disclosure.' : 'No Play Data safety equivalent: decide from the app and its SDKs.')); const set = `set appPrivacy.types.${id}.collected to have it filled`;
if (g && name === 'Other Data Types') out.push(ask(aid, l, `dataSafety.data.${g.from.join(', ')}`, `${g.from.join(', ')} has no exact App Store type: decide where it belongs (${set}).`));
else if (g) { out.push(ok(aid, l, true, `dataSafety.data.${g.from.join(', ')}`)); collected.push(id); }
else if (ds && mapped.has(name)) out.push(ok(aid, l, false, 'dataSafety.data (not listed)'));
else out.push(ask(aid, l, `appPrivacy.types.${id}`, `${name === 'Advertising Data' ? 'No Play Data safety equivalent; ad SDKs usually collect it: check each SDK\'s privacy disclosure' : ds ? 'No Play Data safety equivalent: decide from the app and its SDKs' : 'Decide from the app and its SDKs'}; ${set}.`));
} }
for (const [name, g] of got) { for (const id of collected) {
if (name === 'Other Data Types') continue; const name = APPLE_PRIVACY_TYPES[id][1], g = got.get(name), o = ov[id];
for (const p of APPLE_PURPOSES) out.push(ok(`purpose:${name}:${p}`, `${name}: purpose ${p}`, g.purposes.has(p), `dataSafety.data.${g.from.join(', ')}`)); if (o?.purposes) for (const p of APPLE_PURPOSE_IDS) out.push(ok(`purpose:${name}:${purposeName(p)}`, `${name}: purpose ${purposeName(p)}`, o.purposes.includes(p), `appPrivacy.types.${id}.purposes`));
out.push(ask(`linked:${name}`, `${name}: linked to the user's identity?`, 'none', 'Only you know whether you or a partner tie it to an account, device or other identity details.')); else if (g) for (const p of APPLE_PURPOSES) {
out.push(ask(`tracking:${name}`, `${name}: used for tracking?`, 'none', 'Yes when it is combined with other companies\' data for ads or shared with data brokers; tracking also needs App Tracking Transparency.')); const pid = `purpose:${name}:${p}`, pl = `${name}: purpose ${p}`, src = `dataSafety.data.${g.from.join(', ')}`;
if (p === DEV_ADS && g.comms) out.push(ask(pid, pl, src, `Play says "developer communications": marketing messages to your users are Developer's Advertising or Marketing, service notifications are App Functionality. Set appPrivacy.types.${id}.purposes to have it filled.`));
else if (p === DEV_ADS) out.push(ok(pid, pl, false, src, `Yes only for your own ads or marketing to your users (not an ad SDK's ads): set appPrivacy.types.${id}.purposes with DEVELOPERS_ADVERTISING.`));
else out.push(ok(pid, pl, g.purposes.has(p), src));
}
else for (const p of APPLE_PURPOSES) out.push(ask(`purpose:${name}:${p}`, `${name}: purpose ${p}`, `appPrivacy.types.${id}.purposes`, `Set appPrivacy.types.${id}.purposes to have it filled.`));
out.push(o?.linked !== undefined ? ok(`linked:${name}`, `${name}: linked to the user's identity?`, o.linked, `appPrivacy.types.${id}.linked`)
: ask(`linked:${name}`, `${name}: linked to the user's identity?`, `appPrivacy.types.${id}.linked`, `Only you know whether you or a partner tie it to an account, device or other identity details. Set appPrivacy.types.${id}.linked to have it filled.`));
out.push(o?.tracking !== undefined ? ok(`tracking:${name}`, `${name}: used for tracking?`, o.tracking, `appPrivacy.types.${id}.tracking`)
: ask(`tracking:${name}`, `${name}: used for tracking?`, `appPrivacy.types.${id}.tracking`, `Yes when it is combined with other companies' data for ads or shared with data brokers; tracking also needs App Tracking Transparency. Set appPrivacy.types.${id}.tracking to have it filled.`));
} }
return out; return out;
} }

View file

@ -66,14 +66,21 @@ export const APPLE_PRIVACY: Record<string, [string, string]> = {
PSL_DEVICE_ID: ['Identifiers', 'Device ID'], PSL_DEVICE_ID: ['Identifiers', 'Device ID'],
}; };
/** Play purpose -> App Privacy purpose. Advertising depends on who shows the ads (shared = third-party advertising). */ /**
export function applePurpose(p: PlayPurpose, shared: boolean): string { * Play purpose -> the ONE App Privacy purpose it means (definitions: developer.apple.com/app-store/app-privacy-details/,
* quoted in cli/lib/app-privacy.ts). Play "advertising" is ads in the app, which in a mobile app or game come from an
* ad SDK: Third-Party Advertising, never also Developer's Advertising or Marketing (first-party ads, marketing to your
* own users): that one is only the owner's answer (appPrivacy.types.<ID>.purposes: DEVELOPERS_ADVERTISING). Play
* "communications" (news and notifications about the app) is App Functionality; marketing messages are the owner's
* call (console fill asks). Analytics is Analytics only, not Product Personalization; fraud prevention, account
* management and functionality are App Functionality.
*/
export function applePurpose(p: PlayPurpose): string {
switch (p) { switch (p) {
case 'analytics': return 'Analytics'; case 'analytics': return 'Analytics';
case 'advertising': return shared ? 'Third-Party Advertising' : 'Developer\'s Advertising or Marketing'; case 'advertising': return 'Third-Party Advertising';
case 'communications': return 'Developer\'s Advertising or Marketing';
case 'personalization': return 'Product Personalization'; case 'personalization': return 'Product Personalization';
default: return 'App Functionality'; default: return 'App Functionality'; // functionality, fraud, account, communications
} }
} }
@ -134,8 +141,7 @@ export function declarations(config: ShipConfig, inp: DeclarationInputs): Declar
const [category, name] = APPLE_PRIVACY[id] ?? ['Other Data', 'Other Data Types']; const [category, name] = APPLE_PRIVACY[id] ?? ['Other Data', 'Other Data Types'];
const e = byType.get(name) ?? { apple: name, category, from: [], purposes: new Set<string>(), thirdParty: false }; const e = byType.get(name) ?? { apple: name, category, from: [], purposes: new Set<string>(), thirdParty: false };
e.from.push(id); e.from.push(id);
for (const p of u.collect) e.purposes.add(applePurpose(p, false)); for (const p of [...u.collect, ...(u.shared ? u.share ?? [] : [])]) e.purposes.add(applePurpose(p));
for (const p of u.shared ? u.share ?? [] : []) e.purposes.add(applePurpose(p, true));
e.thirdParty ||= !!u.shared; e.thirdParty ||= !!u.shared;
byType.set(name, e); byType.set(name, e);
} }

View file

@ -3,6 +3,7 @@
// marked "detected (file:line)" or "ask owner", and a diff against the config's dataSafety / appPrivacy blocks. // marked "detected (file:line)" or "ask owner", and a diff against the config's dataSafety / appPrivacy blocks.
// Only detected items are ever written (`scan --write`); "ask owner" items stay questions (AGENTS.md rule 5). Pure. // Only detected items are ever written (`scan --write`); "ask owner" items stay questions (AGENTS.md rule 5). Pure.
import type { AppPrivacyConfig, DataSafety, DataUsage, PlayPurpose, ShipConfig } from '../config'; import type { AppPrivacyConfig, DataSafety, DataUsage, PlayPurpose, ShipConfig } from '../config';
import { type AppleAppPrivacyPurpose, type AppleDataTypeId, type AppleTypeAnswer, purposeIdOf, typeIdOf } from '../app-privacy';
import { ACCOUNT_CREATION, ACCOUNT_SIGN_UP, accountCreationOf, APPLE_PRIVACY, applePurpose } from '../declarations'; import { ACCOUNT_CREATION, ACCOUNT_SIGN_UP, accountCreationOf, APPLE_PRIVACY, applePurpose } from '../declarations';
import { REQUIRED_REASON_APIS } from '../privacy-manifest'; import { REQUIRED_REASON_APIS } from '../privacy-manifest';
import { IOS_PERMISSIONS } from './permissions'; import { IOS_PERMISSIONS } from './permissions';
@ -27,6 +28,9 @@ export interface Proposal {
dataSafety: Partial<DataSafety> & { data: Record<string, DataUsage> } | null; dataSafety: Partial<DataSafety> & { data: Record<string, DataUsage> } | null;
appPrivacy: AppPrivacyConfig | null; appPrivacy: AppPrivacyConfig | null;
appPrivacyChange: { from: boolean | null; to: boolean } | null; appPrivacyChange: { from: boolean | null; to: boolean } | null;
/** appPrivacy.types entries --write would add (types the config does not answer yet): collected + purposes from the
* detected SDKs / code only. linked / tracking are never proposed: the SDK disclosures do not prove them. */
appPrivacyTypes: Partial<Record<AppleDataTypeId, AppleTypeAnswer>> | null;
/** dataSafety.accountCreation --write would set (from accounts.signUp, while the config says PSL_ACM_NONE or nothing). */ /** dataSafety.accountCreation --write would set (from accounts.signUp, while the config says PSL_ACM_NONE or nothing). */
accountCreationChange: { from: string[] | null; to: string[] } | null; accountCreationChange: { from: string[] | null; to: string[] } | null;
/** Types an SDK collects that the config's dataSafety does not declare (the privacy-labels rule). */ /** Types an SDK collects that the config's dataSafety does not declare (the privacy-labels rule). */
@ -135,10 +139,24 @@ export function proposeDeclarations(p: ProjectFacts, c: ShipConfig | null, confi
// App Privacy per type (linked / tracking are owner answers) // App Privacy per type (linked / tracking are owner answers)
for (const d of diff) { for (const d of diff) {
const shared = d.after.shared ? d.after.share ?? [] : []; const shared = d.after.shared ? d.after.share ?? [] : [];
// a purpose the data is shared for counts once, as the third party's (AdMob: Third-Party Advertising, not the developer's) // one App Privacy purpose per Play purpose (AdMob: Third-Party Advertising, never also the developer's)
const purposes = uniq([...d.after.collect.filter(x => !shared.includes(x)).map(x => applePurpose(x, false)), ...shared.map(x => applePurpose(x, true))]).sort(); const purposes = uniq([...d.after.collect, ...shared].map(x => applePurpose(x))).sort();
items.push({ area: 'appPrivacy', what: d.apple, value: purposes.join(', '), status: d.change === 'kept' ? 'ask' : 'detected', evidence: d.evidence.slice(0, 1), note: 'linked to identity? used for tracking? ask owner' }); items.push({ area: 'appPrivacy', what: d.apple, value: purposes.join(', '), status: d.change === 'kept' ? 'ask' : 'detected', evidence: d.evidence.slice(0, 1), note: 'linked to identity? used for tracking? ask owner' });
} }
// appPrivacy.types: propose collected + purposes for detected types the config does not answer (Apple apps only)
const haveTypes = c?.appPrivacy?.types ?? {};
const typesAdded: Partial<Record<AppleDataTypeId, AppleTypeAnswer>> = {};
if (c?.apple) for (const d of diff) {
if (d.change === 'kept') continue;
const id = typeIdOf(d.apple.split(' / ')[1]!);
if (!id || id === 'OTHER_DATA_TYPES' || haveTypes[id]) continue;
const shared = d.after.shared ? d.after.share ?? [] : [];
const ps = [...d.after.collect, ...shared].map(x => purposeIdOf(applePurpose(x))).filter((x): x is AppleAppPrivacyPurpose => !!x);
typesAdded[id] = { collected: true, purposes: uniq([...(typesAdded[id]?.purposes ?? []), ...ps]).sort() };
}
for (const [id, a] of Object.entries(typesAdded)) items.push({ area: 'appPrivacy', what: `types.${id}`, value: `collected, purposes: ${a!.purposes!.join(', ')}`, status: 'detected', evidence: [],
note: `linked / tracking: ask owner (set appPrivacy.types.${id}.linked / .tracking)` });
const appPrivacyTypes = Object.keys(typesAdded).length ? typesAdded : null;
// tracking + ATT // tracking + ATT
const attReq = grep(p.sources, SIGNALS.attRequest, 1); const attReq = grep(p.sources, SIGNALS.attRequest, 1);
@ -172,7 +190,9 @@ export function proposeDeclarations(p: ProjectFacts, c: ShipConfig | null, confi
const dataSafety = anyData || c?.dataSafety ? { ...(c?.dataSafety ?? {}), collectsData: anyData || !!c?.dataSafety?.collectsData, ...(accountCreation ? { accountCreation } : {}), data: out } : null; const dataSafety = anyData || c?.dataSafety ? { ...(c?.dataSafety ?? {}), collectsData: anyData || !!c?.dataSafety?.collectsData, ...(accountCreation ? { accountCreation } : {}), data: out } : null;
const from = c?.appPrivacy?.tracking ?? null; const from = c?.appPrivacy?.tracking ?? null;
const appPrivacyChange = tracking !== null && from !== tracking ? { from, to: tracking } : null; const appPrivacyChange = tracking !== null && from !== tracking ? { from, to: tracking } : null;
const appPrivacy = appPrivacyChange ? { ...(c?.appPrivacy ?? {}), tracking: appPrivacyChange.to } : c?.appPrivacy ?? null; const appPrivacy = appPrivacyChange || appPrivacyTypes ? {
...(c?.appPrivacy ?? {}), ...(appPrivacyChange ? { tracking: appPrivacyChange.to } : {}), ...(appPrivacyTypes ? { types: { ...haveTypes, ...appPrivacyTypes } } : {}),
} : c?.appPrivacy ?? null;
const accountCreationChange = accountCreation ? { from: c?.dataSafety?.accountCreation ?? null, to: accountCreation } : null; const accountCreationChange = accountCreation ? { from: c?.dataSafety?.accountCreation ?? null, to: accountCreation } : null;
return { items, diff, dataSafety, appPrivacy, appPrivacyChange, accountCreationChange, labelGaps, changed: dsChanged || !!appPrivacyChange }; return { items, diff, dataSafety, appPrivacy, appPrivacyChange, appPrivacyTypes, accountCreationChange, labelGaps, changed: dsChanged || !!appPrivacyChange || !!appPrivacyTypes };
} }

View file

@ -116,7 +116,7 @@ export function formatScan(r: ScanReport, o: { declarations?: boolean } = {}): s
for (const x of items) L.push(` ${x.status === 'detected' ? 'detected ' : 'ask owner'} ${x.what}: ${x.value}${x.evidence[0] ? ` (${x.evidence[0].file}:${x.evidence[0].line})` : ''}${x.note ? ` · ${x.note}` : ''}`); for (const x of items) L.push(` ${x.status === 'detected' ? 'detected ' : 'ask owner'} ${x.what}: ${x.value}${x.evidence[0] ? ` (${x.evidence[0].file}:${x.evidence[0].line})` : ''}${x.note ? ` · ${x.note}` : ''}`);
} }
const changes = d.diff.filter(x => x.change === 'add' || x.change === 'merge'); const changes = d.diff.filter(x => x.change === 'add' || x.change === 'merge');
if (changes.length || d.appPrivacyChange || d.accountCreationChange) { if (changes.length || d.appPrivacyChange || d.appPrivacyTypes || d.accountCreationChange) {
L.push('', ` Diff against ${r.config ?? 'the config'} (written only with --write):`); L.push('', ` Diff against ${r.config ?? 'the config'} (written only with --write):`);
for (const x of changes) { for (const x of changes) {
if (x.change === 'add') L.push(` + dataSafety.data.${x.type}: { shared: ${x.after.shared}, collect: [${x.after.collect.join(', ')}]${x.after.share?.length ? `, share: [${x.after.share.join(', ')}]` : ''} }`); if (x.change === 'add') L.push(` + dataSafety.data.${x.type}: { shared: ${x.after.shared}, collect: [${x.after.collect.join(', ')}]${x.after.share?.length ? `, share: [${x.after.share.join(', ')}]` : ''} }`);
@ -124,6 +124,7 @@ export function formatScan(r: ScanReport, o: { declarations?: boolean } = {}): s
} }
if (d.accountCreationChange) L.push(` ~ dataSafety.accountCreation: ${d.accountCreationChange.from ? JSON.stringify(d.accountCreationChange.from) : 'unset'} -> ${JSON.stringify(d.accountCreationChange.to)}`); if (d.accountCreationChange) L.push(` ~ dataSafety.accountCreation: ${d.accountCreationChange.from ? JSON.stringify(d.accountCreationChange.from) : 'unset'} -> ${JSON.stringify(d.accountCreationChange.to)}`);
if (d.appPrivacyChange) L.push(` ~ appPrivacy.tracking: ${d.appPrivacyChange.from ?? 'unset'} -> ${d.appPrivacyChange.to}`); if (d.appPrivacyChange) L.push(` ~ appPrivacy.tracking: ${d.appPrivacyChange.from ?? 'unset'} -> ${d.appPrivacyChange.to}`);
for (const [id, a] of Object.entries(d.appPrivacyTypes ?? {})) L.push(` + appPrivacy.types.${id}: { collected: true, purposes: [${a!.purposes!.join(', ')}] } (linked / tracking: ask owner)`);
} else if (r.config) L.push('', ` No changes to ${r.config}: the dataSafety / appPrivacy blocks already cover what was detected.`); } else if (r.config) L.push('', ` No changes to ${r.config}: the dataSafety / appPrivacy blocks already cover what was detected.`);
} }
if (r.originality) { if (r.originality) {

View file

@ -55,14 +55,15 @@ export async function run(args: Args): Promise<void> {
const d = report.declarations; const d = report.declarations;
if (!configPath) warn('scan', '--write: no storebound.config.ts in this project (storebound init creates one)'); if (!configPath) warn('scan', '--write: no storebound.config.ts in this project (storebound init creates one)');
else if (!d.changed) log('scan', `--write: nothing to change in ${report.config}`); else if (!d.changed) log('scan', `--write: nothing to change in ${report.config}`);
else if (args.has('dry')) log('scan', `--dry: would write ${[(d.diff.some(x => x.change !== 'kept' && x.change !== 'same') || d.accountCreationChange) && 'dataSafety', d.appPrivacyChange && 'appPrivacy'].filter(Boolean).join(' + ')} into ${report.config}`); else if (args.has('dry')) log('scan', `--dry: would write ${[(d.diff.some(x => x.change !== 'kept' && x.change !== 'same') || d.accountCreationChange) && 'dataSafety', (d.appPrivacyChange || d.appPrivacyTypes) && 'appPrivacy'].filter(Boolean).join(' + ')} into ${report.config}`);
else { else {
let text = readFileSync(configPath, 'utf8'); let text = readFileSync(configPath, 'utf8');
const ds = d.dataSafety!; const ds = d.dataSafety!;
const missing = (['encryptedInTransit', 'deletionRequest'] as const).filter(k => typeof ds[k] !== 'boolean'); const missing = (['encryptedInTransit', 'deletionRequest'] as const).filter(k => typeof ds[k] !== 'boolean');
if (d.diff.some(x => x.change === 'add' || x.change === 'merge') || d.accountCreationChange) if (d.diff.some(x => x.change === 'add' || x.change === 'merge') || d.accountCreationChange)
text = upsertBlock(text, configPath, 'dataSafety', ds, missing.length ? `storebound scan: answer ${missing.join(' and ')} (ask the owner; store-declarations skill)` : undefined); text = upsertBlock(text, configPath, 'dataSafety', ds, missing.length ? `storebound scan: answer ${missing.join(' and ')} (ask the owner; store-declarations skill)` : undefined);
if (d.appPrivacyChange) text = upsertBlock(text, configPath, 'appPrivacy', d.appPrivacy); if (d.appPrivacyChange || d.appPrivacyTypes) text = upsertBlock(text, configPath, 'appPrivacy', d.appPrivacy,
d.appPrivacyTypes ? 'storebound scan: types proposed from the detected SDKs; answer linked / tracking per type (ask the owner; store-declarations skill)' : undefined);
writeFileSync(configPath, text); writeFileSync(configPath, text);
log('scan', `wrote the detected answers into ${report.config}${missing.length ? `; still to answer: dataSafety.${missing.join(', dataSafety.')}` : ''}. Review the diff (git diff) before pushing it to a store.`); log('scan', `wrote the detected answers into ${report.config}${missing.length ? `; still to answer: dataSafety.${missing.join(', dataSafety.')}` : ''}. Review the diff (git diff) before pushing it to a store.`);
} }

View file

@ -9,6 +9,7 @@ fails without the fix.
| # | date | lesson | guard | | # | date | lesson | guard |
|---|---|---|---| |---|---|---|---|
| 10 | 2026-10 | App Privacy purposes were over-mapped: Play "advertising" became both Third-Party Advertising and Developer's Advertising or Marketing (Device ID, Coarse Location, Product Interaction, Performance Data). | `applePurpose` maps one Play purpose to one Apple purpose (advertising: third-party only); Developer's Advertising only from `appPrivacy.types`; `check` compares `appPrivacy.types` with Info.plist / PrivacyInfo.xcprivacy (`tests/app-privacy.test.ts`). |
| 9 | 2026-10 | A new Play app has no API: Play Console's "Create app" is the only way, its page-level button carries the same words as the form's final submit, and Free cannot become Paid later. | `console fill play-app-record`: `createAppAllowed` lets the opener through only on the app list, never in a form or dialog (EN + TR); declarations never ticked; Free / Paid outlined as an owner check (`tests/console-fill.test.ts`). | | 9 | 2026-10 | A new Play app has no API: Play Console's "Create app" is the only way, its page-level button carries the same words as the form's final submit, and Free cannot become Paid later. | `console fill play-app-record`: `createAppAllowed` lets the opener through only on the app list, never in a form or dialog (EN + TR); declarations never ticked; Free / Paid outlined as an owner check (`tests/console-fill.test.ts`). |
| 8 | 2026-10 | Capacitor plugins in a monorepo live in `apps/native/node_modules`, so `scan` missed them. | `scan` / `privacy-manifest` resolve workspace packages (`cli/lib/scan/project.ts`, `cli/lib/node-packages.ts`). | | 8 | 2026-10 | Capacitor plugins in a monorepo live in `apps/native/node_modules`, so `scan` missed them. | `scan` / `privacy-manifest` resolve workspace packages (`cli/lib/scan/project.ts`, `cli/lib/node-packages.ts`). |
| 7 | 2026-10 | Console UIs: the App Store Connect sign-in runs in an `idmsa.apple.com` iframe; "User Access" is a plain heading, not a labeled group; Chrome drops session cookies without `--restore-last-session`. | `console` session and fill (`cli/console/`), `tests/console-*.test.ts`. | | 7 | 2026-10 | Console UIs: the App Store Connect sign-in runs in an `idmsa.apple.com` iframe; "User Access" is a plain heading, not a labeled group; Chrome drops session cookies without `--restore-last-session`. | `console` session and fill (`cli/console/`), `tests/console-*.test.ts`. |

View file

@ -20,7 +20,7 @@ It is not available over MCP.
|---|---|---| |---|---|---|
| `apple-app-record` | App Store Connect > Apps > + > New App | apple.name (else app.name), apple.primaryLocale, apple.bundleId, console.appRecord (SKU, user access) | | `apple-app-record` | App Store Connect > Apps > + > New App | apple.name (else app.name), apple.primaryLocale, apple.bundleId, console.appRecord (SKU, user access) |
| `apple-age-rating` | App Information > Age Ratings | guide only: `storebound apple appinfo` sets every question through the API | | `apple-age-rating` | App Information > Age Ratings | guide only: `storebound apple appinfo` sets every question through the API |
| `apple-app-privacy` | the app > App Privacy | dataSafety (types and purposes); linked to identity and tracking are always the owner's | | `apple-app-privacy` | the app > App Privacy | appPrivacy.types (the owner's answers per Apple type id: collected, purposes, linked, tracking; certain), else dataSafety (types and purposes; Play advertising = Third-Party Advertising only); unset linked / tracking stay the owner's |
| `play-app-record` | Play Console > Home (All apps) > Create app | play.name or app.name (30 chars), play.defaultLanguage or the first language's play code, app.profile (App / Game), play.free or monetization (Free, owner check); the declarations are never ticked | | `play-app-record` | Play Console > Home (All apps) > Create app | play.name or app.name (30 chars), play.defaultLanguage or the first language's play code, app.profile (App / Game), play.free or monetization (Free, owner check); the declarations are never ticked |
| `play-content-rating` | Policy > App content > Content rating | app.contactEmail, app.profile, products, console.contentRating | | `play-content-rating` | Policy > App content > Content rating | app.contactEmail, app.profile, products, console.contentRating |
| `play-target-audience` | Policy > App content > Target audience and content (+ Ads) | console.targetAudience, ads.appAdsTxt | | `play-target-audience` | Policy > App content > Target audience and content (+ Ads) | console.targetAudience, ads.appAdsTxt |
@ -130,7 +130,8 @@ It is not available over MCP.
## The owner decides ## The owner decides
Every `[check]` answer, linked-to-identity and tracking for each App Privacy data type, the IARC answers, the target Every `[check]` answer, linked-to-identity and tracking for each App Privacy data type (unless `appPrivacy.types`
answers them), Developer's Advertising or Marketing, the IARC answers, the target
ages, Play's Free or paid and its declarations, and pressing the final button (App Privacy Publish, IARC Submit, ages, Play's Free or paid and its declarations, and pressing the final button (App Privacy Publish, IARC Submit,
Target audience Save, New App Create, Play Create app). Target audience Save, New App Create, Play Create app).

View file

@ -25,6 +25,27 @@ CLI: `storebound` (or `bunx storebound` in a project that has it, or `bun <toolc
4. **Apple age rating (API).** `storebound apple appinfo` (all NONE except your overrides, e.g. `advertising: true`). 4. **Apple age rating (API).** `storebound apple appinfo` (all NONE except your overrides, e.g. `advertising: true`).
5. **Apple App Privacy (UI only).** App Store Connect > the app > App Privacy > Get Started / Edit, from 5. **Apple App Privacy (UI only).** App Store Connect > the app > App Privacy > Get Started / Edit, from
`store/app-privacy.md`; per data type: purposes > linked to identity > used for tracking. Then **Publish**. `store/app-privacy.md`; per data type: purposes > linked to identity > used for tracking. Then **Publish**.
- Purposes follow Apple's definitions (developer.apple.com/app-store/app-privacy-details/), one per Play purpose:
Play `advertising` (ads from an ad SDK) is **Third-Party Advertising only**, never also Developer's Advertising
or Marketing (that one is first-party ads or marketing to your own users: the owner's answer); `analytics` is
Analytics (not Product Personalization); `personalization` is Product Personalization; functionality, fraud,
account and `communications` are App Functionality (marketing messages: ask the owner).
- The owner's answers go into `appPrivacy.types`, keyed by Apple's type id (USER_ID, DEVICE_ID, GAMEPLAY_CONTENT,
ADVERTISING_DATA, CUSTOMER_SUPPORT, ENVIRONMENT_SCANNING, HANDS, HEAD ... all 35 in `cli/lib/app-privacy.ts`):
```ts
appPrivacy: { tracking: true, types: {
DEVICE_ID: { collected: true, linked: false, tracking: true, purposes: ['THIRD_PARTY_ADVERTISING', 'ANALYTICS'] },
ADVERTISING_DATA: { collected: true, linked: false, tracking: true, purposes: ['THIRD_PARTY_ADVERTISING'] },
GAMEPLAY_CONTENT: { collected: false },
} },
```
Purposes: THIRD_PARTY_ADVERTISING, DEVELOPERS_ADVERTISING, ANALYTICS, PRODUCT_PERSONALIZATION, APP_FUNCTIONALITY,
OTHER_PURPOSES. A set field wins over what storebound derives from `dataSafety`; types with no Play equivalent
(Advertising Data, Gameplay Content, Customer Support, Environment Scanning, Hands, Head) are answered only here.
`scan --write` proposes `collected` + `purposes` for detected types the block does not answer yet; `linked` and
`tracking` are never proposed (ask the owner). `storebound check` compares the block with the iOS project:
tracking true <-> `NSUserTrackingUsageDescription` and `NSPrivacyTracking` true; the app's
`NSPrivacyCollectedDataTypes` <-> the types marked collected (mismatches both ways).
6. **Export compliance.** `export-compliance` skill (`ITSAppUsesNonExemptEncryption` in Info.plist, `apple encryption`). 6. **Export compliance.** `export-compliance` skill (`ITSAppUsesNonExemptEncryption` in Info.plist, `apple encryption`).
7. **Privacy manifest (iOS).** `privacy-manifest` skill; keep it consistent with App Privacy. 7. **Privacy manifest (iOS).** `privacy-manifest` skill; keep it consistent with App Privacy.

View file

@ -1,6 +1,6 @@
--- ---
name: store-pitfalls name: store-pitfalls
description: Known pitfalls with App Store Connect, Google Play and storebound itself, learned from real releases, and what to do about each - store lists that lag right after a create, dry runs that print a count instead of a plan, App Store names taken on a storefront, keyword limits in bytes, Data safety answers without code evidence, missing font glyphs in screenshots, console sign-in and sessions, Capacitor monorepo plugins, Play's Create app form (no API, opener and submit share a name, Free is final). Read it before any store task, and when a store command does something you did not expect. description: Known pitfalls with App Store Connect, Google Play and storebound itself, learned from real releases, and what to do about each - store lists that lag right after a create, dry runs that print a count instead of a plan, App Store names taken on a storefront, keyword limits in bytes, Data safety answers without code evidence, missing font glyphs in screenshots, console sign-in and sessions, Capacitor monorepo plugins, Play's Create app form (no API, opener and submit share a name, Free is final), App Privacy purposes over-mapped (Play advertising is Third-Party Advertising only). Read it before any store task, and when a store command does something you did not expect.
--- ---
# Store pitfalls # Store pitfalls
@ -79,6 +79,17 @@ Each entry: **symptom** → cause → what to do → what guards it now. The ful
- **Guard:** `createAppAllowed` lets the opener through only on the app list, never inside a form or dialog (English - **Guard:** `createAppAllowed` lets the opener through only on the app list, never inside a form or dialog (English
and Turkish); agreement checkboxes are never ticked; Free or paid is outlined as an owner check. and Turkish); agreement checkboxes are never ticked; Free or paid is outlined as an owner check.
## 10. App Privacy purposes over-mapped
- **Symptom:** App Privacy says Developer's Advertising or Marketing for Device ID, Coarse Location, Product Interaction
or Performance Data, although the app only shows an ad SDK's ads.
- **Cause:** a Play purpose was turned into two Apple purposes ("advertising" -> Third-Party Advertising AND
Developer's Advertising or Marketing). Apple's definitions (developer.apple.com/app-store/app-privacy-details/):
third-party ads are Third-Party Advertising; Developer's Advertising is first-party ads or marketing to your users.
- **Do:** one Apple purpose per Play purpose; put the owner's real answers in `appPrivacy.types` (Apple type ids,
purposes, linked, tracking) and let `storebound check` compare them with Info.plist and PrivacyInfo.xcprivacy.
- **Guard:** `applePurpose` (cli/lib/declarations.ts), `appPrivacy.types` validation and `appPrivacyMismatches`
(cli/lib/app-privacy.ts), `tests/app-privacy.test.ts`.
## Adding a lesson ## Adding a lesson
Every bug found in real use gets an entry in `docs/pitfalls.md` and here, and, where possible, a check or a test Every bug found in real use gets an entry in `docs/pitfalls.md` and here, and, where possible, a check or a test
that fails without the fix (see CONTRIBUTING.md). that fails without the fix (see CONTRIBUTING.md).

View file

@ -26,6 +26,24 @@ Not collected (typical): Contact Info, Health and Fitness, Financial Info, Preci
Emails or Text Messages, Photos or Videos, Audio, Browsing History, Search History, Crash Data (unless you ship a crash Emails or Text Messages, Photos or Videos, Audio, Browsing History, Search History, Crash Data (unless you ship a crash
reporter). reporter).
Purposes follow Apple's definitions (https://developer.apple.com/app-store/app-privacy-details/): ads shown by an ad
SDK are **Third-Party Advertising** only. **Developer's Advertising or Marketing** is your own ads or marketing to your
users; tick it only when that is true.
Put the answers into `storebound.config.ts` so `storebound console fill apple-app-privacy` fills them and
`storebound check` compares them with Info.plist and PrivacyInfo.xcprivacy (all type ids: storebound's
cli/lib/app-privacy.ts):
```ts
appPrivacy: { tracking: true, types: {
DEVICE_ID: { collected: true, linked: false, tracking: true, purposes: ['THIRD_PARTY_ADVERTISING', 'ANALYTICS', 'APP_FUNCTIONALITY'] },
COARSE_LOCATION: { collected: true, linked: false, tracking: true, purposes: ['THIRD_PARTY_ADVERTISING', 'ANALYTICS'] },
ADVERTISING_DATA: { collected: true, linked: false, tracking: true, purposes: ['THIRD_PARTY_ADVERTISING', 'ANALYTICS'] },
PRODUCT_INTERACTION: { collected: true, linked: false, tracking: false, purposes: ['ANALYTICS'] },
GAMEPLAY_CONTENT: { collected: false },
} },
```
Per data type the UI asks, in order: purposes (checkboxes) > "Is this data linked to the user's identity?" > Per data type the UI asks, in order: purposes (checkboxes) > "Is this data linked to the user's identity?" >
"Do you or your third-party partners use this data for tracking purposes?". "Do you or your third-party partners use this data for tracking purposes?".

163
tests/app-privacy.test.ts Normal file
View file

@ -0,0 +1,163 @@
// App Privacy: the Play -> Apple purpose mapping (one purpose per Play purpose; advertising is third-party only), the
// owner's appPrivacy.types answers (certain, and they win over what dataSafety suggests), their validation, the
// scan proposal (collected + purposes only, never linked / tracking) and `check` against the iOS project.
// Placeholder data only.
import { describe, expect, test } from 'bun:test';
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { run as check } from '../cli/check';
import { APPLE_DATA_TYPE_IDS, APPLE_PRIVACY_TYPES, appPrivacyMismatches, typeIdOfManifest, validateAppPrivacyTypes } from '../cli/lib/app-privacy';
import { parseArgs } from '../cli/lib/args';
import type { ShipConfig } from '../cli/lib/config';
import { validateExtras } from '../cli/lib/config';
import { consoleAnswers } from '../cli/lib/console-answers';
import { formDef } from '../cli/lib/console-forms';
import { applePurpose, declarations } from '../cli/lib/declarations';
import { proposeDeclarations } from '../cli/lib/scan/declare';
import { detectProject } from '../cli/lib/scan/project';
const base: ShipConfig = {
app: { name: 'Example Game', profile: 'game', privacyPolicyUrl: 'https://example.com/privacy', supportUrl: 'https://example.com/support', website: 'https://example.com', contactEmail: 'support@example.com' },
languages: [{ id: 'en', play: 'en-US', apple: 'en-US' }],
apple: { bundleId: 'com.example.game' },
play: { packageName: 'com.example.game' },
dataSafety: {
collectsData: true, encryptedInTransit: true, deletionRequest: false,
data: {
PSL_DEVICE_ID: { shared: true, collect: ['advertising', 'analytics'], share: ['advertising'] },
PSL_APPROX_LOCATION: { shared: true, collect: ['advertising', 'analytics'], share: ['advertising'] },
PSL_USER_INTERACTION: { shared: true, collect: ['advertising', 'analytics'], share: ['advertising'] },
PSL_PERFORMANCE_DIAGNOSTICS: { shared: true, collect: ['advertising', 'analytics'], share: ['advertising'] },
PSL_EMAIL: { shared: false, collect: ['communications', 'account'] },
},
},
} as ShipConfig;
const answers = (c: ShipConfig = base) => new Map(consoleAnswers('apple-app-privacy', c).map(a => [a.id, a]));
const TPA = 'Third-Party Advertising', DEV = 'Developer\'s Advertising or Marketing';
describe('purpose mapping (developer.apple.com/app-store/app-privacy-details/)', () => {
test('one App Privacy purpose per Play purpose; advertising is third-party only', () => {
expect(applePurpose('advertising')).toBe(TPA);
expect(applePurpose('analytics')).toBe('Analytics');
expect(applePurpose('personalization')).toBe('Product Personalization');
for (const p of ['functionality', 'fraud', 'account', 'communications'] as const) expect(applePurpose(p)).toBe('App Functionality');
});
test('ad SDK data (shared for advertising): Third-Party Advertising yes, Developer\'s Advertising no, for every type', () => {
const a = answers();
for (const t of ['Device ID', 'Coarse Location', 'Product Interaction', 'Performance Data']) {
expect(a.get(`purpose:${t}:${TPA}`)).toMatchObject({ value: true, certain: true });
expect(a.get(`purpose:${t}:${DEV}`)).toMatchObject({ value: false, certain: true });
expect(a.get(`purpose:${t}:Analytics`)?.value).toBe(true);
expect(a.get(`purpose:${t}:Product Personalization`)?.value).toBe(false);
}
// Play "developer communications" may be marketing: asked, never guessed
expect(a.get(`purpose:Email Address:${DEV}`)).toMatchObject({ value: null, certain: false });
expect(a.get('purpose:Email Address:App Functionality')?.value).toBe(true);
const d = declarations(base, { demoUser: null, contactEmail: null, uploaded: null });
expect(d.appPrivacy!.items.find(x => x.apple === 'Device ID')!.purposes).toEqual(['Analytics', TPA]);
});
});
describe('appPrivacy.types (the owner\'s answers)', () => {
test('override wins over dataSafety; types without a Play equivalent work from the block alone', () => {
const c = { ...base, appPrivacy: { types: {
DEVICE_ID: { collected: true, linked: false, tracking: true, purposes: ['THIRD_PARTY_ADVERTISING', 'DEVELOPERS_ADVERTISING'] },
ADVERTISING_DATA: { collected: true, linked: false, tracking: true, purposes: ['THIRD_PARTY_ADVERTISING'] },
GAMEPLAY_CONTENT: { collected: false },
PERFORMANCE_DATA: { linked: false },
} } } as ShipConfig;
const a = answers(c);
expect(a.get(`purpose:Device ID:${DEV}`)).toMatchObject({ value: true, certain: true, source: 'appPrivacy.types.DEVICE_ID.purposes' });
expect(a.get('purpose:Device ID:Analytics')).toMatchObject({ value: false, certain: true }); // the list replaces the derived one
expect(a.get('linked:Device ID')).toMatchObject({ value: false, certain: true });
expect(a.get('tracking:Device ID')).toMatchObject({ value: true, certain: true });
expect(a.get('type:Advertising Data')).toMatchObject({ value: true, certain: true, source: 'appPrivacy.types.ADVERTISING_DATA.collected' });
expect(a.get(`purpose:Advertising Data:${TPA}`)?.value).toBe(true);
expect(a.get('type:Gameplay Content')).toMatchObject({ value: false, certain: true });
expect(a.get('linked:Performance Data')).toMatchObject({ value: false, certain: true });
expect(a.get('tracking:Performance Data')).toMatchObject({ value: null, certain: false }); // not set: (you decide)
expect(a.get('type:Customer Support')).toMatchObject({ value: null, certain: false });
// the Advertising Data dialog gets a section of its own
expect(formDef('apple-app-privacy', [...a.values()]).sections.map(s => s.title)).toContain('Advertising Data');
});
test('without dataSafety: only appPrivacy.types', () => {
const c = { ...base, dataSafety: undefined, appPrivacy: { types: { HANDS: { collected: true, purposes: ['APP_FUNCTIONALITY'] } } } } as ShipConfig;
const a = answers(c);
expect(a.get('collects')).toMatchObject({ value: true, certain: true });
expect(a.get('type:Hands')?.value).toBe(true);
expect(a.get('type:Device ID')).toMatchObject({ value: null, certain: false });
expect(a.get('linked:Hands')?.certain).toBe(false);
const none = { ...base, dataSafety: undefined, appPrivacy: { types: Object.fromEntries(APPLE_DATA_TYPE_IDS.map(id => [id, { collected: false }])) } } as ShipConfig;
expect([...answers(none).values()]).toEqual([expect.objectContaining({ id: 'collects', value: false, certain: true })]);
});
test('validation: ids and purposes against Apple\'s lists', () => {
expect(validateExtras({ appPrivacy: { types: { USER_ID: { collected: true, linked: true, tracking: false, purposes: ['APP_FUNCTIONALITY'] } } } })).toEqual([]);
const e = validateAppPrivacyTypes({ IDFA: { collected: true }, DEVICE_ID: { collected: 'yes', purposes: ['ADS'] }, HEAD: { collected: false, tracking: true }, HANDS: { seen: true } }).join('\n');
for (const k of ['appPrivacy.types.IDFA', 'DEVICE_ID.collected', '"ADS"', 'HEAD: collected is false', 'HANDS.seen']) expect(e).toContain(k);
expect(APPLE_DATA_TYPE_IDS).toHaveLength(35);
for (const id of APPLE_DATA_TYPE_IDS) expect(typeIdOfManifest(APPLE_PRIVACY_TYPES[id][2])).toBe(id);
});
});
describe('scan proposes collected + purposes, never linked / tracking', () => {
test('clean fixture without types: proposed from the SDKs and the code', () => {
const dir = join(import.meta.dir, 'fixtures', 'scan', 'clean');
const p = detectProject(dir);
const c = { ...base, accounts: { enabled: true }, dataSafety: undefined } as ShipConfig;
const d = proposeDeclarations(p, c);
expect(d.changed).toBe(true);
const t = d.appPrivacyTypes!;
expect(Object.keys(t).length).toBeGreaterThan(0);
for (const a of Object.values(t)) { expect(a!.collected).toBe(true); expect(a!.linked).toBeUndefined(); expect(a!.tracking).toBeUndefined(); expect(a!.purposes).not.toContain('DEVELOPERS_ADVERTISING'); }
// an owner answer is never overwritten
const owned = proposeDeclarations(p, { ...c, appPrivacy: { types: { USER_ID: { collected: true, linked: true } } } } as ShipConfig);
expect(owned.appPrivacyTypes?.USER_ID).toBeUndefined();
expect(owned.appPrivacy?.types?.USER_ID).toEqual({ collected: true, linked: true });
});
});
describe('check: appPrivacy.types against the iOS project', () => {
const MANIFEST = (tracking: boolean, types: string[]) => `<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0"><dict>
<key>NSPrivacyTracking</key><${tracking}/>
<key>NSPrivacyCollectedDataTypes</key><array>${types.map(t => `<dict><key>NSPrivacyCollectedDataType</key><string>${t}</string></dict>`).join('')}</array>
</dict></plist>`;
test('pure: both ways', () => {
const m = (tracking: boolean | null, collectedTypes: string[]) => ({ path: 'App/PrivacyInfo.xcprivacy', tracking, collectedTypes });
const msgs = (r: { level: string; msg: string }[]) => r.map(x => `${x.level}: ${x.msg}`).join('\n');
let r = appPrivacyMismatches({ DEVICE_ID: { collected: true, tracking: true } }, { attString: false, manifest: m(false, ['NSPrivacyCollectedDataTypeDeviceID']) });
expect(msgs(r)).toContain('error: appPrivacy.types says DEVICE_ID is used for tracking, but Info.plist has no NSUserTrackingUsageDescription');
expect(msgs(r)).toContain('NSPrivacyTracking false');
r = appPrivacyMismatches({ DEVICE_ID: { collected: true, tracking: true }, USER_ID: { collected: false } }, { attString: true, manifest: m(true, ['NSPrivacyCollectedDataTypeDeviceID', 'NSPrivacyCollectedDataTypeUserID', 'NSPrivacyCollectedDataTypeEmailAddress', 'NSPrivacyCollectedDataTypeBogus']) });
expect(msgs(r)).toContain('error: App/PrivacyInfo.xcprivacy declares NSPrivacyCollectedDataTypeUserID (User ID) as collected, but appPrivacy.types.USER_ID.collected is false');
expect(msgs(r)).toContain('warn: App/PrivacyInfo.xcprivacy declares NSPrivacyCollectedDataTypeEmailAddress (Email Address) as collected, but appPrivacy.types has no answer for EMAIL_ADDRESS');
expect(msgs(r)).toContain('unknown NSPrivacyCollectedDataType "NSPrivacyCollectedDataTypeBogus"');
r = appPrivacyMismatches({ GAMEPLAY_CONTENT: { collected: true, tracking: false } }, { attString: true, manifest: m(true, []) });
expect(msgs(r)).toContain('warn: Info.plist has NSUserTrackingUsageDescription, but appPrivacy.types marks no collected type as used for tracking');
expect(msgs(r)).toContain('has NSPrivacyTracking true, but appPrivacy.types marks no collected type');
expect(msgs(r)).toContain('appPrivacy.types.GAMEPLAY_CONTENT is collected, but App/PrivacyInfo.xcprivacy has no NSPrivacyCollectedDataTypeGameplayContent');
expect(appPrivacyMismatches({ DEVICE_ID: { collected: true, tracking: true } }, { attString: true, manifest: m(true, ['NSPrivacyCollectedDataTypeDeviceID']) })).toEqual([]);
});
test('storebound check reports the mismatches (errors are problems)', async () => {
const dir = mkdtempSync(join(tmpdir(), 'storebound-ap-'));
try {
mkdirSync(join(dir, 'ios', 'App.xcodeproj'), { recursive: true });
writeFileSync(join(dir, 'ios', 'App.xcodeproj', 'project.pbxproj'), '// placeholder\n');
writeFileSync(join(dir, 'ios', 'Info.plist'), '<?xml version="1.0"?><plist version="1.0"><dict><key>CFBundleName</key><string>Example</string></dict></plist>');
writeFileSync(join(dir, 'ios', 'PrivacyInfo.xcprivacy'), MANIFEST(false, ['NSPrivacyCollectedDataTypeDeviceID']));
writeFileSync(join(dir, '.gitignore'), '.storebound/\n');
const c = { app: base.app, languages: base.languages, apple: base.apple, appPrivacy: { types: { DEVICE_ID: { collected: true, tracking: true } } } } as ShipConfig;
const out: string[] = [];
const orig = console.log;
console.log = (s: string) => { out.push(s); };
try { await check({ loaded: { config: c, root: dir, path: join(dir, 'storebound.config.ts'), resolve: p => join(dir, p) }, args: parseArgs(['--json']) }); }
finally { console.log = orig; process.exitCode = 0; }
const r = JSON.parse(out.at(-1)!);
const problems = (r.problems as string[]).join('\n');
expect(problems).toContain('Info.plist has no NSUserTrackingUsageDescription');
expect(problems).toContain('NSPrivacyTracking false');
expect(r.items.some((i: { what: string }) => i.what === 'app privacy')).toBe(true);
} finally { rmSync(dir, { recursive: true, force: true }); }
});
});

View file

@ -34,7 +34,9 @@ describe('declarations', () => {
expect(d.ask.map(a => a.id)).toEqual(['ap-linked']); expect(d.ask.map(a => a.id)).toEqual(['ap-linked']);
expect(d.encryption).toBe(false); expect(d.encryption).toBe(false);
expect(d.review.contact).toBe('a***@example.com'); expect(d.review.contact).toBe('a***@example.com');
expect(applePurpose('advertising', false)).toBe('Developer\'s Advertising or Marketing'); // ads in an app come from an ad SDK: Third-Party Advertising only; Developer's Advertising is the owner's answer
expect(applePurpose('advertising')).toBe('Third-Party Advertising');
expect(applePurpose('communications')).toBe('App Functionality');
}); });
test('changes since the last upload compare answers, not labels', () => { test('changes since the last upload compare answers, not labels', () => {
const ds = { collectsData: true, encryptedInTransit: true, deletionRequest: false, data: { PSL_CRASH_LOGS: { shared: false, collect: ['analytics' as const] } } }; const ds = { collectsData: true, encryptedInTransit: true, deletionRequest: false, data: { PSL_CRASH_LOGS: { shared: false, collect: ['analytics' as const] } } };

View file

@ -14,7 +14,19 @@ export default {
languages: [{ id: 'en', play: 'en-US', apple: 'en-US' }], languages: [{ id: 'en', play: 'en-US', apple: 'en-US' }],
play: { packageName: 'org.example.cleannotes', accountType: 'organization', targetAges: ['13-15', '16-17', '18+'] }, play: { packageName: 'org.example.cleannotes', accountType: 'organization', targetAges: ['13-15', '16-17', '18+'] },
apple: { bundleId: 'org.example.cleannotes', usesNonExemptEncryption: false }, apple: { bundleId: 'org.example.cleannotes', usesNonExemptEncryption: false },
appPrivacy: { tracking: true, trackingDomains: ['ads.example.com'] }, appPrivacy: {
tracking: true, trackingDomains: ['ads.example.com'],
types: {
NAME: { collected: true, linked: true, tracking: false, purposes: ['APP_FUNCTIONALITY'] },
EMAIL_ADDRESS: { collected: true, linked: true, tracking: false, purposes: ['APP_FUNCTIONALITY'] },
USER_ID: { collected: true, linked: true, tracking: false, purposes: ['APP_FUNCTIONALITY'] },
DEVICE_ID: { collected: true, linked: false, tracking: true, purposes: ['ANALYTICS', 'APP_FUNCTIONALITY', 'THIRD_PARTY_ADVERTISING'] },
COARSE_LOCATION: { collected: true, linked: false, tracking: true, purposes: ['ANALYTICS', 'APP_FUNCTIONALITY', 'THIRD_PARTY_ADVERTISING'] },
PRODUCT_INTERACTION: { collected: true, linked: false, tracking: false, purposes: ['ANALYTICS', 'THIRD_PARTY_ADVERTISING'] },
PERFORMANCE_DATA: { collected: true, linked: false, tracking: false, purposes: ['ANALYTICS'] },
PURCHASE_HISTORY: { collected: true, linked: true, tracking: false, purposes: ['APP_FUNCTIONALITY'] },
},
},
products: [ products: [
{ id: 'org.example.cleannotes.themes', type: 'non_consumable', usd: 1.99, listings: { en: { title: 'Themes', description: 'Every color theme' } } }, { id: 'org.example.cleannotes.themes', type: 'non_consumable', usd: 1.99, listings: { en: { title: 'Themes', description: 'Every color theme' } } },
], ],