@capgo/cli 8.0.0-alpha.5 → 8.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.
Files changed (222) hide show
  1. package/README.md +733 -84
  2. package/dist/index.js +1132 -317
  3. package/dist/keychain-export.swift +351 -0
  4. package/dist/package.json +120 -30
  5. package/dist/src/ai/analyze.d.ts +48 -0
  6. package/dist/src/ai/log-capture.d.ts +14 -0
  7. package/dist/src/ai/prompt.d.ts +1 -0
  8. package/dist/src/ai/render-markdown.d.ts +12 -0
  9. package/dist/src/ai/sse.d.ts +5 -0
  10. package/dist/src/ai/stream-markdown.d.ts +22 -0
  11. package/dist/src/ai/telemetry.d.ts +39 -0
  12. package/dist/src/analytics/error-category.d.ts +11 -0
  13. package/dist/src/analytics/org-resolver.d.ts +11 -0
  14. package/dist/src/analytics/supabase-perf.d.ts +48 -0
  15. package/dist/src/analytics/track.d.ts +70 -0
  16. package/dist/src/api/app.d.ts +17 -8
  17. package/dist/src/api/channels.d.ts +2442 -2729
  18. package/dist/src/api/crypto.d.ts +26 -0
  19. package/dist/src/api/update.d.ts +7 -1
  20. package/dist/src/api/versions.d.ts +9 -2
  21. package/dist/src/app/add.d.ts +6 -4
  22. package/dist/src/app/debug.d.ts +3 -7
  23. package/dist/src/app/delete.d.ts +1 -2
  24. package/dist/src/app/info.d.ts +5 -1
  25. package/dist/src/app/list.d.ts +23 -2
  26. package/dist/src/app/set.d.ts +0 -1
  27. package/dist/src/app/setting.d.ts +3 -9
  28. package/dist/src/app/updateProbe.d.ts +43 -0
  29. package/dist/src/build/credentials-command.d.ts +89 -0
  30. package/dist/src/build/credentials-manage.d.ts +7 -0
  31. package/dist/src/build/credentials.d.ts +78 -0
  32. package/dist/src/build/env-render.d.ts +8 -0
  33. package/dist/src/build/last-output-command.d.ts +6 -0
  34. package/dist/src/build/mobileprovision-parser.d.ts +35 -0
  35. package/dist/src/build/needed.d.ts +28 -0
  36. package/dist/src/build/onboarding/ai-fit.d.ts +110 -0
  37. package/dist/src/build/onboarding/analytics.d.ts +23 -0
  38. package/dist/src/build/onboarding/android/gcp-api.d.ts +128 -0
  39. package/dist/src/build/onboarding/android/gradle-parser.d.ts +19 -0
  40. package/dist/src/build/onboarding/android/keystore.d.ts +77 -0
  41. package/dist/src/build/onboarding/android/oauth-config.d.ts +24 -0
  42. package/dist/src/build/onboarding/android/oauth-google.d.ts +134 -0
  43. package/dist/src/build/onboarding/android/play-api.d.ts +91 -0
  44. package/dist/src/build/onboarding/android/progress.d.ts +22 -0
  45. package/dist/src/build/onboarding/android/service-account-validation.d.ts +58 -0
  46. package/dist/src/build/onboarding/android/types.d.ts +72 -0
  47. package/dist/src/build/onboarding/android/ui/app.d.ts +17 -0
  48. package/dist/src/build/onboarding/app-verification.d.ts +86 -0
  49. package/dist/src/build/onboarding/apple-api.d.ts +234 -0
  50. package/dist/src/build/onboarding/build-log.d.ts +10 -0
  51. package/dist/src/build/onboarding/bundle-id-detector.d.ts +117 -0
  52. package/dist/src/build/onboarding/ci-secrets.d.ts +87 -0
  53. package/dist/src/build/onboarding/command.d.ts +6 -0
  54. package/dist/src/build/onboarding/csr.d.ts +33 -0
  55. package/dist/src/build/onboarding/diff-utils.d.ts +24 -0
  56. package/dist/src/build/onboarding/env-export.d.ts +46 -0
  57. package/dist/src/build/onboarding/error-categories.d.ts +13 -0
  58. package/dist/src/build/onboarding/file-picker.d.ts +47 -0
  59. package/dist/src/build/onboarding/macos-signing.d.ts +190 -0
  60. package/dist/src/build/onboarding/min-terminal-size.d.ts +16 -0
  61. package/dist/src/build/onboarding/progress.d.ts +51 -0
  62. package/dist/src/build/onboarding/recovery.d.ts +7 -0
  63. package/dist/src/build/onboarding/telemetry.d.ts +28 -0
  64. package/dist/src/build/onboarding/types.d.ts +140 -0
  65. package/dist/src/build/onboarding/ui/app.d.ts +36 -0
  66. package/dist/src/build/onboarding/ui/completed-steps-log.d.ts +9 -0
  67. package/dist/src/build/onboarding/ui/components.d.ts +178 -0
  68. package/dist/src/build/onboarding/ui/frame-fit.d.ts +10 -0
  69. package/dist/src/build/onboarding/ui/min-size-gate.d.ts +20 -0
  70. package/dist/src/build/onboarding/ui/platform-picker.d.ts +19 -0
  71. package/dist/src/build/onboarding/ui/shell.d.ts +33 -0
  72. package/dist/src/build/onboarding/ui/steps/android-ci.d.ts +45 -0
  73. package/dist/src/build/onboarding/ui/steps/android-keystore.d.ts +75 -0
  74. package/dist/src/build/onboarding/ui/steps/android-sa-gcp.d.ts +85 -0
  75. package/dist/src/build/onboarding/ui/steps/android-shared.d.ts +67 -0
  76. package/dist/src/build/onboarding/ui/steps/ios-ci.d.ts +44 -0
  77. package/dist/src/build/onboarding/ui/steps/ios-credentials.d.ts +66 -0
  78. package/dist/src/build/onboarding/ui/steps/ios-import.d.ts +79 -0
  79. package/dist/src/build/onboarding/ui/steps/ios-shared.d.ts +93 -0
  80. package/dist/src/build/onboarding/workflow-generator.d.ts +48 -0
  81. package/dist/src/build/onboarding/workflow-ui-helpers.d.ts +18 -0
  82. package/dist/src/build/onboarding/workflow-writer.d.ts +36 -0
  83. package/dist/src/build/output-record.d.ts +30 -0
  84. package/dist/src/build/pbxproj-parser.d.ts +48 -0
  85. package/dist/src/build/platform-paths.d.ts +20 -0
  86. package/dist/src/build/qr.d.ts +5 -0
  87. package/dist/src/build/request.d.ts +102 -43
  88. package/dist/src/build/telemetry.d.ts +17 -0
  89. package/dist/src/bundle/builder-cta.d.ts +67 -0
  90. package/dist/src/bundle/check.d.ts +0 -1
  91. package/dist/src/bundle/cleanup.d.ts +3 -12
  92. package/dist/src/bundle/compatibility.d.ts +23 -12
  93. package/dist/src/bundle/decrypt.d.ts +4 -0
  94. package/dist/src/bundle/delete.d.ts +3 -8
  95. package/dist/src/bundle/encrypt.d.ts +4 -0
  96. package/dist/src/bundle/list.d.ts +5 -2
  97. package/dist/src/bundle/partial.d.ts +5 -3
  98. package/dist/src/bundle/releaseType.d.ts +15 -0
  99. package/dist/src/bundle/unlink.d.ts +6 -5
  100. package/dist/src/bundle/upload-command.d.ts +8 -0
  101. package/dist/src/bundle/upload.d.ts +21 -14
  102. package/dist/src/bundle/upload_interface.d.ts +2 -50
  103. package/dist/src/bundle/zip.d.ts +4 -19
  104. package/dist/src/capacitor-cli.d.ts +13 -0
  105. package/dist/src/channel/add.d.ts +8 -10
  106. package/dist/src/channel/currentBundle.d.ts +3 -9
  107. package/dist/src/channel/delete.d.ts +3 -9
  108. package/dist/src/channel/list.d.ts +31 -4
  109. package/dist/src/channel/set.d.ts +2 -17
  110. package/dist/src/checksum.d.ts +1 -2
  111. package/dist/src/config/index.d.ts +2 -13
  112. package/dist/src/docs.d.ts +0 -1
  113. package/dist/src/github-command.d.ts +9 -0
  114. package/dist/src/github.d.ts +40 -0
  115. package/dist/src/index.d.ts +0 -1
  116. package/dist/src/init/app-conflict.d.ts +2 -0
  117. package/dist/src/init/command.d.ts +57 -0
  118. package/dist/src/init/index.d.ts +1 -0
  119. package/dist/src/init/prompts.d.ts +41 -0
  120. package/dist/src/init/runtime.d.ts +111 -0
  121. package/dist/src/init/ui/app.d.ts +9 -0
  122. package/dist/src/init/ui/components.d.ts +31 -0
  123. package/dist/src/init/ui.d.ts +12 -0
  124. package/dist/src/init/updater.d.ts +13 -0
  125. package/dist/src/key.d.ts +16 -0
  126. package/dist/src/login.d.ts +0 -1
  127. package/dist/src/mcp/server.d.ts +5 -0
  128. package/dist/src/onboarding-support.d.ts +18 -0
  129. package/dist/src/organization/add.d.ts +26 -0
  130. package/dist/src/organization/delete.d.ts +3 -0
  131. package/dist/src/{organisation → organization}/index.d.ts +1 -1
  132. package/dist/src/{organisation → organization}/list.d.ts +14 -2
  133. package/dist/src/organization/members.d.ts +12 -0
  134. package/dist/src/organization/set.d.ts +21 -0
  135. package/dist/src/posthog.d.ts +13 -0
  136. package/dist/src/probe.d.ts +20 -0
  137. package/dist/src/promptPreferences.d.ts +13 -0
  138. package/dist/src/replicationProgress.d.ts +8 -0
  139. package/dist/src/run/device.d.ts +5 -0
  140. package/dist/src/runner-command.d.ts +5 -0
  141. package/dist/src/schemas/app.d.ts +26 -0
  142. package/dist/src/schemas/base.d.ts +7 -0
  143. package/dist/src/schemas/build.d.ts +196 -0
  144. package/dist/src/schemas/bundle.d.ts +157 -0
  145. package/dist/src/schemas/channel.d.ts +62 -0
  146. package/dist/src/schemas/common.d.ts +46 -0
  147. package/dist/src/schemas/config.d.ts +20 -0
  148. package/dist/src/schemas/index.d.ts +19 -0
  149. package/dist/src/schemas/organization.d.ts +41 -0
  150. package/dist/src/schemas/sdk.d.ts +335 -0
  151. package/dist/src/schemas/validate.d.ts +12 -0
  152. package/dist/src/sdk.d.ts +69 -337
  153. package/dist/src/sdk.js +542 -301
  154. package/dist/src/terminal-table.d.ts +7 -0
  155. package/dist/src/types/supabase.types.d.ts +2770 -296
  156. package/dist/src/updaterConfig.d.ts +8 -0
  157. package/dist/src/user/account.d.ts +0 -1
  158. package/dist/src/utils/latest-version.d.ts +0 -1
  159. package/dist/src/utils/safeWrites.d.ts +21 -0
  160. package/dist/src/utils/security_policy_errors.d.ts +47 -0
  161. package/dist/src/utils.d.ts +2869 -341
  162. package/dist/src/versionHelpers.d.ts +19 -0
  163. package/package.json +120 -30
  164. package/skills/native-builds/SKILL.md +255 -0
  165. package/skills/organization-management/SKILL.md +93 -0
  166. package/skills/release-management/SKILL.md +225 -0
  167. package/skills/usage/SKILL.md +92 -0
  168. package/dist/src/api/app.d.ts.map +0 -1
  169. package/dist/src/api/channels.d.ts.map +0 -1
  170. package/dist/src/api/cryptoV2.d.ts +0 -16
  171. package/dist/src/api/cryptoV2.d.ts.map +0 -1
  172. package/dist/src/api/update.d.ts.map +0 -1
  173. package/dist/src/api/versions.d.ts.map +0 -1
  174. package/dist/src/app/add.d.ts.map +0 -1
  175. package/dist/src/app/debug.d.ts.map +0 -1
  176. package/dist/src/app/delete.d.ts.map +0 -1
  177. package/dist/src/app/info.d.ts.map +0 -1
  178. package/dist/src/app/list.d.ts.map +0 -1
  179. package/dist/src/app/set.d.ts.map +0 -1
  180. package/dist/src/app/setting.d.ts.map +0 -1
  181. package/dist/src/build/request.d.ts.map +0 -1
  182. package/dist/src/bundle/check.d.ts.map +0 -1
  183. package/dist/src/bundle/cleanup.d.ts.map +0 -1
  184. package/dist/src/bundle/compatibility.d.ts.map +0 -1
  185. package/dist/src/bundle/decryptV2.d.ts +0 -13
  186. package/dist/src/bundle/decryptV2.d.ts.map +0 -1
  187. package/dist/src/bundle/delete.d.ts.map +0 -1
  188. package/dist/src/bundle/encryptV2.d.ts +0 -14
  189. package/dist/src/bundle/encryptV2.d.ts.map +0 -1
  190. package/dist/src/bundle/list.d.ts.map +0 -1
  191. package/dist/src/bundle/partial.d.ts.map +0 -1
  192. package/dist/src/bundle/unlink.d.ts.map +0 -1
  193. package/dist/src/bundle/upload.d.ts.map +0 -1
  194. package/dist/src/bundle/upload_interface.d.ts.map +0 -1
  195. package/dist/src/bundle/zip.d.ts.map +0 -1
  196. package/dist/src/channel/add.d.ts.map +0 -1
  197. package/dist/src/channel/currentBundle.d.ts.map +0 -1
  198. package/dist/src/channel/delete.d.ts.map +0 -1
  199. package/dist/src/channel/list.d.ts.map +0 -1
  200. package/dist/src/channel/set.d.ts.map +0 -1
  201. package/dist/src/checksum.d.ts.map +0 -1
  202. package/dist/src/config/index.d.ts.map +0 -1
  203. package/dist/src/docs.d.ts.map +0 -1
  204. package/dist/src/index.d.ts.map +0 -1
  205. package/dist/src/init.d.ts +0 -7
  206. package/dist/src/init.d.ts.map +0 -1
  207. package/dist/src/keyV2.d.ts +0 -19
  208. package/dist/src/keyV2.d.ts.map +0 -1
  209. package/dist/src/login.d.ts.map +0 -1
  210. package/dist/src/organisation/add.d.ts +0 -19
  211. package/dist/src/organisation/add.d.ts.map +0 -1
  212. package/dist/src/organisation/delete.d.ts +0 -8
  213. package/dist/src/organisation/delete.d.ts.map +0 -1
  214. package/dist/src/organisation/index.d.ts.map +0 -1
  215. package/dist/src/organisation/list.d.ts.map +0 -1
  216. package/dist/src/organisation/set.d.ts +0 -13
  217. package/dist/src/organisation/set.d.ts.map +0 -1
  218. package/dist/src/sdk.d.ts.map +0 -1
  219. package/dist/src/types/supabase.types.d.ts.map +0 -1
  220. package/dist/src/user/account.d.ts.map +0 -1
  221. package/dist/src/utils/latest-version.d.ts.map +0 -1
  222. package/dist/src/utils.d.ts.map +0 -1
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Returns true if we're on macOS and can use the native file picker.
3
+ */
4
+ export declare function canUseFilePicker(): boolean;
5
+ /**
6
+ * Open the macOS native file picker dialog filtered to .p8 files.
7
+ * Returns the selected file path, or null if the user cancelled.
8
+ * Non-blocking — uses async execFile so Ink spinners keep animating.
9
+ */
10
+ export declare function openFilePicker(): Promise<string | null>;
11
+ export declare function openPackageJsonPicker(): Promise<string | null>;
12
+ export interface SaveFilePickerOptions {
13
+ prompt: string;
14
+ defaultName?: string;
15
+ defaultLocation?: string;
16
+ }
17
+ /**
18
+ * Open the macOS native "Save As…" dialog. Returns the chosen path, or null if
19
+ * the user cancelled. macOS prompts for overwrite confirmation natively, so
20
+ * callers do not need to re-confirm.
21
+ */
22
+ export declare function openSaveFilePicker(opts: SaveFilePickerOptions): Promise<string | null>;
23
+ /**
24
+ * Open the macOS native file picker filtered to Android keystore files.
25
+ * Accepts .jks, .keystore, and .p12 extensions.
26
+ */
27
+ export declare function openKeystorePicker(): Promise<string | null>;
28
+ /**
29
+ * Open the macOS native file picker filtered to .mobileprovision files.
30
+ * Returns the selected path, or null if the user cancelled.
31
+ *
32
+ * Used by the no-match-recovery "Use a .mobileprovision file from disk"
33
+ * option — covers users who have a profile downloaded somewhere outside
34
+ * Xcode's standard provisioning-profile directories (e.g. a downloads
35
+ * folder, an artifact from another machine, a shared team archive).
36
+ */
37
+ export declare function openMobileprovisionPicker(): Promise<string | null>;
38
+ /**
39
+ * Open the macOS native file picker filtered to Google Play service account
40
+ * JSON files. Used by the Android onboarding "import existing SA" path.
41
+ *
42
+ * Uses the official `public.json` Uniform Type Identifier rather than the raw
43
+ * `"json"` extension hint — AppleScript treats unrecognized strings as 4-char
44
+ * OSType codes, and the legacy OSType code for `"json"` does not match real
45
+ * `.json` files, which makes the dialog grey them all out.
46
+ */
47
+ export declare function openServiceAccountJsonPicker(): Promise<string | null>;
@@ -0,0 +1,190 @@
1
+ import type { MobileprovisionDetail } from '../mobileprovision-parser.js';
2
+ /** Standard locations Xcode writes provisioning profiles into. */
3
+ export declare const PROVISIONING_PROFILE_DIRS: readonly ["Library/Developer/Xcode/UserData/Provisioning Profiles", "Library/MobileDevice/Provisioning Profiles"];
4
+ export type IdentityType = 'distribution' | 'development' | 'unknown';
5
+ export interface SigningIdentity {
6
+ /** SHA1 hash of the certificate, lowercase 40-char hex */
7
+ sha1: string;
8
+ /** Full identity string from `security find-identity` (e.g. "Apple Distribution: Acme Corp (XYZ123ABCD)") */
9
+ name: string;
10
+ /** Best-effort classification from the name prefix */
11
+ type: IdentityType;
12
+ /** Human-readable team name extracted from the identity string */
13
+ teamName: string;
14
+ /** Apple Team ID (10-char alphanumeric) extracted from the identity string */
15
+ teamId: string;
16
+ }
17
+ export interface DiscoveredProfile extends MobileprovisionDetail {
18
+ /** Absolute path to the .mobileprovision file */
19
+ path: string;
20
+ }
21
+ export interface IdentityProfileMatch {
22
+ identity: SigningIdentity;
23
+ /** Profiles whose embedded developer certs include this identity's SHA1 */
24
+ profiles: DiscoveredProfile[];
25
+ }
26
+ export interface ExportedP12 {
27
+ /** Base64-encoded PKCS#12 blob containing the chosen identity's cert + private key */
28
+ base64: string;
29
+ /** Auto-generated passphrase used to wrap the export */
30
+ passphrase: string;
31
+ }
32
+ export declare class MacOSSigningError extends Error {
33
+ readonly cause?: unknown | undefined;
34
+ constructor(message: string, cause?: unknown | undefined);
35
+ }
36
+ export declare class NotMacOSError extends MacOSSigningError {
37
+ constructor();
38
+ }
39
+ /** Returns `true` when running on macOS (Darwin). */
40
+ export declare function isMacOS(): boolean;
41
+ /**
42
+ * Run a subprocess and capture stdout/stderr/exit-code.
43
+ *
44
+ * Public so tests can inject a fake runner via the optional argument on
45
+ * higher-level functions. Not intended for downstream callers.
46
+ */
47
+ export interface SecurityRunResult {
48
+ stdout: string;
49
+ stderr: string;
50
+ code: number | null;
51
+ }
52
+ export type SecurityRunner = (args: readonly string[]) => Promise<SecurityRunResult>;
53
+ /**
54
+ * Parse the human-readable output of `security find-identity -v -p codesigning`.
55
+ * Each line looks like:
56
+ * ` 1) <SHA1> "Apple Distribution: Acme Corp (XYZ123ABCD)"`
57
+ *
58
+ * Exported so unit tests can verify parsing without spawning a subprocess.
59
+ */
60
+ export declare function parseFindIdentityOutput(stdout: string): SigningIdentity[];
61
+ /**
62
+ * List all code-signing identities visible in the user's default Keychain.
63
+ * Read-only — does NOT trigger any Keychain access prompt.
64
+ *
65
+ * @param runner Optional injection point for testing. Pass a fake to avoid
66
+ * spawning the real `/usr/bin/security` binary.
67
+ */
68
+ export declare function listSigningIdentities(runner?: SecurityRunner): Promise<SigningIdentity[]>;
69
+ /**
70
+ * Scan all standard Xcode provisioning-profile directories under the user's
71
+ * home and return parsed metadata for every readable `.mobileprovision`.
72
+ *
73
+ * Read-only — pure filesystem reads, no Keychain interaction.
74
+ *
75
+ * Files that fail to parse are silently skipped (a teammate's malformed
76
+ * profile shouldn't break the whole listing).
77
+ *
78
+ * @param homeDirOverride Optional override for HOME, used in tests.
79
+ */
80
+ export declare function scanProvisioningProfiles(homeDirOverride?: string): Promise<DiscoveredProfile[]>;
81
+ /**
82
+ * Given a list of identities and profiles, return one match entry per
83
+ * identity, populated with profiles whose embedded developer certs include
84
+ * that identity's SHA1.
85
+ *
86
+ * Pure function — no I/O.
87
+ */
88
+ export declare function matchIdentitiesToProfiles(identities: readonly SigningIdentity[], profiles: readonly DiscoveredProfile[]): IdentityProfileMatch[];
89
+ /**
90
+ * Compare a provisioning profile's bundle id against the app's concrete bundle
91
+ * id, honoring Apple's wildcard syntax. The mobileprovision parser leaves the
92
+ * asterisk in place after stripping the team-id prefix, so a wildcard profile
93
+ * arrives here as either the bare `*` (matches everything the team owns) or a
94
+ * suffix wildcard like `com.example.*` (matches `com.example.<anything>`).
95
+ *
96
+ * Exported so the file-picker validation in the Ink UI can reuse the same
97
+ * matching rule as `filterProfilesForApp` — otherwise a wildcard
98
+ * `.mobileprovision` picked manually would be hard-rejected even though the
99
+ * underlying profile is valid for the current app.
100
+ */
101
+ export declare function bundleIdMatches(profileBundleId: string, appId: string): boolean;
102
+ /**
103
+ * Filter profiles that are actually usable for a given Capacitor app + iOS
104
+ * distribution mode. Used by the import-existing flow to detect dead-end
105
+ * situations where an identity has profiles for a different app or the wrong
106
+ * distribution mode — in which case the no-match-recovery menu can offer
107
+ * "fetch / create via Apple" instead of dropping the user at an empty picker.
108
+ *
109
+ * `importDistribution` is null/undefined when the user hasn't picked yet —
110
+ * in that case any profileType is accepted.
111
+ *
112
+ * Bundle-id comparison goes through {@link bundleIdMatches} so wildcard
113
+ * profiles (the norm for ad_hoc/enterprise teams that share one profile
114
+ * across many apps) are accepted alongside literal-equality matches. Apple
115
+ * never issues wildcard `app_store` profiles in practice, so when the caller
116
+ * pins `importDistribution = 'app_store'` the conjunction naturally drops
117
+ * any ad_hoc/enterprise wildcards that happen to be installed.
118
+ */
119
+ export declare function filterProfilesForApp(profiles: readonly DiscoveredProfile[], appId: string, importDistribution: 'app_store' | 'ad_hoc' | null | undefined): DiscoveredProfile[];
120
+ /**
121
+ * Generate a cryptographically random passphrase suitable for wrapping the
122
+ * exported PKCS#12. 32 bytes of entropy → 64-char hex string.
123
+ */
124
+ export declare function generateP12Passphrase(): string;
125
+ /**
126
+ * Output shape from the Swift helper's stdout — always emitted as one line of
127
+ * JSON regardless of success or failure. See keychain-export.swift for the
128
+ * source of truth.
129
+ */
130
+ interface SwiftHelperResult {
131
+ ok: boolean;
132
+ p12Path?: string;
133
+ p12SizeBytes?: number;
134
+ identityName?: string;
135
+ errorCode?: 'INVALID_ARGS' | 'NO_IDENTITY' | 'USER_DENIED' | 'EXPORT_FAILED' | 'WRITE_FAILED' | 'INTERNAL';
136
+ message?: string;
137
+ osStatus?: number;
138
+ }
139
+ /**
140
+ * Returns true if the Swift helper is already cached at the version-keyed
141
+ * tmp path. Lets the UI decide whether to show a "compiling…" step or skip
142
+ * straight to the export step (the cached case is effectively instant).
143
+ *
144
+ * Sync + cheap (single existsSync). Safe to call from a React onChange
145
+ * handler.
146
+ */
147
+ export declare function isHelperCached(): boolean;
148
+ /**
149
+ * Pre-compile the Swift helper without doing anything else. Used by the UI
150
+ * to show an explicit "compiling helper" step before the export, so the user
151
+ * isn't left staring at a spinner that says "look for the macOS dialog"
152
+ * while we silently build a binary.
153
+ *
154
+ * Returns the path to the compiled binary (same as `ensureSwiftHelper`).
155
+ */
156
+ export declare function precompileSwiftHelper(): Promise<string>;
157
+ export interface ExportP12Options {
158
+ /**
159
+ * Pre-resolved Swift helper binary path. Used in tests to inject a fake
160
+ * binary; in production this is computed automatically.
161
+ */
162
+ helperPathOverride?: string;
163
+ }
164
+ /**
165
+ * Export the chosen identity from the user's Keychain as a base64'd PKCS#12.
166
+ *
167
+ * Triggers exactly TWO macOS Keychain prompts on the user's first run for
168
+ * a given identity (one for "access" ACL, one for "export" ACL). Both
169
+ * decisions are cached when the user clicks "Always Allow", so subsequent
170
+ * runs against the same identity from the same binary are silent.
171
+ *
172
+ * Internally calls the bundled Swift helper (compiled on first use to the
173
+ * OS temp folder via `swiftc`). The helper uses Security framework's
174
+ * `SecItemExport(.formatPKCS12)` — the only Apple-supported path that works
175
+ * on Xcode-imported (non-extractable) signing keys.
176
+ *
177
+ * @param targetSha1 SHA1 of the identity to export (from {@link listSigningIdentities})
178
+ * @param options See {@link ExportP12Options}
179
+ */
180
+ export declare function exportP12FromKeychain(targetSha1: string, options?: ExportP12Options): Promise<ExportedP12>;
181
+ /**
182
+ * Parse the helper's JSON output. Tolerates: extra whitespace, trailing
183
+ * newline, BOM. Throws a clear error if the output is unparsable — that
184
+ * indicates the helper crashed without emitting JSON, which our Swift code
185
+ * tries hard to never do (see keychain-export.swift's top-level catch).
186
+ *
187
+ * Exported for tests.
188
+ */
189
+ export declare function parseHelperJson(stdout: string, stderr: string, exitCode: number | null): SwiftHelperResult;
190
+ export {};
@@ -0,0 +1,16 @@
1
+ export declare const MIN_COLS = 80;
2
+ export declare const IOS_MIN_ROWS = 38;
3
+ export declare const ANDROID_MIN_ROWS = 49;
4
+ export declare const MIN_ROWS: number;
5
+ /** The full-onboarding row floor for a given platform. */
6
+ export declare function onboardingMinRows(platform: 'ios' | 'android'): number;
7
+ /**
8
+ * True when the given terminal size can run a platform's onboarding without a
9
+ * mid-flow resize. `platform` defaults to the conservative 'android' (larger)
10
+ * floor for platform-agnostic callers.
11
+ */
12
+ export declare function terminalFitsOnboarding(cols: number, rows: number, platform?: 'ios' | 'android'): boolean;
13
+ export declare const PICKER_MIN_COLS = 44;
14
+ export declare const PICKER_MIN_ROWS = 11;
15
+ /** True when the terminal can render the platform picker (banner + picker). */
16
+ export declare function terminalFitsPicker(cols: number, rows: number): boolean;
@@ -0,0 +1,51 @@
1
+ import type { OnboardingProgress, OnboardingStep } from './types.js';
2
+ /**
3
+ * Load onboarding progress for an app. Returns null if no progress file exists.
4
+ */
5
+ export declare function loadProgress(appId: string, baseDir?: string): Promise<OnboardingProgress | null>;
6
+ /**
7
+ * Save onboarding progress. Creates the onboarding directory if needed.
8
+ * File is written with mode 0o600, directory with 0o700.
9
+ */
10
+ export declare function saveProgress(appId: string, progress: OnboardingProgress, baseDir?: string): Promise<void>;
11
+ /**
12
+ * Delete the progress file for an app (called on successful completion).
13
+ */
14
+ export declare function deleteProgress(appId: string, baseDir?: string): Promise<void>;
15
+ /**
16
+ * Determine the first incomplete step based on saved progress.
17
+ * Returns the step to resume from.
18
+ *
19
+ * Branches on `setupMethod` so the import flow doesn't accidentally resume
20
+ * into the create-new path's `creating-certificate` step (which would trigger
21
+ * the Apple 3-cert-limit error for users at the limit).
22
+ */
23
+ export declare function getResumeStep(progress: OnboardingProgress | null): OnboardingStep;
24
+ /**
25
+ * Pure routing decision used by the `import-scanning` useEffect to skip
26
+ * questions the user already answered on a previous attempt.
27
+ *
28
+ * The shipped flow always sent users to `import-distribution-mode` after
29
+ * scanning, and the distribution-mode picker always sent app_store users to
30
+ * `api-key-instructions`. That re-asked the .p8 file path on resume even
31
+ * though `keyId` / `issuerId` / `p8Path` were already saved in progress —
32
+ * exposed by users seeing "✔ API Key verified — Key: X" (hydrated log)
33
+ * alongside "How do you want to provide the .p8 file?" on the same screen.
34
+ *
35
+ * IMPORTANT — we intentionally do NOT short-circuit on
36
+ * `completedSteps.apiKeyVerified`. Going through `verifying-key` on every
37
+ * resume is a brief network round-trip that catches two failure modes a
38
+ * short-circuit would silently allow:
39
+ * 1. The user moved/deleted the saved .p8 between runs — `verifying-key`
40
+ * surfaces this via NeedP8Error and routes back to the .p8 input.
41
+ * 2. The key was revoked on Apple's side — `verifying-key` gets a 401 and
42
+ * the user gets a clear error instead of a late failure inside
43
+ * `saving-credentials` (after the Keychain ACL prompt has already
44
+ * fired for the .p12 export).
45
+ *
46
+ * Exported so the routing decision can be unit-tested without rendering Ink.
47
+ *
48
+ * Returns the step to land on after a successful Keychain scan.
49
+ */
50
+ export declare function getImportEntryStep(progress: OnboardingProgress | null): OnboardingStep;
51
+ export declare function extractKeyIdFromP8Path(filePath: string): string;
@@ -0,0 +1,7 @@
1
+ import type { OnboardingStep } from './types.js';
2
+ export interface BuildOnboardingRecoveryAdvice {
3
+ summary: string[];
4
+ commands: string[];
5
+ docs: string[];
6
+ }
7
+ export declare function getBuildOnboardingRecoveryAdvice(message: string, step: OnboardingStep | null, pmRunner: string, appId: string): BuildOnboardingRecoveryAdvice;
@@ -0,0 +1,28 @@
1
+ import type { AndroidOnboardingErrorCategory, AndroidOnboardingStep } from './android/types.js';
2
+ import type { OnboardingErrorCategory, OnboardingStep, Platform } from './types.js';
3
+ export interface TrackBuilderOnboardingStepInput {
4
+ apikey: string;
5
+ appId: string;
6
+ orgId: string;
7
+ platform: Platform;
8
+ step: OnboardingStep | AndroidOnboardingStep;
9
+ durationMs?: number;
10
+ /** Step whose elapsed time is represented by durationMs. */
11
+ durationStep?: OnboardingStep | AndroidOnboardingStep;
12
+ /** Raw caught error — mapped via the platform's category mapper. Use this OR errorCategory, not both. */
13
+ error?: unknown;
14
+ /** Pre-computed category. Takes precedence over `error` if both are present. */
15
+ errorCategory?: OnboardingErrorCategory | AndroidOnboardingErrorCategory;
16
+ }
17
+ export type BuilderOnboardingAction = 'resume_prompt_decision' | 'android_sa_method_selected' | 'android_sa_validation_recovery_selected' | 'android_sa_validation_result';
18
+ export interface TrackBuilderOnboardingActionInput {
19
+ apikey: string;
20
+ appId: string;
21
+ orgId: string;
22
+ platform: Platform;
23
+ step: OnboardingStep | AndroidOnboardingStep;
24
+ action: BuilderOnboardingAction;
25
+ tags?: Record<string, boolean | number | string>;
26
+ }
27
+ export declare function trackBuilderOnboardingStep(input: TrackBuilderOnboardingStepInput): Promise<void>;
28
+ export declare function trackBuilderOnboardingAction(input: TrackBuilderOnboardingActionInput): Promise<void>;
@@ -0,0 +1,140 @@
1
+ export type Platform = 'ios' | 'android';
2
+ export interface OnboardingCompletionSummary {
3
+ /** The Capgo dashboard build URL, when a build was kicked off. */
4
+ buildUrl?: string;
5
+ /** One-line CI-secret upload summary, when secrets were pushed. */
6
+ ciSecretUploadSummary?: string | null;
7
+ /** Path to the generated GitHub Actions workflow file, when written. */
8
+ workflowFilePath?: string | null;
9
+ /** Path to the exported .env file, when the user chose the env-export fallback. */
10
+ envExportPath?: string | null;
11
+ /** The "run anytime" build-request command shown on the final screen. */
12
+ buildRequestCommand?: string;
13
+ }
14
+ export interface OnboardingResult {
15
+ outcome: 'completed' | 'cancelled';
16
+ /** Present only when outcome === 'completed'. */
17
+ summary?: OnboardingCompletionSummary;
18
+ }
19
+ export type OnboardingStep = 'welcome' | 'resume-prompt' | 'platform-select' | 'adding-platform' | 'credentials-exist' | 'backing-up' | 'setup-method-select' | 'import-scanning' | 'import-distribution-mode' | 'import-pick-identity' | 'import-pick-profile' | 'import-validating-all-certs' | 'import-checking-apple-cert' | 'import-no-match-recovery' | 'import-portal-explanation' | 'import-provide-profile-path' | 'import-create-profile-only' | 'import-export-warning' | 'import-compiling-helper' | 'import-exporting' | 'api-key-instructions' | 'p8-method-select' | 'input-p8-path' | 'input-key-id' | 'input-issuer-id' | 'verifying-key' | 'verify-app' | 'creating-certificate' | 'cert-limit-prompt' | 'revoking-certificate' | 'creating-profile' | 'duplicate-profile-prompt' | 'deleting-duplicate-profiles' | 'saving-credentials' | 'detecting-ci-secrets' | 'ci-secrets-setup' | 'ci-secrets-target-select' | 'ask-ci-secrets' | 'checking-ci-secrets' | 'confirm-ci-secret-overwrite' | 'uploading-ci-secrets' | 'ci-secrets-failed' | 'ask-github-actions-setup' | 'confirm-secrets-push' | 'ask-export-env' | 'exporting-env' | 'confirm-env-export-overwrite' | 'overwrite-and-export-env' | 'pick-package-manager' | 'pick-build-script' | 'pick-build-script-custom' | 'preview-workflow-file' | 'view-workflow-diff' | 'writing-workflow-file' | 'ask-build' | 'requesting-build' | 'ai-analysis-prompt' | 'ai-analysis-running' | 'ai-analysis-result' | 'ai-analysis-result-scroll' | 'build-complete' | 'no-platform' | 'error';
20
+ export type OnboardingErrorCategory = 'apple_api_unauthorized' | 'apple_api_rate_limited' | 'cert_limit_reached' | 'profile_creation_failed' | 'p8_invalid' | 'keychain_no_identities' | 'keychain_export_failed' | 'keychain_helper_compile_failed' | 'profile_no_match' | 'profile_read_failed' | 'unknown';
21
+ export interface ApiKeyData {
22
+ keyId: string;
23
+ issuerId: string;
24
+ }
25
+ /**
26
+ * Per-identity result of the eager Apple-side validation run. Populated by
27
+ * the `import-validating-all-certs` step useEffect, consumed by the two-
28
+ * table picker in `import-pick-identity`. Kept here (alongside the Step
29
+ * type) so the renderer and the validation logic share a single shape.
30
+ */
31
+ export interface EnrichedIdentityAvailability {
32
+ /** True when Apple's API returned a SHA1 match for this identity. */
33
+ available: boolean;
34
+ /**
35
+ * Stable reason code for unavailable identities. Drives the per-reason
36
+ * detail rendering in the unavailable table (e.g. notice about the
37
+ * Apple-managed signing constraint, or about private-key-missing).
38
+ */
39
+ reason?: 'expired' | 'managed' | 'not-visible' | 'check-failed' | 'no-private-key';
40
+ /** One-line summary shown in the Reason column of the unavailable table. */
41
+ reasonText?: string;
42
+ /** When available — Apple-side cert resource id, reused downstream. */
43
+ appleCertId?: string;
44
+ /**
45
+ * Apple-side cert name as returned by /v1/certificates. Useful when
46
+ * the local Keychain name differs from the portal name (e.g. multiple
47
+ * "iOS Distribution" certs in the same team — the portal column says
48
+ * exactly which one).
49
+ */
50
+ appleCertName?: string;
51
+ /**
52
+ * ISO timestamp from Apple's expiration field. Shown in the manual-
53
+ * portal walkthrough so the user can tell which row to click when
54
+ * multiple certs are listed.
55
+ */
56
+ appleCertExpirationDate?: string;
57
+ /**
58
+ * Full serial number from Apple. The portal shows it in the cert
59
+ * detail view; surfacing the last 8 chars here gives the user a
60
+ * concrete disambiguator without leaking the full 40-byte serial
61
+ * into the terminal.
62
+ */
63
+ appleCertSerialNumber?: string;
64
+ }
65
+ export interface CertificateData {
66
+ certificateId: string;
67
+ expirationDate: string;
68
+ teamId: string;
69
+ p12Base64: string;
70
+ }
71
+ export interface ProfileData {
72
+ profileId: string;
73
+ profileName: string;
74
+ profileBase64: string;
75
+ }
76
+ export interface OnboardingProgress {
77
+ platform: Platform;
78
+ appId: string;
79
+ startedAt: string;
80
+ /** Path to the .p8 file on disk (content is NOT stored, only the path) */
81
+ p8Path?: string;
82
+ /** Partial input — saved incrementally so resume works mid-flow */
83
+ keyId?: string;
84
+ issuerId?: string;
85
+ /**
86
+ * Records which fork the user picked at `setup-method-select`. Crucial for
87
+ * resume — without this, a partial import-flow run would resume at
88
+ * `creating-certificate` (the create-new path) and immediately hit the
89
+ * Apple cert-limit error.
90
+ *
91
+ * Absent on legacy progress files (created before this field existed) →
92
+ * resume defaults to `create-new` for backward compatibility.
93
+ */
94
+ setupMethod?: 'create-new' | 'import-existing';
95
+ /**
96
+ * Records the distribution mode picked at `import-distribution-mode`.
97
+ *
98
+ * Persisted (not derived from .p8 presence) because ad_hoc users can
99
+ * legitimately enter a one-shot .p8 during no-match recovery, which would
100
+ * otherwise make .p8-presence-implies-app_store an incorrect heuristic. On
101
+ * resume the UI hydrates `importDistribution` from this field so the
102
+ * `verifying-key` branch and `doSaveCredentials` route correctly.
103
+ *
104
+ * Only meaningful when `setupMethod === 'import-existing'`.
105
+ */
106
+ importDistribution?: 'app_store' | 'ad_hoc';
107
+ /**
108
+ * The resolved iOS bundle id (the authoritative Release
109
+ * `PRODUCT_BUNDLE_IDENTIFIER`) when it differs from `capacitor.config.appId`.
110
+ * Used for Apple-side operations (cert lookup, profile filtering,
111
+ * `ensureBundleId`, `createProfile`) and as the key in the provisioning_map.
112
+ * The progress-file key and Capgo SaaS API calls still use `appId` so existing
113
+ * build commands keep finding these credentials without editing
114
+ * `capacitor.config`.
115
+ *
116
+ * Persisted so verify-app / redirectIfMismatch don't re-resolve on resume —
117
+ * once set, the override sticks unless the configuration context (see
118
+ * `iosBundleIdContextAppId`) changes between CLI runs.
119
+ */
120
+ iosBundleIdOverride?: string;
121
+ /**
122
+ * Snapshot of `config.appId` at the time the `iosBundleIdOverride` was
123
+ * resolved. On the next run we compare this to the current `config.appId`;
124
+ * if it changed (user renamed the app, added/removed a dev-tunnel suffix,
125
+ * etc.) the saved override is stale and we re-resolve / re-verify via the
126
+ * verify-app step. Without this we'd silently keep using a bundle id the
127
+ * user already moved on from.
128
+ */
129
+ iosBundleIdContextAppId?: string;
130
+ completedSteps: {
131
+ apiKeyVerified?: ApiKeyData;
132
+ certificateCreated?: CertificateData;
133
+ profileCreated?: ProfileData;
134
+ };
135
+ /** Temporary — wiped after .p12 creation */
136
+ _privateKeyPem?: string;
137
+ }
138
+ /** Maps each step to a progress percentage (0-100) */
139
+ export declare const STEP_PROGRESS: Record<OnboardingStep, number>;
140
+ export declare function getPhaseLabel(step: OnboardingStep): string;
@@ -0,0 +1,36 @@
1
+ import type { FC } from 'react';
2
+ import type { OnboardingProgress, OnboardingResult } from '../types.js';
3
+ interface AppProps {
4
+ /**
5
+ * Capgo lookup key (progress files, saved credentials, Capgo SaaS build
6
+ * API). Resolved by `getAppId()`, which prefers
7
+ * `config.plugins.CapacitorUpdater.appId` over `config.appId` so dev-tunnel
8
+ * sandboxes can override the Capgo-side identifier without renaming the
9
+ * iOS bundle. Do NOT use for Apple-side operations — see
10
+ * `iosBundleIdInitial`.
11
+ */
12
+ appId: string;
13
+ /**
14
+ * Default value for the iOS bundle ID used for Apple-side operations
15
+ * (cert lookup, profile filtering, ensureBundleId, createProfile, and the
16
+ * provisioning_map key). Sourced from `config.appId` directly — what
17
+ * `cap sync` writes into project.pbxproj's PRODUCT_BUNDLE_IDENTIFIER.
18
+ * When pbxproj's Release id and config.appId disagree, the wizard adopts the
19
+ * authoritative Release id (verify-app confirms it remotely). command.ts
20
+ * falls back to `appId` if config.appId is missing, so this prop is always a
21
+ * valid string.
22
+ */
23
+ iosBundleIdInitial: string;
24
+ initialProgress: OnboardingProgress | null;
25
+ /** Resolved iOS directory from capacitor.config (defaults to 'ios') */
26
+ iosDir: string;
27
+ /** Optional Capgo API key passed via -a/--apikey flag; takes precedence over saved key */
28
+ apikey?: string;
29
+ supaHost?: string;
30
+ /** Reports the wizard outcome to the shell when it reaches build-complete, so
31
+ * the caller prints an accurate post-exit message + durable summary instead of
32
+ * always claiming success. Never fires on cancel/missing-platform exits. */
33
+ onResult?: (result: OnboardingResult) => void;
34
+ }
35
+ declare const OnboardingApp: FC<AppProps>;
36
+ export default OnboardingApp;
@@ -0,0 +1,9 @@
1
+ import type { FC } from 'react';
2
+ export interface LogEntry {
3
+ text: string;
4
+ color?: string;
5
+ }
6
+ export declare const CompletedStepsLog: FC<{
7
+ entries: LogEntry[];
8
+ maxRows: number;
9
+ }>;