@superwall/cli 1.6.2 → 1.7.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 (58) hide show
  1. package/README.md +110 -3
  2. package/dist/{actions-H7f6knyY.js → actions-B7ym3oVS.js} +2 -2
  3. package/dist/{api-Dv3LyZ5m.js → api-CZzirVMj.js} +6 -6
  4. package/dist/{app-mJC5NDtW.js → app-DH6U8yuI.js} +11 -10
  5. package/dist/{asa-D6H7Pjae.js → asa-C-sQzPPn.js} +8 -8
  6. package/dist/{asc-xCin0akG.js → asc-1ZBJ6DwS.js} +280 -41
  7. package/dist/asc-Bf7zBbyS.js +65 -0
  8. package/dist/{asc-products-Dvcyef3_.js → asc-products-9JXtDxI4.js} +2 -35
  9. package/dist/{auth-ZlLL-Gko.js → auth-YRhlV3DE.js} +11 -10
  10. package/dist/auth.js +2 -2
  11. package/dist/{billing-C8kBge_S.js → billing-CCYHdApx.js} +1 -1
  12. package/dist/{bind-BIzaGq8K.js → bind-YrJvuRF9.js} +3 -3
  13. package/dist/{build-B7BS1rF2.js → build-DLoCW5Ri.js} +7 -7
  14. package/dist/bundle-id-CKxl_026.js +121 -0
  15. package/dist/{command-3fGYyC8r.js → command-CMIz81Da.js} +5 -5
  16. package/dist/{create-CwnnNqv4.js → create-pkANt1Gs.js} +22 -22
  17. package/dist/dev-DZy6pOnB.js +22 -0
  18. package/dist/{dev-CgGAb5Al.js → dev-DmB3XqaJ.js} +12 -7
  19. package/dist/{doctor-CyUvut31.js → doctor-H-hf-Yww.js} +10 -10
  20. package/dist/{drivers-6RMOPIdn.js → drivers-Qx9LxmRN.js} +2 -2
  21. package/dist/entry.js +382 -39
  22. package/dist/{existing-DHpPn1y6.js → existing-AVEfZu2A.js} +2 -2
  23. package/dist/{feedback-RKyGuQ8_.js → feedback-CKf-rpBW.js} +6 -6
  24. package/dist/{hosted-BeGVAntr.js → hosted-CXe9TrWx.js} +2 -2
  25. package/dist/{integrate-BR2LR-EK.js → integrate-brmhPG-S.js} +23 -22
  26. package/dist/{login-Bhxgqwtm.js → login-Do4wFuLv.js} +31 -16
  27. package/dist/{migrate-C-4ISELN.js → migrate-C9ERDR6y.js} +24 -24
  28. package/dist/notification-url-DuKF2659.js +1273 -0
  29. package/dist/{open-studio-BnVD6tJ9.js → open-studio-DOw-6ydc.js} +10 -10
  30. package/dist/{org-CQduIOic.js → org-sj7uyvp-.js} +2 -2
  31. package/dist/{output-C-4UKMot.js → output-C4o2gJ1K.js} +12 -2
  32. package/dist/{pipeline-CHX0Syre.js → pipeline-BqzqZhX1.js} +6 -6
  33. package/dist/{print-skill-BiZLdCKv.js → print-skill-ZojRSybs.js} +7 -7
  34. package/dist/{promote-Pgpz-3xl.js → promote-BG8X4Nv_.js} +17 -17
  35. package/dist/publish-sxLh-G4G.js +35 -0
  36. package/dist/push-bQ6Vxtg8.js +35 -0
  37. package/dist/{query-CWLaZkdm.js → query-_FbybaH-.js} +8 -8
  38. package/dist/{resource-jwASPCrw.js → resource-CGIwSd29.js} +16 -176
  39. package/dist/revenue-provider-ebsRINY8.js +100 -0
  40. package/dist/{run-D-NbZLpj.js → run-DsVZ5snL.js} +2 -2
  41. package/dist/{scan-BmAW413l.js → scan-zKsddO72.js} +1 -1
  42. package/dist/scope-BvzD-kO4.js +223 -0
  43. package/dist/{selection-BGi6GyxC.js → selection-CxZoX4NT.js} +2 -2
  44. package/dist/setup-Bxj22rYi.js +189 -0
  45. package/dist/{skills-AxAf7bDB.js → skills-DPzlnfCK.js} +3 -3
  46. package/dist/{skills-FK5aDuNV.js → skills-D_R-lEsK.js} +8 -8
  47. package/dist/{spinner-DFctF_Jw.js → spinner-TWa0hia6.js} +1 -1
  48. package/dist/{telemetry-Ch9cCTI-.js → telemetry-DeA1mvnT.js} +1 -1
  49. package/dist/{token-BGAVPSQc.js → token-C0it-Xh7.js} +1 -1
  50. package/dist/{ui-4gLyfrgl.js → ui-Dy0b-9L8.js} +4 -3
  51. package/dist/{update-DIXbL-H9.js → update-B2fWIc4q.js} +2 -2
  52. package/dist/{upgrade-De7JMI1g.js → upgrade-BmzkTKrh.js} +6 -6
  53. package/package.json +2 -2
  54. package/dist/dev-Dx99K183.js +0 -22
  55. package/dist/publish-BPeuc3lq.js +0 -35
  56. package/dist/push-DcSQ4odB.js +0 -35
  57. /package/dist/{reports-DqMs9xNR.js → reports-CfJqoava.js} +0 -0
  58. /package/dist/{storekit-CC4gnTI6.js → storekit-Cj9Cpjcz.js} +0 -0
