Review access and account deletion: demo account from .storebound (masked) to App Review, accounts config, profile checks in check and validate, Data safety extra rows

This commit is contained in:
CRTkafa 2026-10-10 17:47:08 +00:00
parent 1e57cfec27
commit 7e1d839d68
12 changed files with 578 additions and 21 deletions

View file

@ -1,11 +1,19 @@
// Per-project config (storebound.config.ts at the project root). Everything game-specific lives here; credentials never
// Per-project config (storebound.config.ts at the project root). Everything app-specific lives here; credentials never
// do (see credentials.ts). The file default-exports a plain object; `import type { ShipConfig }` is optional.
import { existsSync } from 'node:fs';
import { dirname, isAbsolute, join, resolve } from 'node:path';
import { validateCapture, validateRecord } from '../shots/devices';
import { validateSubscriptions } from './subscriptions';
import { type TfConfig, validateTestflight } from './testflight';
export type ProductType = 'consumable' | 'non_consumable';
/** consumable / non_consumable: both stores. non_renewing: Apple NON_RENEWING_SUBSCRIPTION (access for a fixed time,
* you track the expiry); Google Play has no such type, so it becomes a one-time product your app consumes when the
* access ends (or model it as a prepaid base plan in Play Console). */
export type ProductType = 'consumable' | 'non_consumable' | 'non_renewing';
/** Which stores sell an item (app identity: one catalog, per-platform availability). Default: every store the config
* has a section for (apple = iOS / iPadOS App Store, play = Google Play). */
export type Platform = 'ios' | 'android';
export interface PriceOverride {
/** ISO 3166-1 alpha-2 region for Play, e.g. "TR". */
@ -36,6 +44,8 @@ export interface Product {
/** Apple only: review screenshot (path relative to the project root). */
reviewScreenshot?: string;
familySharable?: boolean;
/** Sell this product only on these platforms (default: all of app.platforms). */
platforms?: Platform[];
}
export interface Language {
@ -68,6 +78,13 @@ export interface DataSafety {
accountCreation?: string[];
/** Play data type id (e.g. "PSL_DEVICE_ID") -> usage. Types not listed are "not collected". */
data: Record<string, DataUsage>;
/**
* Extra CSV rows for questions storebound does not model, appended as they are. Google does not publish every
* question id (e.g. the delete-account URL asked when accountCreation is not PSL_ACM_NONE): export the form from
* Play Console (App content > Data safety > Export to CSV), copy the exact ids from it, e.g.
* { question: '<id from the export>', value: 'https://example.com/delete-account' }.
*/
extra?: { question: string; response?: string; value: string; label?: string }[];
}
export interface ShotBadgeSlot { y: number; side: 'l' | 'r'; icon?: string; iconBg?: string; hot?: boolean; stars?: boolean; rot?: number }
@ -76,6 +93,10 @@ export interface Palette { bg: [string, string, string]; glow: string; ink: stri
export interface ShotScene { id: string; palette: string | Palette; hero?: boolean; frames: ShotFrame[]; badges?: ShotBadgeSlot[]; over?: number }
export interface ShotsConfig {
/** Look of the rendered screenshots: game (sunburst, sparkles, badges, bold outlined titles) or app (calm gradient,
* device frame, headline + subline, no sparkles or badges). Default: app for the app / subscription-app profiles,
* else game. */
style?: 'game' | 'app';
/** JSON file: { [languageId]: { [sceneId]: { eyebrow, title: [line1, line2], sub, badges: [[big, small?]] } } } */
copy: string;
/** Raw frames: <frames>/<languageId>/<phone|tablet>/<name>.png */
@ -123,7 +144,7 @@ export interface ShotSpec {
export interface ShotsCapture {
/** Where frames come from. Default "web". */
source?: 'web' | 'ios-sim' | 'android-emu' | 'folder';
/** web: URL of the running game, e.g. http://127.0.0.1:5173 */
/** web: URL of the running app or game, e.g. http://127.0.0.1:5173 */
baseUrl?: string;
/** web: appended to every URL, e.g. "lang={lang}&noads=1". */
query?: string;
@ -256,16 +277,157 @@ export interface AppleAppInfo {
reviewNotes?: string;
}
/** What kind of app this is. Picks the `init` templates, the default screenshot style and the profile checks of
* `check` / `validate`. game = free-to-play game with ads + IAP; app = utility / productivity app (optional account,
* analytics, no ads); subscription-app = app with accounts and auto-renewable subscriptions. */
export type AppProfile = 'game' | 'app' | 'subscription-app';
export const PROFILES: readonly AppProfile[] = ['app', 'game', 'subscription-app'];
/** Accounts in the app (sign-up / sign-in). Both stores then want account deletion: Apple 5.1.1(v) inside the app,
* Google Play inside the app and on the web (the URL goes into Data safety). See the account-deletion skill. */
export interface AccountsConfig {
/** The app lets people create an account (or sign in with one you create for them). */
enabled: boolean;
/** Public https page where people request account + data deletion without the app (Play "Delete account URL"). */
deletionUrl?: string;
/** Where deletion starts inside the app, e.g. "Settings > Account > Delete account" (goes into the review notes). */
inApp?: string;
}
/** 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. */
export interface ReviewAccess {
/** Some or all features need a sign-in: App Review gets demoAccountRequired + the demo account. */
signInRequired: boolean;
/** Steps for the reviewer, appended to the App Review notes, e.g. "Sign in with the demo account, open Projects." */
instructions?: string;
}
export type SubscriptionPeriod = 'P1W' | 'P1M' | 'P2M' | 'P3M' | 'P6M' | 'P1Y';
/** Introductory offer for new subscribers. Apple: subscriptionIntroductoryOffers (first-time subscribers of the group,
* per territory). Play: an offer on the base plan for users who never had this subscription. */
export interface IntroOffer {
/** free = free trial; pay-as-you-go = a lower price for `periods` billing periods; pay-up-front = one price for `duration`. */
type: 'free' | 'pay-as-you-go' | 'pay-up-front';
/** free / pay-up-front: P3D, P1W, P2W, P1M, P2M, P3M, P6M or P1Y. pay-as-you-go: the subscription period (default). */
duration?: string;
/** pay-as-you-go: number of discounted periods (1-12). */
periods?: number;
/** pay-as-you-go: price per period, pay-up-front: the whole price, in USD (Apple: equalized price points; Play: converted). */
usd?: number;
/** Play offer id (lowercase letters, digits, hyphens). Default "intro". */
playOfferId?: string;
}
/** A promotional / developer-determined offer. Apple: subscriptionPromotionalOffers (offerCode = id). Play: a base
* plan offer with offer tag = id and no acquisition targeting (your app decides who sees it). */
export interface SubscriptionOfferDef {
/** Apple offer code / Play offer id: lowercase letters, digits, hyphens (Play rule; Apple accepts it too). */
id: string;
/** Apple reference name (default: the id). */
name?: string;
type: 'free' | 'pay-as-you-go' | 'pay-up-front';
/** free / pay-up-front: P3D ... P1Y; pay-as-you-go: the subscription period (default). */
duration?: string;
/** pay-as-you-go: number of discounted periods (1-12). */
periods?: number;
/** USD price (per period for pay-as-you-go, total for pay-up-front). */
usd?: number;
}
/** Apple subscription offer code campaign. Custom codes (e.g. "SPRING26") are created only from a terminal run that
* confirms; one-time-use codes are generated by you in App Store Connect (or later with the API). */
export interface OfferCodeDef {
/** Reference name of the offer code campaign. */
name: string;
/** Who may redeem: NEW (never subscribed), EXISTING, EXPIRED. */
eligibility: ('NEW' | 'EXISTING' | 'EXPIRED')[];
/** true = stack with the introductory offer (STACK_WITH_INTRO_OFFERS), false = replace it (default). */
stackWithIntro?: boolean;
type: 'free' | 'pay-as-you-go' | 'pay-up-front';
duration?: string;
periods?: number;
usd?: number;
/** Custom codes: the code, how many redemptions, optional expiry (YYYY-MM-DD). */
customCodes?: { code: string; count: number; expires?: string }[];
}
export interface SubscriptionListing {
/** Apple display name (30) / Play title. */
title: string;
/** Apple description (45) / Play description. */
description: string;
/** Play only: up to 4 benefits shown on the purchase screen (40 characters each). */
benefits?: string[];
}
export interface Subscription {
/** Product id, same on both stores, e.g. "com.example.app.pro_monthly". */
id: string;
period: SubscriptionPeriod;
/** Rank inside the group, 1 = highest level of service (Apple groupLevel; up / downgrades follow it). */
level: number;
/** Base price per period in USD. Apple: the USA price point and its equalizations; Play: convertRegionPrices. */
usd: number;
/** Regions set by hand (Apple needs a price point with exactly that value). */
overrides?: PriceOverride[];
/** Language id -> display name + description (+ Play benefits). */
listings: Record<string, SubscriptionListing>;
/** Apple only: internal reference name (defaults to the first listing title). */
referenceName?: string;
/** Apple only: note for the reviewer on this subscription. */
reviewNote?: string;
/** Apple only: review screenshot of the purchase screen (path relative to the project root). */
reviewScreenshot?: string;
familySharable?: boolean;
intro?: IntroOffer;
/** More offers people get when your app decides (Apple promotional offers, signed by your server; Play offers
* without acquisition targeting, picked by offer tag in your app). */
offers?: SubscriptionOfferDef[];
/** Apple subscription offer codes (redeemed in the App Store or in the app), with optional custom codes. */
offerCodes?: OfferCodeDef[];
/** Sell this subscription only on these platforms (default: all of app.platforms). */
platforms?: Platform[];
/** Play base plan id (lowercase letters, digits, hyphens). Default from the period: weekly, monthly, yearly, ... */
basePlanId?: string;
/** Play grace period (ISO 8601: P3D, P7D, P14D, P30D). Default: Play's default. */
gracePeriod?: string;
}
/** One subscription group. Apple: a subscription group (people can hold one subscription per group and move between
* its levels). Play has no groups: each subscription becomes a Play subscription with one auto-renewing base plan. */
export interface SubscriptionGroup {
/** Apple reference name of the group (internal, unique per app). */
name: string;
/** Language id -> group display name on the App Store (+ optional custom app name). */
listings: Record<string, { name: string; customAppName?: string }>;
subscriptions: Subscription[];
}
export interface ShipConfig {
app: {
name: string;
/** game | app | subscription-app (see AppProfile). Default: game for configs written before 0.5.0. */
profile?: AppProfile;
/** App identity: the platforms this one app ships on. Default: ios when there is an `apple` section, android when
* there is a `play` section. `apple` / `play` hold the per-platform settings; languages, listings, products and
* subscriptions are shared, with `platforms` on an item to sell it on one store only. */
platforms?: Platform[];
copyright?: string;
privacyPolicyUrl: string;
/** Terms of Use / EULA page. Needed with subscriptions (Apple 3.1.2: in the app and in the metadata). */
termsUrl?: string;
supportUrl: string;
marketingUrl?: string;
website: string;
contactEmail: string;
};
/** Accounts in the app: account deletion checks (Apple 5.1.1(v), Play Data safety delete-account URL). */
accounts?: AccountsConfig;
/** Sign-in for store reviewers (demo account; credentials live in .storebound/ only). */
reviewAccess?: ReviewAccess;
languages: Language[];
play?: {
packageName: string; defaultLanguage?: string; listing?: string; icon?: string;
@ -278,7 +440,7 @@ export interface ShipConfig {
apple?: {
bundleId: string; appId?: string; primaryLocale?: string; listing?: string; info?: AppleAppInfo; reviewShots?: string;
/**
* Export compliance answer for every build (`storebound apple encryption`, `validate`). false ONLY when the game uses
* Export compliance answer for every build (`storebound apple encryption`, `validate`). false ONLY when the app uses
* no encryption beyond what the OS provides (HTTPS / TLS through the system, standard auth). Never set it to false
* to skip the question: a wrong answer is a legal problem, not a store one. Unset = storebound will not answer.
*/
@ -298,6 +460,8 @@ export interface ShipConfig {
testflight?: TfConfig;
};
products?: Product[];
/** Auto-renewable subscriptions (`storebound apple subscriptions`, `storebound play subscriptions`). */
subscriptions?: SubscriptionGroup[];
/** Price sheet for `storebound prices export | import` (product x store x region). */
prices?: {
/** CSV path. Default store/prices.csv. */
@ -314,6 +478,22 @@ export interface ShipConfig {
icons?: IconsConfig;
}
/** Platforms of the app (app identity): app.platforms, else from the store sections. */
export const platformsOf = (c: Pick<ShipConfig, 'app' | 'apple' | 'play'>): Platform[] =>
c.app.platforms ?? [...(c.apple ? ['ios' as const] : []), ...(c.play ? ['android' as const] : [])];
/** Is a catalog item (product / subscription) sold on this store? Pure. */
export const sellsOn = (c: Pick<ShipConfig, 'app' | 'apple' | 'play'>, item: { platforms?: Platform[] }, store: 'apple' | 'play'): boolean => {
const p: Platform = store === 'apple' ? 'ios' : 'android';
return platformsOf(c).includes(p) && (!item.platforms || item.platforms.includes(p));
};
/** The profile of a config: app.profile, else "game" (configs written before profiles existed were games). */
export const profileOf = (c: Pick<ShipConfig, 'app'>): AppProfile => c.app.profile ?? 'game';
/** Screenshot style: shots.style, else app for the app / subscription-app profiles, else game. */
export const shotsStyle = (c: Pick<ShipConfig, 'app' | 'shots'>): 'game' | 'app' => c.shots?.style ?? (profileOf(c) === 'game' ? 'game' : 'app');
/** Identity helper for typed configs: `export default defineConfig({...})`. */
export const defineConfig = (c: ShipConfig): ShipConfig => c;
@ -333,7 +513,21 @@ export function validateConfig(c: unknown): string[] {
for (const k of ['privacyPolicyUrl', 'supportUrl', 'website'] as const) if (!URL_RE.test(app[k] ?? '')) e.push(`app.${k}: must be an https URL`);
if (app.marketingUrl && !URL_RE.test(app.marketingUrl)) e.push('app.marketingUrl: must be an https URL');
if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(app.contactEmail ?? '')) e.push('app.contactEmail: not an email address');
if (app.termsUrl && !URL_RE.test(app.termsUrl)) e.push('app.termsUrl: must be an https URL');
if (app.profile !== undefined && !PROFILES.includes(app.profile)) e.push(`app.profile: one of ${PROFILES.join(', ')}`);
if (app.platforms !== undefined) {
if (!Array.isArray(app.platforms) || !app.platforms.length || !app.platforms.every(x => x === 'ios' || x === 'android')) e.push('app.platforms: a list of ios | android');
else {
if (app.platforms.includes('ios') && !cfg.apple) e.push('app.platforms: ios needs an apple section');
if (app.platforms.includes('android') && !cfg.play) e.push('app.platforms: android needs a play section');
}
}
}
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.reviewAccess && typeof cfg.reviewAccess.signInRequired !== 'boolean') e.push('reviewAccess.signInRequired: true | false');
const langs = cfg.languages;
if (!Array.isArray(langs) || !langs.length) e.push('languages: at least one language');
const ids = new Set<string>();
@ -363,7 +557,8 @@ export function validateConfig(c: unknown): string[] {
if (!PRODUCT_RE.test(p.id ?? '')) e.push(`${at}.id: letters, digits, "." and "_" only`);
if (seen.has(p.id)) e.push(`${at}.id: duplicate "${p.id}"`);
seen.add(p.id);
if (p.type !== 'consumable' && p.type !== 'non_consumable') e.push(`${at}.type: consumable | non_consumable`);
if (p.type !== 'consumable' && p.type !== 'non_consumable' && p.type !== 'non_renewing') e.push(`${at}.type: consumable | non_consumable | non_renewing`);
if (p.platforms !== undefined && !(Array.isArray(p.platforms) && p.platforms.length && p.platforms.every(x => x === 'ios' || x === 'android'))) e.push(`${at}.platforms: a list of ios | android`);
if (!(typeof p.usd === 'number' && p.usd > 0)) e.push(`${at}.usd: positive number`);
if (!p.listings || !Object.keys(p.listings).length) e.push(`${at}.listings: at least one language`);
for (const [lang, l] of Object.entries(p.listings ?? {})) {
@ -378,6 +573,7 @@ export function validateConfig(c: unknown): string[] {
if (!(o.price > 0)) e.push(`${at}.overrides: price must be positive`);
}
}
e.push(...validateSubscriptions(cfg.subscriptions, ids, seen));
if (cfg.prices?.baseTerritory && !/^[A-Z]{3}$/.test(cfg.prices.baseTerritory)) e.push('prices.baseTerritory: App Store territory, alpha-3 (USA)');
if (cfg.dataSafety) {
for (const [t, u] of Object.entries(cfg.dataSafety.data ?? {})) {
@ -385,10 +581,13 @@ export function validateConfig(c: unknown): string[] {
if (!u.collect?.length) e.push(`dataSafety.data.${t}: at least one collection purpose`);
if (u.shared && !u.share?.length) e.push(`dataSafety.data.${t}: shared, so it needs sharing purposes`);
}
for (const [i, x] of (cfg.dataSafety.extra ?? []).entries()) if (!/^[A-Z][A-Z0-9_:]+$/.test(x?.question ?? '') || typeof x.value !== 'string')
e.push(`dataSafety.extra[${i}]: { question: "<PSL_... id from a Play Console export>", value: "..." }`);
}
if (cfg.shots) {
const s = cfg.shots;
for (const k of ['copy', 'frames', 'out'] as const) if (!s[k]) e.push(`shots.${k}: missing`);
if (s.style !== undefined && s.style !== 'game' && s.style !== 'app') e.push('shots.style: game | app');
if (!s.scenes?.length) e.push('shots.scenes: at least one scene');
for (const sc of s.scenes ?? []) if (!sc.frames?.length) e.push(`shots.scenes[${sc.id}].frames: at least one frame`);
e.push(...validateCapture(s.capture));

View file

@ -3,7 +3,9 @@
// ASC_P8 (path to AuthKey_<id>.p8, or the PEM itself)
// 2. <project>/.storebound/credentials.json (gitignored), same names:
// { "PLAY_SERVICE_ACCOUNT": "...", "ASC_KEY_ID": "...", "ASC_ISSUER_ID": "...", "ASC_P8": "...",
// "reviewContact": { "firstName": "", "lastName": "", "phone": "", "email": "" } }
// "reviewContact": { "firstName": "", "lastName": "", "phone": "", "email": "" },
// "reviewDemoAccount": { "username": "", "password": "" } }
// The demo account for App Review can also come from env: REVIEW_DEMO_USER, REVIEW_DEMO_PASSWORD.
// 3. ASC_P8 only: ~/.appstoreconnect/private_keys/AuthKey_<ASC_KEY_ID>.p8 (where Xcode / altool keep it)
import { existsSync, readFileSync } from 'node:fs';
import { homedir } from 'node:os';
@ -59,3 +61,22 @@ export function reviewContact(root: string): ReviewContact | null {
if (!c?.email) return null;
return { firstName: c.firstName ?? '', lastName: c.lastName ?? '', phone: c.phone ?? '', email: c.email };
}
export interface DemoAccount { username: string; password: string }
/** App Review demo account (sign-in for the reviewer): env REVIEW_DEMO_USER + REVIEW_DEMO_PASSWORD, else
* "reviewDemoAccount" in .storebound/credentials.json. Never in the config or the repo. */
export function reviewDemoAccount(root: string): DemoAccount | null {
const eu = process.env.REVIEW_DEMO_USER, ep = process.env.REVIEW_DEMO_PASSWORD;
if (eu && ep) return { username: eu, password: ep };
const d = fileStore(root).reviewDemoAccount as Partial<DemoAccount> | undefined;
if (typeof d?.username === 'string' && d.username && typeof d.password === 'string' && d.password) return { username: d.username, password: d.password };
return null;
}
/** For logs: "d***@example.com" / "d***"; a password is never shown, only its length class. */
export const maskUser = (u: string): string => {
const at = u.indexOf('@');
return at > 0 ? `${u[0]}***${u.slice(at)}` : `${u[0] ?? ''}***`;
};
export const maskSecret = (s: string): string => (s ? '********' : '(empty)');

View file

@ -63,6 +63,7 @@ export function dataSafetyRows(ds: DataSafety): string[][] {
for (const p of PURPOSES) rows.push([q('DATA_USAGE_COLLECTION_PURPOSE'), p, pick(collect.has(p)), 'MULTIPLE_CHOICE', label + ' / Collection purpose']);
for (const p of PURPOSES) rows.push([q('DATA_USAGE_SHARING_PURPOSE'), p, pick(share.has(p)), 'MULTIPLE_CHOICE', label + ' / Sharing purpose']);
}
for (const x of ds.extra ?? []) rows.push([x.question, x.response ?? '', x.value, x.response ? 'MULTIPLE_CHOICE' : 'MAYBE_REQUIRED', x.label ?? x.question]);
return rows;
}

36
cli/lib/profile.ts Normal file
View file

@ -0,0 +1,36 @@
// Offline profile checks for `storebound check`: what an app with accounts, a sign-in for review or subscriptions
// 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 { allSubscriptions } from './subscriptions';
export interface ProfileIssue { level: 'error' | 'warn'; msg: string }
export function profileIssues(config: ShipConfig, o: { demoAccount: boolean }): ProfileIssue[] {
const out: ProfileIssue[] = [];
const err = (msg: string) => out.push({ level: 'error', msg });
const warn = (msg: string) => out.push({ level: 'warn', msg });
const accounts = !!config.accounts?.enabled;
const acm = config.dataSafety?.accountCreation ?? ['PSL_ACM_NONE'];
if (accounts) {
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 (!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 }');
if (config.reviewAccess?.signInRequired) {
if (!o.demoAccount) err('reviewAccess.signInRequired: no demo account ("reviewDemoAccount" in .storebound/credentials.json, or REVIEW_DEMO_USER / REVIEW_DEMO_PASSWORD; review-access skill)');
if (!config.reviewAccess.instructions) warn('reviewAccess.instructions: tell the reviewer how to sign in and where the main features are');
} else if (accounts && config.reviewAccess === undefined) warn('the app has accounts: set reviewAccess { signInRequired } so App Review and Play App access get a demo account when needed');
const subs = allSubscriptions(config.subscriptions);
if (subs.length) {
if (!config.app.termsUrl) err('subscriptions: set app.termsUrl (Terms of Use / EULA, linked in the app and the metadata; Apple 3.1.2)');
if (config.apple && subs.some(x => !x.sub.reviewScreenshot)) warn(`subscriptions without reviewScreenshot: ${subs.filter(x => !x.sub.reviewScreenshot).map(x => x.sub.id).join(', ')} (App Store review needs one each)`);
}
const p = profileOf(config);
if (p === 'subscription-app' && !subs.length) warn('app.profile is subscription-app but there are no subscriptions in the config');
if (p === 'game' && config.shots?.style === 'app') warn('app.profile is game but shots.style is app (fine if intended)');
return out;
}

41
cli/lib/review-details.ts Normal file
View file

@ -0,0 +1,41 @@
// App Review information as pure parts: the appStoreReviewDetails attributes from the config, the review contact and
// the demo account, plus the notes (review notes, sign-in instructions, where account deletion is). Apple: the notes
// field takes up to 4000 bytes; a demo account must keep working during the whole review (Guideline 2.1).
// https://developer.apple.com/help/app-store-connect/reference/app-information/platform-version-information
// https://developer.apple.com/documentation/appstoreconnectapi/appstorereviewdetail/attributes-data.dictionary
import type { ShipConfig } from './config';
import { type DemoAccount, maskSecret, maskUser } from './credentials';
export const NOTES_MAX_BYTES = 4000;
/** Notes for the reviewer: apple.info.reviewNotes, then reviewAccess.instructions, then where account deletion is. */
export function reviewNotes(config: Pick<ShipConfig, 'apple' | 'reviewAccess' | 'accounts'>): string {
const parts = [config.apple?.info?.reviewNotes?.trim() ?? ''];
const ins = config.reviewAccess?.instructions?.trim();
if (ins && !parts[0]!.includes(ins)) parts.push(`Sign-in: ${ins}`);
const del = config.accounts?.enabled ? config.accounts.inApp?.trim() : '';
if (del && !parts.join('\n').includes(del)) parts.push(`Account deletion: ${del}`);
return parts.filter(Boolean).join('\n\n');
}
export interface ReviewDetailPlan {
attributes: Record<string, string | boolean | null>;
/** Log line without secrets. */
summary: string;
}
/**
* Attributes for POST / PATCH appStoreReviewDetails. With reviewAccess.signInRequired the demo account is required
* (throws when it is missing, so a submission never goes out with "sign-in required" and no account); without it the
* demo fields are cleared.
*/
export function reviewDetailPlan(config: Pick<ShipConfig, 'apple' | 'reviewAccess' | 'accounts'>, contact: Record<string, string>, demo: DemoAccount | null): ReviewDetailPlan {
const notes = reviewNotes(config);
const bytes = new TextEncoder().encode(notes).length;
if (bytes > NOTES_MAX_BYTES) throw new Error(`review notes are ${bytes} bytes; App Store Connect takes ${NOTES_MAX_BYTES}`);
const required = !!config.reviewAccess?.signInRequired;
if (required && !demo) throw new Error('reviewAccess.signInRequired is true but there is no demo account: add "reviewDemoAccount": { "username", "password" } to .storebound/credentials.json (or set REVIEW_DEMO_USER / REVIEW_DEMO_PASSWORD); see the review-access skill');
const attributes = { ...contact, demoAccountRequired: required, demoAccountName: required ? demo!.username : null, demoAccountPassword: required ? demo!.password : null, notes };
const summary = `${required ? `demo account ${maskUser(demo!.username)} / ${maskSecret(demo!.password)}` : 'no demo account (no sign-in needed)'}, notes ${bytes} bytes`;
return { attributes, summary };
}

View file

@ -48,6 +48,40 @@ export interface AppleSnapshot {
privacyUrl: UrlCheck;
/** Local renders (Apple sizes only), checked before upload. Optional: validate fills it when a renders dir exists. */
renders?: RendersCheck;
/** Auto-renewable subscriptions on App Store Connect (validate reads them when the config has subscriptions). */
subscriptions?: AppleSubSnapshot[];
/** Subscription product ids of the config, with the App Store locales their listings need. */
expectedSubscriptions?: { id: string; group: string; locales: string[] }[];
/** App profile facts (accounts, sign-in for review, terms URL); see profileRules. */
profile?: ProfileFacts;
}
export interface AppleSubSnapshot {
productId: string;
group: string;
state: string;
locales: { locale: string; state?: string }[];
groupLocales: { locale: string; state?: string }[];
reviewScreenshot: boolean;
}
/** What the profile checks need, collected by validate (local config + credentials + public URL checks). */
export interface ProfileFacts {
profile: 'game' | 'app' | 'subscription-app';
/** accounts.enabled */
accounts: boolean;
/** accounts.inApp is set (where in-app deletion is). */
inAppDeletion: boolean;
/** accounts.deletionUrl, checked (null = not set). */
deletionUrl: UrlCheck | null;
/** reviewAccess.signInRequired */
signInRequired: boolean;
/** A demo account exists locally (.storebound/credentials.json reviewDemoAccount or REVIEW_DEMO_USER / _PASSWORD). */
demoAccountLocal: boolean;
/** The config has subscriptions. */
subscriptions: boolean;
/** app.termsUrl, checked (null = not set). */
termsUrl: UrlCheck | null;
}
export interface PlaySnapshot {
@ -64,6 +98,10 @@ export interface PlaySnapshot {
expectedProducts: string[];
/** Local renders (Play sizes only), checked before upload. */
renders?: RendersCheck;
/** Play subscriptions and their base plans (validate reads them when the config has subscriptions). */
subscriptions?: { productId: string; basePlans: { basePlanId: string; state?: string }[] }[];
expectedSubscriptions?: { id: string; basePlanId: string }[];
profile?: ProfileFacts;
}
const EDITABLE = ['PREPARE_FOR_SUBMISSION', 'DEVELOPER_REJECTED', 'REJECTED', 'METADATA_REJECTED', 'INVALID_BINARY'];
@ -132,7 +170,9 @@ export function appleRules(s: AppleSnapshot): Finding[] {
}
if (s.iaps.length && !f.some(x => x.code === 'iap')) add('ok', 'iap', `${s.iaps.length} in-app purchases ready`);
f.push(...appleSubscriptionRules(s));
add(urlOk(s.privacyUrl) ? 'ok' : 'blocker', 'privacy-url', `privacy policy ${s.privacyUrl.url}: ${urlMsg(s.privacyUrl)}`, 'privacy-policy skill');
if (s.profile) f.push(...profileRules('apple', s.profile, { reviewDetail: s.reviewDetail, descriptions: s.locales.map(l => ({ locale: l.locale, text: l.description ?? '' })) }));
f.push(...rendersFindings('apple', s.renders));
return sortFindings(f);
}
@ -159,11 +199,11 @@ export function playRules(s: PlaySnapshot): Finding[] {
if (s.appAdsLines.length || s.adsLikely) {
if (!s.website) add('blocker', 'app-ads', 'no developer website on the listing (app-ads.txt is looked up there)', 'storebound play listing (app.website)');
else if (!s.appAds || !urlOk(s.appAds)) add(s.appAdsLines.length ? 'blocker' : 'warn', 'app-ads', `${s.website.replace(/\/$/, '')}/app-ads.txt: ${s.appAds ? urlMsg(s.appAds) : 'not checked'}`, 'ads-levelplay-checks skill');
else if (!s.appAds || !urlOk(s.appAds)) add(s.appAdsLines.length ? 'blocker' : 'warn', 'app-ads', `${s.website.replace(/\/$/, '')}/app-ads.txt: ${s.appAds ? urlMsg(s.appAds) : 'not checked'}`, 'ads-mediation-checks skill');
else if (s.appAdsLines.length) {
const body = new Set((s.appAds.body ?? '').split(/\r?\n/).map(normAdsLine).filter(Boolean));
const missing = s.appAdsLines.filter(l => !body.has(normAdsLine(l)));
if (missing.length) add('blocker', 'app-ads', `app-ads.txt lacks ${missing.length} line(s): ${missing.slice(0, 3).join(' | ')}${missing.length > 3 ? ' ...' : ''}`, 'ads-levelplay-checks skill');
if (missing.length) add('blocker', 'app-ads', `app-ads.txt lacks ${missing.length} line(s): ${missing.slice(0, 3).join(' | ')}${missing.length > 3 ? ' ...' : ''}`, 'ads-mediation-checks skill');
else add('ok', 'app-ads', `app-ads.txt has all ${s.appAdsLines.length} lines`);
} else add('warn', 'app-ads', 'app-ads.txt reachable; set ads.appAdsTxt in the config to check its lines');
}
@ -183,10 +223,84 @@ export function playRules(s: PlaySnapshot): Finding[] {
else if (!p.states.includes('ACTIVE')) add('blocker', 'products', `${id}: purchase option ${p.states.join(',') || 'no state'}`, 'storebound play products');
}
if (s.expectedProducts.length && !f.some(x => x.code === 'products')) add('ok', 'products', `${s.expectedProducts.length} products active`);
const subs = new Map((s.subscriptions ?? []).map(x => [x.productId, x] as const));
for (const e of s.expectedSubscriptions ?? []) {
const cur = subs.get(e.id);
const bp = cur?.basePlans.find(b => b.basePlanId === e.basePlanId);
if (!cur) add('blocker', 'subscriptions', `${e.id}: subscription not on Play`, 'storebound play subscriptions');
else if (!bp) add('blocker', 'subscriptions', `${e.id}: no base plan ${e.basePlanId}`, 'storebound play subscriptions');
else if (bp.state !== 'ACTIVE') add('blocker', 'subscriptions', `${e.id}: base plan ${e.basePlanId} is ${bp.state ?? 'not active'}`, 'storebound play subscriptions (activates it)');
}
if (s.expectedSubscriptions?.length && !f.some(x => x.code === 'subscriptions')) add('ok', 'subscriptions', `${s.expectedSubscriptions.length} subscriptions with an active base plan`);
if (s.profile) f.push(...profileRules('play', s.profile, {}));
f.push(...rendersFindings('play', s.renders));
return sortFindings(f);
}
const SUB_OK = ['READY_TO_SUBMIT', 'WAITING_FOR_REVIEW', 'IN_REVIEW', 'APPROVED', 'PENDING_BINARY_APPROVAL'];
/** Subscriptions on App Store Connect vs the config: present, state, localizations (and their review state), group
* display names, review screenshot. */
export function appleSubscriptionRules(s: Pick<AppleSnapshot, 'subscriptions' | 'expectedSubscriptions'>): Finding[] {
const f: Finding[] = [];
const add = (level: Level, msg: string, fix?: string) => f.push({ store: 'apple', level, code: 'subscriptions', msg, fix });
const have = new Map((s.subscriptions ?? []).map(x => [x.productId, x] as const));
const groupsDone = new Set<string>();
for (const e of s.expectedSubscriptions ?? []) {
const cur = have.get(e.id);
if (!cur) { add('blocker', `${e.id}: subscription not on App Store Connect`, 'storebound apple subscriptions'); continue; }
if (!groupsDone.has(cur.group)) {
groupsDone.add(cur.group);
if (!cur.groupLocales.length) add('blocker', `group "${cur.group}": no localization (display name)`, 'storebound apple subscriptions');
for (const l of cur.groupLocales) if (l.state === 'REJECTED') add('blocker', `group "${cur.group}" ${l.locale}: localization rejected`, 'fix the group display name, then storebound apple subscriptions');
}
if (cur.state === 'MISSING_METADATA') add('blocker', `${e.id}: MISSING_METADATA (localization, price, availability or review screenshot missing)`, 'storebound apple subscriptions');
else if (!SUB_OK.includes(cur.state)) add('blocker', `${e.id}: ${cur.state}`, cur.state === 'REJECTED' || cur.state === 'DEVELOPER_ACTION_NEEDED' ? 'review-rejections skill; fix and resubmit with a version' : 'store-subscriptions skill');
const locs = new Map(cur.locales.map(l => [l.locale, l] as const));
for (const loc of e.locales) if (!locs.has(loc)) add('blocker', `${e.id}: no ${loc} localization`, 'storebound apple subscriptions');
for (const l of cur.locales) if (l.state === 'REJECTED') add('blocker', `${e.id} ${l.locale}: localization rejected`, 'fix the display name / description, then storebound apple subscriptions');
if (!cur.reviewScreenshot && cur.state !== 'APPROVED') add('blocker', `${e.id}: no review screenshot`, 'subscriptions[].reviewScreenshot, then storebound apple subscriptions');
}
if (s.expectedSubscriptions?.length && !f.length) add('ok', `${s.expectedSubscriptions.length} subscriptions ready (state, localizations, review screenshots)`);
return f;
}
/**
* App profile checks. Accounts: Apple 5.1.1(v) wants deletion inside the app (no API can see it: a reminder unless
* accounts.inApp says where), Play wants a reachable delete-account URL as well. Sign-in for review: the demo account
* must exist locally and be on the App Review details. Subscriptions: a reachable Terms of Use (EULA) URL, and Apple
* metadata (description) that links it (3.1.2).
*/
export function profileRules(store: 'apple' | 'play', p: ProfileFacts, o: { reviewDetail?: AppleSnapshot['reviewDetail']; descriptions?: { locale: string; text: string }[] }): Finding[] {
const f: Finding[] = [];
const add = (level: Level, code: string, msg: string, fix?: string) => f.push({ store, level, code, msg, fix });
if (p.accounts) {
if (store === 'play') {
if (!p.deletionUrl) add('blocker', 'account-deletion', 'the app has accounts but accounts.deletionUrl is not set (Play Data safety asks for a delete-account URL)', 'account-deletion skill');
else if (!urlOk(p.deletionUrl)) add('blocker', 'account-deletion', `delete-account page ${p.deletionUrl.url}: ${urlMsg(p.deletionUrl)}`, 'account-deletion skill');
else add('ok', 'account-deletion', `delete-account page ${p.deletionUrl.url} answers`);
} else if (!p.inAppDeletion) add('warn', 'account-deletion', 'the app has accounts: deletion must start inside the app (5.1.1(v)); set accounts.inApp to where it is, it goes into the review notes', 'account-deletion skill');
else add('ok', 'account-deletion', 'in-app account deletion named in the config (5.1.1(v); test it before review)');
}
if (p.signInRequired) {
if (!p.demoAccountLocal) add('blocker', 'demo-account', 'sign-in required for review but no demo account in .storebound/credentials.json (reviewDemoAccount) or REVIEW_DEMO_USER / REVIEW_DEMO_PASSWORD', 'review-access skill');
if (store === 'apple' && o.reviewDetail && !(o.reviewDetail.demoAccountRequired && o.reviewDetail.demoAccountName))
add('blocker', 'demo-account', 'App Review information has no demo account although the app needs a sign-in (Guideline 2.1)', 'storebound apple review-details');
if (store === 'play') add('warn', 'app-access', 'sign-in required: Play Console > App content > App access must list the demo credentials and steps (no API)', 'review-access skill');
if (!f.some(x => x.code === 'demo-account')) add('ok', 'demo-account', 'demo account for review present');
}
if (p.subscriptions) {
if (!p.termsUrl) add('blocker', 'terms-url', 'subscriptions need a Terms of Use (EULA) link in the app and the metadata: app.termsUrl is not set', 'store-subscriptions skill');
else if (!urlOk(p.termsUrl)) add('blocker', 'terms-url', `terms of use ${p.termsUrl.url}: ${urlMsg(p.termsUrl)}`, 'store-subscriptions skill');
else {
add('ok', 'terms-url', `terms of use ${p.termsUrl.url} answers`);
const missing = (o.descriptions ?? []).filter(d => d.text && !d.text.includes(p.termsUrl!.url) && !/terms of use|\beula\b|license agreement/i.test(d.text)).map(d => d.locale);
if (store === 'apple' && missing.length) add('warn', 'terms-url', `description without a Terms of Use link: ${missing.join(', ')} (3.1.2; or set a custom EULA in App Information)`, 'store-subscriptions skill');
}
}
return f;
}
/** Blockers first, then warnings, then ok; stable inside a level (rule order). */
export function sortFindings(f: Finding[]): Finding[] {
const rank: Record<Level, number> = { blocker: 0, warn: 1, ok: 2 };