cdk-insights 0.7.2 → 0.7.4
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/cli/entry.js +46 -2
- package/package.json +1 -1
package/dist/cli/entry.js
CHANGED
|
@@ -82487,6 +82487,49 @@ var decodeJWTPayload = (token) => {
|
|
|
82487
82487
|
var hashLicenseKey = (licenseKey) => {
|
|
82488
82488
|
return crypto6.createHash("sha256").update(licenseKey).digest("hex").slice(0, 16);
|
|
82489
82489
|
};
|
|
82490
|
+
var fetchLicenseInfo = async (licenseKey, apiBase) => {
|
|
82491
|
+
try {
|
|
82492
|
+
const quotaUrl = `${apiBase}/license/quota`;
|
|
82493
|
+
cliLogger.debug("\u{1F4E1} Fetching fresh license info", {
|
|
82494
|
+
url: quotaUrl
|
|
82495
|
+
});
|
|
82496
|
+
const response = await axios_default.get(quotaUrl, {
|
|
82497
|
+
headers: {
|
|
82498
|
+
Authorization: `Bearer ${licenseKey}`,
|
|
82499
|
+
"Content-Type": "application/json"
|
|
82500
|
+
},
|
|
82501
|
+
timeout: 1e4
|
|
82502
|
+
});
|
|
82503
|
+
const data = response.data;
|
|
82504
|
+
cliLogger.debug("\u{1F4E5} Received fresh license info", {
|
|
82505
|
+
hasData: !!data,
|
|
82506
|
+
totalResourcesAnalyzed: data?.totalResourcesAnalyzed,
|
|
82507
|
+
maxUsage: data?.maxUsage,
|
|
82508
|
+
status: data?.status
|
|
82509
|
+
});
|
|
82510
|
+
return {
|
|
82511
|
+
licenseType: data?.licenseType,
|
|
82512
|
+
tier: data?.tier || (data?.status === "TRIAL" ? "trial" : "pro"),
|
|
82513
|
+
status: data?.status,
|
|
82514
|
+
maxUsage: data?.maxUsage,
|
|
82515
|
+
currentPeriodUsage: data?.currentPeriodUsage,
|
|
82516
|
+
totalResourcesAnalyzed: data?.totalResourcesAnalyzed,
|
|
82517
|
+
createdAt: data?.createdAt,
|
|
82518
|
+
updatedAt: data?.updatedAt,
|
|
82519
|
+
lastUsageAt: data?.lastUsageAt,
|
|
82520
|
+
trialStart: data?.trialStart,
|
|
82521
|
+
trialEnd: data?.trialEnd,
|
|
82522
|
+
expiresAt: data?.expiresAt,
|
|
82523
|
+
trialUsageLimit: data?.trialUsageLimit,
|
|
82524
|
+
productMetadata: data?.productMetadata
|
|
82525
|
+
};
|
|
82526
|
+
} catch (error2) {
|
|
82527
|
+
cliLogger.warn("Failed to fetch fresh license info", {
|
|
82528
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
82529
|
+
});
|
|
82530
|
+
return void 0;
|
|
82531
|
+
}
|
|
82532
|
+
};
|
|
82490
82533
|
var getCachedAuthToken = (licenseKey) => {
|
|
82491
82534
|
try {
|
|
82492
82535
|
if (!fs2.existsSync(AUTH_TOKEN_CACHE_FILE)) return null;
|
|
@@ -82545,15 +82588,16 @@ async function authenticateUser(licenseKey, fingerprint, project2) {
|
|
|
82545
82588
|
const apiBase2 = resolveApiBase();
|
|
82546
82589
|
const jwtPayload = decodeJWTPayload(cachedToken.token);
|
|
82547
82590
|
const jwtFingerprint = jwtPayload?.fingerprint;
|
|
82548
|
-
cliLogger.info("\u2705 Using cached auth token", {
|
|
82591
|
+
cliLogger.info("\u2705 Using cached auth token, fetching fresh license info", {
|
|
82549
82592
|
hasToken: true,
|
|
82550
82593
|
hasJwtFingerprint: !!jwtFingerprint,
|
|
82551
82594
|
apiUrl: apiBase2
|
|
82552
82595
|
});
|
|
82596
|
+
const freshLicenseInfo = apiBase2 ? await fetchLicenseInfo(licenseKey, apiBase2) : void 0;
|
|
82553
82597
|
return {
|
|
82554
82598
|
token: cachedToken.token,
|
|
82555
82599
|
usageData: void 0,
|
|
82556
|
-
licenseInfo:
|
|
82600
|
+
licenseInfo: freshLicenseInfo,
|
|
82557
82601
|
fingerprint: jwtFingerprint,
|
|
82558
82602
|
apiUrl: apiBase2
|
|
82559
82603
|
};
|