@sitepong/fastnode 0.3.0 → 0.3.1

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 (64) hide show
  1. package/README.md +6 -0
  2. package/dist/actions/index.cjs +80 -0
  3. package/dist/actions/index.cjs.map +1 -1
  4. package/dist/actions/index.mjs +81 -1
  5. package/dist/actions/index.mjs.map +1 -1
  6. package/dist/cert/index.d.cts +3 -3
  7. package/dist/cert/index.d.ts +3 -3
  8. package/dist/{cert-RvXmdMke.d.ts → cert-ClacRx9y.d.ts} +1 -1
  9. package/dist/{cert-eOoxGMN1.d.cts → cert-DffLKURp.d.cts} +1 -1
  10. package/dist/cli/index.cjs +115 -28
  11. package/dist/cli/index.cjs.map +1 -1
  12. package/dist/cli/index.d.cts +1 -1
  13. package/dist/cli/index.d.ts +1 -1
  14. package/dist/cli/index.mjs +116 -29
  15. package/dist/cli/index.mjs.map +1 -1
  16. package/dist/client/index.cjs +76 -0
  17. package/dist/client/index.cjs.map +1 -1
  18. package/dist/client/index.d.cts +1 -1
  19. package/dist/client/index.d.ts +1 -1
  20. package/dist/client/index.mjs +71 -1
  21. package/dist/client/index.mjs.map +1 -1
  22. package/dist/deliver/index.d.cts +2 -2
  23. package/dist/deliver/index.d.ts +2 -2
  24. package/dist/{index-DGkgRnZp.d.cts → index-925_Ov7X.d.cts} +1 -1
  25. package/dist/{index-DfkIz7i0.d.cts → index-BbVQzSV1.d.cts} +1 -1
  26. package/dist/{index-BaNcf7jt.d.cts → index-BhGaVlK1.d.cts} +1 -1
  27. package/dist/{index-DjC_gmnL.d.ts → index-C-EEYXSE.d.ts} +1 -1
  28. package/dist/{index-D1GHEM3c.d.ts → index-C18cijCd.d.ts} +1 -1
  29. package/dist/{index-rTZOdMRE.d.ts → index-CBM5XZKC.d.ts} +1 -1
  30. package/dist/{index-lsuS2R1T.d.ts → index-CemR3UI9.d.ts} +32 -1
  31. package/dist/{index-laE3_wm9.d.cts → index-CmcFPn_G.d.cts} +1 -1
  32. package/dist/{index-DrmS802s.d.cts → index-CpGV1f0L.d.cts} +32 -1
  33. package/dist/{index-C01Rkrir.d.ts → index-D9YQQ3FM.d.ts} +1 -1
  34. package/dist/{index-C9mHBJED.d.ts → index-Dkf5sH1E.d.ts} +1 -1
  35. package/dist/{index-CAEiXVWd.d.ts → index-N6eV5yym.d.ts} +1 -1
  36. package/dist/{index-icIH5e5V.d.cts → index-O3EMrd5s.d.cts} +3 -3
  37. package/dist/{index-BvyZ4uiw.d.ts → index-Ol0RtbQA.d.ts} +3 -3
  38. package/dist/{index-DLJso7Vs.d.cts → index-_24DRp3a.d.cts} +1 -1
  39. package/dist/{index-DWOLZNlz.d.cts → index-isT08RuY.d.cts} +1 -1
  40. package/dist/{index-BE7bwNff.d.cts → index-on573dnO.d.cts} +1 -1
  41. package/dist/{index-CBf0-NUQ.d.ts → index-s2PigtDM.d.ts} +1 -1
  42. package/dist/index.cjs +118 -31
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.d.cts +11 -11
  45. package/dist/index.d.ts +11 -11
  46. package/dist/index.mjs +118 -31
  47. package/dist/index.mjs.map +1 -1
  48. package/dist/lane/index.cjs +80 -0
  49. package/dist/lane/index.cjs.map +1 -1
  50. package/dist/lane/index.mjs +81 -1
  51. package/dist/lane/index.mjs.map +1 -1
  52. package/dist/match/index.d.cts +4 -4
  53. package/dist/match/index.d.ts +4 -4
  54. package/dist/pem/index.d.cts +2 -2
  55. package/dist/pem/index.d.ts +2 -2
  56. package/dist/pilot/index.d.cts +2 -2
  57. package/dist/pilot/index.d.ts +2 -2
  58. package/dist/precheck/index.d.cts +2 -2
  59. package/dist/precheck/index.d.ts +2 -2
  60. package/dist/produce/index.d.cts +2 -2
  61. package/dist/produce/index.d.ts +2 -2
  62. package/dist/sigh/index.d.cts +2 -2
  63. package/dist/sigh/index.d.ts +2 -2
  64. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { Command } from 'commander';
