secure-repo 1.0.8 → 1.0.9
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/bin/cli.js +32 -28
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -10,7 +10,8 @@ const FREE_DIR = path.join(TEMPLATES_DIR, "free");
|
|
|
10
10
|
|
|
11
11
|
const POLAR_ORGANIZATION_ID = "d55baa70-3a94-4549-901a-2b4c920ff122";
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// Pro download endpoint (server-side proxy — token never ships in client code)
|
|
14
|
+
const PRO_DOWNLOAD_URL = "https://shipsecure.app/api/download-pro";
|
|
14
15
|
|
|
15
16
|
const args = process.argv.slice(2);
|
|
16
17
|
const command = args[0];
|
|
@@ -173,37 +174,40 @@ function verifyLicense(licenseKey) {
|
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
// ============================================================
|
|
176
|
-
// Download
|
|
177
|
+
// Download pro zip via server-side proxy
|
|
177
178
|
// ============================================================
|
|
178
|
-
function
|
|
179
|
+
function downloadProZip(destPath, licenseKey) {
|
|
179
180
|
return new Promise((resolve, reject) => {
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
181
|
+
const parsed = new URL(PRO_DOWNLOAD_URL);
|
|
182
|
+
const postData = JSON.stringify({ license_key: licenseKey });
|
|
183
|
+
const opts = {
|
|
184
|
+
hostname: parsed.hostname,
|
|
185
|
+
path: parsed.pathname,
|
|
186
|
+
method: "POST",
|
|
187
|
+
headers: {
|
|
188
|
+
"User-Agent": "secure-repo-cli",
|
|
189
|
+
"Content-Type": "application/json",
|
|
190
|
+
"Content-Length": Buffer.byteLength(postData),
|
|
191
|
+
},
|
|
192
|
+
};
|
|
194
193
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
const req = https.request(opts, (res) => {
|
|
195
|
+
if (res.statusCode !== 200) {
|
|
196
|
+
let body = "";
|
|
197
|
+
res.on("data", (chunk) => (body += chunk));
|
|
198
|
+
res.on("end", () => {
|
|
199
|
+
reject(new Error(`Download failed (HTTP ${res.statusCode}): ${body}`));
|
|
199
200
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const file = fs.createWriteStream(destPath);
|
|
204
|
+
res.pipe(file);
|
|
205
|
+
file.on("finish", () => { file.close(); resolve(); });
|
|
206
|
+
});
|
|
205
207
|
|
|
206
|
-
|
|
208
|
+
req.on("error", (err) => reject(new Error(`Network error: ${err.message}`)));
|
|
209
|
+
req.write(postData);
|
|
210
|
+
req.end();
|
|
207
211
|
});
|
|
208
212
|
}
|
|
209
213
|
|
|
@@ -300,7 +304,7 @@ async function init() {
|
|
|
300
304
|
console.log("\n Downloading pro templates...");
|
|
301
305
|
|
|
302
306
|
try {
|
|
303
|
-
await
|
|
307
|
+
await downloadProZip(zipPath, licenseKey);
|
|
304
308
|
const proResult = installFromZip(zipPath, outputDir, force);
|
|
305
309
|
|
|
306
310
|
const totalCopied = freeResult.copied + proResult.copied;
|
package/package.json
CHANGED