@solongate/proxy 0.1.15 → 0.1.16
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.js +33 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3149,35 +3149,41 @@ var SolonGateProxy = class {
|
|
|
3149
3149
|
log("Starting SolonGate Proxy...");
|
|
3150
3150
|
const apiUrl = this.config.apiUrl ?? "https://api.solongate.com";
|
|
3151
3151
|
if (this.config.apiKey) {
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3152
|
+
if (this.config.apiKey.startsWith("sg_test_")) {
|
|
3153
|
+
log("Using test API key \u2014 skipping online validation.");
|
|
3154
|
+
} else {
|
|
3155
|
+
log(`Validating license with ${apiUrl}...`);
|
|
3156
|
+
try {
|
|
3157
|
+
const res = await fetch(`${apiUrl}/api/v1/auth/me`, {
|
|
3158
|
+
headers: {
|
|
3159
|
+
"X-API-Key": this.config.apiKey,
|
|
3160
|
+
"Authorization": `Bearer ${this.config.apiKey}`
|
|
3161
|
+
},
|
|
3162
|
+
signal: AbortSignal.timeout(1e4)
|
|
3163
|
+
});
|
|
3164
|
+
if (res.status === 401) {
|
|
3165
|
+
log("ERROR: Invalid or expired API key.");
|
|
3166
|
+
process.exit(1);
|
|
3167
|
+
}
|
|
3168
|
+
if (res.status === 403) {
|
|
3169
|
+
log("ERROR: Your subscription is inactive. Renew at https://solongate.com");
|
|
3170
|
+
process.exit(1);
|
|
3171
|
+
}
|
|
3172
|
+
log("License validated.");
|
|
3173
|
+
} catch (err) {
|
|
3174
|
+
log(`ERROR: Unable to reach SolonGate license server. Check your internet connection.`);
|
|
3175
|
+
log(`Details: ${err instanceof Error ? err.message : String(err)}`);
|
|
3167
3176
|
process.exit(1);
|
|
3168
3177
|
}
|
|
3169
|
-
log("License validated.");
|
|
3170
|
-
} catch (err) {
|
|
3171
|
-
log(`ERROR: Unable to reach SolonGate license server. Check your internet connection.`);
|
|
3172
|
-
log(`Details: ${err instanceof Error ? err.message : String(err)}`);
|
|
3173
|
-
process.exit(1);
|
|
3174
3178
|
}
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3179
|
+
if (!this.config.apiKey.startsWith("sg_test_")) {
|
|
3180
|
+
try {
|
|
3181
|
+
const cloudPolicy = await fetchCloudPolicy(this.config.apiKey, apiUrl);
|
|
3182
|
+
this.config.policy = cloudPolicy;
|
|
3183
|
+
log(`Loaded cloud policy: ${cloudPolicy.name} (${cloudPolicy.rules.length} rules)`);
|
|
3184
|
+
} catch (err) {
|
|
3185
|
+
log(`Cloud policy fetch failed, using local policy: ${err instanceof Error ? err.message : String(err)}`);
|
|
3186
|
+
}
|
|
3181
3187
|
}
|
|
3182
3188
|
}
|
|
3183
3189
|
log(`Policy: ${this.config.policy.name} (${this.config.policy.rules.length} rules)`);
|
|
@@ -3296,7 +3302,7 @@ var SolonGateProxy = class {
|
|
|
3296
3302
|
const decision = result.isError ? "DENY" : "ALLOW";
|
|
3297
3303
|
const evaluationTimeMs = Date.now() - startTime;
|
|
3298
3304
|
log(`Result: ${decision} (${evaluationTimeMs}ms)`);
|
|
3299
|
-
if (this.config.apiKey) {
|
|
3305
|
+
if (this.config.apiKey && !this.config.apiKey.startsWith("sg_test_")) {
|
|
3300
3306
|
const apiUrl = this.config.apiUrl ?? "https://api.solongate.com";
|
|
3301
3307
|
sendAuditLog(this.config.apiKey, apiUrl, {
|
|
3302
3308
|
tool: name,
|
package/package.json
CHANGED