2
- import { A as AppStoreConnectClient } from '../index-DrmS802s.cjs';
2
+ import { A as AppStoreConnectClient } from '../index-CpGV1f0L.cjs';
3
3
  import '../enums-yXNVh3UI.cjs';
4
4
  import '../apple-session-jUzBrql5.cjs';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { Command } from 'commander';
2
- import { A as AppStoreConnectClient } from '../index-lsuS2R1T.js';
2
+ import { A as AppStoreConnectClient } from '../index-CemR3UI9.js';
3
3
  import '../enums-yXNVh3UI.js';
4
4
  import '../apple-session-jUzBrql5.js';
5
5
 
@@ -1,7 +1,7 @@
1
1
  import * as x509 from '@peculiar/x509';
2
2
  import { randomUUID, createHash, webcrypto, randomBytes, pbkdf2Sync, createCipheriv, createDecipheriv } from 'crypto';
3
3
  import { spawn, execFile, execFileSync } from 'child_process';
4
- import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, copyFileSync, mkdtempSync, rmSync, chmodSync } from 'fs';
4
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, chmodSync, unlinkSync, copyFileSync, mkdtempSync, rmSync } from 'fs';
5
5
  import { join, extname, resolve, basename, relative } from 'path';
6
6
  import { homedir, tmpdir } from 'os';
7
7
  import { promisify } from 'util';
@@ -1755,20 +1755,6 @@ var init_srp = __esm({
1755
1755
  };
1756
1756
  }
1757
1757
  });
