@corsair-dev/cli 0.1.13 → 0.1.15

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.
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../auth.ts"],"names":[],"mappings":"AAguBA,wBAAsB,OAAO,CAAC,EAC7B,GAAG,EACH,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,eAAuB,EACpC,MAAM,EAAE,UAAkB,EAC1B,OAAO,EAAE,WAAmB,EAC5B,SAAS,GACT,EAAE;IACF,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iFAAiF;IACjF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgJhB"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../auth.ts"],"names":[],"mappings":"AA4pBA,wBAAsB,OAAO,CAAC,EAC7B,GAAG,EACH,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,eAAuB,EACpC,MAAM,EAAE,UAAkB,EAC1B,OAAO,EAAE,WAAmB,EAC5B,SAAS,GACT,EAAE;IACF,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iFAAiF;IACjF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgJhB"}
package/dist/index.js CHANGED
@@ -1591,6 +1591,7 @@ import {
1591
1591
  createAccountKeyManager as createAccountKeyManager3,
1592
1592
  createIntegrationKeyManager as createIntegrationKeyManager3,
1593
1593
  encryptDEK,
1594
+ exchangeCodeForTokens,
1594
1595
  generateDEK
1595
1596
  } from "corsair/core";
1596
1597
  import { createCorsairOrm } from "corsair/orm";
@@ -1683,56 +1684,6 @@ function waitForOAuthCode(port) {
1683
1684
  server.on("error", reject);
1684
1685
  });
1685
1686
  }
1686
- function exchangeCodeForTokens(code, clientId, clientSecret, oauthConfig, redirectUri) {
1687
- const tokenUrl = new URL(oauthConfig.tokenUrl);
1688
- const useBasicAuth = oauthConfig.tokenAuthMethod === "basic";
1689
- return new Promise((resolve, reject) => {
1690
- const postDataParams = {
1691
- code: code.trim(),
1692
- redirect_uri: redirectUri,
1693
- grant_type: "authorization_code"
1694
- };
1695
- if (!useBasicAuth) {
1696
- postDataParams.client_id = clientId;
1697
- postDataParams.client_secret = clientSecret;
1698
- }
1699
- const postData = querystring.stringify(postDataParams);
1700
- const headers = {
1701
- "Content-Type": "application/x-www-form-urlencoded",
1702
- "Content-Length": Buffer.byteLength(postData).toString()
1703
- };
1704
- if (useBasicAuth) {
1705
- headers.Authorization = `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString("base64")}`;
1706
- }
1707
- const req = https.request(
1708
- {
1709
- hostname: tokenUrl.hostname,
1710
- path: tokenUrl.pathname,
1711
- method: "POST",
1712
- headers
1713
- },
1714
- (res) => {
1715
- let data = "";
1716
- res.on("data", (chunk) => {
1717
- data += chunk;
1718
- });
1719
- res.on("end", () => {
1720
- if (res.statusCode !== 200) {
1721
- reject(new Error(`Token exchange failed: ${data}`));
1722
- return;
1723
- }
1724
- resolve(JSON.parse(data));
1725
- });
1726
- }
1727
- );
1728
- req.on(
1729
- "error",
1730
- (error) => reject(new Error(`Request failed: ${error.message}`))
1731
- );
1732
- req.write(postData);
1733
- req.end();
1734
- });
1735
- }
1736
1687
  async function extractInternalConfig3(cwd) {
1737
1688
  const instance = await getCorsairInstance({ cwd, shouldThrowOnError: true });
1738
1689
  const internal = instance[CORSAIR_INTERNAL3];
@@ -2554,14 +2505,26 @@ function parseAuthArgs(args) {
2554
2505
  }
2555
2506
  function parseSetupArgs(args) {
2556
2507
  let backfill = false;
2508
+ let tenantId;
2557
2509
  const credentials = {};
2558
2510
  let currentPlugin = null;
2559
- for (const arg of args) {
2511
+ for (let i = 0; i < args.length; i++) {
2512
+ const arg = args[i];
2560
2513
  if (arg === "--backfill" || arg === "-backfill") {
2561
2514
  backfill = true;
2562
2515
  currentPlugin = null;
2563
2516
  continue;
2564
2517
  }
2518
+ if (arg === "--tenant" && args[i + 1]) {
2519
+ tenantId = args[++i];
2520
+ currentPlugin = null;
2521
+ continue;
2522
+ }
2523
+ if (arg.startsWith("--tenant=")) {
2524
+ tenantId = arg.slice("--tenant=".length);
2525
+ currentPlugin = null;
2526
+ continue;
2527
+ }
2565
2528
  if (arg.startsWith("--plugin=")) {
2566
2529
  currentPlugin = arg.slice("--plugin=".length);
2567
2530
  if (!credentials[currentPlugin]) credentials[currentPlugin] = {};
@@ -2577,7 +2540,7 @@ function parseSetupArgs(args) {
2577
2540
  credentials[currentPlugin][field] = value;
2578
2541
  }
2579
2542
  }
2580
- return { backfill, credentials };
2543
+ return { backfill, tenantId, credentials };
2581
2544
  }
2582
2545
  function parseRunArgs(args) {
2583
2546
  let endpointPath;
@@ -2649,8 +2612,8 @@ function printHelp() {
2649
2612
  const lines = [
2650
2613
  "Corsair CLI",
2651
2614
  "",
2652
- "pnpm corsair setup Init (add -backfill to seed data)",
2653
- "pnpm corsair setup --plugin=<id> <field>=VALUE Set plugin credentials",
2615
+ "pnpm corsair setup [--tenant=<id>] Init (add -backfill to seed data)",
2616
+ "pnpm corsair setup [--tenant=<id>] --plugin=<id> <field>=VALUE Set plugin credentials",
2654
2617
  "pnpm corsair auth --plugin=<id> Start OAuth flow",
2655
2618
  "pnpm corsair auth --plugin=<id> --code=<code> Exchange OAuth code for tokens",
2656
2619
  "pnpm corsair auth --plugin=<id> --credentials Show credential status",
@@ -2673,11 +2636,12 @@ async function main() {
2673
2636
  const args = process.argv.slice(2);
2674
2637
  const command = args[0];
2675
2638
  if (command === "setup") {
2676
- const { backfill, credentials } = parseSetupArgs(args.slice(1));
2639
+ const { backfill, tenantId, credentials } = parseSetupArgs(args.slice(1));
2677
2640
  const { setupCorsair } = await import("corsair/setup");
2678
2641
  const instance = await getCorsairInstance({ cwd });
2679
2642
  await setupCorsair(instance, {
2680
2643
  backfill,
2644
+ tenantId,
2681
2645
  credentials,
2682
2646
  caller: "cli"
2683
2647
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corsair-dev/cli",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "@clack/prompts": "^1.0.0",
24
24
  "c12": "^3.3.3",
25
25
  "zod": "^3.25.76",
26
- "corsair": "0.1.60"
26
+ "corsair": "0.1.67"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/jest": "^29.5.14",