@@ -1,15 +1,21 @@
1
- import { g as SUPERWALL_HOME } from "./output-C-4UKMot.js";
2
- import "./telemetry-Ch9cCTI-.js";
3
- import "./update-DIXbL-H9.js";
4
- import "./token-BGAVPSQc.js";
5
- import { t as defineCommand } from "./command-3fGYyC8r.js";
6
- import "./ui-4gLyfrgl.js";
7
- import "./spinner-DFctF_Jw.js";
1
+ import { v as SUPERWALL_HOME } from "./output-C4o2gJ1K.js";
2
+ import "./telemetry-DeA1mvnT.js";
3
+ import "./update-B2fWIc4q.js";
4
+ import "./token-C0it-Xh7.js";
5
+ import { t as defineCommand } from "./command-CMIz81Da.js";
6
+ import "./ui-Dy0b-9L8.js";
7
+ import "./scan-zKsddO72.js";
8
+ import "./existing-AVEfZu2A.js";
9
+ import "./spinner-TWa0hia6.js";
8
10
  import { T as rowName } from "./resources-Bf9O1JNM.js";
9
- import { t as requireOrg } from "./org-CQduIOic.js";
11
+ import { t as requireOrg } from "./org-sj7uyvp-.js";
10
12
  import { t as parseParams } from "./params-l3CrvRtR.js";
11
13
  import { n as emitJson, t as apiCall } from "./api-output-aJNw7Syy.js";
12
- import { a as ascProxy, c as listAscConfigs, i as listAscApps, n as fetchUnimportedAscProducts, o as createAscConfig, r as findAscAppId, s as deleteAscConfig, t as ascTypeDisplay } from "./asc-products-Dvcyef3_.js";
14
+ import { c as saveAppAscKey, i as deleteAscConfig, l as saveAppPurchaseKey, o as listAscConfigs, r as createAscConfig, s as replaceAscConfig, t as ascProxy } from "./asc-Bf7zBbyS.js";
15
+ import { i as listAscApps, n as fetchUnimportedAscProducts, r as findAscAppId, t as ascTypeDisplay } from "./asc-products-9JXtDxI4.js";
16
+ import { S as appleDeps, a as KEY_KINDS, f as keyKind, g as text, i as runNotificationUrl, m as savedKey, o as KEY_LABEL, s as appFlags, u as createAppKey, v as chooseIosApp, x as savedBundleId, y as differentBundleId } from "./notification-url-DuKF2659.js";
17
+ import { c as getIntegrations, d as removeAppKey, l as importAppKey, o as copyAppKey, u as listKeySources } from "./scope-BvzD-kO4.js";
18
+ import { n as testModeWarning } from "./bundle-id-CKxl_026.js";
13
19
  import { dirname, join } from "node:path";
14
20
  import { homedir } from "node:os";
15
21
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
@@ -306,14 +312,239 @@ function renderAscDocs(query, verb) {
306
312
  return `${header}\n${hits.slice(0, 60).join("\n")}${hits.length > 60 ? `\n… ${hits.length - 60} more` : ""}\n\nRun \`asc docs <path> [verb]\` for a full schema.`;
307
313
  }
308
314
 
