From 1d4dc8573d4084609785591d325164c643a073bd Mon Sep 17 00:00:00 2001 From: CRT Date: Sun, 11 Oct 2026 17:59:29 +0000 Subject: [PATCH 1/4] teaser v5: 42 s 16:9 cut, same story and captions as v4 Nine scenes of 4-5 s (4.5 / 4.5 / 5 / 5 / 4.5 / 5 / 5 / 4.5 / 4), one camera move per scene with a quick quartic ease-out that settles at 80% of the scene, 0.4 s dissolves on the cuts. Captions fade in and out faster and stay fully on screen 3.25-4.25 s. Long terminal output streams faster instead of being cut: init types at 22 cps with 0.12 s lines, the prompt at 40 cps, the plan at 0.13 s per line, products, declarations, form rows and findings closer together. tests/teaser.test.ts: scenes 4-5 s, 38-46 s in total, captions at least 3 s. --- media/teaser/README.md | 31 ++++++------- media/teaser/script.js | 100 +++++++++++++++++++---------------------- media/teaser/teaser.js | 21 ++++----- tests/teaser.test.ts | 18 ++++---- 4 files changed, 82 insertions(+), 88 deletions(-) diff --git a/media/teaser/README.md b/media/teaser/README.md index 4659027b..33cc4535 100644 --- a/media/teaser/README.md +++ b/media/teaser/README.md @@ -1,31 +1,32 @@ -# storebound teaser (60 s, 16:9) +# storebound teaser (42 s, 16:9) A calm, scripted motion piece: from an empty folder to everything ready on both stores. Every frame is a pure function of time, rendered from an HTML/CSS/JS timeline in headless Chrome and encoded with ffmpeg. The music and the sound design are original and synthesized from scratch in the same browser (Web Audio `OfflineAudioContext`): no samples, no downloaded audio, nothing to license. -One idea per scene, 6-7 s each, one slow camera move per scene, soft dissolves between scenes. Each scene has one -plain-English caption at the top, fully on screen for at least 4 s; below it, the real product. +One idea per scene, 4-5 s each, one camera move per scene (a quick ease-out that settles before the cut), short +dissolves on the cuts, no whips or rapid montages. Long terminal output streams faster rather than being cut. Each scene +has one plain-English caption at the top, fully on screen for at least 3 s; below it, the real product. | s | shows | caption | |---|---|---| -| 0-6 | the demo game's icon, "Done"; the stores' to-do list line by line; one rejection mail (Guideline 2.1) | Your app is done. The stores are not. | -| 6-12 | an empty folder; `bunx storebound init` is typed; the files it creates list in | storebound takes it from an empty folder. | -| 12-19 | the prompt "Get my app ready for both stores."; `storebound release plan 1.0.0`: 25 steps in fix order | You ask once. It plans every step. | -| 19-26 | the demo game's store text in 4 languages; its renders in 7 store sizes x 4 languages | Store text and screenshots. Every language, every size. | -| 26-33 | `play products --dry` (174 regions), then `catalog diff` (175 / 174 region prices, 0 mismatches) | In-app products on both stores, priced in 175 countries. | -| 33-40 | the scan's declarations proposal: detected answers with file:line, one "ask owner" line highlighted; 764 Data safety answers | The forms, answered from your code. It asks what it can't know. | -| 40-47 | `storebound scan`: three findings, each with a plain reason; fixed, the re-scan is clean | It catches rejections before Apple does. | -| 47-54 | the desktop app: the release timeline with both stores on one track, then Store readiness: "No blockers" | Both stores, one view. Ready for review. | -| 54-60 | "Submit for Review" with the cursor resting on it (it never clicks), then the end card: storebound.dev, Open source · CLI · Desktop app | You press Submit. That's it. | +| 0-4.5 | the demo game's icon, "Done"; the stores' to-do list line by line; one rejection mail (Guideline 2.1) | Your app is done. The stores are not. | +| 4.5-9 | an empty folder; `bunx storebound init` is typed; the files it creates list in | storebound takes it from an empty folder. | +| 9-14 | the prompt "Get my app ready for both stores."; `storebound release plan 1.0.0`: 25 steps in fix order | You ask once. It plans every step. | +| 14-19 | the demo game's store text in 4 languages; its renders in 7 store sizes x 4 languages | Store text and screenshots. Every language, every size. | +| 19-23.5 | `play products --dry` (174 regions), then `catalog diff` (175 / 174 region prices, 0 mismatches) | In-app products on both stores, priced in 175 countries. | +| 23.5-28.5 | the scan's declarations proposal: detected answers with file:line, one "ask owner" line highlighted; 764 Data safety answers | The forms, answered from your code. It asks what it can't know. | +| 28.5-33.5 | `storebound scan`: three findings, each with a plain reason; fixed, the re-scan is clean | It catches rejections before Apple does. | +| 33.5-38 | the desktop app: the release timeline with both stores on one track, then Store readiness: "No blockers" | Both stores, one view. Ready for review. | +| 38-42 | "Submit for Review" with the cursor resting on it (it never clicks), then the end card: storebound.dev, Open source · CLI · Desktop app | You press Submit. That's it. | | file | what | |---|---| | `script.js` | the timeline: scenes in seconds, camera moves, captions, every line shown, the sound cues | | `desktop.ts` | the desktop frames: apps/desktop's Vite dev server in fixture mode (`VITE_FIXTURES=1`, example.com-style data), captured headlessly in dark at 1280x800 @2x with the dev markers hidden, plus `boxes.json` (callout targets) -> `out/desktop/` | | `index.html` + `teaser.js` | the picture; `window.teaser.seek(t)` sets every element for time `t` | -| `music.js` | calm music (D major, one chord per scene: pads, a slow soft pluck, a quiet sub) and soft sound design: a bell and an airy swell on each scene change, key clicks, quiet ticks, chimes for the fixes | +| `music.js` | music (D major, one chord per scene: pads, a slow soft pluck, a quiet sub) and soft sound design: a bell and an airy swell on each scene change, key clicks, quiet ticks, chimes for the fixes | | `render.ts` | frames at 60 fps blended to 30 fps -> ffmpeg (H.264 high, yuv420p), sound -> loudnorm (-16 LUFS, -1.5 dBTP), mux, poster, the 1280x720 web version | | `icons/` | the mouse cursor and the UI icons: Phosphor files copied unchanged by `bun tools/site-icons.ts` (no hand-written SVG; CI checks it) | @@ -44,7 +45,7 @@ clock prefix and the "(0s)" timer left out): The plain reasons under the findings and the callouts on the desktop frames are annotations, set apart from the CLI text. The store text is `examples/demo-game/store/shots/copy.json`, the screenshots its real renders, the app icon its `store/icon/icon.png`. The mail row is fictional: no real names or addresses, no mail-app branding. The test also checks -the timing: scenes 6-7 s, captions on screen at least 4 s, 55-65 s in total, 16:9 only. +the timing: scenes 4-5 s, captions on screen at least 3 s, 38-46 s in total, 16:9 only. ## Render @@ -54,7 +55,7 @@ game's store renders: ```sh cd examples/demo-game && bun serve.ts & bun ../../cli/index.ts shots capture && bun ../../cli/index.ts shots fonts && bun ../../cli/index.ts shots render # from the repo root -bun media/teaser/render.ts > media/teaser/out/render.log 2>&1 & # master, sound, poster, web version: about 15 min +bun media/teaser/render.ts > media/teaser/out/render.log 2>&1 & # master, sound, poster, web version: about 10 min bun media/teaser/render.ts --desktop # capture the desktop app frames again (after a UI change) bun media/teaser/render.ts --stills 2,12.5,30 # PNG stills in out/stills for a quick layout check bun media/teaser/render.ts --serve --port 8750 # live preview: /index.html?play=1 (or ?t=12.5) diff --git a/media/teaser/script.js b/media/teaser/script.js index beb0ffe1..a0c03772 100644 --- a/media/teaser/script.js +++ b/media/teaser/script.js @@ -1,7 +1,8 @@ -// Teaser timeline (v4): the single source of truth for the picture (teaser.js) and the sound (music.js). -// One idea per scene, 6-7 s each, one slow camera move per scene, soft dissolves between scenes (no whips, no rapid -// cuts). Every scene has one plain-English caption at the top that is fully on screen for at least 4 s; the lower part -// shows the real product: CLI output and desktop-app frames. +// Teaser timeline (v5): the single source of truth for the picture (teaser.js) and the sound (music.js). +// One idea per scene, 4-5 s each (about 42 s in all), one camera move per scene with a quick ease-out, short dissolves +// on the cuts (no whips, no rapid montages). Long terminal output streams faster instead of being cut. Every scene has +// one plain-English caption at the top that is fully on screen for at least 3 s; the lower part shows the real +// product: CLI output and desktop-app frames. // // Every CLI line shown here is real output; tests/teaser.test.ts runs each command and checks every line: // init `storebound init` in an empty folder (the clock prefix left out) @@ -20,24 +21,15 @@ export const FPS = 30; /** 16:9 only: the master; render.ts also makes the 1280x720 web version from it. */ export const FORMAT = { w: 1920, h: 1080 }; -/** Scenes in seconds. Each holds 6-7 s; the next one dissolves in over DISSOLVE s centred on the cut. */ -export const SCENES = [ - { id: 'hook', start: 0, end: 6 }, - { id: 'init', start: 6, end: 12 }, - { id: 'plan', start: 12, end: 19 }, - { id: 'store', start: 19, end: 26 }, - { id: 'products', start: 26, end: 33 }, - { id: 'forms', start: 33, end: 40 }, - { id: 'rejections', start: 40, end: 47 }, - { id: 'desktop', start: 47, end: 54 }, - { id: 'submit', start: 54, end: 60 }, -]; +/** Scene lengths in seconds (4-5 s each). The next scene dissolves in over DISSOLVE s centred on the cut. */ +const LENGTHS = [['hook', 4.5], ['init', 4.5], ['plan', 5], ['store', 5], ['products', 4.5], ['forms', 5], ['rejections', 5], ['desktop', 4.5], ['submit', 4]]; +export const SCENES = LENGTHS.reduce((a, [id, len]) => { const start = a.at(-1)?.end ?? 0; return [...a, { id, start, end: start + len }]; }, []); export const DURATION = SCENES.at(-1).end; -export const DISSOLVE = 0.6; +export const DISSOLVE = 0.4; export const scene = id => SCENES.find(s => s.id === id); /** - * One slow camera move per scene, over the whole scene: from -> to, eased in and out. + * One camera move per scene, over the whole scene: from -> to, a quick ease-out that settles before the cut. * z = zoom, x / y = pan in px (applied to the scene's content, never to the caption). */ export const CAMERA = { @@ -65,8 +57,8 @@ export const CAPTIONS = [ { id: 'submit', lines: ['You press *Submit.* That\'s it.'] }, ]; /** Caption fade: in over CAP_IN from CAP_DELAY after the scene starts; out over CAP_OUT, ending CAP_END before it ends. */ -export const CAP_DELAY = 0.15, CAP_IN = 0.4, CAP_OUT = 0.4, CAP_END = 0.1; -/** When each caption is fully on screen (tests: at least 4 s). */ +export const CAP_DELAY = 0.1, CAP_IN = 0.3, CAP_OUT = 0.3, CAP_END = 0.05; +/** When each caption is fully on screen (tests: at least 3 s). */ export function captionTimes() { return CAPTIONS.map(c => { const s = scene(c.id); @@ -79,20 +71,20 @@ export function captionTimes() { export const APP_NAME = 'Prism Puddle'; /** The stores' to-do list (line by line at reading speed). at = seconds into the scene. */ export const TODO = [ - { at: 0.6, text: '2 store consoles' }, - { at: 1.25, text: 'dozens of forms' }, - { at: 1.9, text: '7 screenshot sizes × 14 languages' }, - { at: 2.6, text: 'prices in 175 countries' }, + { at: 0.35, text: '2 store consoles' }, + { at: 0.7, text: 'dozens of forms' }, + { at: 1.05, text: '7 screenshot sizes × 14 languages' }, + { at: 1.4, text: 'prices in 175 countries' }, ]; /** A generic, made-up inbox row (no mail-app branding, no real names or addresses): fades in over MAIL_IN from `at`, * then holds to the cut. */ -export const MAIL_IN = 0.5; -export const MAIL = { at: 3.3, from: 'App Store Connect', date: '9:41 AM', subject: "There's an issue with your Prism Puddle submission", guideline: 'Guideline 2.1 · Information Needed' }; +export const MAIL_IN = 0.4; +export const MAIL = { at: 1.7, from: 'App Store Connect', date: '9:41 AM', subject: "There's an issue with your Prism Puddle submission", guideline: 'Guideline 2.1 · Information Needed' }; // ---------- 2 init: an empty folder, `storebound init` ---------- export const FOLDER = 'my-app'; export const INIT_CMD = 'bunx storebound init'; -export const INIT_TYPE_AT = 0.5, INIT_CPS = 13, INIT_OUT_AT = 2.5, INIT_STEP = 0.22; +export const INIT_TYPE_AT = 0.35, INIT_CPS = 22, INIT_OUT_AT = 1.45, INIT_STEP = 0.12; /** Real output of `storebound init` (clock prefix left out). file = the file the line creates (the folder list). */ export const INIT_LINES = [ '[init] create storebound.config.ts', @@ -109,9 +101,9 @@ export const INIT_LINES = [ // ---------- 3 plan: the agent prompt, `storebound release plan` ---------- export const PROMPT = 'Get my app ready for both stores.'; -export const PROMPT_AT = 0.3, PROMPT_CPS = 26; +export const PROMPT_AT = 0.2, PROMPT_CPS = 40; export const PLAN_CMD = 'storebound release plan 1.0.0'; -export const PLAN_CMD_AT = 1.9, PLAN_AT = 2.3, PLAN_STEP = 0.2; +export const PLAN_CMD_AT = 1.25, PLAN_AT = 1.55, PLAN_STEP = 0.13; /** Real lines of the plan (a brand-new app record on both stores); the "-> fix" lines and some steps left out. */ export const PLAN_LINES = [ 'Example App 1.0.0', @@ -139,7 +131,7 @@ export const COPY = [ { lang: 'ja', title: ['カラフルなしずくを', 'キャッチ!'] }, { lang: 'ar', title: ['التقط كل', 'قطرة ملوّنة!'], rtl: true }, ]; -export const COPY_AT = 0.5, COPY_STEP = 0.5; +export const COPY_AT = 0.3, COPY_STEP = 0.3; /** The demo game's renders, one column per store size (cli/shots/lib.ts SIZES), one row per language. */ export const SHOT_SIZES = [ { id: 'ios69', label: 'iPhone\n6.9″' }, @@ -151,25 +143,25 @@ export const SHOT_SIZES = [ { id: 'feature', label: 'Play\nfeature graphic' }, ]; export const SHOT_LANGS = COPY.map(c => c.lang); -export const SHOTS_AT = 0.9, SHOTS_STEP = 0.38; +export const SHOTS_AT = 0.6, SHOTS_STEP = 0.25; export const SHOTS_CMD = 'storebound shots render'; export const SHOTS_PILL = `*${SHOT_SIZES.length}* sizes × *${COPY.length}* languages`; // ---------- 5 products: `play products --dry`, then `catalog diff` ---------- /** Real output (clock prefix and the "(0s)" timer left out). at = seconds into the scene. */ export const PRODUCT_LINES = [ - { at: 0.4, text: '$ storebound play products --dry', cmd: true }, - { at: 0.9, text: '[play] 1/2 com.example.app.no_ads: would create · 174 regions · 2 listings (dry)' }, - { at: 1.2, text: '[play] 2/2 com.example.app.gems_100: would create · 174 regions · 2 listings (dry)' }, - { at: 1.5, text: '[play] products checked (dry run, nothing written)' }, - { at: 2.2, text: '$ storebound catalog diff', cmd: true }, - { at: 2.7, text: 'ok [apple] com.example.app.gems_100: consumable, 175 region prices, READY_TO_SUBMIT' }, - { at: 3.0, text: 'ok [play] com.example.app.gems_100: consumable, 174 region prices, ACTIVE' }, - { at: 3.3, text: 'ok [apple] com.example.app.no_ads: non_consumable, 175 region prices, READY_TO_SUBMIT' }, - { at: 3.6, text: 'ok [play] com.example.app.no_ads: non_consumable, 174 region prices, ACTIVE' }, - { at: 4.0, text: '[catalog] 2 catalog items: 0 mismatch(es), 0 warning(s), 0 price difference(s) between the stores' }, + { at: 0.3, text: '$ storebound play products --dry', cmd: true }, + { at: 0.6, text: '[play] 1/2 com.example.app.no_ads: would create · 174 regions · 2 listings (dry)' }, + { at: 0.8, text: '[play] 2/2 com.example.app.gems_100: would create · 174 regions · 2 listings (dry)' }, + { at: 1.0, text: '[play] products checked (dry run, nothing written)' }, + { at: 1.35, text: '$ storebound catalog diff', cmd: true }, + { at: 1.65, text: 'ok [apple] com.example.app.gems_100: consumable, 175 region prices, READY_TO_SUBMIT' }, + { at: 1.85, text: 'ok [play] com.example.app.gems_100: consumable, 174 region prices, ACTIVE' }, + { at: 2.05, text: 'ok [apple] com.example.app.no_ads: non_consumable, 175 region prices, READY_TO_SUBMIT' }, + { at: 2.25, text: 'ok [play] com.example.app.no_ads: non_consumable, 174 region prices, ACTIVE' }, + { at: 2.5, text: '[catalog] 2 catalog items: 0 mismatch(es), 0 warning(s), 0 price difference(s) between the stores' }, ]; -export const PRODUCTS_PILL = { at: 4.5, text: '*175* App Store regions · *174* Google Play regions · parity *✓*' }; +export const PRODUCTS_PILL = { at: 2.9, text: '*175* App Store regions · *174* Google Play regions · parity *✓*' }; // ---------- 6 forms: the declarations proposal from the scan, then the Data safety answers ---------- /** Real lines of the proposal (scan of the teaser fixture). */ @@ -180,45 +172,45 @@ export const DECL_LINES = [ { what: 'PSL_USER_ACCOUNT', value: 'collect: account, functionality', where: 'Podfile.lock:3' }, ]; export const DECL_ASK = 'ask owner encryptedInTransit: ? · all traffic over HTTPS / TLS?'; -export const DECL_AT = 0.5, DECL_STEP = 0.4, ASK_AT = 2.3; +export const DECL_AT = 0.4, DECL_STEP = 0.25, ASK_AT = 1.5; /** Play Data safety form rows the detected answers fill (Play's own labels for the PSL_* types above and the rest). */ export const DATA_SAFETY_ROWS = ['Device or other IDs', 'Approximate location', 'App interactions', 'Diagnostics', 'Name', 'Email address', 'User IDs']; -export const FORM_AT = 2.9, FORM_STEP = 0.2; +export const FORM_AT = 1.9, FORM_STEP = 0.14; /** Data safety CSV rows `storebound check` builds from the config. */ export const DECL_TOTAL = 764; -export const FORMS_PILL = { at: 4.5, text: 'Data safety answers' }; +export const FORMS_PILL = { at: 3.0, text: 'Data safety answers' }; // ---------- 7 rejections: three findings with a plain reason each, then fixed ---------- export const SCAN_CMD = 'storebound scan'; export const RISKS_LINE = 'Rejection risks: 2 blocker, 3 high, 0 medium, 0 low'; /** Three of the five findings (real text); why = a plain-English annotation, not CLI output. */ export const FINDINGS = [ - { at: 1.1, sev: 'BLOCKER', guideline: '2.1(a)', title: 'Sign-in is required but there is no demo account for App Review', where: 'storebound.config.ts:12', + { at: 0.8, sev: 'BLOCKER', guideline: '2.1(a)', title: 'Sign-in is required but there is no demo account for App Review', where: 'storebound.config.ts:12', why: 'Apple rejects sign-in apps without a demo account.' }, - { at: 1.9, sev: 'BLOCKER', guideline: '5.1.1(v)', title: 'Accounts can be created but no in-app account deletion was found', where: 'Planner/LoginView.swift:11', + { at: 1.3, sev: 'BLOCKER', guideline: '5.1.1(v)', title: 'Accounts can be created but no in-app account deletion was found', where: 'Planner/LoginView.swift:11', why: 'Apps that create accounts must let people delete them.' }, - { at: 2.7, sev: 'HIGH', guideline: '5.1.2(i)', title: 'Tracking-capable code without App Tracking Transparency (Google AdMob, IDFA)', where: 'Planner/Ads.swift:7', + { at: 1.8, sev: 'HIGH', guideline: '5.1.2(i)', title: 'Tracking-capable code without App Tracking Transparency (Google AdMob, IDFA)', where: 'Planner/Ads.swift:7', why: 'Ads that track people must ask permission first.' }, ]; /** Each finding turns green (fixed), then the re-scan of the fixed copy (tests/fixtures/scan/teaser-fixed). */ -export const FIX_AT = [4.0, 4.35, 4.7]; -export const RESCAN_AT = 5.2; +export const FIX_AT = [2.7, 2.95, 3.2]; +export const RESCAN_AT = 3.6; export const RESCAN_LINE = 'Rejection risks: 0 blocker, 0 high, 0 medium, 0 low'; // ---------- 8 desktop: the release timeline (both stores), then Store readiness: no blockers ---------- /** Real frames (desktop.ts). The camera pushes from the timeline to the readiness card; the frames dissolve between. */ export const DESKTOP = { frames: ['releases', 'ready'], - swap: [3.1, 3.8], + swap: [2.1, 2.6], cam: { from: { f: [0.56, 0.42], z: 1.0 }, to: { f: [0.8, 0.4], z: 1.22 } }, callouts: [ - { at: 1.1, until: 3.0, target: 'timeline', text: 'App Store + Google Play, one track' }, - { at: 4.3, until: 7, target: 'readyEmpty', text: 'Validate: 0 blockers on both', green: true }, + { at: 0.7, until: 2.0, target: 'timeline', text: 'App Store + Google Play, one track' }, + { at: 2.9, until: 5, target: 'readyEmpty', text: 'Validate: 0 blockers on both', green: true }, ], }; // ---------- 9 submit + end card ---------- -export const SUBMIT = { hover: 1.5, logoAt: 3.0, logoIn: 0.8 }; +export const SUBMIT = { hover: 1.0, logoAt: 2.0, logoIn: 0.6 }; export const URL = 'storebound.dev'; export const TAGLINE = 'Open source · CLI · Desktop app'; diff --git a/media/teaser/teaser.js b/media/teaser/teaser.js index a1457bcf..cf988969 100644 --- a/media/teaser/teaser.js +++ b/media/teaser/teaser.js @@ -1,4 +1,4 @@ -// Teaser picture (v4): every element is set from the time t alone (window.teaser.seek(t)), so frames render +// Teaser picture (v5): every element is set from the time t alone (window.teaser.seek(t)), so frames render // deterministically, in any order. 16:9 only (1920x1080). URL: &t=12.5 holds a frame, &play=1 previews in real time. import { APP_NAME, ASK_AT, CAMERA, CAP_DELAY, CAP_END, CAP_IN, CAP_OUT, CAPTIONS, captionTimes, COPY, COPY_AT, COPY_FILE, COPY_STEP, DATA_SAFETY_ROWS, DECL_ASK, DECL_AT, DECL_LINES, DECL_STEP, DECL_TOTAL, DESKTOP, DISSOLVE, DURATION, FINDINGS, FIX_AT, FOLDER, @@ -18,7 +18,8 @@ const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x)); const prog = (t, a, d) => (d <= 0 ? (t >= a ? 1 : 0) : clamp((t - a) / d)); const eoc = p => 1 - Math.pow(1 - p, 3); const eio = p => (p < 0.5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2); -const ess = p => p * p * (3 - 2 * p); // smoothstep: the slow camera moves +/** The camera: a quick ease-out (quartic) that settles at 80% of the scene, so each move reads snappy, then rests. */ +const ecam = p => 1 - Math.pow(1 - clamp(p / 0.8), 4); const lerp = (a, b, p) => a + (b - a) * p; const esc = s => String(s).replace(/&/g, '&').replace(//g, '>'); const set = (el, k, v) => { if (el.__s?.[k] !== v) { (el.__s ??= {})[k] = v; el.style[k] = v; } }; @@ -38,7 +39,7 @@ function pillAt(el, t, at, base = 'translate(-50%, 0)') { set(el, 'transform', `${base} translateY(${((1 - eoc(p)) * 16).toFixed(1)}px)`); } -// ---------- scenes: dissolves and one slow camera move each ---------- +// ---------- scenes: dissolves and one camera move each ---------- const sceneEls = Object.fromEntries(SCENES.map(s => [s.id, { el: $(`#s-${s.id}`), cam: $(`#s-${s.id} > .cam`) }])); function scenes(t) { SCENES.forEach((s, i) => { @@ -48,7 +49,7 @@ function scenes(t) { set(el, 'visibility', 'visible'); set(el, 'opacity', String(i === 0 ? 1 : eio(prog(t, from, DISSOLVE)))); const c = CAMERA[s.id]; - const p = ess(clamp((t - (s.start - DISSOLVE / 2)) / (s.end - s.start + DISSOLVE))); + const p = ecam(clamp((t - (s.start - DISSOLVE / 2)) / (s.end - s.start + DISSOLVE))); const z = lerp(c.from.z, c.to.z, p), x = lerp(c.from.x, c.to.x, p), y = lerp(c.from.y, c.to.y, p); set(cam, 'transform', `translate(${x.toFixed(2)}px, ${y.toFixed(2)}px) scale(${z.toFixed(5)})`); }); @@ -99,8 +100,8 @@ mailEl.querySelector('.prev').innerHTML = `Hello, Thank you for submitting your function hook(t) { const s = scene('hook'); if (t > s.end + 1) return; const r = t - s.start; - appear(appcard, r, 0.1, 0.5, 20); - appear($('#todo'), r, 0.35, 0.45, 20); + appear(appcard, r, 0.05, 0.4, 20); + appear($('#todo'), r, 0.2, 0.4, 20); todoEls.forEach((el, i) => appear(el, r, TODO[i].at, 0.4, 10)); const p = prog(r, MAIL.at, MAIL_IN); set(mailEl, 'opacity', String(eoc(p))); @@ -258,7 +259,7 @@ function forms(t) { set(el.querySelector('.tg'), 'opacity', String(p)); set(el, 'color', p > 0.5 ? '#fff' : 'var(--ink-2)'); }); - const np = prog(r, FORMS_PILL.at, 1.0); + const np = prog(r, FORMS_PILL.at, 0.8); html(formsPill, `${Math.round(DECL_TOTAL * eoc(np))} ${esc(FORMS_PILL.text)}`); pillAt(formsPill, r, FORMS_PILL.at); } @@ -277,8 +278,8 @@ function rejections(t) { const s = scene('rejections'); if (t < s.start - 1 || t > s.end + 1) return; const r = t - s.start; appear($('#scanterm'), r, 0.0, 0.4, 14); - appear(scanLns[0], r, 0.25, 0.25, 4); - appear(scanLns[1], r, 0.6, 0.3, 6); + appear(scanLns[0], r, 0.2, 0.25, 4); + appear(scanLns[1], r, 0.45, 0.3, 6); fdEls.forEach((el, i) => { appear(el, r, FINDINGS[i].at, 0.4, 10); const f = prog(r, FIX_AT[i], 0.45); @@ -306,7 +307,7 @@ const cam2 = $('#s-desktop .cam2'), frameEls = [...cam2.querySelectorAll('img')] const rings = [...deskCam.querySelectorAll('.ring')], callouts = [...deskCam.querySelectorAll('.callout')]; function deskView(r) { const s = scene('desktop'), len = s.end - s.start; - const p = ess(clamp((r + DISSOLVE / 2) / (len + DISSOLVE))); + const p = ecam(clamp((r + DISSOLVE / 2) / (len + DISSOLVE))); const { from, to } = DESKTOP.cam; const S = S0 * lerp(from.z, to.z, p), fx = lerp(from.f[0], to.f[0], p), fy = lerp(from.f[1], to.f[1], p); const ox = clamp(VIEW.w / 2 - fx * 1280 * S, VIEW.w - 1280 * S, 0), oy = clamp(VIEW.h / 2 - fy * 800 * S, VIEW.h - 800 * S, 0); diff --git a/tests/teaser.test.ts b/tests/teaser.test.ts index c6f6dd9f..cdad7cfa 100644 --- a/tests/teaser.test.ts +++ b/tests/teaser.test.ts @@ -1,5 +1,5 @@ -// The teaser video (media/teaser, v4): every CLI line it shows is real output of the command it names, each scene holds -// 6-7 s, each caption is fully on screen for at least 4 s, the whole cut is 55-65 s, and it is 16:9 only. +// The teaser video (media/teaser, v5): every CLI line it shows is real output of the command it names, each scene holds +// 4-5 s, each caption is fully on screen for at least 3 s, the whole cut is 38-46 s, and it is 16:9 only. import { afterAll, beforeAll, describe, expect, test } from 'bun:test'; import { generateKeyPairSync } from 'node:crypto'; import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; @@ -156,23 +156,23 @@ describe('teaser: timing and format', () => { expect(render).not.toMatch(/1080\s*x\s*1920|w: 1080, h: 1920|vertical/i); expect(render).toContain('scale=1280:720'); }); - test('scenes are contiguous, 6-7 s each, 55-65 s in total', () => { + test('scenes are contiguous, 4-5 s each, 38-46 s in total', () => { expect(T.SCENES[0]!.start).toBe(0); for (let i = 1; i < T.SCENES.length; i++) expect(T.SCENES[i]!.start).toBe(T.SCENES[i - 1]!.end); for (const s of T.SCENES) { - expect(s.end - s.start, s.id).toBeGreaterThanOrEqual(6); - expect(s.end - s.start, s.id).toBeLessThanOrEqual(7); + expect(s.end - s.start, s.id).toBeGreaterThanOrEqual(4); + expect(s.end - s.start, s.id).toBeLessThanOrEqual(5); } expect(T.DURATION).toBe(T.SCENES.at(-1)!.end); - expect(T.DURATION).toBeGreaterThanOrEqual(55); - expect(T.DURATION).toBeLessThanOrEqual(65); + expect(T.DURATION).toBeGreaterThanOrEqual(38); + expect(T.DURATION).toBeLessThanOrEqual(46); }); - test('one caption per scene, fully on screen for at least 4 s, inside its scene', () => { + test('one caption per scene, fully on screen for at least 3 s, inside its scene', () => { const c = T.captionTimes(); expect(c.map(x => x.id)).toEqual(T.SCENES.map(s => s.id)); for (const x of c) { const s = T.SCENES.find(y => y.id === x.id)!; - expect(x.hold, x.text).toBeGreaterThanOrEqual(4); + expect(x.hold, x.text).toBeGreaterThanOrEqual(3); expect(x.at).toBeGreaterThanOrEqual(s.start); expect(x.to).toBeLessThanOrEqual(s.end); } From 6c6e29a11b058efd092289a47de4367f29155f69 Mon Sep 17 00:00:00 2001 From: CRT Date: Sun, 11 Oct 2026 18:03:07 +0000 Subject: [PATCH 2/4] scan: accounts mean User ID, never email without evidence; accounts.signUp (username -> PSL_ACM_USER_ID_OTHER_AUTH); built bundles are low-trust evidence; privacy-manifest and scan find plugins in monorepo node_modules, workspaces and local SwiftPM packages --- .gitignore | 3 + CHANGELOG.md | 13 ++ cli/lib/config.ts | 13 ++ cli/lib/declarations.ts | 40 +++++- cli/lib/node-packages.ts | 132 ++++++++++++++++++ cli/lib/profile.ts | 6 +- cli/lib/scan/declare.ts | 53 +++++-- cli/lib/scan/index.ts | 3 +- cli/lib/scan/project.ts | 58 +++++++- cli/lib/scan/rules.ts | 9 +- cli/lib/scan/sdks.ts | 2 +- cli/mcp-tools.ts | 2 +- cli/privacy-manifest.ts | 23 ++- cli/scan.ts | 4 +- skills/account-deletion/SKILL.md | 7 +- skills/privacy-manifest/SKILL.md | 8 +- skills/store-declarations/SKILL.md | 6 + templates/profiles/app/storebound.config.ts | 4 + .../subscription-app/storebound.config.ts | 4 + templates/storebound.config.ts | 3 + .../scan/android/storebound.config.ts | 2 +- tests/fixtures/scan/monorepo/README.md | 8 ++ .../scan/monorepo/apps/game/package.json | 7 + .../scan/monorepo/apps/game/src/account.ts | 9 ++ .../monorepo/apps/native/capacitor.config.ts | 8 ++ .../ios/App/App.xcodeproj/project.pbxproj | 7 + .../apps/native/ios/App/App/AppDelegate.swift | 7 + .../apps/native/ios/App/App/Info.plist | 10 ++ .../native/ios/App/CapApp-SPM/Package.swift | 12 ++ .../capacitor-haptics/ExampleHaptics.podspec | 7 + .../ios/Sources/PrivacyInfo.xcprivacy | 10 ++ .../@example/capacitor-haptics/package.json | 4 + .../ExampleAdsPlugin.podspec | 7 + .../example-ads-plugin/Package.swift | 11 ++ .../example-ads-plugin/android/build.gradle | 3 + .../ios/Sources/ExampleAdsPlugin/Plugin.swift | 4 + .../example-ads-plugin/package.json | 4 + .../scan/monorepo/apps/native/package.json | 10 ++ .../apps/native/web/bundle/routes-AbC12345.js | 1 + .../apps/native/web/bundle/vendor-XyZ98765.js | 1 + tests/fixtures/scan/monorepo/package.json | 8 ++ .../monorepo/packages/shared/package.json | 4 + .../monorepo/packages/shared/src/routes.ts | 8 ++ .../scan/monorepo/storebound.config.ts | 30 ++++ tests/scan.test.ts | 88 +++++++++++- 45 files changed, 625 insertions(+), 38 deletions(-) create mode 100644 cli/lib/node-packages.ts create mode 100644 tests/fixtures/scan/monorepo/README.md create mode 100644 tests/fixtures/scan/monorepo/apps/game/package.json create mode 100644 tests/fixtures/scan/monorepo/apps/game/src/account.ts create mode 100644 tests/fixtures/scan/monorepo/apps/native/capacitor.config.ts create mode 100644 tests/fixtures/scan/monorepo/apps/native/ios/App/App.xcodeproj/project.pbxproj create mode 100644 tests/fixtures/scan/monorepo/apps/native/ios/App/App/AppDelegate.swift create mode 100644 tests/fixtures/scan/monorepo/apps/native/ios/App/App/Info.plist create mode 100644 tests/fixtures/scan/monorepo/apps/native/ios/App/CapApp-SPM/Package.swift create mode 100644 tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/ExampleHaptics.podspec create mode 100644 tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/ios/Sources/PrivacyInfo.xcprivacy create mode 100644 tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/package.json create mode 100644 tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/ExampleAdsPlugin.podspec create mode 100644 tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/Package.swift create mode 100644 tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/android/build.gradle create mode 100644 tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/ios/Sources/ExampleAdsPlugin/Plugin.swift create mode 100644 tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/package.json create mode 100644 tests/fixtures/scan/monorepo/apps/native/package.json create mode 100644 tests/fixtures/scan/monorepo/apps/native/web/bundle/routes-AbC12345.js create mode 100644 tests/fixtures/scan/monorepo/apps/native/web/bundle/vendor-XyZ98765.js create mode 100644 tests/fixtures/scan/monorepo/package.json create mode 100644 tests/fixtures/scan/monorepo/packages/shared/package.json create mode 100644 tests/fixtures/scan/monorepo/packages/shared/src/routes.ts create mode 100644 tests/fixtures/scan/monorepo/storebound.config.ts diff --git a/.gitignore b/.gitignore index 3995e6c0..0187f25b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ apps/desktop/src-tauri/binaries/ apps/desktop/src-tauri/gen/ apps/desktop/.screens/ .scratch/ + +# scan fixtures: a monorepo whose Capacitor plugins live in apps/native/node_modules +!tests/fixtures/scan/monorepo/apps/native/node_modules/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 32c3ed2e..c603030f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ ## Unreleased +- Fixes from a live monorepo game (username accounts, Capacitor in `apps/native`): + - `scan` no longer turns accounts into "Email Address" / `PSL_EMAIL`: accounts mean User ID; email is "detected" + only with real evidence (an email field or keyboard, an `email` property in a body / schema / type, an email + validation or endpoint, an email sign-in call, an SDK that collects it, or `accounts.signUp`), otherwise a question. + - New `accounts.signUp` (`username`, `username-password`, `email-password`, `email-link`, `phone`, `oauth`, `other`): + `scan` proposes the account data and `dataSafety.accountCreation` from it (`scan --write` writes it); a username + with no password is Play's "Username and other authentication" (`PSL_ACM_USER_ID_OTHER_AUTH`). + - Built output (bundles, dist / build, the Capacitor webDir, minified files) is low-trust evidence: `scan` prefers + the own sources and `*.test.*` / `*.spec.*` files are no longer app sources. + - `privacy-manifest --ios` finds Capacitor / Cordova / React Native plugins without `--sdk-dirs`: node_modules next to + the app's package.json and above it, workspace packages, local SwiftPM packages (CapApp-SPM), nested Pods. + - `scan` reads the native dependencies behind each npm plugin (its podspec, Package.swift, android/build.gradle), so an + ad SDK wrapped in a Capacitor plugin (Unity LevelPlay) is detected; LevelPlay's Swift package is matched too. - `storebound flow list | validate | run `: repo-local workflows in `store/workflows/*.yml` (or `storebound.workflows.yml|json|ts`): named steps run in order with progress, `${VAR}` params and captures, `if:` conditions, sub-flows, before / after / onError hooks. Writes run as dry runs unless `--apply`; owner steps (submit, diff --git a/cli/lib/config.ts b/cli/lib/config.ts index e0ab4b5b..025b179b 100644 --- a/cli/lib/config.ts +++ b/cli/lib/config.ts @@ -300,8 +300,19 @@ export interface AccountsConfig { deletionUrl?: string; /** Where deletion starts inside the app, e.g. "Settings > Account > Delete account" (goes into the review notes). */ inApp?: string; + /** + * How people sign up. Decides which account data `storebound scan` proposes and the Play Data safety "Account + * creation" answer it suggests for dataSafety.accountCreation (ACCOUNT_SIGN_UP in declarations.ts): + * 'username' = a username or player name picked in the app with no password and no email (the server keeps a token on + * the device), 'username-password', 'email-password', 'email-link' (magic link / one-time code by email), 'phone' + * (SMS code), 'oauth' (Sign in with Apple / Google / Facebook ...), 'other'. Only 'email-*' means an email address. + */ + signUp?: AccountSignUp[]; } +export type AccountSignUp = 'username' | 'username-password' | 'email-password' | 'email-link' | 'phone' | 'oauth' | 'other'; +export const ACCOUNT_SIGN_UPS: readonly AccountSignUp[] = ['username', 'username-password', 'email-password', 'email-link', 'phone', 'oauth', 'other']; + /** How a reviewer gets past a sign-in (App Review demo account, Play App content > App access). The credentials * themselves are never in the config: "reviewDemoAccount" in .storebound/credentials.json or REVIEW_DEMO_USER / * REVIEW_DEMO_PASSWORD. See the review-access skill. */ @@ -712,6 +723,8 @@ export function validateConfig(c: unknown): string[] { if (cfg.accounts) { if (typeof cfg.accounts.enabled !== 'boolean') e.push('accounts.enabled: true | false'); if (cfg.accounts.deletionUrl !== undefined && !URL_RE.test(cfg.accounts.deletionUrl)) e.push('accounts.deletionUrl: must be an https URL'); + if (cfg.accounts.signUp !== undefined && (!Array.isArray(cfg.accounts.signUp) || cfg.accounts.signUp.some(x => !ACCOUNT_SIGN_UPS.includes(x)))) + e.push(`accounts.signUp: a list of ${ACCOUNT_SIGN_UPS.map(x => `'${x}'`).join(' | ')}`); } if (cfg.reviewAccess && typeof cfg.reviewAccess.signInRequired !== 'boolean') e.push('reviewAccess.signInRequired: true | false'); const langs = cfg.languages; diff --git a/cli/lib/declarations.ts b/cli/lib/declarations.ts index ed59615b..1ee4e692 100644 --- a/cli/lib/declarations.ts +++ b/cli/lib/declarations.ts @@ -5,7 +5,7 @@ // content rights), the export compliance answer and the App Review details (presence only, masked). Every answer the // config does not prove is an "ask the owner" item, never a guess (AGENTS.md rule 5). Pure. import { parseCsv } from './csv'; -import { type DataSafety, type PlayPurpose, profileOf, type ShipConfig } from './config'; +import { type AccountSignUp, type DataSafety, type PlayPurpose, profileOf, type ShipConfig } from './config'; import { CATEGORIES, dataSafetyCsv } from './data-safety'; import type { DeclarationsResult, DeclAsk } from './desktop-protocol'; import { NOTES_MAX_BYTES, reviewNotes } from './review-details'; @@ -13,6 +13,42 @@ import { NOTES_MAX_BYTES, reviewNotes } from './review-details'; /** Where `storebound play data-safety` keeps the CSV it uploaded last (gitignored). */ export const DATA_SAFETY_UPLOADED = '.storebound/data-safety.uploaded.csv'; +/** + * Play Data safety "Account creation" (question PSL_SUPPORTED_ACCOUNT_CREATION_METHODS): the options Play Console + * shows (Data safety > Data collection and security > Account creation) and the response ids storebound writes. + * Google publishes no list of these ids (README "Not verified"): compare with a Console export (App content > Data + * safety > Export to CSV) when an import is refused. + */ +export const ACCOUNT_CREATION: Record = { + PSL_ACM_USER_ID_PASSWORD: 'Username and password', + PSL_ACM_USER_ID_OTHER_AUTH: 'Username and other authentication', + PSL_ACM_USER_ID_PASSWORD_OTHER_AUTH: 'Username, password and other authentication', + PSL_ACM_OAUTH: 'OAuth', + PSL_ACM_OTHER: 'Other', + PSL_ACM_NONE: 'My app does not allow users to create an account', +}; + +/** + * accounts.signUp -> the closest Play "Account creation" option and the account data it means (Play type ids). + * A username with no password and a server token kept on the device is "Username and other authentication" (the + * token is the other authentication; there is no "username only" option): User ID, and no email. + */ +export const ACCOUNT_SIGN_UP: Record = { + username: { acm: 'PSL_ACM_USER_ID_OTHER_AUTH', data: ['PSL_USER_ACCOUNT'] }, + 'username-password': { acm: 'PSL_ACM_USER_ID_PASSWORD', data: ['PSL_USER_ACCOUNT'] }, + 'email-password': { acm: 'PSL_ACM_USER_ID_PASSWORD', data: ['PSL_EMAIL', 'PSL_USER_ACCOUNT'] }, + 'email-link': { acm: 'PSL_ACM_USER_ID_OTHER_AUTH', data: ['PSL_EMAIL', 'PSL_USER_ACCOUNT'] }, + phone: { acm: 'PSL_ACM_USER_ID_OTHER_AUTH', data: ['PSL_PHONE', 'PSL_USER_ACCOUNT'] }, + oauth: { acm: 'PSL_ACM_OAUTH', data: ['PSL_USER_ACCOUNT'] }, + other: { acm: 'PSL_ACM_OTHER', data: ['PSL_USER_ACCOUNT'] }, +}; + +/** The accountCreation answer accounts.signUp implies (null when signUp is not set). */ +export function accountCreationOf(signUp: readonly AccountSignUp[] | undefined): string[] | null { + if (!signUp?.length) return null; + return [...new Set(signUp.map(s => ACCOUNT_SIGN_UP[s]?.acm).filter((x): x is string => !!x))]; +} + /** Play data type -> the App Store App Privacy data type it usually is (Apple's own names). */ export const APPLE_PRIVACY: Record = { PSL_NAME: ['Contact Info', 'Name'], PSL_EMAIL: ['Contact Info', 'Email Address'], PSL_PHONE: ['Contact Info', 'Phone Number'], @@ -88,7 +124,7 @@ export function declarations(config: ShipConfig, inp: DeclarationInputs): Declar if (ds.collectsData && !types.length) ask.push({ area: 'dataSafety', id: 'ds-no-types', text: 'collectsData is true but no data type is listed.', fix: 'List each data type the app or its SDKs collect in dataSafety.data, or set collectsData: false if nothing is.' }); if (!ds.collectsData && types.length) ask.push({ area: 'dataSafety', id: 'ds-contradiction', text: 'collectsData is false but data types are listed.', fix: 'Decide which is true; Play rejects a form that says both.' }); if (profile === 'game' && !ds.data.PSL_DEVICE_ID) ask.push({ area: 'dataSafety', id: 'ds-ads-id', text: 'A game profile usually ships an ads or analytics SDK that reads the advertising id, but PSL_DEVICE_ID is not declared.', fix: 'Check every SDK\'s data disclosure; declare PSL_DEVICE_ID (advertising, analytics) if any reads it.' }); - if (config.accounts?.enabled && (ds.accountCreation ?? ['PSL_ACM_NONE']).includes('PSL_ACM_NONE')) ask.push({ area: 'dataSafety', id: 'ds-accounts', text: 'The app has accounts, but the form says no account creation.', fix: 'Set dataSafety.accountCreation to the methods the app offers, and the delete-account URL in dataSafety.extra.' }); + if (config.accounts?.enabled && (ds.accountCreation ?? ['PSL_ACM_NONE']).includes('PSL_ACM_NONE')) ask.push({ area: 'dataSafety', id: 'ds-accounts', text: 'The app has accounts, but the form says no account creation.', fix: `Set dataSafety.accountCreation to the methods the app offers${accountCreationOf(config.accounts.signUp) ? ` (accounts.signUp means ${JSON.stringify(accountCreationOf(config.accounts.signUp))})` : ' (or set accounts.signUp and run storebound scan)'}, and the delete-account URL in dataSafety.extra.` }); if (!ds.deletionRequest && config.accounts?.enabled) ask.push({ area: 'dataSafety', id: 'ds-deletion', text: 'Users can create accounts but deletionRequest is false.', fix: 'Both stores want account deletion (account-deletion skill); then set deletionRequest: true.' }); } diff --git a/cli/lib/node-packages.ts b/cli/lib/node-packages.ts new file mode 100644 index 00000000..ac44c791 --- /dev/null +++ b/cli/lib/node-packages.ts @@ -0,0 +1,132 @@ +// Where a JS project's native plugins (Capacitor, Cordova, React Native) live, also in monorepos: Node's own lookup +// (node_modules next to the app's package.json and in every folder above it, up to the repo root), workspace package +// folders (package.json "workspaces", npm / yarn / pnpm-style array or { packages }, as Bun reads them) and local +// SwiftPM packages (`.package(path:)` in a Package.swift, e.g. Capacitor 8's CapApp-SPM). Used by `privacy-manifest` +// and `scan`. Read-only; never throws. +import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs'; +import { dirname, join, resolve } from 'node:path'; + +interface PkgJson { name?: string; dependencies?: Record; workspaces?: string[] | { packages?: string[] } } +const readJson = (p: string): PkgJson | null => { try { return JSON.parse(readFileSync(p, 'utf8')) as PkgJson; } catch { return null; } }; +const isDir = (p: string): boolean => { try { return statSync(p).isDirectory(); } catch { return false; } }; +const real = (p: string): string => { try { return realpathSync(p); } catch { return resolve(p); } }; + +/** The repo root at or above `dir`: the nearest folder with .git, else the top-most package.json with workspaces, + * else `dir` itself. */ +export function repoRoot(dir: string): string { + let ws: string | null = null; + for (let d = resolve(dir); ; d = dirname(d)) { + if (existsSync(join(d, '.git'))) return d; + if (readJson(join(d, 'package.json'))?.workspaces) ws = d; + if (dirname(d) === d) return ws ?? resolve(dir); + } +} + +/** Workspace package folders of a repo root ("apps/*", "packages/**" one level deep, or literal folders). */ +export function workspaceDirs(root: string): string[] { + const w = readJson(join(root, 'package.json'))?.workspaces; + const pats = Array.isArray(w) ? w : Array.isArray(w?.packages) ? w.packages : []; + const out: string[] = []; + for (const p of pats) { + if (typeof p !== 'string' || p.startsWith('!')) continue; + const m = /^(.*?)\/\*\*?$/.exec(p); + if (m) { + const base = join(root, m[1]!); + let names: string[] = []; + try { names = readdirSync(base).sort(); } catch { /* missing */ } + for (const n of names) if (existsSync(join(base, n, 'package.json'))) out.push(join(base, n)); + } else if (!p.includes('*') && existsSync(join(root, p, 'package.json'))) out.push(join(root, p)); + } + return out; +} + +/** Folder of package `name` as Node resolves it from `fromDir` (node_modules there and in every parent up to `root`), + * else the workspace package of that name. */ +export function resolvePackage(name: string, fromDir: string, root: string): string | null { + const top = resolve(root); + for (let d = resolve(fromDir); ; d = dirname(d)) { + const p = join(d, 'node_modules', name); + if (existsSync(join(p, 'package.json'))) return p; + if (d === top || dirname(d) === d) break; + } + for (const w of workspaceDirs(top)) if (readJson(join(w, 'package.json'))?.name === name) return w; + return null; +} + +/** The package has native iOS code: a podspec or Package.swift at its root, or an ios/ folder. */ +export function hasNativeIos(dir: string): boolean { + let names: string[] = []; + try { names = readdirSync(dir); } catch { return false; } + return names.some(n => n.endsWith('.podspec') || n === 'Package.swift') || isDir(join(dir, 'ios')); +} + +/** Local SwiftPM packages (`.package(path: "...")` / `.package(name: "X", path: "...")`) of every Package.swift under + * `dir` (a few levels, skipping build output and checkouts). */ +export function localSwiftPackages(dir: string): string[] { + const out: string[] = []; + const skip = new Set(['Pods', 'build', 'DerivedData', 'node_modules', '.build', 'SourcePackages', '.git', 'xcuserdata']); + const walk = (d: string, depth: number) => { + if (depth > 4) return; + let names: string[] = []; + try { names = readdirSync(d); } catch { return; } + for (const n of names) { + if (skip.has(n)) continue; + const p = join(d, n); + if (n === 'Package.swift') { + let t = ''; + try { t = readFileSync(p, 'utf8'); } catch { continue; } + for (const m of t.matchAll(/\.package\(\s*(?:name:\s*"[^"]*"\s*,\s*)?path:\s*"([^"]+)"/g)) { + const target = resolve(d, m[1]!); + if (isDir(target)) out.push(target); + } + } else if (isDir(p) && !/\.(xc)?framework$|\.xcassets$/.test(n)) walk(p, depth + 1); + } + }; + walk(dir, 0); + return out; +} + +export interface NativePlugin { name: string; dir: string } + +/** + * The native plugin packages an iOS project at `iosDir` builds: the dependencies of the app's package.json (the + * nearest one at or above `iosDir`, i.e. next to capacitor.config) resolved through node_modules and workspaces, + * plus the local SwiftPM packages its Package.swift files reference. Without a package.json: every package with + * native iOS code in the node_modules folders from `iosDir` up to the repo root. Deduplicated by real path. + */ +export function nativeIosPlugins(iosDir: string): NativePlugin[] { + const start = resolve(iosDir); + const root = repoRoot(start); + const out: NativePlugin[] = []; + const seen = new Set(); + const add = (dir: string, name?: string) => { + const r = real(dir); + if (seen.has(r) || !hasNativeIos(dir)) return; + seen.add(r); + out.push({ name: name ?? readJson(join(dir, 'package.json'))?.name ?? dir.split(/[\\/]/).pop()!, dir }); + }; + let appDir: string | null = null; + for (let d = start; ; d = dirname(d)) { + if (existsSync(join(d, 'package.json'))) { appDir = d; break; } + if (d === root || dirname(d) === d) break; + } + if (appDir) { + for (const name of Object.keys(readJson(join(appDir, 'package.json'))?.dependencies ?? {})) { + const p = resolvePackage(name, appDir, root); + if (p) add(p, name); + } + } else { + for (let d = start; ; d = dirname(d)) { + const nm = join(d, 'node_modules'); + let names: string[] = []; + try { names = readdirSync(nm).filter(n => !n.startsWith('.')).sort(); } catch { /* none */ } + for (const n of names) { + if (n.startsWith('@')) { try { for (const k of readdirSync(join(nm, n)).sort()) add(join(nm, n, k), `${n}/${k}`); } catch { /* unreadable */ } } + else add(join(nm, n), n); + } + if (d === root || dirname(d) === d) break; + } + } + for (const p of localSwiftPackages(start)) add(p); + return out; +} diff --git a/cli/lib/profile.ts b/cli/lib/profile.ts index 5145b08d..289f33c3 100644 --- a/cli/lib/profile.ts +++ b/cli/lib/profile.ts @@ -2,6 +2,7 @@ // must have in the config before any store sees it. Pure. The online counterparts (URLs answer, the demo account is // on App Review, subscription states) are in validate-rules.ts (profileRules, appleSubscriptionRules). import { profileOf, type ShipConfig } from './config'; +import { accountCreationOf } from './declarations'; import { allSubscriptions } from './subscriptions'; export interface ProfileIssue { level: 'error' | 'warn'; msg: string } @@ -18,7 +19,10 @@ export function profileIssues(config: ShipConfig, o: { demoAccount: boolean }): if (config.play && !config.accounts!.deletionUrl) err('accounts.enabled: set accounts.deletionUrl (Play asks for a web page to request account deletion; account-deletion skill)'); if (config.apple && !config.accounts!.inApp) warn('accounts.enabled: set accounts.inApp to where deletion starts in the app (Apple 5.1.1(v); it goes into the review notes)'); if (config.dataSafety) { - if (acm.includes('PSL_ACM_NONE')) err('accounts.enabled but dataSafety.accountCreation says PSL_ACM_NONE: list the sign-up methods you offer'); + if (acm.includes('PSL_ACM_NONE')) { + const s = accountCreationOf(config.accounts!.signUp); + err(`accounts.enabled but dataSafety.accountCreation says PSL_ACM_NONE: list the sign-up methods you offer${s ? ` (accounts.signUp means accountCreation: ${JSON.stringify(s)})` : ' (accounts.signUp, e.g. [\'username\'] for a username with no password, tells storebound scan which)'}`); + } if (!config.dataSafety.deletionRequest) err('accounts.enabled but dataSafety.deletionRequest is false: people must be able to delete their account and data'); } } else if (config.dataSafety && !acm.includes('PSL_ACM_NONE')) warn('dataSafety.accountCreation lists sign-up methods but accounts.enabled is not set: add accounts { enabled: true, deletionUrl, inApp }'); diff --git a/cli/lib/scan/declare.ts b/cli/lib/scan/declare.ts index 2f4dadca..f61b5426 100644 --- a/cli/lib/scan/declare.ts +++ b/cli/lib/scan/declare.ts @@ -3,10 +3,10 @@ // 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 { 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 { IOS_PERMISSIONS } from './permissions'; -import { grep, type Hit, lineOf, type ProjectFacts } from './project'; +import { grep, grepOwn, type Hit, lineOf, type ProjectFacts } from './project'; import { SIGNALS } from './rules'; export type DeclArea = 'dataSafety' | 'appPrivacy' | 'att' | 'privacyManifest'; @@ -27,6 +27,8 @@ export interface Proposal { dataSafety: Partial & { data: Record } | null; appPrivacy: AppPrivacyConfig | null; appPrivacyChange: { from: boolean | null; to: boolean } | 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). */ labelGaps: { type: string; apple: string; evidence: Hit[] }[]; /** --write would change the config. */ @@ -61,14 +63,27 @@ export function proposeDeclarations(p: ProjectFacts, c: ShipConfig | null, confi detected.set(d.type, e); } } - // accounts proven by the config or sign-up code - const signUp = grep(p.sources, SIGNALS.signUp, 1); - if (c?.accounts?.enabled || signUp.length) { - const ev: Hit[] = signUp.length ? signUp : [{ file: configFile?.path ?? 'storebound.config.ts', line: configFile ? lineOf(configFile.text, /accounts\s*:/) : 1, text: 'accounts.enabled' }]; - for (const t of ['PSL_EMAIL', 'PSL_USER_ACCOUNT']) { - const e = detected.get(t) ?? { collect: new Set(), share: new Set(), evidence: [], from: [] }; - e.collect.add('account'); e.collect.add('functionality'); e.evidence.push(...ev); e.from.push('accounts'); - detected.set(t, e); + // accounts proven by the config or sign-up code: a user id. Email (or phone) only with real evidence: an email field, + // property, validation, endpoint or sign-in call in the own sources, or accounts.signUp saying so. Built output + // (bundles, the Capacitor webDir) is low trust: alone it only makes a question. + const su = grepOwn(p, SIGNALS.signUp, 1); + const signUp = su.built ? [] : su.hits; + const cfgAt = (re: RegExp, text: string): Hit => ({ file: configFile?.path ?? 'storebound.config.ts', line: configFile ? lineOf(configFile.text, re) : 1, text }); + const accounts = !!c?.accounts?.enabled || signUp.length > 0; + const signUpCfg = c?.accounts?.signUp ?? []; + const markAccount = (t: string, ev: Hit[], from: string) => { + const e = detected.get(t) ?? { collect: new Set(), share: new Set(), evidence: [], from: [] }; + e.collect.add('account'); e.collect.add('functionality'); e.evidence.push(...ev); if (!e.from.includes(from)) e.from.push(from); + detected.set(t, e); + }; + if (accounts) { + markAccount('PSL_USER_ACCOUNT', signUp.length ? signUp : [cfgAt(/accounts\s*:/, 'accounts.enabled')], 'accounts'); + for (const s of signUpCfg) for (const t of ACCOUNT_SIGN_UP[s]?.data ?? []) if (t !== 'PSL_USER_ACCOUNT') markAccount(t, [cfgAt(/signUp\s*:/, `accounts.signUp: ${s}`)], `accounts.signUp ${s}`); + const em = grepOwn(p, SIGNALS.email, 2); + if (em.hits.length && !em.built) markAccount('PSL_EMAIL', em.hits, 'email in the sources'); + else if (!detected.has('PSL_EMAIL')) { + if (em.hits.length) items.push({ area: 'dataSafety', what: 'PSL_EMAIL', value: 'collected? an email field shows up only in built output', status: 'ask', evidence: em.hits.slice(0, 1), note: 'check the source; not written' }); + else if (!signUpCfg.length) items.push({ area: 'dataSafety', what: 'PSL_EMAIL', value: 'collected? only if sign-up, sign-in or support asks for an email address (none found in the sources)', status: 'ask', evidence: [], note: 'set accounts.signUp to say how people sign up; not written' }); } } const have = c?.dataSafety?.data ?? {}; @@ -107,8 +122,15 @@ export function proposeDeclarations(p: ProjectFacts, c: ShipConfig | null, confi if (anyData) items.push({ area: 'dataSafety', what: 'collectsData', value: 'true', status: 'detected', evidence: diff.flatMap(d => d.evidence).slice(0, 1) }); for (const k of ['encryptedInTransit', 'deletionRequest'] as const) items.push({ area: 'dataSafety', what: k, value: c?.dataSafety ? String(c.dataSafety[k]) : '?', status: 'ask', evidence: [], note: k === 'encryptedInTransit' ? 'all traffic over HTTPS / TLS? (ATS and the SDKs\' own endpoints)' : 'can users ask for their data to be deleted?' }); - if ((c?.accounts?.enabled || signUp.length) && (c?.dataSafety?.accountCreation ?? ['PSL_ACM_NONE']).includes('PSL_ACM_NONE')) - items.push({ area: 'dataSafety', what: 'accountCreation', value: 'which sign-up methods (PSL_ACM_USER_ID_PASSWORD, PSL_ACM_OAUTH, ...)?', status: 'ask', evidence: signUp.slice(0, 1) }); + const acmFromCfg = accountCreationOf(signUpCfg); + const acmNone = (c?.dataSafety?.accountCreation ?? ['PSL_ACM_NONE']).includes('PSL_ACM_NONE'); + let accountCreation: string[] | null = null; + if (accounts && acmNone) { + if (acmFromCfg) { + accountCreation = acmFromCfg; + items.push({ area: 'dataSafety', what: 'accountCreation', value: `${JSON.stringify(acmFromCfg)} (${acmFromCfg.map(x => ACCOUNT_CREATION[x] ?? x).join('; ')})`, status: 'detected', evidence: [cfgAt(/signUp\s*:/, 'accounts.signUp')], note: 'from accounts.signUp' }); + } else items.push({ area: 'dataSafety', what: 'accountCreation', value: 'which sign-up methods? set accounts.signUp (\'username\' = username, no password: PSL_ACM_USER_ID_OTHER_AUTH; \'email-password\': PSL_ACM_USER_ID_PASSWORD; \'oauth\': PSL_ACM_OAUTH ...)', status: 'ask', evidence: signUp.slice(0, 1) }); + } // App Privacy per type (linked / tracking are owner answers) for (const d of diff) { @@ -146,10 +168,11 @@ export function proposeDeclarations(p: ProjectFacts, c: ShipConfig | null, confi if (diff.length) items.push({ area: 'privacyManifest', what: 'NSPrivacyCollectedDataTypes', value: uniq(diff.map(d => d.apple.split(' / ')[1]!)).join(', '), status: 'detected', evidence: diff.flatMap(d => d.evidence).slice(0, 1), note: 'the app\'s own collection; SDKs declare theirs in their manifests' }); } - const dsChanged = diff.some(d => d.change === 'add' || d.change === 'merge') || (anyData && c?.dataSafety?.collectsData === false); - const dataSafety = anyData || c?.dataSafety ? { ...(c?.dataSafety ?? {}), collectsData: anyData || !!c?.dataSafety?.collectsData, data: out } : null; + const dsChanged = diff.some(d => d.change === 'add' || d.change === 'merge') || (anyData && c?.dataSafety?.collectsData === false) || !!accountCreation; + 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; - return { items, diff, dataSafety, appPrivacy, appPrivacyChange, labelGaps, changed: dsChanged || !!appPrivacyChange }; + const accountCreationChange = accountCreation ? { from: c?.dataSafety?.accountCreation ?? null, to: accountCreation } : null; + return { items, diff, dataSafety, appPrivacy, appPrivacyChange, accountCreationChange, labelGaps, changed: dsChanged || !!appPrivacyChange }; } diff --git a/cli/lib/scan/index.ts b/cli/lib/scan/index.ts index 5fd41dad..7314e650 100644 --- a/cli/lib/scan/index.ts +++ b/cli/lib/scan/index.ts @@ -116,12 +116,13 @@ 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) { + if (changes.length || d.appPrivacyChange || 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(', ')}]` : ''} }`); else L.push(` ~ dataSafety.data.${x.type}: collect [${x.before!.collect.join(', ')}] -> [${x.after.collect.join(', ')}]${x.after.shared !== x.before!.shared ? `, shared ${x.before!.shared} -> ${x.after.shared}` : ''}${(x.after.share ?? []).join() !== (x.before!.share ?? []).join() ? `, share [${(x.before!.share ?? []).join(', ')}] -> [${(x.after.share ?? []).join(', ')}]` : ''}`); } + 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}`); } else if (r.config) L.push('', ` No changes to ${r.config}: the dataSafety / appPrivacy blocks already cover what was detected.`); } diff --git a/cli/lib/scan/project.ts b/cli/lib/scan/project.ts index 0d20d916..4dd9fae9 100644 --- a/cli/lib/scan/project.ts +++ b/cli/lib/scan/project.ts @@ -4,7 +4,8 @@ // privacy manifests, the Android manifest (permissions, services, target SDK) and the app's own source files. // Tolerant on purpose: an unreadable or odd file is skipped, never an exception. import { readdirSync, readFileSync, statSync } from 'node:fs'; -import { basename, extname, join, relative, sep } from 'node:path'; +import { basename, dirname, extname, join, relative, sep } from 'node:path'; +import { resolvePackage } from '../node-packages'; import { type Manifest, parseManifest } from '../privacy-manifest'; import { type DepRef, type Eco, matchesSdk, SDKS, type SdkDef } from './sdks'; @@ -85,6 +86,8 @@ export interface ProjectFacts { remoteStart: { url: string; at: Loc } | null; /** App source files (Swift, Objective-C, Kotlin, Java, Dart, JS / TS, C#, GDScript, HTML). */ sources: { path: string; text: string }[]; + /** Folders of built web output inside the project (Capacitor webDir): low-trust evidence, see isBuilt. */ + builtDirs: string[]; /** Files looked at, relative to root (for the report). */ scanned: number; } @@ -257,6 +260,46 @@ function packageJson(file: string, text: string): DepRef[] { return Object.entries(j.dependencies ?? {}).map(([n, v]) => ({ eco: 'npm' as const, name: n, version: v, file, line: lineOf(text, `"${n}"`) })); } catch { return []; } } +/** `s.dependency 'IronSourceSDK', '~> 9.6'` lines of a podspec (a native plugin's own CocoaPods dependencies). */ +function podspec(file: string, text: string): DepRef[] { + return [...text.matchAll(/^\s*\w+\.dependency\s+['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?/gm)].map(m => ({ eco: 'cocoapods' as const, name: m[1]!, version: m[2] ?? null, file, line: lineAt(text, m.index!) })); +} +/** `.package(url: "...", from: "1.0")` lines of a Package.swift. */ +function packageSwift(file: string, text: string): DepRef[] { + return [...text.matchAll(/\.package\(\s*(?:name:\s*"[^"]*"\s*,\s*)?url:\s*"([^"]+)"\s*,?\s*(?:(?:from|exact):\s*)?(?:"([^"]+)")?/g)] + .map(m => ({ eco: 'spm' as const, name: m[1]!, version: m[2] ?? null, file, line: lineAt(text, m.index!) })); +} +/** The native dependencies an npm plugin package brings (its podspec, Package.swift and android/build.gradle), with + * paths relative to the scanned root. Capacitor / Cordova / React Native plugins wrap the real SDK this way. */ +function pluginNativeDeps(root: string, dir: string): DepRef[] { + const out: DepRef[] = []; + const rd = (p: string): string => { try { return readFileSync(p, 'utf8'); } catch { return ''; } }; + const rel = (p: string) => relative(root, p).split(sep).join('/'); + let names: string[] = []; + try { names = readdirSync(dir); } catch { return out; } + for (const n of names) { + if (n.endsWith('.podspec')) out.push(...podspec(rel(join(dir, n)), rd(join(dir, n)))); + else if (n === 'Package.swift') out.push(...packageSwift(rel(join(dir, n)), rd(join(dir, n)))); + } + for (const g of ['android/build.gradle', 'android/build.gradle.kts']) { const t = rd(join(dir, g)); if (t) out.push(...gradle(rel(join(dir, g)), t)); } + return out; +} + +/** Built output (bundles, dist / build folders, minified files, the Capacitor webDir): low-trust evidence for what the + * app collects; the own sources are preferred and these are only a fallback. */ +export function isBuilt(path: string, builtDirs: readonly string[] = []): boolean { + return /(^|\/)(bundles?|dist|build|out|www|\.output|\.vite)\//.test(path) || /\.min\.(js|css)$|\.map$|\.(bundle|chunk)\.js$/.test(path) + || builtDirs.some(d => path.startsWith(`${d}/`)); +} + +/** grep the own sources first; built output (isBuilt) only when they have no match. `built` marks that fallback. */ +export function grepOwn(p: Pick, re: RegExp, max = 5): { hits: Hit[]; built: boolean } { + const own = grep(p.sources, re, max, f => !isBuilt(f, p.builtDirs)); + if (own.length) return { hits: own, built: false }; + const b = grep(p.sources, re, max, f => isBuilt(f, p.builtDirs)); + return { hits: b, built: b.length > 0 }; +} + function pubspec(file: string, text: string): DepRef[] { const sec = /^dependencies:\n([\s\S]*?)(?=^\S|$(?![\s\S]))/m.exec(text); if (!sec) return []; @@ -315,6 +358,7 @@ export function detectProject(root: string): ProjectFacts { let remoteStart: ProjectFacts['remoteStart'] = null; const sources: { path: string; text: string }[] = []; const stacks = new Set(); + const builtDirs: string[] = []; let pubLock = new Map(); for (const f of files) { @@ -376,6 +420,12 @@ export function detectProject(root: string): ProjectFacts { const t = read(f); const d = packageJson(f, t); deps.push(...d); + // the native SDKs behind each plugin, resolved like Node does (node_modules next to this package.json, then up + // to the root, then workspace packages): apps/native/node_modules in a monorepo too + for (const x of d) { + const dir = resolvePackage(x.name, join(root, dirname(f)), root); + if (dir) deps.push(...pluginNativeDeps(root, dir)); + } const names = new Set(d.map(x => x.name)); if (names.has('react-native')) stacks.add('react-native'); if (names.has('expo')) stacks.add('expo'); @@ -403,6 +453,8 @@ export function detectProject(root: string): ProjectFacts { } else if (/^capacitor\.config\.(json|ts|js)$/.test(n)) { stacks.add('capacitor'); const t = read(f); + const wd = /webDir\s*["']?\s*:\s*["']([^"']+)["']/.exec(t)?.[1]; + if (wd) builtDirs.push(join(dirname(f), wd).split(sep).join('/').replace(/^\.\//, '').replace(/\/$/, '')); const m = /server\s*["']?\s*:\s*\{[\s\S]*?\burl["']?\s*:\s*["'](https?:\/\/[^"']+)["']/.exec(t); if (m && !/^https?:\/\/(localhost|127\.0\.0\.1|10\.0\.2\.2|192\.168\.)/.test(m[1]!)) remoteStart = { url: m[1]!, at: { file: f, line: lineAt(t, m.index! + m[0].indexOf(m[1]!)) } }; } else if (n === 'config.xml' && /](Create (an )?account|Sign up)["'<]/, + // real evidence that the app collects an email address: an email input or keyboard, an `email` property in a request + // body / schema / type (not a quoted constant or label), an email validation, an email endpoint or an email sign-in + // call. Accounts alone never mean email (a username with a device token has none). + email: /type\s*[:=]\s*["'{]*email["'}]|inputMode=["']email["']|keyboardType=["']?email-address|autoComplete=["']email|textContentType=["']?(emailAddress|\.emailAddress)|UITextContentType\.emailAddress|\.keyboardType\(\.emailAddress\)|keyboardType\s*=\s*\.emailAddress|TextInputType\.emailAddress|TYPE_TEXT_VARIATION_EMAIL_ADDRESS|KeyboardType\.Email\b|(?]Delete (my |your )?account|\brevokeToken\b|auth\.admin\.deleteUser|Hesab(ı|ımı) sil/i, restore: /restoreCompletedTransactions|AppStore\.sync\(|restorePurchases|restoreTransactions|RestoreTransactions|getAvailablePurchases|\brestorePurchase\b|\.restore\(\)|Restore Purchases|syncPurchases|Purchases\.shared\.restore|store\.restore\b|queryPurchasesAsync/i, subscriptionCode: /subscriptionPeriod|Product\.SubscriptionInfo|\.autoRenewable\b|entitlements\.active|SubscriptionStoreView|ProductType\.Subscription|ProductType\.SUBS|BillingClient\.ProductType\.SUBS/, @@ -149,7 +153,8 @@ export function scanRules(inp: ScanInput): ScanFinding[] { }; const dep = (id: string): Hit[] => p.sdks.filter(s => s.sdk.id === id).flatMap(s => s.deps.slice(0, 2).map(d => ({ file: d.file, line: d.line, text: `${d.name}${d.version ? ` ${d.version}` : ''}` }))); const sdkHits = (pred: (s: ProjectFacts['sdks'][number]) => boolean): Hit[] => p.sdks.filter(pred).flatMap(s => s.deps.slice(0, 1).map(d => ({ file: d.file, line: d.line, text: `${s.sdk.name}: ${d.name}${d.version ? ` ${d.version}` : ''}` }))); - const src = (re: RegExp, max = 3) => grep(p.sources, re, max); + // the own sources first; built output (bundles, dist, the Capacitor webDir, minified files) only as a fallback + const src = (re: RegExp, max = 3) => grepOwn(p, re, max).hits; const native = (path: string) => /\.(swift|m|mm|h)$/.test(path); const apple = c ? !!c.apple : p.ios; const play = c ? !!c.play : p.android; diff --git a/cli/lib/scan/sdks.ts b/cli/lib/scan/sdks.ts index dd05329c..36de5247 100644 --- a/cli/lib/scan/sdks.ts +++ b/cli/lib/scan/sdks.ts @@ -82,7 +82,7 @@ export const SDKS: SdkDef[] = [ { id: 'levelplay', name: 'Unity LevelPlay (ironSource)', category: 'ads', tracking: true, data: ADS_DATA, families: { certified: true, since: '7.2.1', note: 'listed as ironSource; every mediated network must be on the list too' }, docs: 'https://developers.is.com/ironsource-mobile/general/ironsource-mobile-sdk-data-disclosure/', - match: { cocoapods: ['IronSourceSDK', 'IronSourcePod'], gradle: ['com.unity3d.ads-mediation:mediation-sdk', 'com.ironsource.sdk:mediationsdk'], + match: { cocoapods: ['IronSourceSDK', 'IronSourcePod'], spm: ['LevelPlay-Swift-Package'], gradle: ['com.unity3d.ads-mediation:mediation-sdk', 'com.ironsource.sdk:mediationsdk'], npm: ['ironsource-mediation', 'react-native-ironsource-mediation'], pub: ['unity_levelplay_mediation', 'ironsource_mediation'], unity: ['com.unity.services.levelplay', 'IronSource', 'LevelPlay'] } }, { id: 'unity-ads', name: 'Unity Ads', category: 'ads', tracking: true, data: ADS_DATA, diff --git a/cli/mcp-tools.ts b/cli/mcp-tools.ts index e43bbe0f..9a5e2178 100644 --- a/cli/mcp-tools.ts +++ b/cli/mcp-tools.ts @@ -142,7 +142,7 @@ export const TOOLS: ToolDef[] = [ args: i => [...opt('lang', i.lang), ...flag('variants', i.variants)] }, { name: 'privacy_manifest', title: 'iOS privacy manifest scan', command: ['privacy-manifest'], write: false, network: false, description: 'Local scan of an iOS project: PrivacyInfo.xcprivacy present, required-reason APIs declared, SDKs without manifests.', - props: { ios: { type: 'string', description: 'Path of the iOS project folder, e.g. ios/App' }, sdk_dirs: { type: 'string', description: 'Extra plugin / SDK folders, comma-separated' } }, + props: { ios: { type: 'string', description: 'Path of the iOS project folder, e.g. ios/App' }, sdk_dirs: { type: 'string', description: 'Extra plugin / SDK folders, comma-separated (node_modules plugins next to the app, workspaces, local SwiftPM packages and Pods are found without it)' } }, required: ['ios'], args: i => [...opt('ios', i.ios), ...opt('sdk-dirs', i.sdk_dirs)] }, { name: 'whats_new', title: 'Draft release notes', command: ['whats-new'], write: true, network: false, idempotent: true, diff --git a/cli/privacy-manifest.ts b/cli/privacy-manifest.ts index 23a4448d..61a74d3d 100644 --- a/cli/privacy-manifest.ts +++ b/cli/privacy-manifest.ts @@ -1,12 +1,15 @@ // Local scan of an iOS project for Apple's privacy manifest rules (no network, no credentials, no config needed). // storebound privacy-manifest --ios ios/App [--sdk-dirs node_modules/@capacitor,node_modules/some-plugin] [--json] // Reports: the app's PrivacyInfo.xcprivacy, required-reason API categories used in app sources vs declared, tracking -// flag vs the ATT usage string, and every SDK (CocoaPods, .xcframework / .framework, SwiftPM checkouts, --sdk-dirs) +// flag vs the ATT usage string, and every SDK (CocoaPods, .xcframework / .framework, SwiftPM checkouts, local SwiftPM +// packages, the native plugins of a Capacitor / Cordova / React Native app found through node_modules and workspaces +// the way Node resolves them, so a monorepo's apps/native/node_modules works without flags, and --sdk-dirs) // without its own manifest. Heuristic text scan: it can miss uses inside binaries and flag harmless matches. -import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'; +import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs'; import { basename, join, relative, resolve } from 'node:path'; import type { Args } from './lib/args'; import { log } from './lib/log'; +import { nativeIosPlugins } from './lib/node-packages'; import { evaluatePrivacyManifest, type Manifest, parseManifest, scanSources, type SdkInfo } from './lib/privacy-manifest'; const SKIP = new Set(['.git', 'build', 'DerivedData', 'node_modules', '.build', 'xcuserdata']); @@ -40,10 +43,21 @@ export async function run(args: Args): Promise { if (!existsSync(root)) throw new Error(`${root} does not exist`); const sdks: SdkInfo[] = []; const sdkRoots = new Set(); - const addSdk = (p: string) => { if (sdkRoots.has(p)) return; sdkRoots.add(p); sdks.push({ name: basename(p).replace(/\.(xc)?framework$/, ''), path: relative(process.cwd(), p), hasManifest: hasManifest(p) }); }; + const seen = new Set(); + const addSdk = (p: string, name?: string) => { + let key = p; + try { key = realpathSync(p); } catch { /* keep p */ } + if (seen.has(key)) return; + seen.add(key); sdkRoots.add(p); + sdks.push({ name: name ?? basename(p).replace(/\.(xc)?framework$/, ''), path: relative(process.cwd(), p), hasManifest: hasManifest(p) }); + }; + const addPods = (dir: string) => { for (const n of readdirSync(dir)) if (!POD_META.has(n) && statSync(join(dir, n)).isDirectory()) addSdk(join(dir, n)); }; const pods = join(root, 'Pods'); - if (existsSync(pods)) for (const n of readdirSync(pods)) if (!POD_META.has(n) && statSync(join(pods, n)).isDirectory()) addSdk(join(pods, n)); + if (existsSync(pods)) addPods(pods); + // Capacitor / Cordova / React Native plugins: node_modules next to the app's package.json and above it, workspace + // packages, local SwiftPM packages (CapApp-SPM) + for (const pl of nativeIosPlugins(root)) addSdk(pl.dir, pl.name); for (const extra of args.list('sdk-dirs')) { const d = resolve(extra); if (!existsSync(d)) continue; @@ -57,6 +71,7 @@ export async function run(args: Args): Promise { if ([...sdkRoots].some(s => p.startsWith(s + '/') || p === s)) return false; if (isDir) { if (/\.(xc)?framework$/.test(p)) { addSdk(p); return false; } + if (basename(p) === 'Pods') { addPods(p); return false; } if (basename(p) === 'checkouts' && p.includes('SourcePackages')) { for (const n of readdirSync(p)) addSdk(join(p, n)); return false; } return true; } diff --git a/cli/scan.ts b/cli/scan.ts index 11d4f2d0..ee9a4c38 100644 --- a/cli/scan.ts +++ b/cli/scan.ts @@ -55,12 +55,12 @@ export async function run(args: Args): Promise { const d = report.declarations; 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 (args.has('dry')) log('scan', `--dry: would write ${[d.diff.some(x => x.change !== 'kept' && x.change !== 'same') && '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 && 'appPrivacy'].filter(Boolean).join(' + ')} into ${report.config}`); else { let text = readFileSync(configPath, 'utf8'); const ds = d.dataSafety!; const missing = (['encryptedInTransit', 'deletionRequest'] as const).filter(k => typeof ds[k] !== 'boolean'); - if (d.diff.some(x => x.change === 'add' || x.change === 'merge')) + 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); if (d.appPrivacyChange) text = upsertBlock(text, configPath, 'appPrivacy', d.appPrivacy); writeFileSync(configPath, text); diff --git a/skills/account-deletion/SKILL.md b/skills/account-deletion/SKILL.md index 6e80d722..c15d1e4a 100644 --- a/skills/account-deletion/SKILL.md +++ b/skills/account-deletion/SKILL.md @@ -32,7 +32,12 @@ deletion requirements" (https://support.google.com/googleplay/android-developer/ takes. No login wall to read it. `storebound validate --play` checks that it answers. 3. In the app: a clear entry, a confirmation step, then the deletion (or the web page). Sign people out afterwards. 4. Play Data safety: `dataSafety.deletionRequest: true`, `accountCreation` set to the sign-up methods you offer (not - `PSL_ACM_NONE`). Google does not publish the question ids for the delete-account URL: export the form once + `PSL_ACM_NONE`). Say how people sign up in `accounts.signUp` and `storebound scan` proposes it: `username` (a name + picked in the app, no password, no email; a server token on the device) is Play's "Username and other + authentication" (`PSL_ACM_USER_ID_OTHER_AUTH`) with User ID as the only account data; `username-password` and + `email-password` are "Username and password" (`PSL_ACM_USER_ID_PASSWORD`); `email-link` and `phone` are + `PSL_ACM_USER_ID_OTHER_AUTH`; `oauth` is `PSL_ACM_OAUTH`; `other` is `PSL_ACM_OTHER`. An account alone never means + an email address: declare Email only when the app asks for one. Google does not publish the question ids for the delete-account URL: export the form once (Play Console > App content > Data safety > Export to CSV), copy the id, and add it as `dataSafety.extra: [{ question: '', value: '' }]`; otherwise enter the URL in the Console after `storebound play data-safety`. diff --git a/skills/privacy-manifest/SKILL.md b/skills/privacy-manifest/SKILL.md index 2a4337a2..0b497e9a 100644 --- a/skills/privacy-manifest/SKILL.md +++ b/skills/privacy-manifest/SKILL.md @@ -7,8 +7,12 @@ description: Add and check Apple privacy manifests (PrivacyInfo.xcprivacy) for a `storebound scan` runs the same checks as part of its report (no manifest, undeclared required-reason APIs, SDKs older than their first manifest version) and proposes NSPrivacyTracking and the collected data types from the detected SDKs. -Scan: `storebound privacy-manifest --ios ios/App` (local, no credentials). Capacitor / Cordova plugins live outside -the iOS folder: add `--sdk-dirs node_modules/@capacitor,node_modules/`. Exit 1 when something blocks upload. +Scan: `storebound privacy-manifest --ios ios/App` (local, no credentials). Capacitor / Cordova / React Native plugins +live outside the iOS folder; they are found the way Node resolves them: the dependencies of the app's package.json +(next to capacitor.config) in the node_modules there and in every folder above it up to the repo root (so a monorepo's +`apps/native/node_modules` works), workspace packages (package.json `workspaces`, Bun / npm / yarn), local SwiftPM +packages (Capacitor 8's CapApp-SPM `Package.swift`), Pods and SwiftPM checkouts. `--sdk-dirs a,b` adds folders it +cannot find. Exit 1 when something blocks upload. ## What Apple checks at upload - **ITMS-91053 Missing API declaration**: the binary uses a required-reason API and no manifest in the app or in the diff --git a/skills/store-declarations/SKILL.md b/skills/store-declarations/SKILL.md index c2673b61..e9e0bb71 100644 --- a/skills/store-declarations/SKILL.md +++ b/skills/store-declarations/SKILL.md @@ -57,5 +57,11 @@ CLI: `storebound` (or `bunx storebound` in a project that has it, or `bun User ID) and account creation "Username and other + authentication" (`PSL_ACM_USER_ID_OTHER_AUTH`): set `accounts.signUp: ['username']`. `storebound scan` marks Email + "detected" only for an email field, an `email` property in a request or schema, an email validation or endpoint, an + email sign-in call, an SDK that collects it (Google / Apple / Firebase sign-in) or `signUp: ['email-…']`; built + bundles (dist, build, the Capacitor webDir, minified files) only make it a question. - App Privacy saved but not published = not submitted. - Keep store answers, the privacy policy and the in-app privacy settings consistent; reviewers compare them. diff --git a/templates/profiles/app/storebound.config.ts b/templates/profiles/app/storebound.config.ts index 718ff97d..499da67a 100644 --- a/templates/profiles/app/storebound.config.ts +++ b/templates/profiles/app/storebound.config.ts @@ -23,6 +23,10 @@ const config: ShipConfig = { enabled: true, deletionUrl: 'https://example.com/delete-account', // public page, no login needed to request deletion inApp: 'Settings > Account > Delete account', // goes into the App Review notes + // How people sign up: 'username' (a name picked in the app, no password, no email), 'username-password', + // 'email-password', 'email-link', 'phone', 'oauth', 'other'. `storebound scan` proposes the account data and + // dataSafety.accountCreation from it; only the 'email-*' methods mean an email address. + signUp: ['email-password'], }, // Sign-in for store reviewers (review-access skill). The demo account itself lives ONLY in diff --git a/templates/profiles/subscription-app/storebound.config.ts b/templates/profiles/subscription-app/storebound.config.ts index 6526c4c8..c9638545 100644 --- a/templates/profiles/subscription-app/storebound.config.ts +++ b/templates/profiles/subscription-app/storebound.config.ts @@ -23,6 +23,10 @@ const config: ShipConfig = { enabled: true, deletionUrl: 'https://example.com/delete-account', // public page, no login needed to request deletion inApp: 'Settings > Account > Delete account', // goes into the App Review notes + // How people sign up: 'username' (a name picked in the app, no password, no email), 'username-password', + // 'email-password', 'email-link', 'phone', 'oauth', 'other'. `storebound scan` proposes the account data and + // dataSafety.accountCreation from it; only the 'email-*' methods mean an email address. + signUp: ['email-password'], }, // Sign-in for store reviewers (review-access skill). The demo account itself lives ONLY in diff --git a/templates/storebound.config.ts b/templates/storebound.config.ts index c84159d3..0f742d73 100644 --- a/templates/storebound.config.ts +++ b/templates/storebound.config.ts @@ -99,6 +99,9 @@ const config: ShipConfig = { collectsData: true, encryptedInTransit: true, deletionRequest: true, // e.g. "email us"; no accounts, so no account deletion URL needed + // No accounts: PSL_ACM_NONE. A guest account with a name picked on the device and a server token (no password, no + // email): accounts { enabled: true, signUp: ['username'], ... } and ['PSL_ACM_USER_ID_OTHER_AUTH'] here (Play's + // "Username and other authentication"; `storebound scan` proposes it). accountCreation: ['PSL_ACM_NONE'], data: { PSL_APPROX_LOCATION: { shared: true, collect: ['analytics', 'advertising', 'fraud'], share: ['analytics', 'advertising', 'fraud'] }, diff --git a/tests/fixtures/scan/android/storebound.config.ts b/tests/fixtures/scan/android/storebound.config.ts index 7b406f25..98b87d6e 100644 --- a/tests/fixtures/scan/android/storebound.config.ts +++ b/tests/fixtures/scan/android/storebound.config.ts @@ -8,7 +8,7 @@ export default { website: 'https://example.com', contactEmail: 'support@example.com', }, - accounts: { enabled: true, inApp: 'Settings > Account > Delete account' }, + accounts: { enabled: true, inApp: 'Settings > Account > Delete account', signUp: ['email-password'] }, reviewAccess: { signInRequired: false }, languages: [{ id: 'en', play: 'en-US' }], play: { packageName: 'com.example.budget' }, diff --git a/tests/fixtures/scan/monorepo/README.md b/tests/fixtures/scan/monorepo/README.md new file mode 100644 index 00000000..91fa95e9 --- /dev/null +++ b/tests/fixtures/scan/monorepo/README.md @@ -0,0 +1,8 @@ +# monorepo fixture + +A made-up Bun monorepo game (the layout `storebound scan` and `privacy-manifest` met live): the Capacitor shell lives in +apps/native with its plugins in apps/native/node_modules (not the root node_modules), the web build is copied into +apps/native/web (the Capacitor webDir, a minified bundle with route constants), and accounts are a username picked on +the device plus a server token: no password, no email anywhere. Expected: User ID detected, no email finding, the ad +SDK found behind its plugin (podspec, Package.swift, android/build.gradle), the plugins found without --sdk-dirs. +Not a buildable project. diff --git a/tests/fixtures/scan/monorepo/apps/game/package.json b/tests/fixtures/scan/monorepo/apps/game/package.json new file mode 100644 index 00000000..b460a265 --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/game/package.json @@ -0,0 +1,7 @@ +{ + "name": "@rush/game", + "private": true, + "dependencies": { + "@rush/shared": "workspace:*" + } +} diff --git a/tests/fixtures/scan/monorepo/apps/game/src/account.ts b/tests/fixtures/scan/monorepo/apps/game/src/account.ts new file mode 100644 index 00000000..d05bc453 --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/game/src/account.ts @@ -0,0 +1,9 @@ +import { API_PREFIX, ROUTES } from '@rush/shared/src/routes'; + +/** First launch: the player picks a name; the server answers with a token kept on the device. */ +export async function register(username: string): Promise { + const res = await fetch(API_PREFIX + ROUTES.register, { method: 'POST', body: JSON.stringify({ username }) }); + const { token } = (await res.json()) as { token: string }; + localStorage.setItem('token', token); + return token; +} diff --git a/tests/fixtures/scan/monorepo/apps/native/capacitor.config.ts b/tests/fixtures/scan/monorepo/apps/native/capacitor.config.ts new file mode 100644 index 00000000..be2efcd8 --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/capacitor.config.ts @@ -0,0 +1,8 @@ +const config = { + appId: 'org.example.rush', + appName: 'Rush Example', + webDir: 'web', + server: { androidScheme: 'https' }, +}; + +export default config; diff --git a/tests/fixtures/scan/monorepo/apps/native/ios/App/App.xcodeproj/project.pbxproj b/tests/fixtures/scan/monorepo/apps/native/ios/App/App.xcodeproj/project.pbxproj new file mode 100644 index 00000000..d1363529 --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/ios/App/App.xcodeproj/project.pbxproj @@ -0,0 +1,7 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + objectVersion = 77; + objects = { + }; +} diff --git a/tests/fixtures/scan/monorepo/apps/native/ios/App/App/AppDelegate.swift b/tests/fixtures/scan/monorepo/apps/native/ios/App/App/AppDelegate.swift new file mode 100644 index 00000000..ca00f698 --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/ios/App/App/AppDelegate.swift @@ -0,0 +1,7 @@ +import Capacitor +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + var window: UIWindow? +} diff --git a/tests/fixtures/scan/monorepo/apps/native/ios/App/App/Info.plist b/tests/fixtures/scan/monorepo/apps/native/ios/App/App/Info.plist new file mode 100644 index 00000000..559b1df8 --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/ios/App/App/Info.plist @@ -0,0 +1,10 @@ + + + + + CFBundleDisplayName + Rush Example + ITSAppUsesNonExemptEncryption + + + diff --git a/tests/fixtures/scan/monorepo/apps/native/ios/App/CapApp-SPM/Package.swift b/tests/fixtures/scan/monorepo/apps/native/ios/App/CapApp-SPM/Package.swift new file mode 100644 index 00000000..635a286f --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/ios/App/CapApp-SPM/Package.swift @@ -0,0 +1,12 @@ +// swift-tools-version: 5.9 +import PackageDescription + +let package = Package( + name: "CapApp-SPM", + products: [.library(name: "CapApp-SPM", targets: ["CapApp-SPM"])], + dependencies: [ + .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", exact: "8.0.0"), + .package(name: "ExampleAdsPlugin", path: "../../../node_modules/example-ads-plugin") + ], + targets: [.target(name: "CapApp-SPM", dependencies: [.product(name: "ExampleAdsPlugin", package: "ExampleAdsPlugin")])] +) diff --git a/tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/ExampleHaptics.podspec b/tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/ExampleHaptics.podspec new file mode 100644 index 00000000..93553ede --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/ExampleHaptics.podspec @@ -0,0 +1,7 @@ +Pod::Spec.new do |s| + s.name = 'ExampleHaptics' + s.version = '1.0.0' + s.source_files = 'ios/Sources/**/*.swift' + s.resource_bundles = { 'ExampleHapticsPrivacy' => ['ios/Sources/PrivacyInfo.xcprivacy'] } + s.dependency 'Capacitor' +end diff --git a/tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/ios/Sources/PrivacyInfo.xcprivacy b/tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/ios/Sources/PrivacyInfo.xcprivacy new file mode 100644 index 00000000..158726a6 --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/ios/Sources/PrivacyInfo.xcprivacy @@ -0,0 +1,10 @@ + + + + + NSPrivacyTracking + + NSPrivacyAccessedAPITypes + + + diff --git a/tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/package.json b/tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/package.json new file mode 100644 index 00000000..e2c18696 --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/node_modules/@example/capacitor-haptics/package.json @@ -0,0 +1,4 @@ +{ + "name": "@example/capacitor-haptics", + "version": "1.0.0" +} diff --git a/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/ExampleAdsPlugin.podspec b/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/ExampleAdsPlugin.podspec new file mode 100644 index 00000000..23ba3cbc --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/ExampleAdsPlugin.podspec @@ -0,0 +1,7 @@ +Pod::Spec.new do |s| + s.name = 'ExampleAdsPlugin' + s.version = '0.3.0' + s.source_files = 'ios/Sources/**/*.swift' + s.dependency 'Capacitor' + s.dependency 'IronSourceSDK', '~> 9.6.1' +end diff --git a/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/Package.swift b/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/Package.swift new file mode 100644 index 00000000..47c77a7c --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/Package.swift @@ -0,0 +1,11 @@ +// swift-tools-version: 5.9 +import PackageDescription + +let package = Package( + name: "ExampleAdsPlugin", + products: [.library(name: "ExampleAdsPlugin", targets: ["ExampleAdsPlugin"])], + dependencies: [ + .package(url: "https://github.com/ironsource-mobile/LevelPlay-Swift-Package.git", from: "9.6.1") + ], + targets: [.target(name: "ExampleAdsPlugin", path: "ios/Sources/ExampleAdsPlugin")] +) diff --git a/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/android/build.gradle b/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/android/build.gradle new file mode 100644 index 00000000..cae01fba --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/android/build.gradle @@ -0,0 +1,3 @@ +dependencies { + implementation "com.unity3d.ads-mediation:mediation-sdk:9.0.0" +} diff --git a/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/ios/Sources/ExampleAdsPlugin/Plugin.swift b/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/ios/Sources/ExampleAdsPlugin/Plugin.swift new file mode 100644 index 00000000..318625f0 --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/ios/Sources/ExampleAdsPlugin/Plugin.swift @@ -0,0 +1,4 @@ +import Capacitor + +@objc(ExampleAdsPlugin) +public class ExampleAdsPlugin: CAPPlugin {} diff --git a/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/package.json b/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/package.json new file mode 100644 index 00000000..99b432f2 --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/node_modules/example-ads-plugin/package.json @@ -0,0 +1,4 @@ +{ + "name": "example-ads-plugin", + "version": "0.3.0" +} diff --git a/tests/fixtures/scan/monorepo/apps/native/package.json b/tests/fixtures/scan/monorepo/apps/native/package.json new file mode 100644 index 00000000..1c3da992 --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/package.json @@ -0,0 +1,10 @@ +{ + "name": "@rush/native", + "private": true, + "dependencies": { + "@capacitor/core": "8.0.0", + "@capacitor/ios": "8.0.0", + "@example/capacitor-haptics": "1.0.0", + "example-ads-plugin": "0.3.0" + } +} diff --git a/tests/fixtures/scan/monorepo/apps/native/web/bundle/routes-AbC12345.js b/tests/fixtures/scan/monorepo/apps/native/web/bundle/routes-AbC12345.js new file mode 100644 index 00000000..6e013eaa --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/web/bundle/routes-AbC12345.js @@ -0,0 +1 @@ +var e=`/api/v1`,t=`/api/health`,r={session:`/session`,usernameCheck:`/username/check`,register:`/register`,state:`/state`};export{e as A,r as R,t as H}; diff --git a/tests/fixtures/scan/monorepo/apps/native/web/bundle/vendor-XyZ98765.js b/tests/fixtures/scan/monorepo/apps/native/web/bundle/vendor-XyZ98765.js new file mode 100644 index 00000000..85f15b4f --- /dev/null +++ b/tests/fixtures/scan/monorepo/apps/native/web/bundle/vendor-XyZ98765.js @@ -0,0 +1 @@ +function f(n){return n.createElement("input",{type:"email",name:"email"})}export{f as V}; diff --git a/tests/fixtures/scan/monorepo/package.json b/tests/fixtures/scan/monorepo/package.json new file mode 100644 index 00000000..fc085172 --- /dev/null +++ b/tests/fixtures/scan/monorepo/package.json @@ -0,0 +1,8 @@ +{ + "name": "monorepo-game", + "private": true, + "workspaces": [ + "apps/*", + "packages/*" + ] +} diff --git a/tests/fixtures/scan/monorepo/packages/shared/package.json b/tests/fixtures/scan/monorepo/packages/shared/package.json new file mode 100644 index 00000000..307b8c6b --- /dev/null +++ b/tests/fixtures/scan/monorepo/packages/shared/package.json @@ -0,0 +1,4 @@ +{ + "name": "@rush/shared", + "private": true +} diff --git a/tests/fixtures/scan/monorepo/packages/shared/src/routes.ts b/tests/fixtures/scan/monorepo/packages/shared/src/routes.ts new file mode 100644 index 00000000..e843cd73 --- /dev/null +++ b/tests/fixtures/scan/monorepo/packages/shared/src/routes.ts @@ -0,0 +1,8 @@ +// API routes shared by the game client and the server. +export const API_PREFIX = '/api/v1'; +export const ROUTES = { + session: '/session', + usernameCheck: '/username/check', + register: '/register', + state: '/state', +} as const; diff --git a/tests/fixtures/scan/monorepo/storebound.config.ts b/tests/fixtures/scan/monorepo/storebound.config.ts new file mode 100644 index 00000000..2cdf7c09 --- /dev/null +++ b/tests/fixtures/scan/monorepo/storebound.config.ts @@ -0,0 +1,30 @@ +// Fixture config (made up, example.com placeholders only). +export default { + app: { + name: 'Rush Example', + profile: 'game', + privacyPolicyUrl: 'https://example.com/privacy', + supportUrl: 'https://example.com/support', + website: 'https://example.com', + contactEmail: 'support@example.com', + }, + // A guest account is created on first launch with the name the player picks (no password, no email). + accounts: { + enabled: true, + deletionUrl: 'https://example.com/delete-account', + inApp: 'Settings > Delete account', + }, + reviewAccess: { signInRequired: false }, + languages: [{ id: 'en', play: 'en-US', apple: 'en-US' }], + play: { packageName: 'org.example.rush', accountType: 'organization' }, + apple: { bundleId: 'org.example.rush', usesNonExemptEncryption: false }, + dataSafety: { + collectsData: true, + encryptedInTransit: true, + deletionRequest: true, + accountCreation: ['PSL_ACM_NONE'], + data: { + PSL_USER_ACCOUNT: { shared: false, collect: ['account', 'functionality'] }, + }, + }, +}; diff --git a/tests/scan.test.ts b/tests/scan.test.ts index bb49063e..23736c89 100644 --- a/tests/scan.test.ts +++ b/tests/scan.test.ts @@ -12,7 +12,9 @@ import { validateConfig } from '../cli/lib/config'; import { runScan } from '../cli/lib/scan'; import { PLAY_REFS } from '../cli/lib/scan/play-rules'; import { vaguePurpose } from '../cli/lib/scan/permissions'; -import { detectProject, parsePlist } from '../cli/lib/scan/project'; +import { detectProject, isBuilt, parsePlist } from '../cli/lib/scan/project'; +import { SIGNALS } from '../cli/lib/scan/rules'; +import { localSwiftPackages, nativeIosPlugins, workspaceDirs } from '../cli/lib/node-packages'; import type { ScanFinding } from '../cli/lib/scan/rules'; import { matchesSdk, SDKS, versionAtLeast } from '../cli/lib/scan/sdks'; @@ -331,6 +333,87 @@ describe('config writing', () => { }); }); +describe('monorepo: username accounts without email, plugins in apps/native/node_modules', () => { + test('accounts mean a user id, never an email; route constants in the built bundle are not evidence', async () => { + const r = await scan('monorepo'); + const d = r.declarations; + expect(d.diff.find(x => x.type === 'PSL_EMAIL')).toBeUndefined(); + expect(d.dataSafety!.data.PSL_EMAIL).toBeUndefined(); + expect(r.findings.filter(f => /Email|PSL_EMAIL/.test(f.title))).toEqual([]); + const uid = d.items.find(x => x.what === 'PSL_USER_ACCOUNT')!; + expect(uid.status).toBe('detected'); + expect(uid.evidence[0]!.file).toBe('packages/shared/src/routes.ts'); + for (const x of d.items) for (const e of x.evidence) if (x.status === 'detected') expect(e.file).not.toContain('/web/bundle/'); + // the email input in the vendor chunk is built output: a question, never written + expect(d.items.find(x => x.what === 'PSL_EMAIL')).toMatchObject({ status: 'ask', evidence: [{ file: 'apps/native/web/bundle/vendor-XyZ98765.js' }] }); + expect(d.items.find(x => x.area === 'appPrivacy' && x.what === 'Identifiers / User ID')!.status).toBe('detected'); + expect(d.items.some(x => x.area === 'appPrivacy' && x.what === 'Contact Info / Email Address')).toBe(false); + expect(d.items.find(x => x.what === 'accountCreation')!.status).toBe('ask'); + }); + test('accounts.signUp: username -> Username and other authentication, still no email; email-password -> email', async () => { + const dir = mkdtempSync(join(tmpdir(), 'sb-mono-')); + try { + cpSync(join(FX, 'monorepo'), dir, { recursive: true }); + const cfgPath = join(dir, 'storebound.config.ts'); + const base = readFileSync(cfgPath, 'utf8'); + writeFileSync(cfgPath, base.replace("inApp: 'Settings > Delete account',", "inApp: 'Settings > Delete account',\n signUp: ['username'],")); + const d = (await runScan(dir)).report.declarations; + expect(d.accountCreationChange).toEqual({ from: ['PSL_ACM_NONE'], to: ['PSL_ACM_USER_ID_OTHER_AUTH'] }); + expect(d.items.find(x => x.what === 'accountCreation')).toMatchObject({ status: 'detected', value: expect.stringContaining('Username and other authentication') }); + expect(d.dataSafety!.data.PSL_EMAIL).toBeUndefined(); + expect(d.dataSafety!.accountCreation).toEqual(['PSL_ACM_USER_ID_OTHER_AUTH']); + Bun.spawnSync(['bun', CLI, 'scan', '--dir', dir, '--write']); + const after = readFileSync(cfgPath, 'utf8'); + expect(after).toContain("accountCreation: ['PSL_ACM_USER_ID_OTHER_AUTH']"); + expect(after).not.toContain('PSL_EMAIL'); + expect((await runScan(dir)).report.configError).toBeNull(); + // a fresh folder: the config module of the first one stays cached in this process + const dir2 = join(dir, 'email'); + cpSync(join(FX, 'monorepo'), dir2, { recursive: true }); + writeFileSync(join(dir2, 'storebound.config.ts'), base.replace("inApp: 'Settings > Delete account',", "inApp: 'Settings > Delete account',\n signUp: ['email-password'],")); + const e = (await runScan(dir2)).report.declarations; + expect(e.items.find(x => x.what === 'PSL_EMAIL')!.status).toBe('detected'); + expect(e.accountCreationChange!.to).toEqual(['PSL_ACM_USER_ID_PASSWORD']); + } finally { rmSync(dir, { recursive: true, force: true }); } + }); + test('email evidence: fields, properties, validation, endpoints and SDK calls count; labels and constants do not', () => { + const yes = ['', 'n.createElement("input",{type:"email"})', 'body: JSON.stringify({ email: form.email })', 'email?: string;', 'z.string().email()', + 'const RE = /^[^\\s@]+@[^\\s@]+$/', "fetch('/api/auth/forgot-password')", 'auth.createUserWithEmailAndPassword(a, b)', 'Auth.auth().createUser(withEmail: e, password: p)', + 'keyboardType="email-address"', 'request.requestedScopes = [.fullName, .email]']; + const no = ["const ROUTES = { register: '/register', usernameCheck: '/username/check' }", "contactEmail: 'support@example.com'", "email: 'privacy@example.com'", + "labels = { email: 'E-mail' }", 'register(username)', "fetch('/api/v1/session')"]; + for (const s of yes) expect({ s, hit: SIGNALS.email.test(s) }).toEqual({ s, hit: true }); + for (const s of no) expect({ s, hit: SIGNALS.email.test(s) }).toEqual({ s, hit: false }); + }); + test('built output is low trust', () => { + expect(isBuilt('apps/native/web/bundle/routes-AbC12345.js')).toBe(true); + expect(isBuilt('dist/index.min.js')).toBe(true); + expect(isBuilt('apps/native/web/index.js', ['apps/native/web'])).toBe(true); + expect(isBuilt('packages/shared/src/routes.ts')).toBe(false); + }); + test('scan finds the SDK behind a plugin in apps/native/node_modules (podspec, Package.swift, android/build.gradle)', () => { + const p = detectProject(join(FX, 'monorepo')); + expect(p.stacks).toContain('capacitor'); + expect(p.builtDirs).toEqual(['apps/native/web']); + const lp = p.sdks.find(s => s.sdk.id === 'levelplay')!; + expect(lp.deps.map(d => `${d.eco} ${d.file}`).sort()).toEqual([ + 'cocoapods apps/native/node_modules/example-ads-plugin/ExampleAdsPlugin.podspec', + 'gradle apps/native/node_modules/example-ads-plugin/android/build.gradle', + 'spm apps/native/node_modules/example-ads-plugin/Package.swift', + ]); + }); + test('privacy-manifest finds the plugins without --sdk-dirs (node_modules next to the app, local SwiftPM packages)', () => { + const ios = join(FX, 'monorepo/apps/native/ios/App'); + expect(nativeIosPlugins(ios).map(x => x.name).sort()).toEqual(['@example/capacitor-haptics', 'example-ads-plugin']); + expect(localSwiftPackages(ios).map(x => x.split('/').pop())).toEqual(['example-ads-plugin']); + expect(workspaceDirs(join(FX, 'monorepo')).map(x => x.split('/').slice(-2).join('/'))).toEqual(['apps/game', 'apps/native', 'packages/shared']); + const r = Bun.spawnSync(['bun', CLI, 'privacy-manifest', '--ios', ios, '--json']); + const out = r.stdout.toString(); + const j = JSON.parse(out.slice(out.indexOf('{'))) as { sdks: { name: string; hasManifest: boolean }[] }; + expect(j.sdks.map(s => [s.name, s.hasManifest]).sort()).toEqual([['@example/capacitor-haptics', true], ['example-ads-plugin', false]]); + }); +}); + describe('integration', () => { test('2.2: beta / demo / test wording in the app name or the App Store text (not "demo account")', async () => { const dir = mkdtempSync(join(tmpdir(), 'storebound-scan-beta-')); @@ -354,7 +437,8 @@ describe('integration', () => { test('JSON output, --store filter, exit code', () => { const r = Bun.spawnSync(['bun', CLI, 'scan', '--dir', join(FX, 'teaser'), '--json', '--store', 'apple'], { env: { ...process.env, REVIEW_DEMO_USER: '', REVIEW_DEMO_PASSWORD: '' } }); expect(r.exitCode).toBe(1); - const j = JSON.parse(r.stdout.toString()) as { counts: { blocker: number }; findings: ScanFinding[] }; + const out = r.stdout.toString(); + const j = JSON.parse(out.slice(out.indexOf('{'))) as { counts: { blocker: number }; findings: ScanFinding[] }; expect(j.counts.blocker).toBe(2); expect(j.findings.every(f => f.store === 'apple')).toBe(true); }); From 43daeef97f1f020979e988c23d8a7dc33f8f8d61 Mon Sep 17 00:00:00 2001 From: CRT Date: Sun, 11 Oct 2026 18:08:11 +0000 Subject: [PATCH 3/4] scan.ignore: optional match on the finding title, to accept one check of a rule with several (e.g. the ALL CAPS title in play-metadata) --- README.md | 2 +- cli/lib/config.ts | 6 +++--- cli/lib/scan/index.ts | 2 +- cli/lib/scan/rules.ts | 2 +- skills/store-preflight/SKILL.md | 2 +- tests/scan.test.ts | 5 +++++ 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 49f21744..d668d1a7 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ code imply, each marked **detected (file:line)** or **ask owner**, as a diff aga the config. Nothing is written unless you run `storebound scan --write` (only detected answers; questions stay questions). The MCP tool `scan` is read-only and cannot write; `validate` includes the open scan findings; the desktop app shows them on the Checks tab. A finding you decided is fine goes into the config with its reason: -`scan: { ignore: [{ rule: 'demo-account', reason: '...' }] }`. +`scan: { ignore: [{ rule: 'demo-account', reason: '...' }] }`; a rule with several checks (e.g. `play-metadata`) takes `match: ''` to accept just one of them. | rule | App Store | Google Play | what scan proves | |---|---|---|---| diff --git a/cli/lib/config.ts b/cli/lib/config.ts index 025b179b..87227eee 100644 --- a/cli/lib/config.ts +++ b/cli/lib/config.ts @@ -537,7 +537,7 @@ export interface ShipConfig { * them in App Store Connect). `storebound scan` proposes them from the detected SDKs and code. */ appPrivacy?: AppPrivacyConfig; /** `storebound scan`: findings the owner has looked at and accepts, by rule id (with the reason, shown in the report). */ - scan?: { ignore?: { rule: string; store?: 'apple' | 'play'; reason: string }[] }; + scan?: { ignore?: { rule: string; store?: 'apple' | 'play'; /** Only findings whose title contains this text (one check of a rule that has several). */ match?: string; reason: string }[] }; /** Ads: `validate` checks that /app-ads.txt is reachable and contains every line listed here. */ ads?: { appAdsTxt?: string[] }; /** Rendered store graphics dir (///NN.png|jpg). Defaults to shots.out. */ @@ -766,8 +766,8 @@ export function validateConfig(c: unknown): string[] { e.push('appPrivacy.trackingDomains: a list of host names'); } 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')) - e.push(`scan.ignore[${i}]: { rule: '', reason: 'why this is fine', store?: 'apple' | 'play' }`); + 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()))) + e.push(`scan.ignore[${i}]: { rule: '', reason: 'why this is fine', store?: 'apple' | 'play', match?: '' }`); if (cfg.ads?.appAdsTxt && !cfg.ads.appAdsTxt.every(l => typeof l === 'string' && l.split(',').length >= 3)) e.push('ads.appAdsTxt: lines like "example-network.com, pub-123, DIRECT, abc123"'); const seen = new Set(); diff --git a/cli/lib/scan/index.ts b/cli/lib/scan/index.ts index 7314e650..bed6ee07 100644 --- a/cli/lib/scan/index.ts +++ b/cli/lib/scan/index.ts @@ -149,7 +149,7 @@ export function addOriginality(r: ScanReport, o: OriginalityReport, stores: { ap if (stores.play) r.findings.push({ ...base, guideline: 'Play: Repetitive content', store: 'play', ref: 'https://support.google.com/googleplay/android-developer/answer/9898783' }); } for (const f of r.findings) if (f.rule === 'originality' && !f.accepted) { - const hit = ignore.find(i => i.rule === f.rule && (!i.store || i.store === f.store)); + const hit = ignore.find(i => i.rule === f.rule && (!i.store || i.store === f.store) && (!i.match || f.title.toLowerCase().includes(i.match.toLowerCase()))); if (hit) f.accepted = hit.reason; } r.findings = sortScan(r.findings); diff --git a/cli/lib/scan/rules.ts b/cli/lib/scan/rules.ts index 28987a7d..11084274 100644 --- a/cli/lib/scan/rules.ts +++ b/cli/lib/scan/rules.ts @@ -516,7 +516,7 @@ export function scanRules(inp: ScanInput): ScanFinding[] { // ---- owner-accepted findings ---- const ignore = c?.scan?.ignore ?? []; for (const f of out) { - const hit = ignore.find(i => i.rule === f.rule && (!i.store || i.store === f.store)); + const hit = ignore.find(i => i.rule === f.rule && (!i.store || i.store === f.store) && (!i.match || f.title.toLowerCase().includes(i.match.toLowerCase()))); if (hit) f.accepted = hit.reason; } return sortScan(out); diff --git a/skills/store-preflight/SKILL.md b/skills/store-preflight/SKILL.md index ed90252f..c2407087 100644 --- a/skills/store-preflight/SKILL.md +++ b/skills/store-preflight/SKILL.md @@ -17,7 +17,7 @@ the stores; run them freely. Privacy / ATT / privacy manifest proposal, each item "detected (file:line)" or "ask owner", as a diff against the config. Exit 1 on an open blocker. `--write` adds only the detected answers to the config (show the diff and ask the owner first; MCP never writes). `--store apple|play`, `--json`. A finding the owner accepts goes into - `scan.ignore: [{ rule, reason }]`; never add one without the owner's reason. The Play rules also read + `scan.ignore: [{ rule, reason, match? }]` (`match` = text in the finding title, to accept one check of a rule with several); never add one without the owner's reason. The Play rules also read `play.targetAges` (Families), `play.accountType` / `play.accountCreated` (closed-testing requirement) and `play.billingPrograms` (payments): ask the owner for them, never guess. 1. `storebound check`: config, both listing files (limits are checked locally: title 30, subtitle 30, keywords 100 diff --git a/tests/scan.test.ts b/tests/scan.test.ts index 23736c89..d0e861ff 100644 --- a/tests/scan.test.ts +++ b/tests/scan.test.ts @@ -240,6 +240,11 @@ describe('Google Play rules', () => { const soft = await scanVariant('play-listing', { 'store/listing.md': s => s.replace('🔥 #1 Best Free Photo Saver App Pro', 'Free Photo Saver') }); expect(soft.findings.filter(f => f.rule === 'play-metadata' && f.title.includes('Free Photo Saver')).map(f => f.severity)).toEqual(['low']); expect(rules(await scan('ios-native').then(x => x.findings), 'play').size).toBe(0); + // scan.ignore with match: accepts the ALL CAPS check of play-metadata only, the other metadata checks stay open + const caps = await scanVariant('play-listing', { 'storebound.config.ts': s => s.replace(/\n(\s*)app: \{/, "\n$1scan: { ignore: [{ rule: 'play-metadata', match: 'ALL CAPS', reason: 'brand name' }] },\n$1app: {") }); + const md = caps.findings.filter(f => f.rule === 'play-metadata'); + expect(md.find(f => f.title.includes('ALL CAPS'))!.accepted).toBe('brand name'); + expect(md.filter(f => !f.title.includes('ALL CAPS')).every(f => !f.accepted)).toBe(true); }); test('the policy tables cite their sources', () => { for (const u of Object.values(PLAY_REFS)) expect(u).toMatch(/^https:\/\//); From 41b92dfa13626c397ca02f07f9ad8a71876dafce Mon Sep 17 00:00:00 2001 From: CRT Date: Sun, 11 Oct 2026 18:14:27 +0000 Subject: [PATCH 4/4] aso: App Store keyword fill hint and limit both count UTF-8 bytes (non-Latin locales were warned to add characters that would break the 100-byte limit) --- cli/lib/aso.ts | 8 +++++--- tests/wave1.test.ts | 10 +++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cli/lib/aso.ts b/cli/lib/aso.ts index 190910bb..d2a33005 100644 --- a/cli/lib/aso.ts +++ b/cli/lib/aso.ts @@ -27,10 +27,12 @@ export function auditAppleKeywords(locale: string, c: AppleCopy, appName: string const at = `apple ${locale}`; const kw = c.keywords ?? ''; if (!kw) return [{ level: 'error', where: at, msg: 'keywords: empty' }]; - const chars = len(kw); - if (chars > 100) out.push({ level: 'error', where: at, msg: `keywords: ${chars} characters > 100` }); + // App Store Connect limits the keyword field to 100 bytes (UTF-8), not characters: Cyrillic, Arabic, Hindi, Thai, + // Japanese, Korean and Chinese words take 2-3 bytes per character, so both the limit and the fill hint count bytes. + const bytes = Buffer.byteLength(kw, 'utf8'); + if (bytes > 100) out.push({ level: 'error', where: at, msg: `keywords: ${bytes} bytes > 100` }); if (/,\s|\s,/.test(kw)) out.push({ level: 'error', where: at, msg: 'keywords: spaces around commas waste characters' }); - if (chars < 90) out.push({ level: 'warn', where: at, msg: `keywords: ${chars}/100 used; fill at least 90 (${100 - chars} characters free)` }); + if (bytes < 90) out.push({ level: 'warn', where: at, msg: `keywords: ${bytes}/100 bytes used; fill at least 90 (${100 - bytes} bytes free)` }); const terms = kw.split(',').map(t => t.trim().toLocaleLowerCase(locale)).filter(Boolean); const seen = new Set(); for (const t of terms) { diff --git a/tests/wave1.test.ts b/tests/wave1.test.ts index d015ee5c..c1f1a85c 100644 --- a/tests/wave1.test.ts +++ b/tests/wave1.test.ts @@ -148,10 +148,18 @@ describe('mcp: screenshot and video tools', () => { }); describe('aso', () => { + test('App Store keywords count bytes, not characters (limit and fill hint)', () => { + const msgs = (kw: string) => auditAppleKeywords('ru', { keywords: kw } as never, 'X').map(f => f.msg); + const short = 'игра,бег,прыжки,монеты,уровни,рекорд,аркада'; // 43 characters, 80 bytes + expect(msgs(short).some(m => m.includes('80/100 bytes') && m.includes('fill at least 90'))).toBe(true); + const full = short + ',быстро'; // 50 characters but 93 bytes: full enough + expect(msgs(full).some(m => m.includes('fill at least 90'))).toBe(false); + expect(msgs(full + ',звук').some(m => m.includes('102 bytes > 100'))).toBe(true); + }); test('keyword field rules', () => { const f = auditAppleKeywords('en-US', { subtitle: 'Relaxing puzzle', keywords: 'match,puzzle,match,free game' }, 'Tile Match'); const text = f.map(x => `${x.level}:${x.msg}`).join('\n'); - expect(text).toContain('warn:keywords: 28/100 used'); + expect(text).toContain('warn:keywords: 28/100 bytes used'); expect(text).toContain('"match" listed twice'); expect(text).toContain('repeat words from the name / subtitle (already indexed): match, puzzle'); expect(text).toContain('filler words that rarely help: free, game');