@clavis.nexus/setup 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -290,4 +290,5 @@ type OperateKeyPair = {
290
290
  };
291
291
  declare function generateOperateKeyPair(): Promise<OperateKeyPair>;
292
292
 
293
- export { APP_REGIONS, type AppRegion, type CardCheckoutOptions, type CreateSetupClientOptions, DEFAULT_ORIGINS, type DevelopersSession, type HumanAction, type NeedsHuman, type OrgCreationTerms, type Receipt, SetupApiError, type SetupClient, type SetupOrigins, type SetupResult, type SetupStatusReport, clearSession, createSetupClient, defaultSessionPath, formatEnvExport, generateOperateKeyPair, loadSession, originsFromEnv, saveSession };
293
+ export { APP_REGIONS, DEFAULT_ORIGINS, SetupApiError, clearSession, createSetupClient, defaultSessionPath, formatEnvExport, generateOperateKeyPair, loadSession, originsFromEnv, saveSession };
294
+ export type { AppRegion, CardCheckoutOptions, CreateSetupClientOptions, DevelopersSession, HumanAction, NeedsHuman, OrgCreationTerms, Receipt, SetupClient, SetupOrigins, SetupResult, SetupStatusReport };
package/dist/index.js CHANGED
@@ -1096,8 +1096,8 @@ async function buildSetupStatus(args) {
1096
1096
  }
1097
1097
 
1098
1098
  // src/setup-client.ts