315
+ //#endregion
316
+ //#region src/commands/platform/app-keys.ts
317
+ async function target(ctx) {
318
+ const chosen = await chooseIosApp(ctx, ctx.api, appFlags(ctx));
319
+ return {
320
+ ctx,
321
+ app: {
322
+ projectId: String(chosen.project.id),
323
+ applicationId: String(chosen.app.id)
324
+ },
325
+ name: chosen.app.name ?? String(chosen.app.id),
326
+ savedBundleId: savedBundleId(chosen.app)
327
+ };
328
+ }
329
+ function purchaseKeyBundleId(ctx, { app, name, savedBundleId: saved }) {
330
+ const wanted = text(ctx, "bundle-id");
331
+ if (!wanted) {
332
+ if (saved) return {
333
+ bundleId: saved,
334
+ setApplicationBundleId: false
335
+ };
336
+ throw new Error(`\`${name}\` has no bundle ID in Superwall. Pass --bundle-id <id> to save it with the key, or set it first with \`superwall apps bundle-id <id> --app ${app.applicationId}\`.`);
337
+ }
338
+ if (saved && saved !== wanted) throw new Error(differentBundleId(name, app.applicationId, saved, wanted));
339
+ return {
340
+ bundleId: wanted,
341
+ setApplicationBundleId: saved === null
342
+ };
343
+ }
344
+ function requireKind(ctx, action) {
345
+ const kind = keyKind(ctx.argv.value2);
346
+ if (!kind) throw new Error(`Usage: superwall asc keys ${action} <api_key | purchase_key> --app <id>`);
347
+ return kind;
348
+ }
349
+ async function listAppKeys(ctx) {
350
+ const { app, name } = await target(ctx);
351
+ const saved = await apiCall(ctx, "Loading keys", () => getIntegrations(ctx.api, app.applicationId));
352
+ const keys = Object.fromEntries(KEY_KINDS.map((kind) => {
353
+ const key = savedKey(saved, kind);
354
+ return [kind, key ? {
355
+ key_id: key.key_id,
356
+ issuer_id: key.issuer_id,
357
+ ...key.bundle_id ? { bundle_id: key.bundle_id } : {}
358
+ } : null];
359
+ }));
360
+ if (ctx.json) return emitJson(ctx, {
361
+ application_id: app.applicationId,
362
+ ...keys
363
+ });
364
+ ctx.ui.step(`Apple keys saved on \`${name}\``);
365
+ ctx.ui.report(KEY_KINDS.map((kind) => {
366
+ const key = savedKey(saved, kind);
367
+ return `${key ? "✓" : "✗"} ${KEY_LABEL[kind]} ${key ? key.key_id : "not saved"}`;
368
+ }).join("\n"));
369
+ }
370
+ async function setAppKey(ctx, input) {
371
+ const kind = ctx.argv.value2 === void 0 ? "api_key" : requireKind(ctx, "set");
372
+ const chosen = await target(ctx);
373
+ const { app, name } = chosen;
374
+ const bundle = kind === "purchase_key" ? purchaseKeyBundleId(ctx, chosen) : void 0;
375
+ if (ctx.dryRun) {
376
+ const plan = {
377
+ dryRun: true,
378
+ action: "set",
379
+ kind,
380
+ application_id: app.applicationId,
381
+ keyId: input.keyId,
382
+ ...bundle ? {
383
+ bundle_id: bundle.bundleId,
384
+ set_application_bundle_id: bundle.setApplicationBundleId
385
+ } : {}
386
+ };
387
+ const alsoBundle = bundle?.setApplicationBundleId ? ` and its bundle ID ${bundle.bundleId}` : "";
388
+ ctx.json ? emitJson(ctx, plan) : ctx.ui.info(`[dry-run] would save ${KEY_LABEL[kind]} ${input.keyId}${alsoBundle} on ${name}`);
389
+ return;
390
+ }
391
+ if (bundle?.setApplicationBundleId) {
392
+ const warning = await testModeWarning(ctx, ctx.api, app.applicationId, bundle.bundleId);
393
+ if (warning) ctx.ui.warn(warning);
394
+ }
395
+ const credentials = {
396
+ keyId: input.keyId,
397
+ issuerId: input.issuerId,
398
+ privateKey: readFileSync(input.keyFile, "utf8")
399
+ };
400
+ const verdict = await apiCall(ctx, `Saving the ${KEY_LABEL[kind]}`, () => kind === "api_key" ? saveAppAscKey(ctx.api, app, credentials) : saveAppPurchaseKey(ctx.api, app, {
401
+ ...credentials,
402
+ ...bundle
403
+ }));
404
+ if (ctx.json) emitJson(ctx, {
405
+ application_id: app.applicationId,
406
+ kind,
407
+ key_id: input.keyId,
408
+ ...verdict,
409
+ ...bundle ? {
410
+ bundle_id: bundle.bundleId,
411
+ bundle_id_saved: verdict.valid && bundle.setApplicationBundleId
412
+ } : {}
413
+ });
414
+ else if (verdict.valid) ctx.ui.success(bundle?.setApplicationBundleId ? `${KEY_LABEL[kind]} ${input.keyId} and the bundle ID ${bundle.bundleId} saved on \`${name}\`.` : `${KEY_LABEL[kind]} ${input.keyId} saved on \`${name}\`.`);
415
+ else ctx.ui.error(`Apple didn't accept ${KEY_LABEL[kind]} ${input.keyId}${verdict.error ? `: ${verdict.error}` : "."}`);
416
+ if (!verdict.valid) process.exitCode = 1;
417
+ }
418
+ async function removeAppKeyCommand(ctx) {
419
+ const kind = requireKind(ctx, "rm");
420
+ const { app, name } = await target(ctx);
421
+ if (ctx.dryRun) {
422
+ const plan = {
423
+ dryRun: true,
424
+ action: "rm",
425
+ kind,
426
+ application_id: app.applicationId
427
+ };
428
+ ctx.json ? emitJson(ctx, plan) : ctx.ui.info(`[dry-run] would remove the ${KEY_LABEL[kind]} from ${name}`);
429
+ return;
430
+ }
431
+ await apiCall(ctx, "Removing the key", () => removeAppKey(ctx.api, app.applicationId, kind));
432
+ if (ctx.json) return emitJson(ctx, {
433
+ deleted: true,
434
+ kind,
435
+ application_id: app.applicationId
436
+ });
437
+ ctx.ui.success(`Removed the ${KEY_LABEL[kind]} from \`${name}\`. Nothing was revoked at Apple, and your organization's copy is kept.`);
438
+ }
439
+ async function listAppKeySources(ctx) {
440
+ const { app, name } = await target(ctx);
441
+ const sources = await apiCall(ctx, "Loading keys on your other apps", () => listKeySources(ctx.api, app.applicationId));
442
+ if (ctx.json) return emitJson(ctx, {
443
+ application_id: app.applicationId,
444
+ api_key: sources.api_key,
445
+ purchase_key: sources.purchase_key
446
+ });
447
+ const total = sources.api_key.length + sources.purchase_key.length;
448
+ if (total === 0) return void ctx.ui.step(`No other app has a key \`${name}\` could use`);
449
+ ctx.ui.step(`${total} key${total === 1 ? "" : "s"} on your other apps`);
450
+ for (const kind of KEY_KINDS) for (const source of sources[kind]) {
451
+ const more = source.others_count > 0 ? ` and ${source.others_count} more` : "";
452
+ ctx.ui.info(`\`${source.key_id}\` ${KEY_LABEL[kind]} from ${source.name}${more} (app ${source.application_id})`);
453
+ }
454
+ }
455
+ async function copyAppKeyCommand(ctx) {
456
+ const kind = requireKind(ctx, "copy");
457
+ const from = text(ctx, "from");
458
+ if (!from) throw new Error(`Usage: superwall asc keys copy ${kind} --app <id> --from <app id>. \`superwall asc keys sources --app <id>\` lists the apps to copy from.`);
459
+ const { app, name } = await target(ctx);
460
+ if (ctx.dryRun) {
461
+ const plan = {
462
+ dryRun: true,
463
+ action: "copy",
464
+ kind,
465
+ application_id: app.applicationId,
466
+ from
467
+ };
468
+ ctx.json ? emitJson(ctx, plan) : ctx.ui.info(`[dry-run] would copy the ${KEY_LABEL[kind]} from app ${from} to ${name}`);
469
+ return;
470
+ }
471
+ const copy = (confirmed) => apiCall(ctx, `Copying the ${KEY_LABEL[kind]}`, () => copyAppKey(ctx.api, app.applicationId, {
472
+ kind,
473
+ from,
474
+ confirmed
475
+ }));
476
+ let result = await copy(ctx.argv["allow-unconfirmed"] === true);
477
+ if (!result.valid && result.unconfirmed && ctx.interactive) {
478
+ ctx.ui.warn(result.unconfirmed);
479
+ if (await ctx.ui.confirm({ message: "Save this key anyway?" })) result = await copy(true);
480
+ }
481
+ if (ctx.json) emitJson(ctx, {
482
+ application_id: app.applicationId,
483
+ kind,
484
+ from,
485
+ valid: result.valid,
486
+ error: result.error,
487
+ unconfirmed: result.unconfirmed
488
+ });
489
+ else if (result.valid) ctx.ui.success(`${KEY_LABEL[kind]} copied to \`${name}\`.`);
490
+ else if (result.unconfirmed) ctx.ui.error(`${result.unconfirmed}\nNothing was saved. Pass --allow-unconfirmed to save it anyway, once a person has confirmed it is the right team's key.`);
491
+ else ctx.ui.error(`${result.error ?? "The key wasn't copied."}\nNothing was saved.`);
492
+ if (!result.valid) process.exitCode = 1;
493
+ }
494
+ function describeImport(result, name) {
495
+ const label = KEY_LABEL[result.kind];
496
+ if (result.status === "imported") return `${label} ${result.key_id ?? ""} imported to ${name}${result.source_name ? ` from ${result.source_name}` : ""}.`;
497
+ if (result.status === "already_saved") return `${name} already has an ${label}${result.key_id ? ` (${result.key_id})` : ""}. It was left as it is.`;
498
+ if (result.timed_out) return `No ${label} confirmed for ${name} before the search ran out of time (${result.tried} tried). Run it again.`;
499
+ return result.tried === 0 ? `Your organization has no ${label} to try on ${name}.` : `None of your organization's ${result.tried} saved ${label}s is confirmed by Apple for ${name}.`;
500
+ }
501
+ async function importAppKeys(ctx) {
502
+ const requested = ctx.argv.value2;
503
+ const one = keyKind(requested);
504
+ if (requested !== void 0 && !one) throw new Error("Usage: superwall asc keys import [api_key | purchase_key] --app <id>");
505
+ const kinds = one ? [one] : KEY_KINDS;
506
+ const { app, name } = await target(ctx);
507
+ if (ctx.dryRun) {
508
+ const plan = {
509
+ dryRun: true,
510
+ action: "import",
511
+ kinds,
512
+ application_id: app.applicationId
513
+ };
514
+ ctx.json ? emitJson(ctx, plan) : ctx.ui.info(`[dry-run] would try your organization's saved keys on ${name}`);
515
+ return;
516
+ }
517
+ const results = [];
518
+ for (const kind of kinds) results.push(await apiCall(ctx, `Trying your organization's ${KEY_LABEL[kind]}s`, () => importAppKey(ctx.api, app.applicationId, kind)));
519
+ if (results.some((result) => result.status === "not_found")) process.exitCode = 1;
520
+ if (ctx.json) return emitJson(ctx, {
521
+ application_id: app.applicationId,
522
+ results: results.map((result) => ({
523
+ kind: result.kind,
524
+ status: result.status,
525
+ key_id: result.key_id,
526
+ source_name: result.source_name,
527
+ source_application_id: result.source_application_id,
528
+ tried: result.tried,
529
+ timed_out: result.timed_out
530
+ }))
531
+ });
532
+ ctx.ui.report(results.map((result) => `${result.status === "not_found" ? "✗" : "✓"} ${describeImport(result, name)}`).join("\n"));
533
+ }
534
+
309
535
  //#endregion
310
536
  //#region src/commands/platform/keys.ts
311
537
  async function runAscKeys(ctx, api) {
312
538
  const action = ctx.argv.value ?? "list";
313
- if (action === "list") return listKeys(ctx, api);
314
- if (action === "set") return setKey(ctx, api);
315
- if (action === "rm") return removeKey(ctx, api);
316
- throw new Error(`Unknown "asc keys ${action}". Use list | set | rm.`);
539
+ const forApp = text(ctx, "app") !== void 0;
540
+ if (action === "list") return forApp ? listAppKeys(ctx) : listKeys(ctx, api);
541
+ if (action === "set") return setKey(ctx, api, forApp);
542
+ if (action === "rm") return forApp ? removeAppKeyCommand(ctx) : removeKey(ctx, api);
543
+ if (action === "create") return createAppKey(ctx, appleDeps);
544
+ if (action === "sources") return listAppKeySources(ctx);
545
+ if (action === "copy") return copyAppKeyCommand(ctx);
546
+ if (action === "import") return importAppKeys(ctx);
547
+ throw new Error(`Unknown "asc keys ${action}". Use list | set | rm | create | sources | copy | import.`);
317
548
  }
318
549
  async function listKeys(ctx, api) {
319
550
  const configs = await apiCall(ctx, "Loading credentials", () => listAscConfigs(api));
@@ -321,7 +552,7 @@ async function listKeys(ctx, api) {
321
552
  if (configs.length === 0) {
322
553
  ctx.ui.step("No App Store Connect credentials yet");
323
554
  if (ctx.interactive) {
324
- if (await ctx.ui.confirm({ message: "Connect an App Store Connect key now?" })) return setKey(ctx, api);
555
+ if (await ctx.ui.confirm({ message: "Connect an App Store Connect key now?" })) return setKey(ctx, api, false);
325
556
  return;
326
557
  }
327
558
  ctx.ui.info("Add one: superwall asc keys set --key-id <id> --issuer <id> --key-file <path.p8>");
@@ -330,27 +561,33 @@ async function listKeys(ctx, api) {
330
561
  ctx.ui.step(`${configs.length} App Store Connect credential${configs.length === 1 ? "" : "s"}`);
331
562
  for (const c of configs) ctx.ui.info(`\`${rowName(c)}\` ${c.team_id ?? c.id ?? ""}`);
332
563
  }
333
- async function setKey(ctx, api) {
334
- const input = await resolveKeyInput(ctx);
564
+ async function setKey(ctx, api, forApp) {
565
+ const input = await resolveKeyInput(ctx, forApp);
335
566
  if (!input) return void ctx.ui.warn("Cancelled.");
567
+ if (forApp) return setAppKey(ctx, input);
336
568
  const { keyId, issuerId, keyFile, accountName } = input;
569
+ const teamId = text(ctx, "team");
337
570
  if (ctx.dryRun) {
338
571
  const plan = {
339
572
  dryRun: true,
340
573
  action: "set",
341
574
  keyId,
342
575
  issuerId,
343
- keyFile
576
+ keyFile,
577
+ ...teamId ? { teamId } : {}
344
578
  };
345
579
  ctx.json ? emitJson(ctx, plan) : ctx.ui.info(`[dry-run] would upload ASC key ${keyId} (issuer ${issuerId}) from ${keyFile}`);
346
580
  return;
347
581
  }
348
- const privateKey = readFileSync(keyFile, "utf8");
349
- const created = await apiCall(ctx, "Connecting App Store Connect", () => createAscConfig(api, {
582
+ const credentials = {
350
583
  keyId,
351
584
  issuerId,
352
- privateKey,
585
+ privateKey: readFileSync(keyFile, "utf8"),
353
586
  accountName
587
+ };
588
+ const created = await apiCall(ctx, "Connecting App Store Connect", () => teamId ? replaceAscConfig(api, teamId, credentials) : createAscConfig(api, {
589
+ ...credentials,
590
+ accountName: accountName ?? "App Store Connect"
354
591
  }));
355
592
  if (ctx.json) return emitJson(ctx, created);
356
593
  ctx.ui.success(`App Store Connect connected ${created.team_id ?? created.id ?? ""}`);
@@ -358,6 +595,7 @@ async function setKey(ctx, api) {
358
595
  async function removeKey(ctx, api) {
359
596
  const teamId = ctx.argv.value2;
360
597
  if (!teamId) throw new Error("Usage: superwall asc keys rm <team_id>");
598
+ if (keyKind(teamId)) throw new Error(`Usage: superwall asc keys rm ${teamId} --app <id>`);
361
599
  if (ctx.dryRun) {
362
600
  const plan = {
363
601
  dryRun: true,
@@ -374,14 +612,14 @@ async function removeKey(ctx, api) {
374
612
  });
375
613
  ctx.ui.success(`Removed App Store Connect credential ${teamId}`);
376
614
  }
377
- async function resolveKeyInput(ctx) {
615
+ async function resolveKeyInput(ctx, forApp) {
378
616
  const { argv, ui, interactive } = ctx;
379
617
  let keyId = argv["key-id"]?.trim();
380
618
  let issuerId = argv.issuer?.trim();
381
619
  let keyFile = argv["key-file"]?.trim();
382
620
  let name = argv.name?.trim();
383
621
  if (interactive && (!keyId || !issuerId || !keyFile)) {
384
- ui.note("Create a key in App Store Connect → Users and Access → Integrations →\nApp Store Connect API. You'll need its Key ID, the Issuer ID, and the\ndownloaded .p8 file. This is stored org-wide for the signed proxy.", "Connect App Store Connect");
622
+ ui.note(forApp ? "You'll need the key's Key ID, its Issuer ID, and the downloaded .p8 file,\nfrom App Store Connect → Users and Access → Integrations." : "Create a key in App Store Connect → Users and Access → Integrations →\nApp Store Connect API. You'll need its Key ID, the Issuer ID, and the\ndownloaded .p8 file. This is stored org-wide for the signed proxy.", forApp ? "Save an Apple key on the app" : "Connect App Store Connect");
385
623
  if (!keyId) {
386
624
  const v = await ui.text({
387
625
  message: "Key ID",
@@ -413,7 +651,7 @@ async function resolveKeyInput(ctx) {
413
651
  if (v === null) return null;
414
652
  keyFile = v.trim();
415
653
  }
416
- if (!name) {
654
+ if (!name && !forApp) {
417
655
  const v = await ui.text({
418
656
  message: "Name (optional)",
419
657
  placeholder: "App Store Connect"
@@ -422,14 +660,14 @@ async function resolveKeyInput(ctx) {
422
660
  name = v.trim();
423
661
  }
424
662
  }
425
- if (!keyId || !issuerId || !keyFile) throw new Error("Usage: superwall asc keys set --key-id <id> --issuer <id> --key-file <path.p8> [--name <name>]");
663
+ if (!keyId || !issuerId || !keyFile) throw new Error(forApp ? "Usage: superwall asc keys set [api_key | purchase_key] --app <id> --key-id <id> --issuer <id> --key-file <path.p8>" : "Usage: superwall asc keys set --key-id <id> --issuer <id> --key-file <path.p8> [--name <name>] [--team <id>]");
426
664
  const path = expandHome(keyFile);
427
665
  if (!existsSync(path)) throw new Error(`Couldn't find the .p8 key file at ${keyFile}`);
428
666
  return {
429
667
  keyId,
430
668
  issuerId,
431
669
  keyFile: path,
432
- accountName: name || "App Store Connect"
670
+ ...name ? { accountName: name } : {}
433
671
  };
434
672
  }
435
673
  function expandHome(path) {
@@ -462,8 +700,8 @@ const runAsc = defineCommand({
462
700
  auth: "required",
463
701
  output: "both",
464
702
  async run(ctx) {
465
- const target = String(ctx.argv.target ?? "");
466
- if (target === "docs") {
703
+ const target$1 = String(ctx.argv.target ?? "");
704
+ if (target$1 === "docs") {
467
705
  const query = String(ctx.argv.value ?? "");
468
706
  if (query === "refresh") {
469
707
  const quiet = Boolean(ctx.argv.quiet);
@@ -481,46 +719,47 @@ const runAsc = defineCommand({
481
719
  return;
482
720
  }
483
721
  await requireOrg(ctx.api, ctx.interactive);
484
- if (target === "keys") return runAscKeys(ctx, ctx.api);
485
- if (VERBS.has(target)) {
722
+ if (target$1 === "keys") return runAscKeys(ctx, ctx.api);
723
+ if (target$1 === "notification-url") return runNotificationUrl(ctx, appleDeps.sleep);
724
+ if (VERBS.has(target$1)) {
486
725
  const path = String(ctx.argv.value ?? "");
487
726
  if (!path.startsWith("/")) throw new Error(`Path must start with "/", e.g. /v1/apps`);
488
727
  let body = parseParams(ctx.argv.d);
489
- if (target === "post" || target === "patch") {
728
+ if (target$1 === "post" || target$1 === "patch") {
490
729
  await ensureAscIndex(ctx);
491
- const found = lookupAscOp(target, path);
730
+ const found = lookupAscOp(target$1, path);
492
731
  if (found) {
493
- body = buildAscBody(found.op, target, path, body);
494
- const problems = validateAscBody(found.op, target, body);
495
- if (problems.length && !ctx.argv.force) throw new Error(`Invalid ${target.toUpperCase()} ${path} body:\n` + problems.map((p) => ` • ${p}`).join("\n") + `\nFix and retry, run \`superwall asc docs ${path} ${target}\`, or pass --force to send as-is.`);
732
+ body = buildAscBody(found.op, target$1, path, body);
733
+ const problems = validateAscBody(found.op, target$1, body);
734
+ if (problems.length && !ctx.argv.force) throw new Error(`Invalid ${target$1.toUpperCase()} ${path} body:\n` + problems.map((p) => ` • ${p}`).join("\n") + `\nFix and retry, run \`superwall asc docs ${path} ${target$1}\`, or pass --force to send as-is.`);
496
735
  }
497
736
  }
498
737
  const teamId$1 = await resolveTeam(ctx, ctx.api);
499
- return emitJson(ctx, await apiCall(ctx, `${target.toUpperCase()} ${path}`, () => ascProxy(ctx.api, teamId$1, target, path, body)));
738
+ return emitJson(ctx, await apiCall(ctx, `${target$1.toUpperCase()} ${path}`, () => ascProxy(ctx.api, teamId$1, target$1, path, body)));
500
739
  }
501
740
  const teamId = await resolveTeam(ctx, ctx.api);
502
- if (target.startsWith("/")) return emitJson(ctx, await apiCall(ctx, `GET ${target}`, () => ascProxy(ctx.api, teamId, "GET", target)));
503
- if (target === "apps") {
741
+ if (target$1.startsWith("/")) return emitJson(ctx, await apiCall(ctx, `GET ${target$1}`, () => ascProxy(ctx.api, teamId, "GET", target$1)));
742
+ if (target$1 === "apps") {
504
743
  const apps = await apiCall(ctx, "Loading apps", () => listAscApps(ctx.api, teamId));
505
744
  if (ctx.json) return emitJson(ctx, apps);
506
745
  ctx.ui.step(`${apps.length} app${apps.length === 1 ? "" : "s"}`);
507
746
  for (const a of apps) ctx.ui.info(`\`${a.name ?? a.id}\` ${a.bundleId ?? ""} ${a.id}`);
508
747
  return;
509
748
  }
510
- if (target === "products" || target === "subscriptions" || target === "iaps") {
749
+ if (target$1 === "products" || target$1 === "subscriptions" || target$1 === "iaps") {
511
750
  const appArg = ctx.argv.value;
512
- if (!appArg) throw new Error(`Usage: superwall asc ${target} <bundle-id | asc-app-id>`);
751
+ if (!appArg) throw new Error(`Usage: superwall asc ${target$1} <bundle-id | asc-app-id>`);
513
752
  const ascAppId = /^\d+$/.test(appArg) ? appArg : await apiCall(ctx, "Finding app", () => findAscAppId(ctx.api, teamId, appArg));
514
753
  if (!ascAppId) throw new Error(`No App Store Connect app found for "${appArg}".`);
515
754
  const all = await apiCall(ctx, "Loading products", () => fetchUnimportedAscProducts(ctx.api, teamId, ascAppId, /* @__PURE__ */ new Set()));
516
755
  const isSub = (t) => t.includes("SUBSCRIPTION") && t !== "NON_RENEWING_SUBSCRIPTION";
517
- const rows = target === "subscriptions" ? all.filter((p) => isSub(p.type)) : target === "iaps" ? all.filter((p) => !isSub(p.type)) : all;
756
+ const rows = target$1 === "subscriptions" ? all.filter((p) => isSub(p.type)) : target$1 === "iaps" ? all.filter((p) => !isSub(p.type)) : all;
518
757
  if (ctx.json) return emitJson(ctx, rows);
519
758
  ctx.ui.step(`${rows.length} product${rows.length === 1 ? "" : "s"}`);
520
759
  for (const p of rows) ctx.ui.info(`\`${p.productId}\` ${ascTypeDisplay(p.type)}${p.subscriptionPeriod ? ` ${p.subscriptionPeriod}` : ""}`);
521
760
  return;
522
761
  }
523
- throw new Error(`Unknown "${target}". Use get|post|patch|delete <path>, a raw path, or: apps | products | subscriptions | iaps | docs | keys`);
762
+ throw new Error(`Unknown "${target$1}". Use get|post|patch|delete <path>, a raw path, or: apps | products | subscriptions | iaps | docs | keys | notification-url`);
524
763
  }
525
764
  });
526
765
  async function resolveTeam(ctx, api) {
@@ -0,0 +1,65 @@
1
+ //#region src/core/api/asc.ts
2
+ function ascBase(api) {
3
+ const orgId = api.org.id;
4
+ if (!orgId) throw new Error("No organization selected - run `superwall orgs use <id|name>` first.");
5
+ return `/v2/organizations/${orgId}/app-store-connect`;
6
+ }
7
+ async function listAscConfigs(api) {
8
+ return (await api.get(ascBase(api))).data ?? [];
9
+ }
10
+ function createAscConfig(api, c) {
11
+ return api.post(ascBase(api), {
12
+ key_id: c.keyId,
13
+ issuer_id: c.issuerId,
14
+ private_key: c.privateKey,
15
+ ...c.accountName ? { account_name: c.accountName } : {}
16
+ });
17
+ }
18
+ function replaceAscConfig(api, teamId, c) {
19
+ return api.patch(`${ascBase(api)}/${teamId}`, {
20
+ key_id: c.keyId,
21
+ issuer_id: c.issuerId,
22
+ private_key: c.privateKey,
23
+ validate: true,
24
+ ...c.accountName ? { account_name: c.accountName } : {}
25
+ });
26
+ }
27
+ const appIntegrations = (app) => `/v2/projects/${app.projectId}/applications/${app.applicationId}/integrations`;
28
+ function saveAppAscKey(api, app, c) {
29
+ return api.put(`${appIntegrations(app)}/app-store-connect/configuration`, {
30
+ key_id: c.keyId,
31
+ issuer_id: c.issuerId,
32
+ private_key: c.privateKey
33
+ });
34
+ }
35
+ function saveAppPurchaseKey(api, app, c) {
36
+ return api.put(`${appIntegrations(app)}/in-app-purchase/configuration`, {
37
+ bundle_id: c.bundleId,
38
+ key_id: c.keyId,
39
+ issuer_id: c.issuerId,
40
+ private_key: c.privateKey,
41
+ ...c.setApplicationBundleId ? { set_application_bundle_id: true } : {}
42
+ });
43
+ }
44
+ async function getAppNotificationUrl(api, app) {
45
+ return (await api.get(`${appIntegrations(app)}/app-store-connect/notification-url`)).url;
46
+ }
47
+ function deleteAscConfig(api, teamId) {
48
+ return api.del(`${ascBase(api)}/${teamId}`);
49
+ }
50
+ function ascProxy(api, teamId, method, ascPath, body) {
51
+ const path = `${ascBase(api)}/proxy/${teamId}${ascPath}`;
52
+ switch (method.toUpperCase()) {
53
+ case "GET": return api.get(path);
54
+ case "POST": return api.post(path, body ?? {});
55
+ case "PATCH": return api.patch(path, body ?? {});
56
+ case "DELETE": return api.del(path);
57
+ default: throw new Error(`Unsupported method: ${method}`);
58
+ }
59
+ }
60
+ function ascProxyGet(api, teamId, ascPath) {
61
+ return ascProxy(api, teamId, "GET", ascPath);
62
+ }
63
+
64
+ //#endregion
65
+ export { getAppNotificationUrl as a, saveAppAscKey as c, deleteAscConfig as i, saveAppPurchaseKey as l, ascProxyGet as n, listAscConfigs as o, createAscConfig as r, replaceAscConfig as s, ascProxy as t };
@@ -1,38 +1,5 @@
1
- //#region src/core/api/asc.ts
2
- function ascBase(api) {
3
- const orgId = api.org.id;
4
- if (!orgId) throw new Error("No organization selected - run `superwall orgs use <id|name>` first.");
5
- return `/v2/organizations/${orgId}/app-store-connect`;
6
- }
7
- async function listAscConfigs(api) {
8
- return (await api.get(ascBase(api))).data ?? [];
9
- }
10
- function createAscConfig(api, c) {
11
- return api.post(ascBase(api), {
12
- key_id: c.keyId,
13
- issuer_id: c.issuerId,
14
- private_key: c.privateKey,
15
- ...c.accountName ? { account_name: c.accountName } : {}
16
- });
17
- }
18
- function deleteAscConfig(api, teamId) {
19
- return api.del(`${ascBase(api)}/${teamId}`);
20
- }
21
- function ascProxy(api, teamId, method, ascPath, body) {
22
- const path = `${ascBase(api)}/proxy/${teamId}${ascPath}`;
23
- switch (method.toUpperCase()) {
24
- case "GET": return api.get(path);
25
- case "POST": return api.post(path, body ?? {});
26
- case "PATCH": return api.patch(path, body ?? {});
27
- case "DELETE": return api.del(path);
28
- default: throw new Error(`Unsupported method: ${method}`);
29
- }
30
- }
31
- function ascProxyGet(api, teamId, ascPath) {
32
- return ascProxy(api, teamId, "GET", ascPath);
33
- }
1
+ import { n as ascProxyGet } from "./asc-Bf7zBbyS.js";
34
2
 
35
- //#endregion
36
3
  //#region src/core/api/asc-products.ts
37
4
  function attr(r, key) {
38
5
  const v = r.attributes?.[key];
@@ -90,4 +57,4 @@ function ascTypeDisplay(type) {
90
57
  }
91
58
 
92
59
  //#endregion
93
- export { ascProxy as a, listAscConfigs as c, listAscApps as i, fetchUnimportedAscProducts as n, createAscConfig as o, findAscAppId as r, deleteAscConfig as s, ascTypeDisplay as t };
60
+ export { listAscApps as i, fetchUnimportedAscProducts as n, findAscAppId as r, ascTypeDisplay as t };
@@ -1,13 +1,13 @@
1
- import { o as API_HOST } from "./output-C-4UKMot.js";
2
- import { i as track } from "./telemetry-Ch9cCTI-.js";
3
- import "./update-DIXbL-H9.js";
4
- import { i as loadSession, r as clearSession } from "./token-BGAVPSQc.js";
5
- import { t as defineCommand } from "./command-3fGYyC8r.js";
6
- import "./ui-4gLyfrgl.js";
7
- import { n as ensureSkillsCurrent } from "./skills-AxAf7bDB.js";
1
+ import { o as API_HOST } from "./output-C4o2gJ1K.js";
2
+ import { i as track } from "./telemetry-DeA1mvnT.js";
3
+ import "./update-B2fWIc4q.js";
4
+ import { i as loadSession, r as clearSession } from "./token-C0it-Xh7.js";
5
+ import { t as defineCommand } from "./command-CMIz81Da.js";
6
+ import "./ui-Dy0b-9L8.js";
7
+ import { n as ensureSkillsCurrent } from "./skills-DPzlnfCK.js";
8
8
  import "./spawn-DSoTXy_j.js";
9
- import { i as onboardingHooks, n as performLogin, t as loginWithApiKey } from "./login-Bhxgqwtm.js";
10
- import { t as scanProject } from "./scan-BmAW413l.js";
9
+ import { a as onboardingHooks, n as performLogin, r as BROWSER_UNAVAILABLE, t as loginWithApiKey } from "./login-Do4wFuLv.js";
10
+ import { t as scanProject } from "./scan-zKsddO72.js";
11
11
 
12
12
  //#region src/commands/account/auth.ts
13
13
  const runLogin = defineCommand({
@@ -47,8 +47,9 @@ const runLogin = defineCommand({
47
47
  const session = await performLogin({
48
48
  issuer: ctx.argv.host,
49
49
  clientId: ctx.argv.clientId,
50
- onVerify: ({ url, userCode }) => {
50
+ onVerify: ({ url, userCode, browserOpened }) => {
51
51
  ui.info(`Approve this login in your browser · code \`${userCode}\`\n${url}`);
52
+ if (!browserOpened) ui.warn(BROWSER_UNAVAILABLE);
52
53
  spin.start("Waiting for you to approve in the browser");
53
54
  },
54
55
  onStatus: (m) => spin.message(m),
package/dist/auth.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./output-C-4UKMot.js";
2
- import { n as resolveAuthToken, o as NotLoggedInError, t as getOAuthAccessToken } from "./token-BGAVPSQc.js";
1
+ import "./output-C4o2gJ1K.js";
2
+ import { n as resolveAuthToken, o as NotLoggedInError, t as getOAuthAccessToken } from "./token-C0it-Xh7.js";
3
3
 
4
4
  export { NotLoggedInError, getOAuthAccessToken, resolveAuthToken };
@@ -1,4 +1,4 @@
1
- import { n as allDeps, r as readPackageJson } from "./scan-BmAW413l.js";
1
+ import { n as allDeps, r as readPackageJson } from "./scan-zKsddO72.js";
2
2
  import { readFileSync } from "node:fs";
3
3
  import fg from "fast-glob";
4
4
 
@@ -1,7 +1,7 @@
1
- import { m as Integration } from "./output-C-4UKMot.js";
2
- import { n as ui } from "./ui-4gLyfrgl.js";
1
+ import { g as Integration } from "./output-C4o2gJ1K.js";
2
+ import { n as ui } from "./ui-Dy0b-9L8.js";
3
3
  import { b as platformLabel, h as listProjects, n as createApplication, s as createProject } from "./resources-Bf9O1JNM.js";
4
- import { t as requireOrg } from "./org-CQduIOic.js";
4
+ import { t as requireOrg } from "./org-sj7uyvp-.js";
5
5
 
6
6
  //#region src/core/account/bind.ts
7
7
  const NEW = "__new__";
@@ -1,11 +1,11 @@
1
- import { y as VERSION } from "./output-C-4UKMot.js";
2
- import "./telemetry-Ch9cCTI-.js";
3
- import "./update-DIXbL-H9.js";
4
- import "./token-BGAVPSQc.js";
5
- import { t as defineCommand } from "./command-3fGYyC8r.js";
6
- import { n as ui } from "./ui-4gLyfrgl.js";
1
+ import { x as VERSION } from "./output-C4o2gJ1K.js";
2
+ import "./telemetry-DeA1mvnT.js";
3
+ import "./update-B2fWIc4q.js";
4
+ import "./token-C0it-Xh7.js";
5
+ import { t as defineCommand } from "./command-CMIz81Da.js";
6
+ import { n as ui } from "./ui-Dy0b-9L8.js";
7
7
  import "./resources-Bf9O1JNM.js";
8
- import { A as assetBaseUrl, _ as collectProjectDeclarations, k as loadFramework, m as took, n as parseIds, o as requireProject, r as projectDir, s as selectSurfaces, u as kb, v as writeProjectTypes, x as readLock } from "./selection-BGi6GyxC.js";
8
+ import { A as assetBaseUrl, _ as collectProjectDeclarations, k as loadFramework, m as took, n as parseIds, o as requireProject, r as projectDir, s as selectSurfaces, u as kb, v as writeProjectTypes, x as readLock } from "./selection-CxZoX4NT.js";
9
9
  import pc from "picocolors";
10
10
  import * as path from "node:path";
11
11
  import * as fs from "node:fs";