mobileui-os 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +47 -0
- package/CHANGELOG.md +25 -0
- package/README.md +78 -0
- package/bin/cli.mjs +375 -0
- package/knowledge/android/00-apple-to-android-adaption.md +1499 -0
- package/knowledge/android/accessibility.md +333 -0
- package/knowledge/android/components-controls.md +270 -0
- package/knowledge/android/material-design-3.md +174 -0
- package/knowledge/android/navigation-patterns.md +212 -0
- package/knowledge/apple/00-skill-reading-protocol.md +1296 -0
- package/knowledge/apple/Accessibility, Inclusive Design & Human Factors Intelligence.md +735 -0
- package/knowledge/apple/Advanced Interaction Patterns, Gestures, Feedback & State Transitions.md +1140 -0
- package/knowledge/apple/Advanced Navigation, Information Architecture & Wayfinding.md +551 -0
- package/knowledge/apple/Autonomus Ui-UX Improvement Loop.md +611 -0
- package/knowledge/apple/Color, Materials, Contrast, Themes & Visual Depth.md +1351 -0
- package/knowledge/apple/Content, Copy, Microinteractions & UX Communication.md +642 -0
- package/knowledge/apple/Data-Heavy Interfaces, Tables, Lists, Search, Filtering & Large-Scale Content.md +721 -0
- package/knowledge/apple/Design Systems & Component Architecture.md +412 -0
- package/knowledge/apple/Forms, Input, Data Entry & Validation Intelligence.md +705 -0
- package/knowledge/apple/Interaction, State & Edge-Case Engineering.md +491 -0
- package/knowledge/apple/Interaction-behaviour.md +1378 -0
- package/knowledge/apple/Layout Architecture, Responsive Design & Spatial Systems.md +1365 -0
- package/knowledge/apple/MASTER UI-UX ORCHESTRATOR.md +1210 -0
- package/knowledge/apple/Navigation Architecture, Routing, Deep Linking & State Restoration.md +1392 -0
- package/knowledge/apple/Navigation, Information Architecture & Spatial Hierarchy.md +1613 -0
- package/knowledge/apple/Notifications, Permissions, Privacy and Trust.md +1540 -0
- package/knowledge/apple/Patterns-templates-composition.md +647 -0
- package/knowledge/apple/Performance, Perceived Speed, Motion & Rendering Intelligence.md +855 -0
- package/knowledge/apple/Responsive, Adaptive & Cross-Platform UI Intelligence.md +669 -0
- package/knowledge/apple/Responsive, Adaptive, Accessible & Performant UI.md +545 -0
- package/knowledge/apple/Tablet Adaptation & Multi-Device UX.md +1447 -0
- package/knowledge/apple/UI Implementation & Refactoring.md +498 -0
- package/knowledge/apple/UI-UX Decision-Making, Prioritization & Trade-offs.md +533 -0
- package/knowledge/apple/UI-UX Project Lifecycle & Delivery.md +544 -0
- package/knowledge/apple/User Flows & Experience Architecture.md +335 -0
- package/knowledge/apple/Visual Design Systems, Theming, Tokens & Brand Intelligence.md +764 -0
- package/knowledge/apple/Visual QA, Testing & Validation.md +557 -0
- package/knowledge/apple/accessibility-inclusive-interaction.md +1361 -0
- package/knowledge/apple/accessibility.md +2162 -0
- package/knowledge/apple/color.md +1933 -0
- package/knowledge/apple/component-architecture.md +2208 -0
- package/knowledge/apple/components.md +2172 -0
- package/knowledge/apple/design-decision-framework.md +1883 -0
- package/knowledge/apple/design-review-engine.md +2108 -0
- package/knowledge/apple/design-tokens.md +1943 -0
- package/knowledge/apple/designing-for-ios.md +1680 -0
- package/knowledge/apple/gestures, touch behavior, feedback, motion, and micro-interactions.md +1538 -0
- package/knowledge/apple/hig-foundation.md +1806 -0
- package/knowledge/apple/iconography.md +1903 -0
- package/knowledge/apple/interaction-patterns.md +2513 -0
- package/knowledge/apple/interaction.md +2141 -0
- package/knowledge/apple/ios-alerts-confirmations-destructive-actions.md +1342 -0
- package/knowledge/apple/ios-components-and-controls.md +1634 -0
- package/knowledge/apple/ios-components-patterns.md +1343 -0
- package/knowledge/apple/ios-design-system-architecture.md +1520 -0
- package/knowledge/apple/ios-empty-error-offline-states.md +1370 -0
- package/knowledge/apple/ios-empty-loading-error-recovery.md +1674 -0
- package/knowledge/apple/ios-forms-and-input.md +1458 -0
- package/knowledge/apple/ios-forms-input-data-entry.md +1308 -0
- package/knowledge/apple/ios-gestures-and-touch.md +1272 -0
- package/knowledge/apple/ios-lists-collections-and-data-display.md +1735 -0
- package/knowledge/apple/ios-loading-progress-async-states.md +1378 -0
- package/knowledge/apple/ios-materials-and-surfaces.md +1543 -0
- package/knowledge/apple/ios-motion-animation-transitions.md +1178 -0
- package/knowledge/apple/ios-navigation-and-information-architecture.md +1674 -0
- package/knowledge/apple/ios-navigation-user-flows-design-architecture.md +1195 -0
- package/knowledge/apple/ios-search-and-discovery.md +1456 -0
- package/knowledge/apple/ios-search-filtering-discovery.md +1402 -0
- package/knowledge/apple/ios-sheets-modals-popovers.md +1205 -0
- package/knowledge/apple/ios-typography-icons-visual-hierarchy.md +1431 -0
- package/knowledge/apple/layout.md +2331 -0
- package/knowledge/apple/media-centric-content-ui-patterns.md +1470 -0
- package/knowledge/apple/motion, transitions, physics, and animation language.md +1535 -0
- package/knowledge/apple/motion-and-animation.md +1698 -0
- package/knowledge/apple/motion.md +2087 -0
- package/knowledge/apple/navigation.md +2281 -0
- package/knowledge/apple/responsive-adaptive.md +2159 -0
- package/knowledge/apple/screen-architecture.md +2067 -0
- package/knowledge/apple/typography, Content Hierarchy & Readability.md +1411 -0
- package/knowledge/apple/typography.md +1802 -0
- package/knowledge/apple/ui-ux inteligence audit.md +106 -0
- package/knowledge/apple/visual-design-and-premium-ui.md +1555 -0
- package/knowledge/apple/visual-hierarchy-engine.md +1647 -0
- package/knowledge/apple/visual-materials.md +2189 -0
- package/package.json +53 -0
- package/principles/design-principles.md +37 -0
- package/principles/platform-principles.md +25 -0
- package/principles/ux-principles.md +16 -0
- package/references/official-links.md +11 -0
- package/skills/accessibility-engineer/SKILL.md +125 -0
- package/skills/analytics-engineer/SKILL.md +283 -0
- package/skills/animation-engineer/SKILL.md +316 -0
- package/skills/component-designer/SKILL.md +75 -0
- package/skills/component-library-engineer/SKILL.md +140 -0
- package/skills/component-library-ops/SKILL.md +155 -0
- package/skills/design-system/SKILL.md +77 -0
- package/skills/design-token-engineer/SKILL.md +203 -0
- package/skills/design-token-pipeline/SKILL.md +277 -0
- package/skills/device-lab-engineer/SKILL.md +387 -0
- package/skills/forms-engineer/SKILL.md +79 -0
- package/skills/internationalization-engineer/SKILL.md +256 -0
- package/skills/motion-designer/SKILL.md +77 -0
- package/skills/native-data-fetching/SKILL.md +50 -0
- package/skills/navigation-architect/SKILL.md +65 -0
- package/skills/performance-engineer/SKILL.md +250 -0
- package/skills/platform-specialist/SKILL.md +95 -0
- package/skills/pre-release-gate/SKILL.md +75 -0
- package/skills/screen-designer/SKILL.md +117 -0
- package/skills/security-engineer/SKILL.md +375 -0
- package/skills/skills.json +134 -0
- package/skills/testing-auditor/SKILL.md +62 -0
- package/skills/ui-architect/SKILL.md +86 -0
- package/skills/ui-implementer/SKILL.md +188 -0
- package/skills/ux-architect/SKILL.md +49 -0
- package/skills/ux-auditor/SKILL.md +52 -0
- package/skills/visual-auditor/SKILL.md +71 -0
- package/templates/audit-report.md +29 -0
- package/templates/design-tokens.ts +33 -0
- package/templates/screen-spec.md +61 -0
- package/workflows/new-screen.md +17 -0
- package/workflows/pre-release.md +21 -0
- package/workflows/redesign.md +14 -0
- package/workflows/ui-audit.md +22 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Platform Specialist
|
|
2
|
+
|
|
3
|
+
Determine platform-specific vs. shared implementation for every interaction.
|
|
4
|
+
|
|
5
|
+
## Decision Framework
|
|
6
|
+
|
|
7
|
+
For each feature/interaction, classify:
|
|
8
|
+
|
|
9
|
+
| Classification | Criteria | Examples |
|
|
10
|
+
|----------------|----------|----------|
|
|
11
|
+
| **Shared** | Same intent, same mental model, platform conventions align | Button tap, text input, list scroll, toggle, card tap |
|
|
12
|
+
| **iOS-specific** | iOS convention materially better; Android has no equivalent | Large title nav, swipe-back gesture, SF Symbols, haptic engine |
|
|
13
|
+
| **Android-specific** | Android convention materially better; iOS has no equivalent | Back gesture (system), bottom nav/rail/drawer, Material ripple, predictive back |
|
|
14
|
+
| **Adapted** | Same intent, different execution | Sheets (iOS) vs Bottom Sheets (Android), Alerts vs Dialogs |
|
|
15
|
+
|
|
16
|
+
## Navigation Mapping
|
|
17
|
+
|
|
18
|
+
| iOS | Android | Shared Intent |
|
|
19
|
+
|-----|---------|---------------|
|
|
20
|
+
| Navigation bar (large title) | Top app bar (collapsing) | Screen title + actions |
|
|
21
|
+
| Tab bar (fixed) | Bottom nav / Rail / Drawer | Primary destinations |
|
|
22
|
+
| Push (swipe back) | Push (system back) | Drill-down |
|
|
23
|
+
| Sheet (modal) | Bottom sheet (modal/persistent) | Contextual task |
|
|
24
|
+
| Alert (centered) | Dialog / Bottom sheet | Confirmation |
|
|
25
|
+
| Split view (iPad) | Two-pane / Rail (tablet) | Master-detail |
|
|
26
|
+
|
|
27
|
+
## Component Platform Differences
|
|
28
|
+
|
|
29
|
+
| Component | iOS | Android |
|
|
30
|
+
|-----------|-----|---------|
|
|
31
|
+
| **Button** | Rounded rect, no ripple, haptic | Rounded rect, ripple, elevation |
|
|
32
|
+
| **Input** | Native `UITextField`, floating label | `TextInputLayout`, floating label |
|
|
33
|
+
| **Picker** | `UIDatePicker` (inline/wheel) | `MaterialDatePicker` (modal sheet) |
|
|
34
|
+
| **Switch** | `UISwitch` (green track) | `SwitchMaterial` (primary track) |
|
|
35
|
+
| **Slider** | `UISlider` (minimal) | `Slider` (track + thumb + value label) |
|
|
36
|
+
| **Toast** | None (use banner/sheet) | `Snackbar` (action + dismiss) |
|
|
37
|
+
| **Pull-to-refresh** | `UIRefreshControl` | `SwipeRefreshLayout` |
|
|
38
|
+
| **Search** | Nav bar integration | Toolbar / separate screen |
|
|
39
|
+
|
|
40
|
+
## Expo UI / Native Modules
|
|
41
|
+
|
|
42
|
+
When to use native (SwiftUI / Jetpack Compose) via Expo UI:
|
|
43
|
+
|
|
44
|
+
- Complex forms with native pickers, date/time, auto-fill
|
|
45
|
+
- Settings screens (toggles, sections, grouped)
|
|
46
|
+
- Media pickers, document pickers
|
|
47
|
+
- Maps, camera, AR
|
|
48
|
+
- Performance-critical lists (FlashList native)
|
|
49
|
+
- When cross-platform approximation degrades UX
|
|
50
|
+
|
|
51
|
+
## Implementation Strategy
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
// Shared API, platform-specific behavior
|
|
55
|
+
// Button.tsx
|
|
56
|
+
import { Platform } from 'react-native';
|
|
57
|
+
import { ButtonIOS } from './Button.ios';
|
|
58
|
+
import { ButtonAndroid } from './Button.android';
|
|
59
|
+
|
|
60
|
+
export const Button = Platform.select({
|
|
61
|
+
ios: ButtonIOS,
|
|
62
|
+
android: ButtonAndroid,
|
|
63
|
+
default: ButtonBase,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Or use Expo UI Host/RNHostView for native trees
|
|
67
|
+
import { Host, Button } from '@expo/ui';
|
|
68
|
+
<Host>
|
|
69
|
+
<Button variant="filled" onPress={...} />
|
|
70
|
+
</Host>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Validation Checklist
|
|
74
|
+
|
|
75
|
+
- [ ] System back works predictably (Android)
|
|
76
|
+
- [ ] Swipe-back works (iOS)
|
|
77
|
+
- [ ] Large titles / collapsing toolbar correct
|
|
78
|
+
- [ ] Bottom nav / rail / drawer per screen size
|
|
79
|
+
- [ ] Sheets: iOS detents, Android expandable
|
|
80
|
+
- [ ] Dialogs: iOS centered, Android bottom sheet option
|
|
81
|
+
- [ ] Ripple/haptic per platform
|
|
82
|
+
- [ ] Icons: SF Symbols (iOS), Material (Android)
|
|
83
|
+
- [ ] Typography: San Francisco / system font scaling
|
|
84
|
+
- [ ] Safe area / insets handled
|
|
85
|
+
- [ ] Keyboard avoidance per platform
|
|
86
|
+
- [ ] Permissions: iOS pre-prompt → system; Android runtime + rationale
|
|
87
|
+
|
|
88
|
+
## Anti-Patterns
|
|
89
|
+
|
|
90
|
+
- Forcing identical pixels across platforms
|
|
91
|
+
- iOS-style back button on Android
|
|
92
|
+
- Android ripple on iOS
|
|
93
|
+
- Custom picker replacing native
|
|
94
|
+
- Ignoring system font scaling
|
|
95
|
+
- Hardcoded safe area values
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Pre-Release Gate
|
|
2
|
+
|
|
3
|
+
Execute the pre-release workflow: automated checks, manual verification, beta distribution, rollout monitoring.
|
|
4
|
+
|
|
5
|
+
## Workflow (from `workflows/pre-release.md`)
|
|
6
|
+
|
|
7
|
+
1. **Automated Gates** (CI)
|
|
8
|
+
- TypeScript strict: pass
|
|
9
|
+
- Lint: 0 errors
|
|
10
|
+
- Tests: unit + integration + e2e critical paths pass
|
|
11
|
+
- Visual regression: 0 diffs (or approved)
|
|
12
|
+
- A11y automation: 0 violations
|
|
13
|
+
- Performance budgets: all green
|
|
14
|
+
- Bundle size: within budget
|
|
15
|
+
|
|
16
|
+
2. **Manual Verification** (Device)
|
|
17
|
+
- Install on physical iOS + Android
|
|
18
|
+
- Test: cold start, warm start, background restore
|
|
19
|
+
- Test: offline → online, airplane mode, poor network
|
|
20
|
+
- Test: dynamic type (AX1–AX5), reduced motion, bold text
|
|
21
|
+
- Test: VoiceOver / TalkBack full critical paths
|
|
22
|
+
- Test: RTL language (Arabic/Hebrew)
|
|
23
|
+
- Test: iOS 16/17/18, Android 12/13/14/15
|
|
24
|
+
|
|
25
|
+
3. **Beta Distribution**
|
|
26
|
+
- EAS Build → internal distribution (TestFlight, Play Internal)
|
|
27
|
+
- Changelog generated from conventional commits
|
|
28
|
+
- Install links shared with stakeholders
|
|
29
|
+
- Feedback collection: structured form + crash reports
|
|
30
|
+
|
|
31
|
+
4. **Rollout Monitoring** (Post-release)
|
|
32
|
+
- EAS Update insights: crash rate < 0.1%, install success > 99%
|
|
33
|
+
- Analytics: core funnel conversion ±5% of baseline
|
|
34
|
+
- Error tracking: no new critical errors in 24h
|
|
35
|
+
- Performance: p95 launch time, screen transitions within budget
|
|
36
|
+
|
|
37
|
+
## Checklists
|
|
38
|
+
|
|
39
|
+
### Device Test Matrix
|
|
40
|
+
|
|
41
|
+
| Config | iOS | Android |
|
|
42
|
+
|--------|-----|---------|
|
|
43
|
+
| Latest OS | ✓ | ✓ |
|
|
44
|
+
| -1 OS | ✓ | ✓ |
|
|
45
|
+
| Small screen (SE, compact) | ✓ | ✓ |
|
|
46
|
+
| Large screen (Pro Max, foldable) | ✓ | ✓ |
|
|
47
|
+
| Dynamic type AX3 | ✓ | ✓ |
|
|
48
|
+
| Dynamic type AX5 | ✓ | ✓ |
|
|
49
|
+
| Reduced motion | ✓ | ✓ |
|
|
50
|
+
| VoiceOver/TalkBack | ✓ | ✓ |
|
|
51
|
+
| RTL | ✓ | ✓ |
|
|
52
|
+
| Offline first launch | ✓ | ✓ |
|
|
53
|
+
|
|
54
|
+
### Sign-Off
|
|
55
|
+
|
|
56
|
+
- [ ] Design: visual audit pass (visual-auditor)
|
|
57
|
+
- [ ] UX: ux-auditor pass on critical paths
|
|
58
|
+
- [ ] A11y: accessibility-engineer pass
|
|
59
|
+
- [ ] Platform: platform-specialist pass (both)
|
|
60
|
+
- [ ] Performance: testing-auditor budgets met
|
|
61
|
+
- [ ] Data: native-data-fetching states verified
|
|
62
|
+
- [ ] Eng: typecheck, lint, tests green
|
|
63
|
+
|
|
64
|
+
## Rollback Criteria
|
|
65
|
+
|
|
66
|
+
- Crash rate > 0.5% in first hour
|
|
67
|
+
- Core funnel drop > 10%
|
|
68
|
+
- Critical user-reported regression
|
|
69
|
+
- App Store / Play Store rejection
|
|
70
|
+
|
|
71
|
+
## Automation
|
|
72
|
+
|
|
73
|
+
- `eas-update-insights` skill for OTA health
|
|
74
|
+
- Slack/Linear alerts on rollback criteria
|
|
75
|
+
- Auto-promote internal → production after 24h green
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Screen Designer
|
|
2
|
+
|
|
3
|
+
Translate the screen architecture into a visual composition.
|
|
4
|
+
|
|
5
|
+
## Process
|
|
6
|
+
|
|
7
|
+
1. **Establish hierarchy** — What does the user see first, second, third?
|
|
8
|
+
2. **Apply spacing rhythm** — Use token scale (xs, sm, md, lg, xl, xxl, xxxl) consistently
|
|
9
|
+
3. **Align to grid** — 4pt/8pt baseline; optical alignment for type
|
|
10
|
+
4. **Set typography** — Display, heading, subheading, body, caption; respect dynamic type
|
|
11
|
+
5. **Verify contrast** — AA (4.5:1) for text, AAA (7:1) for critical; 3:1 for UI elements
|
|
12
|
+
6. **Control density** — Breathing room vs. information density; no "card soup"
|
|
13
|
+
7. **Group content** — Proximity, similarity, continuity; explicit dividers only when needed
|
|
14
|
+
8. **Size touch targets** — ≥44×44pt (iOS) / 48×48dp (Android); visual ≠ interactive size
|
|
15
|
+
9. **Balance visually** — Weight, color, whitespace; no accidental emphasis
|
|
16
|
+
10. **Apply platform conventions** — iOS: large titles, SF Symbols, sheets; Android: Material, bottom nav, back gesture
|
|
17
|
+
|
|
18
|
+
## Checklist
|
|
19
|
+
|
|
20
|
+
- [ ] Single primary action per screen (visually dominant)
|
|
21
|
+
- [ ] Secondary actions visually quiet
|
|
22
|
+
- [ ] Destructive actions require confirmation
|
|
23
|
+
- [ ] Loading: skeleton matches content structure (not generic spinner)
|
|
24
|
+
- [ ] Empty: explains cause + next action
|
|
25
|
+
- [ ] Error: explains problem, impact, recovery
|
|
26
|
+
- [ ] Offline: shows cached state + sync indicator
|
|
27
|
+
- [ ] Dynamic type: no clipping at 200% (AX3)
|
|
28
|
+
- [ ] Reduced motion: non-essential animation disabled
|
|
29
|
+
- [ ] RTL: layout mirrors, icons flip (directional only)
|
|
30
|
+
|
|
31
|
+
## Anti-Patterns
|
|
32
|
+
|
|
33
|
+
- Starting with shadows, gradients, rounded cards
|
|
34
|
+
- Multiple primary actions competing
|
|
35
|
+
- Generic "card" containers without semantic purpose
|
|
36
|
+
- Spacing by eye instead of token scale
|
|
37
|
+
- Color-only state indication
|
|
38
|
+
- Decorative animation
|
|
39
|
+
|
|
40
|
+
## Output
|
|
41
|
+
|
|
42
|
+
Screen spec (use `templates/screen-spec.md`) + annotated mockups + token mapping.
|
|
43
|
+
|
|
44
|
+
## Token Reference
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { tokens } from '@myorg/design-tokens';
|
|
48
|
+
|
|
49
|
+
const styles = StyleSheet.create({
|
|
50
|
+
container: {
|
|
51
|
+
padding: tokens.spacing.md,
|
|
52
|
+
backgroundColor: tokens.color.surface,
|
|
53
|
+
borderRadius: tokens.radius.md,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Responsive Breakpoints
|
|
59
|
+
|
|
60
|
+
| Size Class | Width | Layout Adaptations |
|
|
61
|
+
|------------|-------|--------------------|
|
|
62
|
+
| **Compact** | < 600dp | Single column, bottom nav, sheets |
|
|
63
|
+
| **Regular** | 600–840dp | Two-column (list+detail), rail, dialogs |
|
|
64
|
+
| **Large** | > 840dp | Multi-pane, permanent rail, split view |
|
|
65
|
+
|
|
66
|
+
## Platform Overrides
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import { Platform } from 'react-native';
|
|
70
|
+
|
|
71
|
+
const Button = Platform.select({
|
|
72
|
+
ios: ButtonIOS,
|
|
73
|
+
android: ButtonAndroid,
|
|
74
|
+
default: ButtonBase,
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Component Mapping
|
|
79
|
+
|
|
80
|
+
| Component | Token | Example |
|
|
81
|
+
|-----------|-------|---------|
|
|
82
|
+
| Button (primary) | `color.primaryAction` | `backgroundColor: tokens.color.primaryAction` |
|
|
83
|
+
| Text (heading) | `typography.heading` | `fontSize: tokens.typography.heading.fontSize` |
|
|
84
|
+
| Card | `spacing.md` | `padding: tokens.spacing.md` |
|
|
85
|
+
|
|
86
|
+
## Accessibility in Design
|
|
87
|
+
|
|
88
|
+
- Add semantic labels to all interactive elements
|
|
89
|
+
- Verify contrast with WCAG 2.1 AA/AAA
|
|
90
|
+
- Ensure focus order matches visual order
|
|
91
|
+
- Use `accessibilityRole` and `accessibilityLabel` in component specs
|
|
92
|
+
|
|
93
|
+
## Handoff to Developers
|
|
94
|
+
|
|
95
|
+
- Export design tokens via Figma Tokens Studio or Style Dictionary
|
|
96
|
+
- Provide a design-spec JSON (see `templates/screen-spec.md`)
|
|
97
|
+
- Include a Figma link with annotated layers and token references
|
|
98
|
+
|
|
99
|
+
## Versioning & Documentation
|
|
100
|
+
|
|
101
|
+
- Store screen specs in a dedicated Git branch or folder
|
|
102
|
+
- Tag releases with semantic versioning (e.g., `v1.2.0`)
|
|
103
|
+
- Keep a changelog of design changes
|
|
104
|
+
|
|
105
|
+
## Testing
|
|
106
|
+
|
|
107
|
+
- Visual regression: Loki, Playwright, or Chromatic
|
|
108
|
+
- Manual QA: check all states, RTL, dynamic type, reduced motion
|
|
109
|
+
- Accessibility audit: VoiceOver, TalkBack, aXe
|
|
110
|
+
|
|
111
|
+
## Iterative Refinement
|
|
112
|
+
|
|
113
|
+
1. Gather feedback from stakeholders
|
|
114
|
+
2. Update the screen spec and tokens
|
|
115
|
+
3. Re-run visual regression
|
|
116
|
+
4. Re-validate accessibility
|
|
117
|
+
5. Commit changes and merge to main
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
# Security & Privacy Engineer
|
|
2
|
+
|
|
3
|
+
Implement defense-in-depth: secure storage, network, authentication, data minimization, compliance.
|
|
4
|
+
|
|
5
|
+
## Threat Model (STRIDE)
|
|
6
|
+
|
|
7
|
+
| Threat | Mitigation |
|
|
8
|
+
|--------|------------|
|
|
9
|
+
| Spoofing | Certificate pinning, biometric auth, device binding |
|
|
10
|
+
| Tampering | Code signing, integrity checks, encrypted storage |
|
|
11
|
+
| Repudiation | Audit logs, signed requests |
|
|
12
|
+
| Information Disclosure | Encryption at rest/transit, data minimization |
|
|
13
|
+
| Denial of Service | Rate limiting, offline-first, graceful degradation |
|
|
14
|
+
| Elevation of Privilege | Principle of least privilege, sandboxed native modules |
|
|
15
|
+
|
|
16
|
+
## Secure Storage
|
|
17
|
+
|
|
18
|
+
### iOS (Keychain)
|
|
19
|
+
```swift
|
|
20
|
+
// KeychainWrapper.swift
|
|
21
|
+
import Security
|
|
22
|
+
|
|
23
|
+
class Keychain {
|
|
24
|
+
static func save(key: String, data: Data) -> OSStatus {
|
|
25
|
+
let query: [String: Any] = [
|
|
26
|
+
kSecClass as String: kSecClassGenericPassword,
|
|
27
|
+
kSecAttrAccount as String: key,
|
|
28
|
+
kSecValueData as String: data,
|
|
29
|
+
kSecAttrAccessible as String: kSecAttrAccessibleWhenUnlockedThisDeviceOnly,
|
|
30
|
+
kSecAttrSynchronizable as String: false, // No iCloud sync
|
|
31
|
+
]
|
|
32
|
+
SecItemDelete(query as CFDictionary)
|
|
33
|
+
return SecItemAdd(query as CFDictionary, nil)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static func load(key: String) -> Data? {
|
|
37
|
+
let query: [String: Any] = [
|
|
38
|
+
kSecClass as String: kSecClassGenericPassword,
|
|
39
|
+
kSecAttrAccount as String: key,
|
|
40
|
+
kSecReturnData as String: true,
|
|
41
|
+
kSecMatchLimit as String: kSecMatchLimitOne,
|
|
42
|
+
]
|
|
43
|
+
var result: AnyObject?
|
|
44
|
+
let status = SecItemCopyMatching(query as CFDictionary, &result)
|
|
45
|
+
return status == errSecSuccess ? result as? Data : nil
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Android (EncryptedSharedPreferences / Keystore)
|
|
51
|
+
```kotlin
|
|
52
|
+
// SecureStorage.kt
|
|
53
|
+
val masterKey = MasterKey.Builder(applicationContext)
|
|
54
|
+
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
|
|
55
|
+
.build()
|
|
56
|
+
|
|
57
|
+
val sharedPrefs = EncryptedSharedPreferences.create(
|
|
58
|
+
applicationContext,
|
|
59
|
+
"secure_prefs",
|
|
60
|
+
masterKey,
|
|
61
|
+
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
|
62
|
+
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
// Usage
|
|
66
|
+
sharedPrefs.edit().putString("auth_token", token).apply()
|
|
67
|
+
val token = sharedPrefs.getString("auth_token", null)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### React Native (expo-secure-store / react-native-keychain)
|
|
71
|
+
```typescript
|
|
72
|
+
// secure-storage.ts
|
|
73
|
+
import * as SecureStore from 'expo-secure-store';
|
|
74
|
+
|
|
75
|
+
export const secureStorage = {
|
|
76
|
+
async set(key: string, value: string) {
|
|
77
|
+
await SecureStore.setItemAsync(key, value, {
|
|
78
|
+
keychainAccessible: SecureStore.WHEN_UNLOCKED_THIS_DEVICE_ONLY,
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
async get(key: string) {
|
|
82
|
+
return SecureStore.getItemAsync(key);
|
|
83
|
+
},
|
|
84
|
+
async delete(key: string) {
|
|
85
|
+
await SecureStore.deleteItemAsync(key);
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// For large data: react-native-encrypted-storage
|
|
90
|
+
import EncryptedStorage from 'react-native-encrypted-storage';
|
|
91
|
+
await EncryptedStorage.setItem('key', JSON.stringify(largeObject));
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Certificate Pinning
|
|
95
|
+
|
|
96
|
+
### React Native (expo-network / okhttp)
|
|
97
|
+
```typescript
|
|
98
|
+
// api/client.ts
|
|
99
|
+
import { PinningConfiguration } from 'expo-network';
|
|
100
|
+
|
|
101
|
+
const pinning: PinningConfiguration = {
|
|
102
|
+
'api.example.com': {
|
|
103
|
+
sha256: ['AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=', 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB='],
|
|
104
|
+
enforce: true,
|
|
105
|
+
includeSubdomains: true,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Expo: app.config.js
|
|
110
|
+
export default {
|
|
111
|
+
expo: {
|
|
112
|
+
network: { pinning },
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Native (Android - Network Security Config)
|
|
118
|
+
```xml
|
|
119
|
+
<!-- res/xml/network_security_config.xml -->
|
|
120
|
+
<network-security-config>
|
|
121
|
+
<domain-config cleartextTrafficPermitted="false">
|
|
122
|
+
<domain includeSubdomains="true">api.example.com</domain>
|
|
123
|
+
<pin-set expiration="2026-12-31">
|
|
124
|
+
<pin algorithm="SHA-256">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</pin>
|
|
125
|
+
<pin algorithm="SHA-256">BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=</pin>
|
|
126
|
+
</pin-set>
|
|
127
|
+
</domain-config>
|
|
128
|
+
</network-security-config>
|
|
129
|
+
|
|
130
|
+
<!-- AndroidManifest.xml -->
|
|
131
|
+
<application android:networkSecurityConfig="@xml/network_security_config" ... />
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Native (iOS - TrustKit / Alamofire)
|
|
135
|
+
```swift
|
|
136
|
+
// TrustKit config
|
|
137
|
+
let trustKitConfig = [
|
|
138
|
+
kTSKSwizzleNetworkDelegates: false,
|
|
139
|
+
kTSKPinnedDomains: [
|
|
140
|
+
"api.example.com": [
|
|
141
|
+
kTSKIncludeSubdomains: true,
|
|
142
|
+
kTSKEnforcePinning: true,
|
|
143
|
+
kTSKPublicKeyHashes: [
|
|
144
|
+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
|
145
|
+
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=",
|
|
146
|
+
],
|
|
147
|
+
kTSKPublicKeyAlgorithms: [kTSKAlgorithmRsa2048, kTSKAlgorithmEcdsa256],
|
|
148
|
+
]
|
|
149
|
+
]
|
|
150
|
+
]
|
|
151
|
+
TrustKit.initSharedInstance(withConfiguration: trustKitConfig)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Network Security
|
|
155
|
+
|
|
156
|
+
### TLS Configuration
|
|
157
|
+
- **Minimum**: TLS 1.2 (TLS 1.3 preferred)
|
|
158
|
+
- **Cipher suites**: ECDHE + AES-GCM + CHACHA20-POLY1305
|
|
159
|
+
- **HSTS**: Preload, max-age=31536000, includeSubDomains
|
|
160
|
+
- **CSP**: Strict, no unsafe-inline/eval
|
|
161
|
+
|
|
162
|
+
### Request Signing (HMAC)
|
|
163
|
+
```typescript
|
|
164
|
+
// api/signed-fetch.ts
|
|
165
|
+
async function signedFetch(url: string, options: RequestInit = {}) {
|
|
166
|
+
const timestamp = Date.now().toString();
|
|
167
|
+
const nonce = crypto.randomUUID();
|
|
168
|
+
const body = options.body ? await textClone(options.body) : '';
|
|
169
|
+
const stringToSign = `${options.method || 'GET'}\n${url}\n${timestamp}\n${nonce}\n${body}`;
|
|
170
|
+
|
|
171
|
+
const key = await crypto.subtle.importKey(
|
|
172
|
+
'raw', new TextEncoder().encode(API_SECRET),
|
|
173
|
+
{ name: 'HMAC', hash: 'SHA-256' }, false, ['sign']
|
|
174
|
+
);
|
|
175
|
+
const signature = await crypto.subtle.sign('HMAC', key, new TextEncoder().encode(stringToSign));
|
|
176
|
+
|
|
177
|
+
return fetch(url, {
|
|
178
|
+
...options,
|
|
179
|
+
headers: {
|
|
180
|
+
...options.headers,
|
|
181
|
+
'X-Timestamp': timestamp,
|
|
182
|
+
'X-Nonce': nonce,
|
|
183
|
+
'X-Signature': btoa(String.fromCharCode(...new Uint8Array(signature))),
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Authentication
|
|
190
|
+
|
|
191
|
+
### Biometric (Face ID / Touch ID / BiometricPrompt)
|
|
192
|
+
```typescript
|
|
193
|
+
// auth/biometric.ts
|
|
194
|
+
import * as LocalAuthentication from 'expo-local-authentication';
|
|
195
|
+
|
|
196
|
+
export async function authenticateWithBiometrics(): Promise<boolean> {
|
|
197
|
+
const hasHardware = await LocalAuthentication.hasHardwareAsync();
|
|
198
|
+
const isEnrolled = await LocalAuthentication.isEnrolledAsync();
|
|
199
|
+
|
|
200
|
+
if (!hasHardware || !isEnrolled) return false;
|
|
201
|
+
|
|
202
|
+
const result = await LocalAuthentication.authenticateAsync({
|
|
203
|
+
promptMessage: 'Authenticate to access your account',
|
|
204
|
+
fallbackLabel: 'Use passcode',
|
|
205
|
+
cancelLabel: 'Cancel',
|
|
206
|
+
disableDeviceFallback: false,
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
return result.success;
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
```kotlin
|
|
214
|
+
// Android BiometricPrompt
|
|
215
|
+
val biometricPrompt = BiometricPrompt(activity, executor, object : BiometricPrompt.AuthenticationCallback() {
|
|
216
|
+
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
|
|
217
|
+
// Get crypto object, decrypt token
|
|
218
|
+
}
|
|
219
|
+
override fun onAuthenticationFailed() { /* ... */ }
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
val promptInfo = BiometricPrompt.PromptInfo.Builder()
|
|
223
|
+
.setTitle("Biometric Authentication")
|
|
224
|
+
.setSubtitle("Authenticate to access your account")
|
|
225
|
+
.setNegativeButtonText("Cancel")
|
|
226
|
+
.build()
|
|
227
|
+
|
|
228
|
+
biometricPrompt.authenticate(promptInfo)
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Token Management
|
|
232
|
+
```typescript
|
|
233
|
+
// auth/tokens.ts
|
|
234
|
+
interface TokenPair {
|
|
235
|
+
accessToken: string;
|
|
236
|
+
refreshToken: string;
|
|
237
|
+
expiresAt: number; // Unix ms
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export class TokenManager {
|
|
241
|
+
private static readonly ACCESS_KEY = 'auth_access';
|
|
242
|
+
private static readonly REFRESH_KEY = 'auth_refresh';
|
|
243
|
+
|
|
244
|
+
async getValidAccessToken(): Promise<string | null> {
|
|
245
|
+
const stored = await secureStorage.get(TokenManager.ACCESS_KEY);
|
|
246
|
+
if (!stored) return await this.refresh();
|
|
247
|
+
|
|
248
|
+
const { accessToken, expiresAt } = JSON.parse(stored);
|
|
249
|
+
if (Date.now() < expiresAt - 60_000) return accessToken; // 1min buffer
|
|
250
|
+
|
|
251
|
+
return await this.refresh();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
private async refresh(): Promise<string | null> {
|
|
255
|
+
const refreshToken = await secureStorage.get(TokenManager.REFRESH_KEY);
|
|
256
|
+
if (!refreshToken) return null;
|
|
257
|
+
|
|
258
|
+
try {
|
|
259
|
+
const response = await fetch('/api/auth/refresh', {
|
|
260
|
+
method: 'POST',
|
|
261
|
+
headers: { 'Content-Type': 'application/json' },
|
|
262
|
+
body: JSON.stringify({ refresh_token: refreshToken }),
|
|
263
|
+
});
|
|
264
|
+
const { access_token, refresh_token, expires_in } = await response.json();
|
|
265
|
+
|
|
266
|
+
await secureStorage.set(TokenManager.ACCESS_KEY, JSON.stringify({
|
|
267
|
+
accessToken: access_token,
|
|
268
|
+
expiresAt: Date.now() + expires_in * 1000,
|
|
269
|
+
}));
|
|
270
|
+
await secureStorage.set(TokenManager.REFRESH_KEY, refresh_token);
|
|
271
|
+
|
|
272
|
+
return access_token;
|
|
273
|
+
} catch {
|
|
274
|
+
await this.clear();
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Data Minimization
|
|
282
|
+
|
|
283
|
+
### Collection Principles
|
|
284
|
+
| Principle | Implementation |
|
|
285
|
+
|-----------|----------------|
|
|
286
|
+
| Purpose limitation | Only collect what's needed for declared feature |
|
|
287
|
+
| Storage limitation | Auto-delete: logs 30d, analytics 13mo, session 24h |
|
|
288
|
+
| Data avoidance | Process on-device when possible (ML, search) |
|
|
289
|
+
| Anonymization | Hash IDs, aggregate before upload |
|
|
290
|
+
| User control | Export, delete, opt-out APIs |
|
|
291
|
+
|
|
292
|
+
### PII Handling
|
|
293
|
+
```typescript
|
|
294
|
+
// pii/redact.ts
|
|
295
|
+
const PII_PATTERNS = [
|
|
296
|
+
{ regex: /\b\d{3}-\d{2}-\d{4}\b/g, replacement: '[SSN]' }, // SSN
|
|
297
|
+
{ regex: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g, replacement: '[EMAIL]' },
|
|
298
|
+
{ regex: /\b(?:\d{4}[-\s]?){3}\d{4}\b/g, replacement: '[CARD]' }, // Credit card
|
|
299
|
+
{ regex: /\b\d{3}-\d{3}-\d{4}\b/g, replacement: '[PHONE]' },
|
|
300
|
+
];
|
|
301
|
+
|
|
302
|
+
export function redactPII(text: string): string {
|
|
303
|
+
return PII_PATTERNS.reduce((t, { regex, replacement }) => t.replace(regex, replacement), text);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Apply to all logs/analytics
|
|
307
|
+
console.log = (...args) => originalLog(...args.map(redactPII));
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Compliance Checklist
|
|
311
|
+
|
|
312
|
+
### GDPR (EU)
|
|
313
|
+
- [ ] Lawful basis documented for each data type
|
|
314
|
+
- [ ] DPIA for high-risk processing
|
|
315
|
+
- [ ] Data Processing Agreement with vendors
|
|
316
|
+
- [ ] Right to access / rectify / erase / portability
|
|
317
|
+
- [ ] DPO appointed (if required)
|
|
318
|
+
- [ ] Breach notification < 72h
|
|
319
|
+
|
|
320
|
+
### CCPA/CPRA (California)
|
|
321
|
+
- [ ] "Do Not Sell" link
|
|
322
|
+
- [ ] Opt-out honored
|
|
323
|
+
- [ ] Deletion requests honored
|
|
324
|
+
- [ ] Non-discrimination for exercising rights
|
|
325
|
+
|
|
326
|
+
### HIPAA (Health)
|
|
327
|
+
- [ ] BAA with all vendors
|
|
328
|
+
- [ ] Encryption at rest (AES-256) + transit (TLS 1.2+)
|
|
329
|
+
- [ ] Audit logs for PHI access
|
|
330
|
+
- [ ] Minimum necessary rule
|
|
331
|
+
|
|
332
|
+
### App Store Requirements
|
|
333
|
+
- [ ] Privacy Nutrition Labels (iOS)
|
|
334
|
+
- [ ] Data Safety Form (Play Store)
|
|
335
|
+
- [ ] No hidden tracking
|
|
336
|
+
- [ ] Clear permission rationale
|
|
337
|
+
|
|
338
|
+
## Security Testing
|
|
339
|
+
|
|
340
|
+
### Static Analysis
|
|
341
|
+
```bash
|
|
342
|
+
# iOS
|
|
343
|
+
xcodebuild analyze -scheme MyApp
|
|
344
|
+
|
|
345
|
+
# Android
|
|
346
|
+
./gradlew lint
|
|
347
|
+
|
|
348
|
+
# JS/TS
|
|
349
|
+
npm run lint:security # eslint-plugin-security
|
|
350
|
+
npm audit
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Dynamic Analysis
|
|
354
|
+
- **OWASP MASVS** checklist
|
|
355
|
+
- **MobSF** (Mobile Security Framework)
|
|
356
|
+
- **Frida** runtime analysis
|
|
357
|
+
- **OWASP ZAP** API testing
|
|
358
|
+
|
|
359
|
+
### Penetration Testing
|
|
360
|
+
- Annual third-party pentest
|
|
361
|
+
- Bug bounty program (HackerOne, Bugcrowd)
|
|
362
|
+
- Internal red team exercises
|
|
363
|
+
|
|
364
|
+
## Incident Response
|
|
365
|
+
|
|
366
|
+
```markdown
|
|
367
|
+
# Security Incident Runbook
|
|
368
|
+
|
|
369
|
+
1. **Detect** → Alert (Sentry, logs, user report)
|
|
370
|
+
2. **Contain** → Revoke tokens, disable feature flag, WAF rule
|
|
371
|
+
3. **Assess** → Scope, data exposed, root cause
|
|
372
|
+
4. **Notify** → Legal, users (if required), authorities (72h GDPR)
|
|
373
|
+
5. **Remediate** → Patch, rotate keys, deploy
|
|
374
|
+
6. **Review** → Postmortem, update threat model
|
|
375
|
+
```
|