1758
-
1759
- // src/client/apple-session.ts
1760
- var apple_session_exports = {};
1761
- __export(apple_session_exports, {
1762
- ProgramLicenseAgreementError: () => ProgramLicenseAgreementError,
1763
- appleJson: () => appleJson,
1764
- beginLogin: () => beginLogin,
1765
- checkPortalResponse: () => checkPortalResponse,
1766
- fetchServiceKey: () => fetchServiceKey,
1767
- loginWithAppleId: () => loginWithAppleId,
1768
- requestSmsCode: () => requestSmsCode,
1769
- serviceKeyFromLocation: () => serviceKeyFromLocation,
1770
- submitTwoFactorCode: () => submitTwoFactorCode
1771
- });
1772
1758
  async function appleJson(res, what) {
1773
1759
  const text = await res.text();
1774
1760
  try {
@@ -6975,6 +6961,90 @@ var init_app_asset_library_placements = __esm({
6975
6961
  }
6976
6962
  });
6977
6963
 
6964
+ // src/client/session-store.ts
6965
+ var session_store_exports = {};
6966
+ __export(session_store_exports, {
6967
+ clearAppleSession: () => clearAppleSession,
6968
+ lastAppleId: () => lastAppleId,
6969
+ loadAppleSession: () => loadAppleSession,
6970
+ saveAppleSession: () => saveAppleSession,
6971
+ sessionDir: () => sessionDir,
6972
+ signInWithAppleId: () => signInWithAppleId
6973
+ });
6974
+ function sessionDir() {
6975
+ return process.env.FASTNODE_SESSION_DIR || join(homedir(), ".fastnode", "sessions");
6976
+ }
6977
+ function fileFor(email) {
6978
+ const key = createHash("sha256").update(email.trim().toLowerCase()).digest("hex").slice(0, 16);
6979
+ return join(sessionDir(), `${key}.json`);
6980
+ }
6981
+ function ensureDir() {
6982
+ const dir = sessionDir();
6983
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true, mode: 448 });
6984
+ chmodSync(dir, 448);
6985
+ }
6986
+ function saveAppleSession(session) {
6987
+ ensureDir();
6988
+ const stored = { email: session.userEmail, savedAt: (/* @__PURE__ */ new Date()).toISOString(), session };
6989
+ const path = fileFor(session.userEmail);
6990
+ writeFileSync(path, JSON.stringify(stored), { mode: 384 });
6991
+ chmodSync(path, 384);
6992
+ writeFileSync(join(sessionDir(), "last-apple-id"), session.userEmail, { mode: 384 });
6993
+ }
6994
+ function clearAppleSession(email) {
6995
+ const path = fileFor(email);
6996
+ if (existsSync(path)) unlinkSync(path);
6997
+ }
6998
+ function lastAppleId() {
6999
+ try {
7000
+ return readFileSync(join(sessionDir(), "last-apple-id"), "utf8").trim() || null;
7001
+ } catch {
7002
+ return null;
7003
+ }
7004
+ }
7005
+ async function loadAppleSession(email, fetchImpl = fetch) {
7006
+ const path = fileFor(email);
7007
+ if (!existsSync(path)) return null;
7008
+ let stored;
7009
+ try {
7010
+ stored = JSON.parse(readFileSync(path, "utf8"));
7011
+ } catch {
7012
+ return null;
7013
+ }
7014
+ const cookie = Object.entries(stored.session.cookies).map(([k, v]) => `${k}=${v}`).join("; ");
7015
+ try {
7016
+ const res = await fetchImpl(OLYMPUS_SESSION2, { headers: { Cookie: cookie, Accept: "application/json" } });
7017
+ if (!res.ok) {
7018
+ clearAppleSession(email);
7019
+ return null;
7020
+ }
7021
+ } catch {
7022
+ return null;
7023
+ }
7024
+ return stored.session;
7025
+ }
7026
+ async function signInWithAppleId(options) {
7027
+ const email = options.email || lastAppleId() || await options.askEmail();
7028
+ if (!options.fresh) {
7029
+ const saved = await loadAppleSession(email);
7030
+ if (saved) {
7031
+ options.onLog?.(`Using saved Apple ID session for ${email}`);
7032
+ return saved;
7033
+ }
7034
+ }
7035
+ const password = await options.askPassword(email);
7036
+ const session = await loginWithAppleId({ email, password, onLog: options.onLog });
7037
+ saveAppleSession(session);
7038
+ return session;
7039
+ }
7040
+ var OLYMPUS_SESSION2;
7041
+ var init_session_store = __esm({
7042
+ "src/client/session-store.ts"() {
7043
+ init_apple_session();
7044
+ OLYMPUS_SESSION2 = "https://appstoreconnect.apple.com/olympus/v1/session";
7045
+ }
7046
+ });
7047
+
6978
7048
  // src/client/portal.ts