1099
- async function requireSession(client) {
1100
- const stored = await loadSession(client.sessionPath);
1099
+ async function requireSession(sessionPath) {
1100
+ const stored = await loadSession(sessionPath);
1101
1101
  if (!stored?.session?.accessToken) {
1102
1102
  return {
1103
1103
  ok: false,
@@ -1108,7 +1108,7 @@ async function requireSession(client) {
1108
1108
  }
1109
1109
  };
1110
1110
  }
1111
- return { ok: true, data: { session: stored.session, origins: stored.origins ?? client.origins } };
1111
+ return { ok: true, data: { session: stored.session, origins: stored.origins } };
1112
1112
  }
1113
1113
  async function runPasskeyCeremony(args) {
1114
1114
  const returnTo = setupCeremonyReturnTo(args.origins.developersOrigin);
@@ -1186,7 +1186,7 @@ function createSetupClient(options = {}) {
1186
1186
  const checked = checkOrgCreationTerms(terms);
1187
1187
  if (!checked.ok) return checked;
1188
1188
  const { incorporation } = checked;
1189
- const auth = await requireSession({ origins, sessionPath });
1189
+ const auth = await requireSession(sessionPath);
1190
1190
  if (!auth.ok) return auth;
1191
1191
  const apiOrigin = auth.data.origins.apiOrigin;
1192
1192
  const closed = await getClosedIncorporations(apiOrigin).catch(() => []);
@@ -1240,7 +1240,7 @@ function createSetupClient(options = {}) {
1240
1240
  };
1241
1241
  },
1242
1242
  async orgAnchorFinish(args) {
1243
- const auth = await requireSession({ origins, sessionPath });
1243
+ const auth = await requireSession(sessionPath);
1244
1244
  if (!auth.ok) return auth;
1245
1245
  const payload = await pollCeremonyResult({
1246
1246
  apiOrigin: auth.data.origins.apiOrigin,
@@ -1278,7 +1278,7 @@ function createSetupClient(options = {}) {
1278
1278
  const checked = checkOrgCreationTerms(args);
1279
1279
  if (!checked.ok) return checked;
1280
1280
  const { incorporation } = checked;
1281
- const auth = await requireSession({ origins, sessionPath });
1281
+ const auth = await requireSession(sessionPath);
1282
1282
  if (!auth.ok) return auth;
1283
1283
  try {
1284
1284
  const out = await postVerifyAnchor(auth.data.origins.apiOrigin, auth.data.session.accessToken, {
@@ -1303,7 +1303,7 @@ function createSetupClient(options = {}) {
1303
1303
  }
1304
1304
  },
1305
1305
  async policyBootstrap(orgId) {
1306
- const auth = await requireSession({ origins, sessionPath });
1306
+ const auth = await requireSession(sessionPath);
1307
1307
  if (!auth.ok) return auth;
1308
1308
  const detail = await getOrg(auth.data.origins.apiOrigin, auth.data.session.accessToken, orgId);
1309
1309
  try {
@@ -1335,7 +1335,7 @@ function createSetupClient(options = {}) {
1335
1335
  const checked = checkOrgCreationTerms(args, INCORPORATION_TERMS_HUMAN);
1336
1336
  if (!checked.ok) return checked;
1337
1337
  const code = checked.incorporation;
1338
- const auth = await requireSession({ origins, sessionPath });
1338
+ const auth = await requireSession(sessionPath);
1339
1339
  if (!auth.ok) return auth;
1340
1340
  const sub = auth.data.session.sub;
1341
1341
  if (!sub) return { ok: false, error: "session_missing_sub \u2014 re-login" };
@@ -1373,7 +1373,7 @@ function createSetupClient(options = {}) {
1373
1373
  async cardCheckout(orgId, opts = {}) {
1374
1374
  const offer = opts.offer === "bundle" ? "bundle" : "meter";
1375
1375
  const lang = checkoutLang(opts.lang);
1376
- const auth = await requireSession({ origins, sessionPath });
1376
+ const auth = await requireSession(sessionPath);
1377
1377
  if (!auth.ok) return auth;
1378
1378
  const sub = auth.data.session.sub;
1379
1379
  if (!sub) return { ok: false, error: "session_missing_sub \u2014 re-login" };
@@ -1456,7 +1456,7 @@ function createSetupClient(options = {}) {
1456
1456
  };
1457
1457
  },
1458
1458
  async appRegister(args) {
1459
- const auth = await requireSession({ origins, sessionPath });
1459
+ const auth = await requireSession(sessionPath);
1460
1460
  if (!auth.ok) return auth;
1461
1461
  const sub = auth.data.session.sub;
1462
1462
  if (!sub) return { ok: false, error: "session_missing_sub \u2014 re-login" };
@@ -1501,7 +1501,7 @@ function createSetupClient(options = {}) {
1501
1501
  };
1502
1502
  },
1503
1503
  async appHostPlan(orgId, appId) {
1504
- const auth = await requireSession({ origins, sessionPath });
1504
+ const auth = await requireSession(sessionPath);
1505
1505
  if (!auth.ok) return auth;
1506
1506
  const ch = await getHostChallenge(auth.data.origins.apiOrigin, auth.data.session.accessToken, orgId, appId);
1507
1507
  return {
@@ -1518,7 +1518,7 @@ function createSetupClient(options = {}) {
1518
1518
  };
1519
1519
  },
1520
1520
  async appVerifyHost(args) {
1521
- const auth = await requireSession({ origins, sessionPath });
1521
+ const auth = await requireSession(sessionPath);
1522
1522
  if (!auth.ok) return auth;
1523
1523
  const ch = await getHostChallenge(
1524
1524
  auth.data.origins.apiOrigin,
@@ -1559,7 +1559,7 @@ function createSetupClient(options = {}) {
1559
1559
  }
1560
1560
  },
1561
1561
  async declarationSet(args) {
1562
- const auth = await requireSession({ origins, sessionPath });
1562
+ const auth = await requireSession(sessionPath);
1563
1563
  if (!auth.ok) return auth;
1564
1564
  const declaration = { endUsers: args.endUsers, uses: args.uses };
1565
1565
  const cer = await runPasskeyCeremony({
@@ -1583,7 +1583,7 @@ function createSetupClient(options = {}) {
1583
1583
  const read = readAppRegionsInput(args.regions);
1584
1584
  if (!read.ok) return read;
1585
1585
  const regions = read.regions;
1586
- const auth = await requireSession({ origins, sessionPath });
1586
+ const auth = await requireSession(sessionPath);
1587
1587
  if (!auth.ok) return auth;
1588
1588
  const sub = auth.data.session.sub;
1589
1589
  if (!sub) return { ok: false, error: "session_missing_sub \u2014 re-login" };