pinme 2.0.2-beta.3 → 2.0.2-beta.5

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.
Files changed (2) hide show
  1. package/dist/index.js +290 -299
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -96,9 +96,9 @@ var require_package = __commonJS({
96
96
  // node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js
97
97
  var require_main = __commonJS({
98
98
  "node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js"(exports2, module2) {
99
- var fs17 = require("fs");
100
- var path18 = require("path");
101
- var os6 = require("os");
99
+ var fs16 = require("fs");
100
+ var path17 = require("path");
101
+ var os5 = require("os");
102
102
  var crypto3 = require("crypto");
103
103
  var packageJson = require_package();
104
104
  var version2 = packageJson.version;
@@ -200,7 +200,7 @@ var require_main = __commonJS({
200
200
  if (options && options.path && options.path.length > 0) {
201
201
  if (Array.isArray(options.path)) {
202
202
  for (const filepath of options.path) {
203
- if (fs17.existsSync(filepath)) {
203
+ if (fs16.existsSync(filepath)) {
204
204
  possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
205
205
  }
206
206
  }
@@ -208,15 +208,15 @@ var require_main = __commonJS({
208
208
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
209
209
  }
210
210
  } else {
211
- possibleVaultPath = path18.resolve(process.cwd(), ".env.vault");
211
+ possibleVaultPath = path17.resolve(process.cwd(), ".env.vault");
212
212
  }
213
- if (fs17.existsSync(possibleVaultPath)) {
213
+ if (fs16.existsSync(possibleVaultPath)) {
214
214
  return possibleVaultPath;
215
215
  }
216
216
  return null;
217
217
  }
218
218
  function _resolveHome(envPath) {
219
- return envPath[0] === "~" ? path18.join(os6.homedir(), envPath.slice(1)) : envPath;
219
+ return envPath[0] === "~" ? path17.join(os5.homedir(), envPath.slice(1)) : envPath;
220
220
  }
221
221
  function _configVault(options) {
222
222
  const debug = Boolean(options && options.debug);
@@ -232,7 +232,7 @@ var require_main = __commonJS({
232
232
  return { parsed };
233
233
  }
234
234
  function configDotenv(options) {
235
- const dotenvPath = path18.resolve(process.cwd(), ".env");
235
+ const dotenvPath = path17.resolve(process.cwd(), ".env");
236
236
  let encoding = "utf8";
237
237
  const debug = Boolean(options && options.debug);
238
238
  if (options && options.encoding) {
@@ -255,13 +255,13 @@ var require_main = __commonJS({
255
255
  }
256
256
  let lastError;
257
257
  const parsedAll = {};
258
- for (const path19 of optionPaths) {
258
+ for (const path18 of optionPaths) {
259
259
  try {
260
- const parsed = DotenvModule.parse(fs17.readFileSync(path19, { encoding }));
260
+ const parsed = DotenvModule.parse(fs16.readFileSync(path18, { encoding }));
261
261
  DotenvModule.populate(parsedAll, parsed, options);
262
262
  } catch (e) {
263
263
  if (debug) {
264
- _debug(`Failed to load ${path19} ${e.message}`);
264
+ _debug(`Failed to load ${path18} ${e.message}`);
265
265
  }
266
266
  lastError = e;
267
267
  }
@@ -810,7 +810,7 @@ var require_has_flag = __commonJS({
810
810
  var require_supports_color = __commonJS({
811
811
  "node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js"(exports2, module2) {
812
812
  "use strict";
813
- var os6 = require("os");
813
+ var os5 = require("os");
814
814
  var hasFlag = require_has_flag();
815
815
  var env = process.env;
816
816
  var forceColor;
@@ -848,7 +848,7 @@ var require_supports_color = __commonJS({
848
848
  }
849
849
  const min = forceColor ? 1 : 0;
850
850
  if (process.platform === "win32") {
851
- const osRelease = os6.release().split(".");
851
+ const osRelease = os5.release().split(".");
852
852
  if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
853
853
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
854
854
  }
@@ -1523,10 +1523,10 @@ var import_chalk25 = __toESM(require("chalk"));
1523
1523
  var import_figlet5 = __toESM(require("figlet"));
1524
1524
 
1525
1525
  // package.json
1526
- var version = "2.0.2-beta.3";
1526
+ var version = "2.0.2-beta.5";
1527
1527
 
1528
1528
  // bin/upload.ts
1529
- var import_path7 = __toESM(require("path"));
1529
+ var import_path6 = __toESM(require("path"));
1530
1530
  var import_chalk5 = __toESM(require("chalk"));
1531
1531
  var import_inquirer = __toESM(require("inquirer"));
1532
1532
  var import_figlet = __toESM(require("figlet"));
@@ -1972,9 +1972,9 @@ function isVisitable(thing) {
1972
1972
  function removeBrackets(key) {
1973
1973
  return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
1974
1974
  }
1975
- function renderKey(path18, key, dots) {
1976
- if (!path18) return key;
1977
- return path18.concat(key).map(function each(token, i) {
1975
+ function renderKey(path17, key, dots) {
1976
+ if (!path17) return key;
1977
+ return path17.concat(key).map(function each(token, i) {
1978
1978
  token = removeBrackets(token);
1979
1979
  return !dots && i ? "[" + token + "]" : token;
1980
1980
  }).join(dots ? "." : "");
@@ -2019,9 +2019,9 @@ function toFormData(obj, formData, options) {
2019
2019
  }
2020
2020
  return value;
2021
2021
  }
2022
- function defaultVisitor(value, key, path18) {
2022
+ function defaultVisitor(value, key, path17) {
2023
2023
  let arr = value;
2024
- if (value && !path18 && typeof value === "object") {
2024
+ if (value && !path17 && typeof value === "object") {
2025
2025
  if (utils_default.endsWith(key, "{}")) {
2026
2026
  key = metaTokens ? key : key.slice(0, -2);
2027
2027
  value = JSON.stringify(value);
@@ -2040,7 +2040,7 @@ function toFormData(obj, formData, options) {
2040
2040
  if (isVisitable(value)) {
2041
2041
  return true;
2042
2042
  }
2043
- formData.append(renderKey(path18, key, dots), convertValue(value));
2043
+ formData.append(renderKey(path17, key, dots), convertValue(value));
2044
2044
  return false;
2045
2045
  }
2046
2046
  const stack = [];
@@ -2049,10 +2049,10 @@ function toFormData(obj, formData, options) {
2049
2049
  convertValue,
2050
2050
  isVisitable
2051
2051
  });
2052
- function build(value, path18) {
2052
+ function build(value, path17) {
2053
2053
  if (utils_default.isUndefined(value)) return;
2054
2054
  if (stack.indexOf(value) !== -1) {
2055
- throw Error("Circular reference detected in " + path18.join("."));
2055
+ throw Error("Circular reference detected in " + path17.join("."));
2056
2056
  }
2057
2057
  stack.push(value);
2058
2058
  utils_default.forEach(value, function each(el, key) {
@@ -2060,11 +2060,11 @@ function toFormData(obj, formData, options) {
2060
2060
  formData,
2061
2061
  el,
2062
2062
  utils_default.isString(key) ? key.trim() : key,
2063
- path18,
2063
+ path17,
2064
2064
  exposedHelpers
2065
2065
  );
2066
2066
  if (result === true) {
2067
- build(el, path18 ? path18.concat(key) : [key]);
2067
+ build(el, path17 ? path17.concat(key) : [key]);
2068
2068
  }
2069
2069
  });
2070
2070
  stack.pop();
@@ -2225,7 +2225,7 @@ var node_default = {
2225
2225
  // node_modules/.pnpm/axios@1.3.2/node_modules/axios/lib/helpers/toURLEncodedForm.js
2226
2226
  function toURLEncodedForm(data, options) {
2227
2227
  return toFormData_default(data, new node_default.classes.URLSearchParams(), Object.assign({
2228
- visitor: function(value, key, path18, helpers) {
2228
+ visitor: function(value, key, path17, helpers) {
2229
2229
  if (node_default.isNode && utils_default.isBuffer(value)) {
2230
2230
  this.append(key, value.toString("base64"));
2231
2231
  return false;
@@ -2254,10 +2254,10 @@ function arrayToObject(arr) {
2254
2254
  return obj;
2255
2255
  }
2256
2256
  function formDataToJSON(formData) {
2257
- function buildPath(path18, value, target, index) {
2258
- let name = path18[index++];
2257
+ function buildPath(path17, value, target, index) {
2258
+ let name = path17[index++];
2259
2259
  const isNumericKey = Number.isFinite(+name);
2260
- const isLast = index >= path18.length;
2260
+ const isLast = index >= path17.length;
2261
2261
  name = !name && utils_default.isArray(target) ? target.length : name;
2262
2262
  if (isLast) {
2263
2263
  if (utils_default.hasOwnProp(target, name)) {
@@ -2270,7 +2270,7 @@ function formDataToJSON(formData) {
2270
2270
  if (!target[name] || !utils_default.isObject(target[name])) {
2271
2271
  target[name] = [];
2272
2272
  }
2273
- const result = buildPath(path18, value, target[name], index);
2273
+ const result = buildPath(path17, value, target[name], index);
2274
2274
  if (result && utils_default.isArray(target[name])) {
2275
2275
  target[name] = arrayToObject(target[name]);
2276
2276
  }
@@ -3332,9 +3332,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
3332
3332
  auth = urlUsername + ":" + urlPassword;
3333
3333
  }
3334
3334
  auth && headers.delete("authorization");
3335
- let path18;
3335
+ let path17;
3336
3336
  try {
3337
- path18 = buildURL(
3337
+ path17 = buildURL(
3338
3338
  parsed.pathname + parsed.search,
3339
3339
  config.params,
3340
3340
  config.paramsSerializer
@@ -3352,7 +3352,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
3352
3352
  false
3353
3353
  );
3354
3354
  const options = {
3355
- path: path18,
3355
+ path: path17,
3356
3356
  method,
3357
3357
  headers: headers.toJSON(),
3358
3358
  agents: { http: config.httpAgent, https: config.httpsAgent },
@@ -3571,14 +3571,14 @@ var cookies_default = node_default.isStandardBrowserEnv ? (
3571
3571
  // Standard browser envs support document.cookie
3572
3572
  /* @__PURE__ */ function standardBrowserEnv() {
3573
3573
  return {
3574
- write: function write(name, value, expires, path18, domain, secure) {
3574
+ write: function write(name, value, expires, path17, domain, secure) {
3575
3575
  const cookie = [];
3576
3576
  cookie.push(name + "=" + encodeURIComponent(value));
3577
3577
  if (utils_default.isNumber(expires)) {
3578
3578
  cookie.push("expires=" + new Date(expires).toGMTString());
3579
3579
  }
3580
- if (utils_default.isString(path18)) {
3581
- cookie.push("path=" + path18);
3580
+ if (utils_default.isString(path17)) {
3581
+ cookie.push("path=" + path17);
3582
3582
  }
3583
3583
  if (utils_default.isString(domain)) {
3584
3584
  cookie.push("domain=" + domain);
@@ -4427,9 +4427,7 @@ function readNumberEnv(name, fallback) {
4427
4427
  var DEFAULT_PINME_WEB_URL = "http://localhost:5173";
4428
4428
  var _a;
4429
4429
  var APP_CONFIG = {
4430
- pinmeApiBase: trimTrailingSlash(
4431
- "https://pinme.benny1996.win/api/v4"
4432
- ),
4430
+ pinmeApiBase: trimTrailingSlash("https://pinme.benny1996.win/api/v4"),
4433
4431
  ipfsApiUrl: trimTrailingSlash("https://pinme.benny1996.win/api/v3"),
4434
4432
  carApiBase: trimTrailingSlash(
4435
4433
  process.env.CAR_API_BASE || "https://pinme.benny1996.win/api/v3"
@@ -5142,7 +5140,7 @@ async function getWalletBalance(tokenAddress, authToken) {
5142
5140
  try {
5143
5141
  const client = createPinmeApiClient();
5144
5142
  const { data } = await client.get(
5145
- "/api/v4/pay/wallet/balance",
5143
+ "/pay/wallet/balance",
5146
5144
  {
5147
5145
  headers: {
5148
5146
  "authentication-tokens": authToken,
@@ -5265,44 +5263,25 @@ function validateDnsDomain(domain) {
5265
5263
  var import_crypto_js = __toESM(require("crypto-js"));
5266
5264
 
5267
5265
  // bin/utils/getDeviceId.ts
5268
- var import_fs_extra3 = __toESM(require("fs-extra"));
5269
- var import_path3 = __toESM(require("path"));
5270
- var import_os3 = __toESM(require("os"));
5271
- var import_uuid = require("uuid");
5272
-
5273
- // bin/utils/auth.ts
5274
5266
  var import_fs_extra2 = __toESM(require("fs-extra"));
5275
- var import_os2 = __toESM(require("os"));
5276
5267
  var import_path2 = __toESM(require("path"));
5277
- var CONFIG_DIR2 = import_path2.default.join(import_os2.default.homedir(), ".pinme");
5278
- var AUTH_FILE2 = import_path2.default.join(CONFIG_DIR2, "auth.json");
5279
- function getAuthConfig2() {
5280
- try {
5281
- if (!import_fs_extra2.default.existsSync(AUTH_FILE2)) return null;
5282
- const data = import_fs_extra2.default.readJsonSync(AUTH_FILE2);
5283
- if (!(data == null ? void 0 : data.address) || !(data == null ? void 0 : data.token)) return null;
5284
- return data;
5285
- } catch {
5286
- return null;
5287
- }
5288
- }
5289
-
5290
- // bin/utils/getDeviceId.ts
5268
+ var import_os2 = __toESM(require("os"));
5269
+ var import_uuid = require("uuid");
5291
5270
  function getDeviceId() {
5292
- const configDir = import_path3.default.join(import_os3.default.homedir(), ".pinme");
5293
- const configFile = import_path3.default.join(configDir, "device-id");
5294
- if (!import_fs_extra3.default.existsSync(configDir)) {
5295
- import_fs_extra3.default.mkdirSync(configDir, { recursive: true });
5271
+ const configDir = import_path2.default.join(import_os2.default.homedir(), ".pinme");
5272
+ const configFile = import_path2.default.join(configDir, "device-id");
5273
+ if (!import_fs_extra2.default.existsSync(configDir)) {
5274
+ import_fs_extra2.default.mkdirSync(configDir, { recursive: true });
5296
5275
  }
5297
- if (import_fs_extra3.default.existsSync(configFile)) {
5298
- return import_fs_extra3.default.readFileSync(configFile, "utf8").trim();
5276
+ if (import_fs_extra2.default.existsSync(configFile)) {
5277
+ return import_fs_extra2.default.readFileSync(configFile, "utf8").trim();
5299
5278
  }
5300
5279
  const deviceId = (0, import_uuid.v4)();
5301
- import_fs_extra3.default.writeFileSync(configFile, deviceId);
5280
+ import_fs_extra2.default.writeFileSync(configFile, deviceId);
5302
5281
  return deviceId;
5303
5282
  }
5304
5283
  function getUid() {
5305
- const auth = getAuthConfig2();
5284
+ const auth = getAuthConfig();
5306
5285
  if (auth == null ? void 0 : auth.address) {
5307
5286
  return auth.address;
5308
5287
  }
@@ -5310,15 +5289,15 @@ function getUid() {
5310
5289
  }
5311
5290
 
5312
5291
  // bin/utils/uploadToIpfsSplit.ts
5313
- var import_fs_extra5 = __toESM(require("fs-extra"));
5314
- var import_path6 = __toESM(require("path"));
5292
+ var import_fs_extra4 = __toESM(require("fs-extra"));
5293
+ var import_path5 = __toESM(require("path"));
5315
5294
  var import_form_data2 = __toESM(require("form-data"));
5316
5295
  var import_ora = __toESM(require("ora"));
5317
5296
  var crypto2 = __toESM(require("crypto"));
5318
5297
 
5319
5298
  // bin/utils/uploadLimits.ts
5320
5299
  var import_fs = __toESM(require("fs"));
5321
- var import_path4 = __toESM(require("path"));
5300
+ var import_path3 = __toESM(require("path"));
5322
5301
  var FILE_SIZE_LIMIT = parseInt("500", 10) * 1024 * 1024;
5323
5302
  var DIRECTORY_SIZE_LIMIT = parseInt("500", 10) * 1024 * 1024;
5324
5303
  function checkFileSizeLimit(filePath) {
@@ -5341,7 +5320,7 @@ function calculateDirectorySize(directoryPath) {
5341
5320
  let totalSize = 0;
5342
5321
  const files = import_fs.default.readdirSync(directoryPath);
5343
5322
  for (const file of files) {
5344
- const filePath = import_path4.default.join(directoryPath, file);
5323
+ const filePath = import_path3.default.join(directoryPath, file);
5345
5324
  const stats = import_fs.default.statSync(filePath);
5346
5325
  if (stats.isFile()) {
5347
5326
  totalSize += stats.size;
@@ -5359,30 +5338,30 @@ function formatSize(bytes) {
5359
5338
  }
5360
5339
 
5361
5340
  // bin/utils/history.ts
5362
- var import_fs_extra4 = __toESM(require("fs-extra"));
5363
- var import_path5 = __toESM(require("path"));
5364
- var import_os4 = __toESM(require("os"));
5341
+ var import_fs_extra3 = __toESM(require("fs-extra"));
5342
+ var import_path4 = __toESM(require("path"));
5343
+ var import_os3 = __toESM(require("os"));
5365
5344
  var import_dayjs = __toESM(require("dayjs"));
5366
5345
  var import_chalk4 = __toESM(require("chalk"));
5367
- var HISTORY_DIR = import_path5.default.join(import_os4.default.homedir(), ".pinme");
5368
- var HISTORY_FILE = import_path5.default.join(HISTORY_DIR, "upload-history.json");
5346
+ var HISTORY_DIR = import_path4.default.join(import_os3.default.homedir(), ".pinme");
5347
+ var HISTORY_FILE = import_path4.default.join(HISTORY_DIR, "upload-history.json");
5369
5348
  var ensureHistoryDir = () => {
5370
- if (!import_fs_extra4.default.existsSync(HISTORY_DIR)) {
5371
- import_fs_extra4.default.mkdirSync(HISTORY_DIR, { recursive: true });
5349
+ if (!import_fs_extra3.default.existsSync(HISTORY_DIR)) {
5350
+ import_fs_extra3.default.mkdirSync(HISTORY_DIR, { recursive: true });
5372
5351
  }
5373
- if (!import_fs_extra4.default.existsSync(HISTORY_FILE)) {
5374
- import_fs_extra4.default.writeJsonSync(HISTORY_FILE, { uploads: [] });
5352
+ if (!import_fs_extra3.default.existsSync(HISTORY_FILE)) {
5353
+ import_fs_extra3.default.writeJsonSync(HISTORY_FILE, { uploads: [] });
5375
5354
  }
5376
5355
  };
5377
5356
  var saveUploadHistory = (uploadData) => {
5378
5357
  try {
5379
5358
  ensureHistoryDir();
5380
- const history = import_fs_extra4.default.readJsonSync(HISTORY_FILE);
5359
+ const history = import_fs_extra3.default.readJsonSync(HISTORY_FILE);
5381
5360
  const newRecord = {
5382
5361
  timestamp: Date.now(),
5383
5362
  date: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss"),
5384
5363
  path: uploadData.path,
5385
- filename: uploadData.filename || import_path5.default.basename(uploadData.path),
5364
+ filename: uploadData.filename || import_path4.default.basename(uploadData.path),
5386
5365
  contentHash: uploadData.contentHash,
5387
5366
  previewHash: uploadData.previewHash,
5388
5367
  size: uploadData.size,
@@ -5391,7 +5370,7 @@ var saveUploadHistory = (uploadData) => {
5391
5370
  shortUrl: (uploadData == null ? void 0 : uploadData.shortUrl) || null
5392
5371
  };
5393
5372
  history.uploads.unshift(newRecord);
5394
- import_fs_extra4.default.writeJsonSync(HISTORY_FILE, history, { spaces: 2 });
5373
+ import_fs_extra3.default.writeJsonSync(HISTORY_FILE, history, { spaces: 2 });
5395
5374
  return true;
5396
5375
  } catch (error) {
5397
5376
  console.error(import_chalk4.default.red(`Error saving upload history: ${error.message}`));
@@ -5401,7 +5380,7 @@ var saveUploadHistory = (uploadData) => {
5401
5380
  var getUploadHistory = (limit = 10) => {
5402
5381
  try {
5403
5382
  ensureHistoryDir();
5404
- const history = import_fs_extra4.default.readJsonSync(HISTORY_FILE);
5383
+ const history = import_fs_extra3.default.readJsonSync(HISTORY_FILE);
5405
5384
  return history.uploads.slice(0, limit);
5406
5385
  } catch (error) {
5407
5386
  console.error(import_chalk4.default.red(`Error reading upload history: ${error.message}`));
@@ -5441,7 +5420,7 @@ var displayUploadHistory = (limit = 10) => {
5441
5420
  var clearUploadHistory = () => {
5442
5421
  try {
5443
5422
  ensureHistoryDir();
5444
- import_fs_extra4.default.writeJsonSync(HISTORY_FILE, { uploads: [] });
5423
+ import_fs_extra3.default.writeJsonSync(HISTORY_FILE, { uploads: [] });
5445
5424
  console.log(import_chalk4.default.green("Upload history cleared successfully."));
5446
5425
  return true;
5447
5426
  } catch (error) {
@@ -5562,7 +5541,7 @@ var StepProgressBar = class {
5562
5541
  async function calculateMD5(filePath) {
5563
5542
  return new Promise((resolve, reject) => {
5564
5543
  const hash = crypto2.createHash("md5");
5565
- const stream4 = import_fs_extra5.default.createReadStream(filePath);
5544
+ const stream4 = import_fs_extra4.default.createReadStream(filePath);
5566
5545
  stream4.on("data", hash.update.bind(hash));
5567
5546
  stream4.on("end", () => resolve(hash.digest("hex")));
5568
5547
  stream4.on("error", reject);
@@ -5571,20 +5550,20 @@ async function calculateMD5(filePath) {
5571
5550
  async function compressDirectory(sourcePath) {
5572
5551
  return new Promise((resolve, reject) => {
5573
5552
  const tempDir = require("os").tmpdir();
5574
- if (!import_fs_extra5.default.existsSync(tempDir)) {
5575
- import_fs_extra5.default.mkdirSync(tempDir, { recursive: true });
5553
+ if (!import_fs_extra4.default.existsSync(tempDir)) {
5554
+ import_fs_extra4.default.mkdirSync(tempDir, { recursive: true });
5576
5555
  }
5577
- const outputPath = import_path6.default.join(
5556
+ const outputPath = import_path5.default.join(
5578
5557
  tempDir,
5579
- `pinme_${import_path6.default.basename(sourcePath)}_${Date.now()}.zip`
5558
+ `pinme_${import_path5.default.basename(sourcePath)}_${Date.now()}.zip`
5580
5559
  );
5581
- const output = import_fs_extra5.default.createWriteStream(outputPath);
5560
+ const output = import_fs_extra4.default.createWriteStream(outputPath);
5582
5561
  const zlib2 = require("zlib");
5583
5562
  const gzip = zlib2.createGzip({ level: 9 });
5584
5563
  output.on("close", () => resolve(outputPath));
5585
5564
  gzip.on("error", reject);
5586
5565
  gzip.pipe(output);
5587
- const stats = import_fs_extra5.default.statSync(sourcePath);
5566
+ const stats = import_fs_extra4.default.statSync(sourcePath);
5588
5567
  if (stats.isDirectory()) {
5589
5568
  const archive = require("archiver");
5590
5569
  const archiveStream = archive("zip", { zlib: { level: 9 } });
@@ -5593,14 +5572,14 @@ async function compressDirectory(sourcePath) {
5593
5572
  archiveStream.directory(sourcePath, false);
5594
5573
  archiveStream.finalize();
5595
5574
  } else {
5596
- const fileStream = import_fs_extra5.default.createReadStream(sourcePath);
5575
+ const fileStream = import_fs_extra4.default.createReadStream(sourcePath);
5597
5576
  fileStream.pipe(gzip);
5598
5577
  }
5599
5578
  });
5600
5579
  }
5601
5580
  async function initChunkSession(filePath, deviceId, isDirectory = false) {
5602
- const stats = import_fs_extra5.default.statSync(filePath);
5603
- const fileName = import_path6.default.basename(filePath);
5581
+ const stats = import_fs_extra4.default.statSync(filePath);
5582
+ const fileName = import_path5.default.basename(filePath);
5604
5583
  const fileSize = stats.size;
5605
5584
  const md5 = await calculateMD5(filePath);
5606
5585
  try {
@@ -5701,7 +5680,7 @@ async function delayWithAbortCheck(delay, signal) {
5701
5680
  });
5702
5681
  }
5703
5682
  async function uploadFileChunks(filePath, sessionId, totalChunks, chunkSize, deviceId, progressBar) {
5704
- const fileData = import_fs_extra5.default.readFileSync(filePath);
5683
+ const fileData = import_fs_extra4.default.readFileSync(filePath);
5705
5684
  const abortController = new AbortController();
5706
5685
  let completedCount = 0;
5707
5686
  let hasFatalError = false;
@@ -5866,7 +5845,7 @@ async function uploadDirectoryInChunks(directoryPath, deviceId, options = {}) {
5866
5845
  )} (size: ${formatSize(sizeCheck.size)})`
5867
5846
  );
5868
5847
  }
5869
- const progressBar = new StepProgressBar(import_path6.default.basename(directoryPath), true);
5848
+ const progressBar = new StepProgressBar(import_path5.default.basename(directoryPath), true);
5870
5849
  try {
5871
5850
  progressBar.startStep(0, "Preparing compression");
5872
5851
  const compressedPath = await compressDirectory(directoryPath);
@@ -5895,12 +5874,12 @@ async function uploadDirectoryInChunks(directoryPath, deviceId, options = {}) {
5895
5874
  const result = await monitorChunkProgress(traceId, deviceId, options, progressBar);
5896
5875
  progressBar.completeStep();
5897
5876
  try {
5898
- import_fs_extra5.default.unlinkSync(compressedPath);
5877
+ import_fs_extra4.default.unlinkSync(compressedPath);
5899
5878
  } catch (error) {
5900
5879
  }
5901
5880
  const uploadData = {
5902
5881
  path: directoryPath,
5903
- filename: import_path6.default.basename(directoryPath),
5882
+ filename: import_path5.default.basename(directoryPath),
5904
5883
  contentHash: (result == null ? void 0 : result.hash) || "unknown",
5905
5884
  size: sizeCheck.size,
5906
5885
  fileCount: 0,
@@ -5927,7 +5906,7 @@ async function uploadFileInChunks(filePath, deviceId, options = {}) {
5927
5906
  )} (size: ${formatSize(sizeCheck.size)})`
5928
5907
  );
5929
5908
  }
5930
- const fileName = import_path6.default.basename(filePath);
5909
+ const fileName = import_path5.default.basename(filePath);
5931
5910
  const progressBar = new StepProgressBar(fileName, false);
5932
5911
  try {
5933
5912
  progressBar.startStep(0, "Initializing session");
@@ -5975,13 +5954,14 @@ async function uploadFileInChunks(filePath, deviceId, options = {}) {
5975
5954
  }
5976
5955
  }
5977
5956
  async function uploadToIpfsSplit_default(filePath, options = {}) {
5978
- const deviceId = getUid();
5979
- if (!deviceId) {
5980
- throw new Error("Device ID not found");
5957
+ var _a2;
5958
+ const uid = ((_a2 = options.uid) == null ? void 0 : _a2.trim()) || getUid();
5959
+ if (!uid) {
5960
+ throw new Error("Upload uid not found");
5981
5961
  }
5982
5962
  try {
5983
- const isDirectory = import_fs_extra5.default.statSync(filePath).isDirectory();
5984
- const result = isDirectory ? await uploadDirectoryInChunks(filePath, deviceId, options) : await uploadFileInChunks(filePath, deviceId, options);
5963
+ const isDirectory = import_fs_extra4.default.statSync(filePath).isDirectory();
5964
+ const result = isDirectory ? await uploadDirectoryInChunks(filePath, uid, options) : await uploadFileInChunks(filePath, uid, options);
5985
5965
  if (result == null ? void 0 : result.hash) {
5986
5966
  return {
5987
5967
  contentHash: result.hash,
@@ -6020,9 +6000,9 @@ function formatShortUrl(shortUrl) {
6020
6000
  }
6021
6001
  return `https://${normalized}.pinit.eth.limo`;
6022
6002
  }
6023
- function resolveUploadUrls(contentHash, shortUrl) {
6024
- const uid = getUid();
6025
- const encryptedCID = encryptHash(contentHash, APP_CONFIG.secretKey, uid);
6003
+ function resolveUploadUrls(contentHash, shortUrl, uid) {
6004
+ const resolvedUid = (uid == null ? void 0 : uid.trim()) || getUid();
6005
+ const encryptedCID = encryptHash(contentHash, APP_CONFIG.secretKey, resolvedUid);
6026
6006
  const managementUrl = `${APP_CONFIG.ipfsPreviewUrl}${encryptedCID}`;
6027
6007
  const publicUrl = formatShortUrl(shortUrl) || managementUrl;
6028
6008
  return {
@@ -6033,12 +6013,13 @@ function resolveUploadUrls(contentHash, shortUrl) {
6033
6013
  async function uploadPath(targetPath, options = {}) {
6034
6014
  const result = await uploadToIpfsSplit_default(targetPath, {
6035
6015
  importAsCar: options.importAsCar,
6036
- projectName: options.projectName
6016
+ projectName: options.projectName,
6017
+ uid: options.uid
6037
6018
  });
6038
6019
  if (!(result == null ? void 0 : result.contentHash)) {
6039
6020
  throw new Error("Upload failed: no content hash returned");
6040
6021
  }
6041
- const urls = resolveUploadUrls(result.contentHash, result.shortUrl);
6022
+ const urls = resolveUploadUrls(result.contentHash, result.shortUrl, options.uid);
6042
6023
  return {
6043
6024
  contentHash: result.contentHash,
6044
6025
  shortUrl: result.shortUrl,
@@ -6051,7 +6032,7 @@ async function uploadPath(targetPath, options = {}) {
6051
6032
  checkNodeVersion();
6052
6033
  function checkPathSync(inputPath) {
6053
6034
  try {
6054
- const absolutePath = import_path7.default.resolve(inputPath);
6035
+ const absolutePath = import_path6.default.resolve(inputPath);
6055
6036
  if (import_fs2.default.existsSync(absolutePath)) {
6056
6037
  return absolutePath;
6057
6038
  }
@@ -6143,13 +6124,10 @@ var upload_default = async (options) => {
6143
6124
  const domainArg = getDomainFromArgs();
6144
6125
  const dnsArg = getDnsFromArgs();
6145
6126
  const needsAuth = !!domainArg || dnsArg;
6146
- let authConfig = null;
6147
- if (needsAuth) {
6148
- authConfig = getAuthConfig();
6149
- if (!authConfig) {
6150
- console.log(import_chalk5.default.red("Please login first. Run: pinme set-appkey <AppKey>"));
6151
- return;
6152
- }
6127
+ const authConfig = getAuthConfig();
6128
+ if (needsAuth && !authConfig) {
6129
+ console.log(import_chalk5.default.red("Please login first. Run: pinme set-appkey <AppKey>"));
6130
+ return;
6153
6131
  }
6154
6132
  const argPath = process.argv[3];
6155
6133
  if (argPath && !argPath.startsWith("-")) {
@@ -6204,7 +6182,8 @@ var upload_default = async (options) => {
6204
6182
  let result;
6205
6183
  try {
6206
6184
  result = await uploadPath(absolutePath, {
6207
- projectName: APP_CONFIG.pinmeProjectName
6185
+ projectName: APP_CONFIG.pinmeProjectName,
6186
+ uid: authConfig == null ? void 0 : authConfig.address
6208
6187
  });
6209
6188
  } catch (error) {
6210
6189
  console.error(import_chalk5.default.red(`Upload error: ${error.message}`));
@@ -6297,7 +6276,8 @@ var upload_default = async (options) => {
6297
6276
  let result;
6298
6277
  try {
6299
6278
  result = await uploadPath(absolutePath, {
6300
- projectName: APP_CONFIG.pinmeProjectName
6279
+ projectName: APP_CONFIG.pinmeProjectName,
6280
+ uid: authConfig == null ? void 0 : authConfig.address
6301
6281
  });
6302
6282
  } catch (error) {
6303
6283
  console.error(import_chalk5.default.red(`Upload error: ${error.message}`));
@@ -6338,7 +6318,7 @@ var upload_default = async (options) => {
6338
6318
  };
6339
6319
 
6340
6320
  // bin/importCar.ts
6341
- var import_path8 = __toESM(require("path"));
6321
+ var import_path7 = __toESM(require("path"));
6342
6322
  var import_chalk6 = __toESM(require("chalk"));
6343
6323
  var import_inquirer2 = __toESM(require("inquirer"));
6344
6324
  var import_figlet2 = __toESM(require("figlet"));
@@ -6361,7 +6341,7 @@ function encryptHash2(contentHash, key, uid) {
6361
6341
  }
6362
6342
  function checkPathSync2(inputPath) {
6363
6343
  try {
6364
- const absolutePath = import_path8.default.resolve(inputPath);
6344
+ const absolutePath = import_path7.default.resolve(inputPath);
6365
6345
  if (import_fs3.default.existsSync(absolutePath)) {
6366
6346
  return absolutePath;
6367
6347
  }
@@ -6415,7 +6395,10 @@ var importCar_default = async (options) => {
6415
6395
  }
6416
6396
  console.log(import_chalk6.default.blue(`importing ${absolutePath} to ipfs as CAR...`));
6417
6397
  try {
6418
- const result = await uploadPath(absolutePath, { importAsCar: true });
6398
+ const result = await uploadPath(absolutePath, {
6399
+ importAsCar: true,
6400
+ uid: getUid2()
6401
+ });
6419
6402
  if (result) {
6420
6403
  const uid = getUid2();
6421
6404
  const encryptedCID = encryptHash2(result.contentHash, APP_CONFIG.secretKey, uid);
@@ -6466,7 +6449,10 @@ var importCar_default = async (options) => {
6466
6449
  }
6467
6450
  console.log(import_chalk6.default.blue(`importing ${absolutePath} to ipfs as CAR...`));
6468
6451
  try {
6469
- const result = await uploadPath(absolutePath, { importAsCar: true });
6452
+ const result = await uploadPath(absolutePath, {
6453
+ importAsCar: true,
6454
+ uid: getUid2()
6455
+ });
6470
6456
  if (result) {
6471
6457
  const uid = getUid2();
6472
6458
  const encryptedCID = encryptHash2(result.contentHash, APP_CONFIG.secretKey, uid);
@@ -6501,7 +6487,7 @@ var importCar_default = async (options) => {
6501
6487
  };
6502
6488
 
6503
6489
  // bin/exportCar.ts
6504
- var import_path9 = __toESM(require("path"));
6490
+ var import_path8 = __toESM(require("path"));
6505
6491
  var import_chalk7 = __toESM(require("chalk"));
6506
6492
  var import_inquirer3 = __toESM(require("inquirer"));
6507
6493
  var import_figlet3 = __toESM(require("figlet"));
@@ -6641,14 +6627,14 @@ var exportCar_default = async () => {
6641
6627
  ]);
6642
6628
  outputDir = answer.output.trim() || currentDir;
6643
6629
  }
6644
- outputDir = import_path9.default.resolve(outputDir);
6630
+ outputDir = import_path8.default.resolve(outputDir);
6645
6631
  if (!import_fs4.default.existsSync(outputDir)) {
6646
6632
  import_fs4.default.mkdirSync(outputDir, { recursive: true });
6647
6633
  } else if (!import_fs4.default.statSync(outputDir).isDirectory()) {
6648
6634
  console.log(import_chalk7.default.red(`Error: ${outputDir} exists but is not a directory.`));
6649
6635
  return;
6650
6636
  }
6651
- const finalOutputPath = import_path9.default.join(outputDir, `${cid}.car`);
6637
+ const finalOutputPath = import_path8.default.join(outputDir, `${cid}.car`);
6652
6638
  if (import_fs4.default.existsSync(finalOutputPath)) {
6653
6639
  const answer = await import_inquirer3.default.prompt([
6654
6640
  {
@@ -7077,7 +7063,7 @@ async function walletBalanceCmd() {
7077
7063
  }
7078
7064
 
7079
7065
  // bin/bind.ts
7080
- var import_path10 = __toESM(require("path"));
7066
+ var import_path9 = __toESM(require("path"));
7081
7067
  var import_chalk15 = __toESM(require("chalk"));
7082
7068
  var import_inquirer7 = __toESM(require("inquirer"));
7083
7069
  function parseArgs() {
@@ -7176,9 +7162,9 @@ async function bindCmd() {
7176
7162
  }
7177
7163
  throw e;
7178
7164
  }
7179
- const absolutePath = import_path10.default.resolve(targetPath);
7165
+ const absolutePath = import_path9.default.resolve(targetPath);
7180
7166
  console.log(import_chalk15.default.blue(`Uploading: ${absolutePath}`));
7181
- const up = await uploadPath(absolutePath);
7167
+ const up = await uploadPath(absolutePath, { uid: authConfig.address });
7182
7168
  if (!(up == null ? void 0 : up.contentHash)) {
7183
7169
  console.log(import_chalk15.default.red("Upload failed, binding aborted."));
7184
7170
  return;
@@ -7253,19 +7239,19 @@ Login failed: ${(e == null ? void 0 : e.message) || e}`));
7253
7239
 
7254
7240
  // bin/create.ts
7255
7241
  var import_chalk19 = __toESM(require("chalk"));
7256
- var import_fs_extra7 = __toESM(require("fs-extra"));
7257
- var import_path12 = __toESM(require("path"));
7242
+ var import_fs_extra6 = __toESM(require("fs-extra"));
7243
+ var import_path11 = __toESM(require("path"));
7258
7244
  var import_inquirer8 = __toESM(require("inquirer"));
7259
7245
  var import_child_process3 = require("child_process");
7260
7246
 
7261
7247
  // bin/utils/installProjectDependencies.ts
7262
- var import_fs_extra6 = __toESM(require("fs-extra"));
7263
- var import_os5 = __toESM(require("os"));
7264
- var import_path11 = __toESM(require("path"));
7248
+ var import_fs_extra5 = __toESM(require("fs-extra"));
7249
+ var import_os4 = __toESM(require("os"));
7250
+ var import_path10 = __toESM(require("path"));
7265
7251
  var import_chalk17 = __toESM(require("chalk"));
7266
7252
  var import_child_process2 = require("child_process");
7267
7253
  function makeTempCacheDir() {
7268
- return import_fs_extra6.default.mkdtempSync(import_path11.default.join(import_os5.default.tmpdir(), "pinme-npm-cache-"));
7254
+ return import_fs_extra5.default.mkdtempSync(import_path10.default.join(import_os4.default.tmpdir(), "pinme-npm-cache-"));
7269
7255
  }
7270
7256
  function runInstall(cwd, cacheDir) {
7271
7257
  (0, import_child_process2.execFileSync)("npm", ["install", "--cache", cacheDir, "--no-audit", "--no-fund"], {
@@ -7292,7 +7278,7 @@ function installProjectDependencies(cwd) {
7292
7278
  } catch (error) {
7293
7279
  lastError = error;
7294
7280
  } finally {
7295
- import_fs_extra6.default.removeSync(cacheDir);
7281
+ import_fs_extra5.default.removeSync(cacheDir);
7296
7282
  }
7297
7283
  }
7298
7284
  throw lastError;
@@ -7475,7 +7461,7 @@ ${configExport}
7475
7461
  `;
7476
7462
  }
7477
7463
  function resolveExtractedTemplateDir(extractDir) {
7478
- const entries = import_fs_extra7.default.readdirSync(extractDir, { withFileTypes: true });
7464
+ const entries = import_fs_extra6.default.readdirSync(extractDir, { withFileTypes: true });
7479
7465
  const templateDir = entries.find((entry) => entry.isDirectory() && entry.name.startsWith(`${TEMPLATE_REPO_NAME}-`));
7480
7466
  if (!templateDir) {
7481
7467
  throw createConfigError("Downloaded template archive structure is invalid.", [
@@ -7483,10 +7469,10 @@ function resolveExtractedTemplateDir(extractDir) {
7483
7469
  `Template branch: ${TEMPLATE_BRANCH}`
7484
7470
  ]);
7485
7471
  }
7486
- return import_path12.default.join(extractDir, templateDir.name);
7472
+ return import_path11.default.join(extractDir, templateDir.name);
7487
7473
  }
7488
7474
  function updateFrontendUrlInConfig(configPath, frontendUrl) {
7489
- let config = import_fs_extra7.default.readFileSync(configPath, "utf-8");
7475
+ let config = import_fs_extra6.default.readFileSync(configPath, "utf-8");
7490
7476
  if (config.includes("frontend_url")) {
7491
7477
  config = config.replace(
7492
7478
  /frontend_url\s*=\s*"[^"]*"/,
@@ -7499,7 +7485,7 @@ function updateFrontendUrlInConfig(configPath, frontendUrl) {
7499
7485
  `
7500
7486
  );
7501
7487
  }
7502
- import_fs_extra7.default.writeFileSync(configPath, config);
7488
+ import_fs_extra6.default.writeFileSync(configPath, config);
7503
7489
  }
7504
7490
  async function createCmd(options) {
7505
7491
  var _a2, _b;
@@ -7529,8 +7515,8 @@ async function createCmd(options) {
7529
7515
  ]);
7530
7516
  projectName = answers.projectName;
7531
7517
  }
7532
- const targetDir = import_path12.default.join(PROJECT_DIR, projectName);
7533
- if (import_fs_extra7.default.existsSync(targetDir) && !options.force) {
7518
+ const targetDir = import_path11.default.join(PROJECT_DIR, projectName);
7519
+ if (import_fs_extra6.default.existsSync(targetDir) && !options.force) {
7534
7520
  console.log(import_chalk19.default.yellow(`
7535
7521
  Directory "${projectName}" already exists.`));
7536
7522
  const answers = await import_inquirer8.default.prompt([
@@ -7545,7 +7531,7 @@ Directory "${projectName}" already exists.`));
7545
7531
  console.log(import_chalk19.default.gray("Cancelled."));
7546
7532
  process.exit(0);
7547
7533
  }
7548
- import_fs_extra7.default.removeSync(targetDir);
7534
+ import_fs_extra6.default.removeSync(targetDir);
7549
7535
  }
7550
7536
  console.log(import_chalk19.default.blue("\n1. Creating worker and database..."));
7551
7537
  const apiUrl = getPinmeApiUrl("/create_worker");
@@ -7580,8 +7566,8 @@ Directory "${projectName}" already exists.`));
7580
7566
  ]);
7581
7567
  }
7582
7568
  console.log(import_chalk19.default.blue("\n2. Downloading template from repository..."));
7583
- const zipPath = import_path12.default.join(PROJECT_DIR, "template.zip");
7584
- const extractDir = import_path12.default.join(PROJECT_DIR, `.pinme-template-${Date.now()}`);
7569
+ const zipPath = import_path11.default.join(PROJECT_DIR, "template.zip");
7570
+ const extractDir = import_path11.default.join(PROJECT_DIR, `.pinme-template-${Date.now()}`);
7585
7571
  const templateZipUrl = getTemplateZipUrl(TEMPLATE_BRANCH);
7586
7572
  let downloadSuccess = false;
7587
7573
  console.log(import_chalk19.default.gray(` Template branch: ${TEMPLATE_BRANCH}`));
@@ -7591,14 +7577,14 @@ Directory "${projectName}" already exists.`));
7591
7577
  (0, import_child_process3.execSync)(`curl -L --retry 3 --retry-delay 2 -o "${zipPath}" "${templateZipUrl}"`, {
7592
7578
  stdio: "inherit"
7593
7579
  });
7594
- if (!import_fs_extra7.default.existsSync(zipPath) || import_fs_extra7.default.statSync(zipPath).size < 100) {
7580
+ if (!import_fs_extra6.default.existsSync(zipPath) || import_fs_extra6.default.statSync(zipPath).size < 100) {
7595
7581
  throw new Error("Downloaded file is too small or empty");
7596
7582
  }
7597
7583
  downloadSuccess = true;
7598
7584
  } catch (downloadError) {
7599
7585
  console.log(import_chalk19.default.yellow(` Attempt ${attempt} failed: ${downloadError.message}`));
7600
- if (import_fs_extra7.default.existsSync(zipPath)) {
7601
- import_fs_extra7.default.removeSync(zipPath);
7586
+ if (import_fs_extra6.default.existsSync(zipPath)) {
7587
+ import_fs_extra6.default.removeSync(zipPath);
7602
7588
  }
7603
7589
  if (attempt === 3) {
7604
7590
  throw new Error(`Failed to download template after 3 attempts: ${downloadError.message}`);
@@ -7606,32 +7592,32 @@ Directory "${projectName}" already exists.`));
7606
7592
  }
7607
7593
  }
7608
7594
  try {
7609
- import_fs_extra7.default.ensureDirSync(extractDir);
7595
+ import_fs_extra6.default.ensureDirSync(extractDir);
7610
7596
  (0, import_child_process3.execSync)(`unzip -o "${zipPath}" -d "${extractDir}"`, {
7611
7597
  stdio: "inherit"
7612
7598
  });
7613
7599
  const subDir = resolveExtractedTemplateDir(extractDir);
7614
- import_fs_extra7.default.copySync(subDir, targetDir);
7615
- import_fs_extra7.default.removeSync(zipPath);
7616
- import_fs_extra7.default.removeSync(extractDir);
7617
- const nodeModulesPath = import_path12.default.join(targetDir, "node_modules");
7618
- const packageLockPath = import_path12.default.join(targetDir, "package-lock.json");
7619
- if (import_fs_extra7.default.existsSync(nodeModulesPath)) {
7600
+ import_fs_extra6.default.copySync(subDir, targetDir);
7601
+ import_fs_extra6.default.removeSync(zipPath);
7602
+ import_fs_extra6.default.removeSync(extractDir);
7603
+ const nodeModulesPath = import_path11.default.join(targetDir, "node_modules");
7604
+ const packageLockPath = import_path11.default.join(targetDir, "package-lock.json");
7605
+ if (import_fs_extra6.default.existsSync(nodeModulesPath)) {
7620
7606
  console.log(import_chalk19.default.gray(" Removing existing node_modules..."));
7621
- import_fs_extra7.default.removeSync(nodeModulesPath);
7607
+ import_fs_extra6.default.removeSync(nodeModulesPath);
7622
7608
  }
7623
- if (import_fs_extra7.default.existsSync(packageLockPath)) {
7609
+ if (import_fs_extra6.default.existsSync(packageLockPath)) {
7624
7610
  console.log(import_chalk19.default.gray(" Removing existing package-lock.json..."));
7625
- import_fs_extra7.default.removeSync(packageLockPath);
7626
- }
7627
- const frontendNodeModules = import_path12.default.join(targetDir, "frontend", "node_modules");
7628
- const backendNodeModules = import_path12.default.join(targetDir, "backend", "node_modules");
7629
- const frontendPackageLock = import_path12.default.join(targetDir, "frontend", "package-lock.json");
7630
- const backendPackageLock = import_path12.default.join(targetDir, "backend", "package-lock.json");
7631
- if (import_fs_extra7.default.existsSync(frontendNodeModules)) import_fs_extra7.default.removeSync(frontendNodeModules);
7632
- if (import_fs_extra7.default.existsSync(backendNodeModules)) import_fs_extra7.default.removeSync(backendNodeModules);
7633
- if (import_fs_extra7.default.existsSync(frontendPackageLock)) import_fs_extra7.default.removeSync(frontendPackageLock);
7634
- if (import_fs_extra7.default.existsSync(backendPackageLock)) import_fs_extra7.default.removeSync(backendPackageLock);
7611
+ import_fs_extra6.default.removeSync(packageLockPath);
7612
+ }
7613
+ const frontendNodeModules = import_path11.default.join(targetDir, "frontend", "node_modules");
7614
+ const backendNodeModules = import_path11.default.join(targetDir, "backend", "node_modules");
7615
+ const frontendPackageLock = import_path11.default.join(targetDir, "frontend", "package-lock.json");
7616
+ const backendPackageLock = import_path11.default.join(targetDir, "backend", "package-lock.json");
7617
+ if (import_fs_extra6.default.existsSync(frontendNodeModules)) import_fs_extra6.default.removeSync(frontendNodeModules);
7618
+ if (import_fs_extra6.default.existsSync(backendNodeModules)) import_fs_extra6.default.removeSync(backendNodeModules);
7619
+ if (import_fs_extra6.default.existsSync(frontendPackageLock)) import_fs_extra6.default.removeSync(frontendPackageLock);
7620
+ if (import_fs_extra6.default.existsSync(backendPackageLock)) import_fs_extra6.default.removeSync(backendPackageLock);
7635
7621
  console.log(import_chalk19.default.green(` Template downloaded to: ${targetDir}`));
7636
7622
  } catch (error) {
7637
7623
  throw createCommandError("template extraction", `unzip -o "${zipPath}" -d "${PROJECT_DIR}"`, error, [
@@ -7639,58 +7625,58 @@ Directory "${projectName}" already exists.`));
7639
7625
  ]);
7640
7626
  }
7641
7627
  console.log(import_chalk19.default.blue("\n3. Updating configuration..."));
7642
- const configPath = import_path12.default.join(targetDir, "pinme.toml");
7643
- const config = import_fs_extra7.default.readFileSync(configPath, "utf-8");
7628
+ const configPath = import_path11.default.join(targetDir, "pinme.toml");
7629
+ const config = import_fs_extra6.default.readFileSync(configPath, "utf-8");
7644
7630
  let updatedConfig = config.replace(
7645
7631
  /project_name = ".*"/,
7646
7632
  `project_name = "${workerData.project_name}"`
7647
7633
  );
7648
- import_fs_extra7.default.writeFileSync(configPath, updatedConfig);
7634
+ import_fs_extra6.default.writeFileSync(configPath, updatedConfig);
7649
7635
  console.log(import_chalk19.default.green(` Updated pinme.toml`));
7650
7636
  console.log(import_chalk19.default.gray(` metadata: ${workerData.metadata}`));
7651
- const backendDir = import_path12.default.join(targetDir, "backend");
7652
- if (import_fs_extra7.default.existsSync(backendDir) && workerData.metadata) {
7637
+ const backendDir = import_path11.default.join(targetDir, "backend");
7638
+ if (import_fs_extra6.default.existsSync(backendDir) && workerData.metadata) {
7653
7639
  const metadataContent = typeof workerData.metadata === "string" ? workerData.metadata : JSON.stringify(workerData.metadata, null, 2);
7654
- import_fs_extra7.default.writeFileSync(
7655
- import_path12.default.join(backendDir, "metadata.json"),
7640
+ import_fs_extra6.default.writeFileSync(
7641
+ import_path11.default.join(backendDir, "metadata.json"),
7656
7642
  metadataContent
7657
7643
  );
7658
7644
  console.log(import_chalk19.default.green(` Saved metadata.json`));
7659
7645
  }
7660
- const wranglerPath = import_path12.default.join(backendDir, "wrangler.toml");
7661
- if (import_fs_extra7.default.existsSync(wranglerPath) && workerData.api_key) {
7662
- let wranglerContent = import_fs_extra7.default.readFileSync(wranglerPath, "utf-8");
7646
+ const wranglerPath = import_path11.default.join(backendDir, "wrangler.toml");
7647
+ if (import_fs_extra6.default.existsSync(wranglerPath) && workerData.api_key) {
7648
+ let wranglerContent = import_fs_extra6.default.readFileSync(wranglerPath, "utf-8");
7663
7649
  wranglerContent = wranglerContent.replace(
7664
7650
  /^name = ".*"$/m,
7665
7651
  `name = "${workerData.project_name}"`
7666
7652
  );
7667
- import_fs_extra7.default.writeFileSync(wranglerPath, wranglerContent);
7653
+ import_fs_extra6.default.writeFileSync(wranglerPath, wranglerContent);
7668
7654
  console.log(import_chalk19.default.green(` Updated backend/wrangler.toml API_KEY`));
7669
7655
  }
7670
- const frontendConfigPath = import_path12.default.join(targetDir, "frontend", "src", "utils", "config.ts");
7656
+ const frontendConfigPath = import_path11.default.join(targetDir, "frontend", "src", "utils", "config.ts");
7671
7657
  if (workerData.public_client_config) {
7672
- const frontendConfigContent = import_fs_extra7.default.existsSync(frontendConfigPath) ? import_fs_extra7.default.readFileSync(frontendConfigPath, "utf-8") : "";
7673
- import_fs_extra7.default.ensureDirSync(import_path12.default.dirname(frontendConfigPath));
7674
- import_fs_extra7.default.writeFileSync(
7658
+ const frontendConfigContent = import_fs_extra6.default.existsSync(frontendConfigPath) ? import_fs_extra6.default.readFileSync(frontendConfigPath, "utf-8") : "";
7659
+ import_fs_extra6.default.ensureDirSync(import_path11.default.dirname(frontendConfigPath));
7660
+ import_fs_extra6.default.writeFileSync(
7675
7661
  frontendConfigPath,
7676
7662
  injectPublicClientConfigIntoFile(frontendConfigContent, workerData.public_client_config)
7677
7663
  );
7678
7664
  console.log(import_chalk19.default.green(` Updated frontend/src/utils/config.ts public_client_config`));
7679
7665
  }
7680
- const envExamplePath = import_path12.default.join(targetDir, "frontend", ".env.example");
7681
- const envPath = import_path12.default.join(targetDir, "frontend", ".env");
7682
- if (import_fs_extra7.default.existsSync(envExamplePath)) {
7683
- let envContent = import_fs_extra7.default.readFileSync(envExamplePath, "utf-8");
7666
+ const envExamplePath = import_path11.default.join(targetDir, "frontend", ".env.example");
7667
+ const envPath = import_path11.default.join(targetDir, "frontend", ".env");
7668
+ if (import_fs_extra6.default.existsSync(envExamplePath)) {
7669
+ let envContent = import_fs_extra6.default.readFileSync(envExamplePath, "utf-8");
7684
7670
  envContent = envContent.replace(/your-project/g, workerData.project_name);
7685
7671
  envContent = envContent.replace(
7686
7672
  /^VITE_API_URL=.*$/m,
7687
7673
  `VITE_API_URL=${workerData.api_domain}`
7688
7674
  );
7689
- import_fs_extra7.default.writeFileSync(envPath, envContent);
7675
+ import_fs_extra6.default.writeFileSync(envPath, envContent);
7690
7676
  console.log(import_chalk19.default.green(` Created frontend/.env file`));
7691
7677
  console.log(import_chalk19.default.gray(` VITE_API_URL: ${workerData.api_domain}`));
7692
7678
  }
7693
- let pinmeConfig = import_fs_extra7.default.readFileSync(configPath, "utf-8");
7679
+ let pinmeConfig = import_fs_extra6.default.readFileSync(configPath, "utf-8");
7694
7680
  if (pinmeConfig.includes("api_url")) {
7695
7681
  pinmeConfig = pinmeConfig.replace(
7696
7682
  /api_url\s*=\s*"[^"]*"/,
@@ -7707,7 +7693,7 @@ Directory "${projectName}" already exists.`));
7707
7693
  }
7708
7694
  pinmeConfig = newLines.join("\n");
7709
7695
  }
7710
- import_fs_extra7.default.writeFileSync(configPath, pinmeConfig);
7696
+ import_fs_extra6.default.writeFileSync(configPath, pinmeConfig);
7711
7697
  console.log(import_chalk19.default.green(` Updated pinme.toml with api_url`));
7712
7698
  console.log(import_chalk19.default.blue("\n4. Installing dependencies..."));
7713
7699
  try {
@@ -7763,26 +7749,26 @@ Directory "${projectName}" already exists.`));
7763
7749
  "Fix the build error shown above, then rerun `pinme create`."
7764
7750
  ]);
7765
7751
  }
7766
- const distWorkerDir = import_path12.default.join(targetDir, "dist-worker");
7767
- const workerJsPath = import_path12.default.join(distWorkerDir, "worker.js");
7768
- if (!import_fs_extra7.default.existsSync(distWorkerDir) || !import_fs_extra7.default.existsSync(workerJsPath)) {
7752
+ const distWorkerDir = import_path11.default.join(targetDir, "dist-worker");
7753
+ const workerJsPath = import_path11.default.join(distWorkerDir, "worker.js");
7754
+ if (!import_fs_extra6.default.existsSync(distWorkerDir) || !import_fs_extra6.default.existsSync(workerJsPath)) {
7769
7755
  throw createConfigError("Built worker output not found: `dist-worker/worker.js`.", [
7770
7756
  "Make sure `npm run build:worker` completed successfully."
7771
7757
  ]);
7772
7758
  }
7773
7759
  const modulePaths = [];
7774
- const files = import_fs_extra7.default.readdirSync(distWorkerDir);
7760
+ const files = import_fs_extra6.default.readdirSync(distWorkerDir);
7775
7761
  for (const file of files) {
7776
7762
  if (file.endsWith(".js") && file !== "worker.js") {
7777
- modulePaths.push(import_path12.default.join(distWorkerDir, file));
7763
+ modulePaths.push(import_path11.default.join(distWorkerDir, file));
7778
7764
  }
7779
7765
  }
7780
- const sqlDir = import_path12.default.join(targetDir, "db");
7766
+ const sqlDir = import_path11.default.join(targetDir, "db");
7781
7767
  const sqlFiles = [];
7782
- if (import_fs_extra7.default.existsSync(sqlDir)) {
7783
- const sqlFileNames = import_fs_extra7.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
7768
+ if (import_fs_extra6.default.existsSync(sqlDir)) {
7769
+ const sqlFileNames = import_fs_extra6.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
7784
7770
  for (const filename of sqlFileNames) {
7785
- sqlFiles.push(import_path12.default.join(sqlDir, filename));
7771
+ sqlFiles.push(import_path11.default.join(sqlDir, filename));
7786
7772
  console.log(import_chalk19.default.gray(` Including SQL: ${filename}`));
7787
7773
  }
7788
7774
  }
@@ -7797,20 +7783,20 @@ Directory "${projectName}" already exists.`));
7797
7783
  formData.append("metadata", new Blob2([metadataContent], {
7798
7784
  type: "application/json"
7799
7785
  }), "metadata.json");
7800
- const workerCode = import_fs_extra7.default.readFileSync(workerJsPath, "utf-8");
7786
+ const workerCode = import_fs_extra6.default.readFileSync(workerJsPath, "utf-8");
7801
7787
  formData.append("worker.js", new Blob2([workerCode], {
7802
7788
  type: "application/javascript+module"
7803
7789
  }), "worker.js");
7804
7790
  for (const modulePath of modulePaths) {
7805
- const filename = import_path12.default.basename(modulePath);
7806
- const content = import_fs_extra7.default.readFileSync(modulePath, "utf-8");
7791
+ const filename = import_path11.default.basename(modulePath);
7792
+ const content = import_fs_extra6.default.readFileSync(modulePath, "utf-8");
7807
7793
  formData.append(filename, new Blob2([content], {
7808
7794
  type: "application/javascript+module"
7809
7795
  }), filename);
7810
7796
  }
7811
7797
  for (const sqlFile of sqlFiles) {
7812
- const filename = import_path12.default.basename(sqlFile);
7813
- const content = import_fs_extra7.default.readFileSync(sqlFile, "utf-8");
7798
+ const filename = import_path11.default.basename(sqlFile);
7799
+ const content = import_fs_extra6.default.readFileSync(sqlFile, "utf-8");
7814
7800
  formData.append("sql_file", new Blob2([content], {
7815
7801
  type: "application/sql"
7816
7802
  }), filename);
@@ -7843,8 +7829,8 @@ Directory "${projectName}" already exists.`));
7843
7829
  ]);
7844
7830
  }
7845
7831
  console.log(import_chalk19.default.blue("\n7. Building frontend..."));
7846
- const frontendDir = import_path12.default.join(targetDir, "frontend");
7847
- if (import_fs_extra7.default.existsSync(frontendDir)) {
7832
+ const frontendDir = import_path11.default.join(targetDir, "frontend");
7833
+ if (import_fs_extra6.default.existsSync(frontendDir)) {
7848
7834
  try {
7849
7835
  (0, import_child_process3.execSync)("npm run build:frontend", {
7850
7836
  cwd: targetDir,
@@ -7858,12 +7844,13 @@ Directory "${projectName}" already exists.`));
7858
7844
  }
7859
7845
  console.log(import_chalk19.default.blue(" Uploading to IPFS..."));
7860
7846
  try {
7861
- const uploadResult = await uploadPath(import_path12.default.join(frontendDir, "dist"), {
7862
- projectName: workerData.project_name
7847
+ const uploadResult = await uploadPath(import_path11.default.join(frontendDir, "dist"), {
7848
+ projectName: workerData.project_name,
7849
+ uid: headers["token-address"]
7863
7850
  });
7864
7851
  console.log(import_chalk19.default.green(` Frontend uploaded to IPFS: ${uploadResult.publicUrl}`));
7865
7852
  updateFrontendUrlInConfig(
7866
- import_path12.default.join(targetDir, "pinme.toml"),
7853
+ import_path11.default.join(targetDir, "pinme.toml"),
7867
7854
  uploadResult.publicUrl
7868
7855
  );
7869
7856
  console.log(import_chalk19.default.green(" Updated pinme.toml with frontend URL"));
@@ -7889,31 +7876,31 @@ Next steps:`));
7889
7876
 
7890
7877
  // bin/save.ts
7891
7878
  var import_chalk20 = __toESM(require("chalk"));
7892
- var import_fs_extra8 = __toESM(require("fs-extra"));
7893
- var import_path13 = __toESM(require("path"));
7879
+ var import_fs_extra7 = __toESM(require("fs-extra"));
7880
+ var import_path12 = __toESM(require("path"));
7894
7881
  var import_child_process4 = require("child_process");
7895
7882
  var PROJECT_DIR2 = process.cwd();
7896
7883
  function loadConfig() {
7897
- const configPath = import_path13.default.join(PROJECT_DIR2, "pinme.toml");
7898
- if (!import_fs_extra8.default.existsSync(configPath)) {
7884
+ const configPath = import_path12.default.join(PROJECT_DIR2, "pinme.toml");
7885
+ if (!import_fs_extra7.default.existsSync(configPath)) {
7899
7886
  throw createConfigError("`pinme.toml` not found in the current directory.", [
7900
7887
  "Run this command from the Pinme project root.",
7901
7888
  "If the project has not been initialized yet, create or restore `pinme.toml` first."
7902
7889
  ]);
7903
7890
  }
7904
- const configContent = import_fs_extra8.default.readFileSync(configPath, "utf-8");
7891
+ const configContent = import_fs_extra7.default.readFileSync(configPath, "utf-8");
7905
7892
  const projectNameMatch = configContent.match(/project_name\s*=\s*"([^"]+)"/);
7906
7893
  return {
7907
7894
  project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
7908
7895
  };
7909
7896
  }
7910
7897
  function getMetadata() {
7911
- const metadataPath = import_path13.default.join(PROJECT_DIR2, "backend", "metadata.json");
7912
- if (!import_fs_extra8.default.existsSync(metadataPath)) {
7898
+ const metadataPath = import_path12.default.join(PROJECT_DIR2, "backend", "metadata.json");
7899
+ if (!import_fs_extra7.default.existsSync(metadataPath)) {
7913
7900
  console.log(import_chalk20.default.yellow(" Warning: metadata.json not found, using empty metadata"));
7914
7901
  return {};
7915
7902
  }
7916
- return import_fs_extra8.default.readJsonSync(metadataPath);
7903
+ return import_fs_extra7.default.readJsonSync(metadataPath);
7917
7904
  }
7918
7905
  function buildWorker() {
7919
7906
  console.log(import_chalk20.default.blue("Building worker..."));
@@ -7974,34 +7961,34 @@ function installDependencies() {
7974
7961
  }
7975
7962
  }
7976
7963
  function getBuiltWorker() {
7977
- const distWorkerDir = import_path13.default.join(PROJECT_DIR2, "dist-worker");
7978
- if (!import_fs_extra8.default.existsSync(distWorkerDir)) {
7964
+ const distWorkerDir = import_path12.default.join(PROJECT_DIR2, "dist-worker");
7965
+ if (!import_fs_extra7.default.existsSync(distWorkerDir)) {
7979
7966
  throw createConfigError("Built worker output not found: `dist-worker/`.", [
7980
7967
  "Make sure `npm run build:worker` completed successfully."
7981
7968
  ]);
7982
7969
  }
7983
- const workerJsPath = import_path13.default.join(distWorkerDir, "worker.js");
7984
- if (!import_fs_extra8.default.existsSync(workerJsPath)) {
7970
+ const workerJsPath = import_path12.default.join(distWorkerDir, "worker.js");
7971
+ if (!import_fs_extra7.default.existsSync(workerJsPath)) {
7985
7972
  throw createConfigError("Built worker entry file not found: `dist-worker/worker.js`.", [
7986
7973
  "Check the worker build output and bundler config."
7987
7974
  ]);
7988
7975
  }
7989
7976
  const modulePaths = [];
7990
- const files = import_fs_extra8.default.readdirSync(distWorkerDir);
7977
+ const files = import_fs_extra7.default.readdirSync(distWorkerDir);
7991
7978
  for (const file of files) {
7992
7979
  if (file.endsWith(".js") && file !== "worker.js") {
7993
- modulePaths.push(import_path13.default.join(distWorkerDir, file));
7980
+ modulePaths.push(import_path12.default.join(distWorkerDir, file));
7994
7981
  }
7995
7982
  }
7996
7983
  return { workerJsPath, modulePaths };
7997
7984
  }
7998
7985
  function getSqlFiles() {
7999
- const sqlDir = import_path13.default.join(PROJECT_DIR2, "db");
8000
- if (!import_fs_extra8.default.existsSync(sqlDir)) {
7986
+ const sqlDir = import_path12.default.join(PROJECT_DIR2, "db");
7987
+ if (!import_fs_extra7.default.existsSync(sqlDir)) {
8001
7988
  return [];
8002
7989
  }
8003
- const files = import_fs_extra8.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
8004
- return files.map((f) => import_path13.default.join(sqlDir, f));
7990
+ const files = import_fs_extra7.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
7991
+ return files.map((f) => import_path12.default.join(sqlDir, f));
8005
7992
  }
8006
7993
  async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, projectName) {
8007
7994
  var _a2, _b;
@@ -8021,20 +8008,20 @@ async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, project
8021
8008
  formData.append("metadata", new Blob2([JSON.stringify(metadata)], {
8022
8009
  type: "application/json"
8023
8010
  }), "metadata.json");
8024
- const workerCode = import_fs_extra8.default.readFileSync(workerJsPath, "utf-8");
8011
+ const workerCode = import_fs_extra7.default.readFileSync(workerJsPath, "utf-8");
8025
8012
  formData.append("worker.js", new Blob2([workerCode], {
8026
8013
  type: "application/javascript+module"
8027
8014
  }), "worker.js");
8028
8015
  for (const modulePath of modulePaths) {
8029
- const filename = import_path13.default.basename(modulePath);
8030
- const content = import_fs_extra8.default.readFileSync(modulePath, "utf-8");
8016
+ const filename = import_path12.default.basename(modulePath);
8017
+ const content = import_fs_extra7.default.readFileSync(modulePath, "utf-8");
8031
8018
  formData.append(filename, new Blob2([content], {
8032
8019
  type: "application/javascript+module"
8033
8020
  }), filename);
8034
8021
  }
8035
8022
  for (const sqlFile of sqlFiles) {
8036
- const filename = import_path13.default.basename(sqlFile);
8037
- const content = import_fs_extra8.default.readFileSync(sqlFile, "utf-8");
8023
+ const filename = import_path12.default.basename(sqlFile);
8024
+ const content = import_fs_extra7.default.readFileSync(sqlFile, "utf-8");
8038
8025
  formData.append("sql_file", new Blob2([content], {
8039
8026
  type: "application/sql"
8040
8027
  }), filename);
@@ -8084,7 +8071,7 @@ function buildFrontend() {
8084
8071
  }
8085
8072
  }
8086
8073
  function updateFrontendUrlInConfig2(configPath, frontendUrl) {
8087
- let config = import_fs_extra8.default.readFileSync(configPath, "utf-8");
8074
+ let config = import_fs_extra7.default.readFileSync(configPath, "utf-8");
8088
8075
  if (config.includes("frontend_url")) {
8089
8076
  config = config.replace(
8090
8077
  /frontend_url\s*=\s*"[^"]*"/,
@@ -8097,16 +8084,18 @@ function updateFrontendUrlInConfig2(configPath, frontendUrl) {
8097
8084
  `
8098
8085
  );
8099
8086
  }
8100
- import_fs_extra8.default.writeFileSync(configPath, config);
8087
+ import_fs_extra7.default.writeFileSync(configPath, config);
8101
8088
  }
8102
8089
  async function deployFrontend(projectName) {
8103
8090
  console.log(import_chalk20.default.blue("Deploying frontend to IPFS..."));
8104
8091
  try {
8105
- const uploadResult = await uploadPath(import_path13.default.join(PROJECT_DIR2, "frontend", "dist"), {
8106
- projectName
8092
+ const headers = getAuthHeaders();
8093
+ const uploadResult = await uploadPath(import_path12.default.join(PROJECT_DIR2, "frontend", "dist"), {
8094
+ projectName,
8095
+ uid: headers["token-address"]
8107
8096
  });
8108
8097
  console.log(import_chalk20.default.green(`Frontend deployed to IPFS: ${uploadResult.publicUrl}`));
8109
- updateFrontendUrlInConfig2(import_path13.default.join(PROJECT_DIR2, "pinme.toml"), uploadResult.publicUrl);
8098
+ updateFrontendUrlInConfig2(import_path12.default.join(PROJECT_DIR2, "pinme.toml"), uploadResult.publicUrl);
8110
8099
  console.log(import_chalk20.default.green("Updated pinme.toml with frontend URL"));
8111
8100
  } catch (error) {
8112
8101
  throw createCommandError("frontend deploy", "upload frontend/dist", error, [
@@ -8122,11 +8111,11 @@ async function saveCmd(options) {
8122
8111
  "Run `pinme login` and retry."
8123
8112
  ]);
8124
8113
  }
8125
- const projectDir = options.projectName || options.name ? import_path13.default.join(PROJECT_DIR2, options.projectName || options.name) : PROJECT_DIR2;
8126
- const tokenFileSrc = import_path13.default.join(PROJECT_DIR2, ".token.json");
8127
- const tokenFileDst = import_path13.default.join(projectDir, ".token.json");
8128
- if (import_fs_extra8.default.existsSync(tokenFileSrc) && !import_fs_extra8.default.existsSync(tokenFileDst)) {
8129
- import_fs_extra8.default.copySync(tokenFileSrc, tokenFileDst);
8114
+ const projectDir = options.projectName || options.name ? import_path12.default.join(PROJECT_DIR2, options.projectName || options.name) : PROJECT_DIR2;
8115
+ const tokenFileSrc = import_path12.default.join(PROJECT_DIR2, ".token.json");
8116
+ const tokenFileDst = import_path12.default.join(projectDir, ".token.json");
8117
+ if (import_fs_extra7.default.existsSync(tokenFileSrc) && !import_fs_extra7.default.existsSync(tokenFileDst)) {
8118
+ import_fs_extra7.default.copySync(tokenFileSrc, tokenFileDst);
8130
8119
  }
8131
8120
  console.log(import_chalk20.default.blue("Deploying to platform...\n"));
8132
8121
  console.log(import_chalk20.default.gray(`Project dir: ${PROJECT_DIR2}`));
@@ -8163,36 +8152,36 @@ async function saveCmd(options) {
8163
8152
 
8164
8153
  // bin/updateDb.ts
8165
8154
  var import_chalk21 = __toESM(require("chalk"));
8166
- var import_fs_extra9 = __toESM(require("fs-extra"));
8167
- var import_path14 = __toESM(require("path"));
8155
+ var import_fs_extra8 = __toESM(require("fs-extra"));
8156
+ var import_path13 = __toESM(require("path"));
8168
8157
  var PROJECT_DIR3 = process.cwd();
8169
8158
  function loadConfig2() {
8170
- const configPath = import_path14.default.join(PROJECT_DIR3, "pinme.toml");
8171
- if (!import_fs_extra9.default.existsSync(configPath)) {
8159
+ const configPath = import_path13.default.join(PROJECT_DIR3, "pinme.toml");
8160
+ if (!import_fs_extra8.default.existsSync(configPath)) {
8172
8161
  throw createConfigError("`pinme.toml` not found in the current directory.", [
8173
8162
  "Run this command from the Pinme project root."
8174
8163
  ]);
8175
8164
  }
8176
- const configContent = import_fs_extra9.default.readFileSync(configPath, "utf-8");
8165
+ const configContent = import_fs_extra8.default.readFileSync(configPath, "utf-8");
8177
8166
  const projectNameMatch = configContent.match(/project_name\s*=\s*"([^"]+)"/);
8178
8167
  return {
8179
8168
  project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
8180
8169
  };
8181
8170
  }
8182
8171
  function getSqlFiles2() {
8183
- const sqlDir = import_path14.default.join(PROJECT_DIR3, "db");
8184
- if (!import_fs_extra9.default.existsSync(sqlDir)) {
8172
+ const sqlDir = import_path13.default.join(PROJECT_DIR3, "db");
8173
+ if (!import_fs_extra8.default.existsSync(sqlDir)) {
8185
8174
  throw createConfigError("SQL directory not found: `db/`.", [
8186
8175
  "Create a `db/` directory and add at least one `.sql` migration file."
8187
8176
  ]);
8188
8177
  }
8189
- const files = import_fs_extra9.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
8178
+ const files = import_fs_extra8.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
8190
8179
  if (files.length === 0) {
8191
8180
  throw createConfigError("No `.sql` files were found in `db/`.", [
8192
8181
  "Add one or more migration files before running `pinme update-db`."
8193
8182
  ]);
8194
8183
  }
8195
- return files.map((f) => import_path14.default.join(sqlDir, f));
8184
+ return files.map((f) => import_path13.default.join(sqlDir, f));
8196
8185
  }
8197
8186
  async function updateDb(sqlFiles, projectName) {
8198
8187
  console.log(import_chalk21.default.blue("Importing SQL files to database..."));
@@ -8207,8 +8196,8 @@ async function updateDb(sqlFiles, projectName) {
8207
8196
  const formData = new FormData4();
8208
8197
  let totalSize = 0;
8209
8198
  for (const sqlFile of sqlFiles) {
8210
- const filename = import_path14.default.basename(sqlFile);
8211
- const content = import_fs_extra9.default.readFileSync(sqlFile);
8199
+ const filename = import_path13.default.basename(sqlFile);
8200
+ const content = import_fs_extra8.default.readFileSync(sqlFile);
8212
8201
  totalSize += content.length;
8213
8202
  if (totalSize > 10 * 1024 * 1024) {
8214
8203
  throw createConfigError("Total SQL payload exceeds the 10MB platform limit.", [
@@ -8263,11 +8252,11 @@ async function updateDbCmd(options) {
8263
8252
  "Run `pinme login` and retry."
8264
8253
  ]);
8265
8254
  }
8266
- const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path14.default.join(PROJECT_DIR3, options.projectName || options.name) : PROJECT_DIR3;
8267
- const tokenFileSrc = import_path14.default.join(PROJECT_DIR3, ".token.json");
8268
- const tokenFileDst = import_path14.default.join(projectDir, ".token.json");
8269
- if (import_fs_extra9.default.existsSync(tokenFileSrc) && !import_fs_extra9.default.existsSync(tokenFileDst)) {
8270
- import_fs_extra9.default.copySync(tokenFileSrc, tokenFileDst);
8255
+ const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path13.default.join(PROJECT_DIR3, options.projectName || options.name) : PROJECT_DIR3;
8256
+ const tokenFileSrc = import_path13.default.join(PROJECT_DIR3, ".token.json");
8257
+ const tokenFileDst = import_path13.default.join(projectDir, ".token.json");
8258
+ if (import_fs_extra8.default.existsSync(tokenFileSrc) && !import_fs_extra8.default.existsSync(tokenFileDst)) {
8259
+ import_fs_extra8.default.copySync(tokenFileSrc, tokenFileDst);
8271
8260
  }
8272
8261
  console.log(import_chalk21.default.blue("Importing SQL to database...\n"));
8273
8262
  console.log(import_chalk21.default.gray(`Project dir: ${PROJECT_DIR3}`));
@@ -8292,31 +8281,31 @@ async function updateDbCmd(options) {
8292
8281
 
8293
8282
  // bin/updateWorker.ts
8294
8283
  var import_chalk22 = __toESM(require("chalk"));
8295
- var import_fs_extra10 = __toESM(require("fs-extra"));
8296
- var import_path15 = __toESM(require("path"));
8284
+ var import_fs_extra9 = __toESM(require("fs-extra"));
8285
+ var import_path14 = __toESM(require("path"));
8297
8286
  var import_child_process5 = require("child_process");
8298
8287
  var PROJECT_DIR4 = process.cwd();
8299
8288
  function loadConfig3() {
8300
- const configPath = import_path15.default.join(PROJECT_DIR4, "pinme.toml");
8301
- if (!import_fs_extra10.default.existsSync(configPath)) {
8289
+ const configPath = import_path14.default.join(PROJECT_DIR4, "pinme.toml");
8290
+ if (!import_fs_extra9.default.existsSync(configPath)) {
8302
8291
  throw createConfigError("`pinme.toml` not found in the current directory.", [
8303
8292
  "Run this command from the Pinme project root."
8304
8293
  ]);
8305
8294
  }
8306
- const configContent = import_fs_extra10.default.readFileSync(configPath, "utf-8");
8295
+ const configContent = import_fs_extra9.default.readFileSync(configPath, "utf-8");
8307
8296
  const projectNameMatch = configContent.match(/project_name\s*=\s*"([^"]+)"/);
8308
8297
  return {
8309
8298
  project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
8310
8299
  };
8311
8300
  }
8312
8301
  function getMetadata2() {
8313
- const metadataPath = import_path15.default.join(PROJECT_DIR4, "backend", "metadata.json");
8314
- if (!import_fs_extra10.default.existsSync(metadataPath)) {
8302
+ const metadataPath = import_path14.default.join(PROJECT_DIR4, "backend", "metadata.json");
8303
+ if (!import_fs_extra9.default.existsSync(metadataPath)) {
8315
8304
  throw createConfigError("`backend/metadata.json` not found.", [
8316
8305
  "Create `backend/metadata.json` or restore it from the project template."
8317
8306
  ]);
8318
8307
  }
8319
- return import_fs_extra10.default.readJsonSync(metadataPath);
8308
+ return import_fs_extra9.default.readJsonSync(metadataPath);
8320
8309
  }
8321
8310
  function buildWorker2() {
8322
8311
  console.log(import_chalk22.default.blue("Building worker..."));
@@ -8333,23 +8322,23 @@ function buildWorker2() {
8333
8322
  }
8334
8323
  }
8335
8324
  function getBuiltWorker2() {
8336
- const distWorkerDir = import_path15.default.join(PROJECT_DIR4, "dist-worker");
8337
- if (!import_fs_extra10.default.existsSync(distWorkerDir)) {
8325
+ const distWorkerDir = import_path14.default.join(PROJECT_DIR4, "dist-worker");
8326
+ if (!import_fs_extra9.default.existsSync(distWorkerDir)) {
8338
8327
  throw createConfigError("Built worker output not found: `dist-worker/`.", [
8339
8328
  "Make sure `npm run build:worker` completed successfully."
8340
8329
  ]);
8341
8330
  }
8342
- const workerJsPath = import_path15.default.join(distWorkerDir, "worker.js");
8343
- if (!import_fs_extra10.default.existsSync(workerJsPath)) {
8331
+ const workerJsPath = import_path14.default.join(distWorkerDir, "worker.js");
8332
+ if (!import_fs_extra9.default.existsSync(workerJsPath)) {
8344
8333
  throw createConfigError("Built worker entry file not found: `dist-worker/worker.js`.", [
8345
8334
  "Check the worker build output and bundler config."
8346
8335
  ]);
8347
8336
  }
8348
8337
  const modulePaths = [];
8349
- const files = import_fs_extra10.default.readdirSync(distWorkerDir);
8338
+ const files = import_fs_extra9.default.readdirSync(distWorkerDir);
8350
8339
  for (const file of files) {
8351
8340
  if (file.endsWith(".js") && file !== "worker.js") {
8352
- modulePaths.push(import_path15.default.join(distWorkerDir, file));
8341
+ modulePaths.push(import_path14.default.join(distWorkerDir, file));
8353
8342
  }
8354
8343
  }
8355
8344
  return { workerJsPath, modulePaths };
@@ -8370,13 +8359,13 @@ async function updateWorker(workerJsPath, modulePaths, metadata, projectName) {
8370
8359
  formData.append("metadata", new Blob2([JSON.stringify(metadata)], {
8371
8360
  type: "application/json"
8372
8361
  }), "metadata.json");
8373
- const workerCode = import_fs_extra10.default.readFileSync(workerJsPath, "utf-8");
8362
+ const workerCode = import_fs_extra9.default.readFileSync(workerJsPath, "utf-8");
8374
8363
  formData.append("worker.js", new Blob2([workerCode], {
8375
8364
  type: "application/javascript+module"
8376
8365
  }), "worker.js");
8377
8366
  for (const modulePath of modulePaths) {
8378
- const filename = import_path15.default.basename(modulePath);
8379
- const content = import_fs_extra10.default.readFileSync(modulePath, "utf-8");
8367
+ const filename = import_path14.default.basename(modulePath);
8368
+ const content = import_fs_extra9.default.readFileSync(modulePath, "utf-8");
8380
8369
  formData.append(filename, new Blob2([content], {
8381
8370
  type: "application/javascript+module"
8382
8371
  }), filename);
@@ -8438,11 +8427,11 @@ async function updateWorkerCmd(options) {
8438
8427
  "Run `pinme login` and retry."
8439
8428
  ]);
8440
8429
  }
8441
- const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path15.default.join(PROJECT_DIR4, options.projectName || options.name) : PROJECT_DIR4;
8442
- const tokenFileSrc = import_path15.default.join(PROJECT_DIR4, ".token.json");
8443
- const tokenFileDst = import_path15.default.join(projectDir, ".token.json");
8444
- if (import_fs_extra10.default.existsSync(tokenFileSrc) && !import_fs_extra10.default.existsSync(tokenFileDst)) {
8445
- import_fs_extra10.default.copySync(tokenFileSrc, tokenFileDst);
8430
+ const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path14.default.join(PROJECT_DIR4, options.projectName || options.name) : PROJECT_DIR4;
8431
+ const tokenFileSrc = import_path14.default.join(PROJECT_DIR4, ".token.json");
8432
+ const tokenFileDst = import_path14.default.join(projectDir, ".token.json");
8433
+ if (import_fs_extra9.default.existsSync(tokenFileSrc) && !import_fs_extra9.default.existsSync(tokenFileDst)) {
8434
+ import_fs_extra9.default.copySync(tokenFileSrc, tokenFileDst);
8446
8435
  }
8447
8436
  console.log(import_chalk22.default.blue("Updating worker...\n"));
8448
8437
  console.log(import_chalk22.default.gray(`Project dir: ${PROJECT_DIR4}`));
@@ -8472,18 +8461,18 @@ async function updateWorkerCmd(options) {
8472
8461
 
8473
8462
  // bin/updateWeb.ts
8474
8463
  var import_chalk23 = __toESM(require("chalk"));
8475
- var import_fs_extra11 = __toESM(require("fs-extra"));
8476
- var import_path16 = __toESM(require("path"));
8464
+ var import_fs_extra10 = __toESM(require("fs-extra"));
8465
+ var import_path15 = __toESM(require("path"));
8477
8466
  var import_child_process6 = require("child_process");
8478
8467
  var PROJECT_DIR5 = process.cwd();
8479
8468
  function loadConfig4() {
8480
- const configPath = import_path16.default.join(PROJECT_DIR5, "pinme.toml");
8481
- if (!import_fs_extra11.default.existsSync(configPath)) {
8469
+ const configPath = import_path15.default.join(PROJECT_DIR5, "pinme.toml");
8470
+ if (!import_fs_extra10.default.existsSync(configPath)) {
8482
8471
  throw createConfigError("`pinme.toml` not found in the current directory.", [
8483
8472
  "Run this command from the Pinme project root."
8484
8473
  ]);
8485
8474
  }
8486
- const configContent = import_fs_extra11.default.readFileSync(configPath, "utf-8");
8475
+ const configContent = import_fs_extra10.default.readFileSync(configPath, "utf-8");
8487
8476
  const projectNameMatch = configContent.match(/project_name\s*=\s*"([^"]+)"/);
8488
8477
  return {
8489
8478
  project_name: (projectNameMatch == null ? void 0 : projectNameMatch[1]) || ""
@@ -8506,8 +8495,10 @@ function buildFrontend2() {
8506
8495
  async function deployFrontend2(projectName) {
8507
8496
  console.log(import_chalk23.default.blue("Deploying frontend to IPFS..."));
8508
8497
  try {
8509
- const uploadResult = await uploadPath(import_path16.default.join(PROJECT_DIR5, "frontend", "dist"), {
8510
- projectName
8498
+ const headers = getAuthHeaders();
8499
+ const uploadResult = await uploadPath(import_path15.default.join(PROJECT_DIR5, "frontend", "dist"), {
8500
+ projectName,
8501
+ uid: headers["token-address"]
8511
8502
  });
8512
8503
  console.log(import_chalk23.default.green(`Frontend deployed to IPFS: ${uploadResult.publicUrl}`));
8513
8504
  } catch (error) {
@@ -8524,11 +8515,11 @@ async function updateWebCmd(options) {
8524
8515
  "Run `pinme login` and retry."
8525
8516
  ]);
8526
8517
  }
8527
- const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path16.default.join(PROJECT_DIR5, options.projectName || options.name) : PROJECT_DIR5;
8528
- const tokenFileSrc = import_path16.default.join(PROJECT_DIR5, ".token.json");
8529
- const tokenFileDst = import_path16.default.join(projectDir, ".token.json");
8530
- if (import_fs_extra11.default.existsSync(tokenFileSrc) && !import_fs_extra11.default.existsSync(tokenFileDst)) {
8531
- import_fs_extra11.default.copySync(tokenFileSrc, tokenFileDst);
8518
+ const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path15.default.join(PROJECT_DIR5, options.projectName || options.name) : PROJECT_DIR5;
8519
+ const tokenFileSrc = import_path15.default.join(PROJECT_DIR5, ".token.json");
8520
+ const tokenFileDst = import_path15.default.join(projectDir, ".token.json");
8521
+ if (import_fs_extra10.default.existsSync(tokenFileSrc) && !import_fs_extra10.default.existsSync(tokenFileDst)) {
8522
+ import_fs_extra10.default.copySync(tokenFileSrc, tokenFileDst);
8532
8523
  }
8533
8524
  console.log(import_chalk23.default.blue("Updating web (frontend)...\n"));
8534
8525
  console.log(import_chalk23.default.gray(`Project dir: ${PROJECT_DIR5}`));
@@ -8554,14 +8545,14 @@ async function updateWebCmd(options) {
8554
8545
  // bin/delete.ts
8555
8546
  var import_chalk24 = __toESM(require("chalk"));
8556
8547
  var import_inquirer9 = __toESM(require("inquirer"));
8557
- var import_fs_extra12 = __toESM(require("fs-extra"));
8558
- var import_path17 = __toESM(require("path"));
8548
+ var import_fs_extra11 = __toESM(require("fs-extra"));
8549
+ var import_path16 = __toESM(require("path"));
8559
8550
  function getProjectName() {
8560
- const configPath = import_path17.default.join(process.cwd(), "pinme.toml");
8561
- if (!import_fs_extra12.default.existsSync(configPath)) {
8551
+ const configPath = import_path16.default.join(process.cwd(), "pinme.toml");
8552
+ if (!import_fs_extra11.default.existsSync(configPath)) {
8562
8553
  return null;
8563
8554
  }
8564
- const config = import_fs_extra12.default.readFileSync(configPath, "utf-8");
8555
+ const config = import_fs_extra11.default.readFileSync(configPath, "utf-8");
8565
8556
  const match = config.match(/project_name\s*=\s*"([^"]+)"/);
8566
8557
  return (match == null ? void 0 : match[1]) || null;
8567
8558
  }