6979
7049
  function pickUniqueKeyName(base, taken) {
6980
7050
  if (!taken.has(base)) return base;
@@ -8052,8 +8122,14 @@ __export(client_exports, {
8052
8122
  TokenManager: () => TokenManager,
8053
8123
  beginLogin: () => beginLogin,
8054
8124
  checkPortalResponse: () => checkPortalResponse,
8125
+ clearAppleSession: () => clearAppleSession,
8126
+ lastAppleId: () => lastAppleId,
8127
+ loadAppleSession: () => loadAppleSession,
8055
8128
  loginWithAppleId: () => loginWithAppleId,
8056
8129
  requestSmsCode: () => requestSmsCode,
8130
+ saveAppleSession: () => saveAppleSession,
8131
+ sessionDir: () => sessionDir,
8132
+ signInWithAppleId: () => signInWithAppleId,
8057
8133
  submitTwoFactorCode: () => submitTwoFactorCode
8058
8134
  });
8059
8135
  var AppStoreConnectClient;
@@ -8101,6 +8177,7 @@ var init_client = __esm({
8101
8177
  init_auth();
8102
8178
  init_request();
8103
8179
  init_apple_session();
8180
+ init_session_store();
8104
8181
  init_portal();
8105
8182
  init_iris();
8106
8183
  AppStoreConnectClient = class {
@@ -9402,12 +9479,12 @@ function fail(what, r) {
9402
9479
  async function selectProviderForApp(session, appId, onLog) {
9403
9480
  const owns = async () => (await iris(session, "GET", `/apps/${appId}?fields[apps]=name`)).status === 200;
9404
9481
  if (await owns()) return;
9405
- const res = await fetch(OLYMPUS_SESSION2, { headers: { Cookie: cookieHeader(session), Accept: "application/json" } });
9482
+ const res = await fetch(OLYMPUS_SESSION3, { headers: { Cookie: cookieHeader(session), Accept: "application/json" } });
9406
9483
  absorbCookies(session, res);
9407
9484
  const info = await res.json().catch(() => null);
9408
9485
  const providers = info?.availableProviders ?? [];
9409
9486
  for (const p of providers) {
9410
- const sw = await fetch(OLYMPUS_SESSION2, {
9487
+ const sw = await fetch(OLYMPUS_SESSION3, {
9411
9488
  method: "POST",
9412
9489
  headers: { Cookie: cookieHeader(session), "Content-Type": "application/json", Accept: "application/json" },
9413
9490
  body: JSON.stringify({ provider: { providerId: p.providerId } })
@@ -9506,11 +9583,11 @@ function validateUsages(usages) {
9506
9583
  if (linked && unlinked) throw new Error(`${u.category} cannot be both linked and not linked to the user.`);
9507
9584
  }
9508
9585
  }
9509
- var IRIS_BASE2, OLYMPUS_SESSION2, DATA_USAGE_CATEGORIES, DATA_USAGE_PURPOSES, DATA_PROTECTIONS;
9586
+ var IRIS_BASE2, OLYMPUS_SESSION3, DATA_USAGE_CATEGORIES, DATA_USAGE_PURPOSES, DATA_PROTECTIONS;
9510
9587
  var init_privacy = __esm({
9511
9588
  "src/privacy/index.ts"() {
9512
9589
  IRIS_BASE2 = "https://appstoreconnect.apple.com/iris/v1";
9513
- OLYMPUS_SESSION2 = "https://appstoreconnect.apple.com/olympus/v1/session";
9590
+ OLYMPUS_SESSION3 = "https://appstoreconnect.apple.com/olympus/v1/session";
9514
9591
  DATA_USAGE_CATEGORIES = [
9515
9592
  "PAYMENT_INFORMATION",
9516
9593
  "CREDIT_AND_FRAUD",
@@ -9939,14 +10016,18 @@ function createLanesCommand() {
9939
10016
  });
9940
10017
  }
9941
10018
  function createPrivacyCommand() {
9942
- return new Command("privacy").description("Upload App Privacy details (nutrition labels) to App Store Connect").requiredOption("--app-id <id>", "App Store Connect app id (numeric Apple ID)").requiredOption("-j, --json-path <path>", "Fastlane-format app_privacy_details.json").option("-u, --username <email>", "Apple ID", process.env.FASTNODE_USER ?? process.env.FASTLANE_USER).option("--skip-publish", "Save the answers without publishing them", false).action(async (opts) => {
9943
- const { loginWithAppleId: loginWithAppleId2 } = await Promise.resolve().then(() => (init_apple_session(), apple_session_exports));
10019
+ return new Command("privacy").description("Upload App Privacy details (nutrition labels) to App Store Connect").requiredOption("--app-id <id>", "App Store Connect app id (numeric Apple ID)").requiredOption("-j, --json-path <path>", "Fastlane-format app_privacy_details.json").option("-u, --username <email>", "Apple ID (defaults to the last one signed in)", process.env.FASTNODE_USER ?? process.env.FASTLANE_USER).option("--fresh-login", "Ignore the saved Apple ID session and sign in again", false).option("--skip-publish", "Save the answers without publishing them", false).action(async (opts) => {
10020
+ const { signInWithAppleId: signInWithAppleId2, saveAppleSession: saveAppleSession2 } = await Promise.resolve().then(() => (init_session_store(), session_store_exports));
9944
10021
  const { uploadAppPrivacyDetails: uploadAppPrivacyDetails2, validateUsages: validateUsages2 } = await Promise.resolve().then(() => (init_privacy(), privacy_exports));
9945
10022
  const usages = JSON.parse(readFileSync(opts.jsonPath, "utf8"));
9946
10023
  validateUsages2(usages);
9947
- const email = opts.username || await ask("Apple ID: ");
9948
- const password = process.env.FASTNODE_PASSWORD ?? process.env.FASTLANE_PASSWORD ?? await ask(`Password for ${email}: `, true);
9949
- const session = await loginWithAppleId2({ email, password, onLog: (m) => console.log(m) });
10024
+ const session = await signInWithAppleId2({
10025
+ email: opts.username,
10026
+ askEmail: () => ask("Apple ID: "),
10027
+ askPassword: async (email) => process.env.FASTNODE_PASSWORD ?? process.env.FASTLANE_PASSWORD ?? await ask(`Password for ${email}: `, true),
10028
+ fresh: opts.freshLogin,
10029
+ onLog: (m) => console.log(m)
10030
+ });
9950
10031
  const result = await uploadAppPrivacyDetails2({
9951
10032
  session,
9952
10033
  appId: opts.appId,
@@ -9954,6 +10035,7 @@ function createPrivacyCommand() {
9954
10035
  skipPublish: opts.skipPublish,
9955
10036
  onLog: (m) => console.log(m)
9956
10037
  });
10038
+ saveAppleSession2(session);
9957
10039
  console.log(`Done: ${result.created} answers${result.published ? ", published" : ""}.`);
9958
10040
  });
9959
10041
  }
@@ -9976,12 +10058,16 @@ function ask(question, secret = false) {
9976
10058
  });
9977
10059
  }
9978
10060
  function createRejectionsCommand() {
9979
- return new Command("rejections").description("Show App Review's Resolution Center messages and rejection reasons").requiredOption("--app-id <ids...>", "App Store Connect app id(s) (numeric Apple ID)").option("-u, --username <email>", "Apple ID", process.env.FASTNODE_USER ?? process.env.FASTLANE_USER).option("--all", "Include resolved submissions, not just ones awaiting you", false).option("--json", "Print JSON instead of text", false).action(async (opts) => {
9980
- const { loginWithAppleId: loginWithAppleId2 } = await Promise.resolve().then(() => (init_apple_session(), apple_session_exports));
10061
+ return new Command("rejections").description("Show App Review's Resolution Center messages and rejection reasons").requiredOption("--app-id <ids...>", "App Store Connect app id(s) (numeric Apple ID)").option("-u, --username <email>", "Apple ID (defaults to the last one signed in)", process.env.FASTNODE_USER ?? process.env.FASTLANE_USER).option("--fresh-login", "Ignore the saved Apple ID session and sign in again", false).option("--all", "Include resolved submissions, not just ones awaiting you", false).option("--json", "Print JSON instead of text", false).action(async (opts) => {
10062
+ const { signInWithAppleId: signInWithAppleId2, saveAppleSession: saveAppleSession2 } = await Promise.resolve().then(() => (init_session_store(), session_store_exports));
9981
10063
  const { getReviewFeedback: getReviewFeedback2 } = await Promise.resolve().then(() => (init_review(), review_exports));
9982
- const email = opts.username || await ask2("Apple ID: ");
9983
- const password = process.env.FASTNODE_PASSWORD ?? process.env.FASTLANE_PASSWORD ?? await ask2(`Password for ${email}: `, true);
9984
- const session = await loginWithAppleId2({ email, password, onLog: (m) => console.error(m) });
10064
+ const session = await signInWithAppleId2({
10065
+ email: opts.username,
10066
+ askEmail: () => ask2("Apple ID: "),
10067
+ askPassword: async (email) => process.env.FASTNODE_PASSWORD ?? process.env.FASTLANE_PASSWORD ?? await ask2(`Password for ${email}: `, true),
10068
+ fresh: opts.freshLogin,
10069
+ onLog: (m) => console.error(m)
10070
+ });
9985
10071
  const all = {};
9986
10072
  for (const appId of opts.appId) {
9987
10073
  const feedback = await getReviewFeedback2(session, appId, { onlyOpen: !opts.all, onLog: (m) => console.error(m) });
@@ -10004,6 +10090,7 @@ Submission ${s.submissionId} \u2014 ${s.state} (submitted ${s.submittedDate ?? "
10004
10090
  }
10005
10091
  }
10006
10092
  }
10093
+ saveAppleSession2(session);
10007
10094
  if (opts.json) console.log(JSON.stringify(all, null, 2));
10008
10095
  });
10009
10096
  }