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:
parent
962cd3cb9d
commit
08e75dc673
17 changed files with 509 additions and 52 deletions
144
cli/lib/app-privacy.ts
Normal file
144
cli/lib/app-privacy.ts
Normal 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;
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
import { existsSync } from 'node:fs';
|
||||
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
||||
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 IapOfferCodeDef, type PromotedConfig, validateIapOfferCodes, validatePromoted, validateWinBack, type WinBackDef } from './offers';
|
||||
import { validateSubscriptions } from './subscriptions';
|
||||
|
|
@ -332,6 +333,11 @@ export interface AppPrivacyConfig {
|
|||
tracking?: boolean;
|
||||
/** Domains that receive tracking data (privacy manifest NSPrivacyTrackingDomains). */
|
||||
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';
|
||||
|
|
@ -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.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(...validateAppPrivacyTypes(cfg.appPrivacy.types));
|
||||
}
|
||||
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())))
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
import { AGE_RATING_NONE } from '../apple/appinfo';
|
||||
import { type AgeGroup, AGE_GROUPS, appleName, IARC_QUESTIONS, type IarcQuestion, profileOf, type ShipConfig } from './config';
|
||||
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';
|
||||
|
||||
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]. */
|
||||
export const APPLE_DATA_TYPES: [string, string][] = [
|
||||
['Contact Info', 'Name'], ['Contact Info', 'Email Address'], ['Contact Info', 'Phone Number'], ['Contact Info', 'Physical Address'], ['Contact Info', 'Other User Contact Info'],
|
||||
['Health & Fitness', 'Health'], ['Health & Fitness', 'Fitness'], ['Financial Info', 'Payment Info'], ['Financial Info', 'Credit Info'], ['Financial Info', 'Other Financial Info'],
|
||||
['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'];
|
||||
export const APPLE_DATA_TYPES: [string, string][] = APPLE_DATA_TYPE_IDS.map(id => [APPLE_PRIVACY_TYPES[id][0], APPLE_PRIVACY_TYPES[id][1]]);
|
||||
export const APPLE_PURPOSES: string[] = APPLE_PURPOSE_IDS.map(purposeName);
|
||||
const DEV_ADS = purposeName('DEVELOPERS_ADVERTISING');
|
||||
|
||||
/** Apple data types the config's Data safety answers say are collected: type -> { from, purposes }. */
|
||||
export function privacyTypes(config: ShipConfig): Map<string, { from: string[]; purposes: Set<string> }> {
|
||||
const m = new Map<string, { from: string[]; purposes: Set<string> }>();
|
||||
/** Apple data types the config's Data safety answers say are collected: type -> { from, purposes, comms (a Play
|
||||
* "communications" purpose: maybe marketing) }. One App Privacy purpose per Play purpose (applePurpose). */
|
||||
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 ?? {})) {
|
||||
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);
|
||||
for (const p of u.collect) e.purposes.add(applePurpose(p, false));
|
||||
for (const p of u.shared ? u.share ?? [] : []) e.purposes.add(applePurpose(p, true));
|
||||
const all = [...u.collect, ...(u.shared ? u.share ?? [] : [])];
|
||||
for (const p of all) e.purposes.add(applePurpose(p));
|
||||
e.comms ||= all.includes('communications');
|
||||
m.set(name, e);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
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?';
|
||||
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 out: Answer[] = [ok('collects', label, ds.collectsData, 'dataSafety.collectsData')];
|
||||
if (!ds.collectsData) return out;
|
||||
const got = privacyTypes(config);
|
||||
const ovIds = Object.keys(ov) as AppleDataTypeId[];
|
||||
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.')];
|
||||
const ovYes = ovIds.filter(id => ov[id]?.collected === true);
|
||||
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));
|
||||
for (const [cat, name] of APPLE_DATA_TYPES) {
|
||||
const g = got.get(name), id = `type:${name}`, l = `Data type: ${cat} > ${name}`;
|
||||
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.`));
|
||||
else if (g) out.push(ok(id, l, true, `dataSafety.data.${g.from.join(', ')}`));
|
||||
else if (mapped.has(name)) out.push(ok(id, l, false, 'dataSafety.data (not listed)'));
|
||||
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 collected: AppleDataTypeId[] = [];
|
||||
for (const id of APPLE_DATA_TYPE_IDS) {
|
||||
const [cat, name] = APPLE_PRIVACY_TYPES[id];
|
||||
const g = got.get(name), o = ov[id], aid = `type:${name}`, l = `Data type: ${cat} > ${name}`;
|
||||
if (o?.collected !== undefined) { out.push(ok(aid, l, o.collected, `appPrivacy.types.${id}.collected`)); if (o.collected) collected.push(id); continue; }
|
||||
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) {
|
||||
if (name === 'Other Data Types') continue;
|
||||
for (const p of APPLE_PURPOSES) out.push(ok(`purpose:${name}:${p}`, `${name}: purpose ${p}`, g.purposes.has(p), `dataSafety.data.${g.from.join(', ')}`));
|
||||
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.'));
|
||||
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.'));
|
||||
for (const id of collected) {
|
||||
const name = APPLE_PRIVACY_TYPES[id][1], g = got.get(name), o = ov[id];
|
||||
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`));
|
||||
else if (g) for (const p of APPLE_PURPOSES) {
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,14 +66,21 @@ export const APPLE_PRIVACY: Record<string, [string, string]> = {
|
|||
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) {
|
||||
case 'analytics': return 'Analytics';
|
||||
case 'advertising': return shared ? 'Third-Party Advertising' : 'Developer\'s Advertising or Marketing';
|
||||
case 'communications': return 'Developer\'s Advertising or Marketing';
|
||||
case 'advertising': return 'Third-Party Advertising';
|
||||
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 e = byType.get(name) ?? { apple: name, category, from: [], purposes: new Set<string>(), thirdParty: false };
|
||||
e.from.push(id);
|
||||
for (const p of u.collect) e.purposes.add(applePurpose(p, false));
|
||||
for (const p of u.shared ? u.share ?? [] : []) e.purposes.add(applePurpose(p, true));
|
||||
for (const p of [...u.collect, ...(u.shared ? u.share ?? [] : [])]) e.purposes.add(applePurpose(p));
|
||||
e.thirdParty ||= !!u.shared;
|
||||
byType.set(name, e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// 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.
|
||||
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 { REQUIRED_REASON_APIS } from '../privacy-manifest';
|
||||
import { IOS_PERMISSIONS } from './permissions';
|
||||
|
|
@ -27,6 +28,9 @@ export interface Proposal {
|
|||
dataSafety: Partial<DataSafety> & { data: Record<string, DataUsage> } | null;
|
||||
appPrivacy: AppPrivacyConfig | 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). */
|
||||
accountCreationChange: { from: string[] | null; to: string[] } | null;
|
||||
/** 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)
|
||||
for (const d of diff) {
|
||||
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)
|
||||
const purposes = uniq([...d.after.collect.filter(x => !shared.includes(x)).map(x => applePurpose(x, false)), ...shared.map(x => applePurpose(x, true))]).sort();
|
||||
// one App Privacy purpose per Play purpose (AdMob: Third-Party Advertising, never also the developer's)
|
||||
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' });
|
||||
}
|
||||
// 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
|
||||
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 from = c?.appPrivacy?.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;
|
||||
return { items, diff, dataSafety, appPrivacy, appPrivacyChange, accountCreationChange, labelGaps, changed: dsChanged || !!appPrivacyChange };
|
||||
return { items, diff, dataSafety, appPrivacy, appPrivacyChange, appPrivacyTypes, accountCreationChange, labelGaps, changed: dsChanged || !!appPrivacyChange || !!appPrivacyTypes };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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}` : ''}`);
|
||||
}
|
||||
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):`);
|
||||
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(', ')}]` : ''} }`);
|
||||
|
|
@ -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.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.`);
|
||||
}
|
||||
if (r.originality) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue