pinme 1.1.6-alpha.1 → 1.1.6-alpha.3

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 +25 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1523,7 +1523,7 @@ var import_chalk9 = __toESM(require("chalk"));
1523
1523
  var import_figlet3 = __toESM(require("figlet"));
1524
1524
 
1525
1525
  // package.json
1526
- var version = "1.1.6-alpha.1";
1526
+ var version = "1.1.6-alpha.3";
1527
1527
 
1528
1528
  // bin/upload.ts
1529
1529
  var import_path6 = __toESM(require("path"));
@@ -5106,7 +5106,7 @@ function getAuthConfig() {
5106
5106
  function getAuthHeaders() {
5107
5107
  const conf = getAuthConfig();
5108
5108
  if (!conf) {
5109
- throw new Error("Auth not set. Run: pinme set-token <address-token>");
5109
+ throw new Error("Auth not set. Run: pinme set-appkey <AppKey>");
5110
5110
  }
5111
5111
  return {
5112
5112
  "token-address": conf.address,
@@ -5188,17 +5188,18 @@ async function getMyDomains() {
5188
5188
  var URL2 = "https://pinme.eth.limo/#/preview/";
5189
5189
  var secretKey = "pinme-secret-key";
5190
5190
  checkNodeVersion();
5191
- function encryptHash(hash, key) {
5191
+ function encryptHash(contentHash, key, uid) {
5192
5192
  try {
5193
5193
  if (!key) {
5194
5194
  throw new Error("Secret key not found");
5195
5195
  }
5196
- const encrypted = import_crypto_js.default.RC4.encrypt(hash, key).toString();
5196
+ const combined = uid ? `${contentHash}-${uid}` : contentHash;
5197
+ const encrypted = import_crypto_js.default.RC4.encrypt(combined, key).toString();
5197
5198
  const urlSafe = encrypted.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
5198
5199
  return urlSafe;
5199
5200
  } catch (error) {
5200
5201
  console.error(`Encryption error: ${error.message}`);
5201
- return hash;
5202
+ return contentHash;
5202
5203
  }
5203
5204
  }
5204
5205
  function checkPathSync(inputPath) {
@@ -5252,7 +5253,7 @@ var upload_default = async (options) => {
5252
5253
  try {
5253
5254
  const result = await uploadToIpfsSplit_default(absolutePath);
5254
5255
  if (result) {
5255
- const encryptedCID = encryptHash(result.contentHash, secretKey);
5256
+ const encryptedCID = encryptHash(result.contentHash, secretKey, result.shortUrl);
5256
5257
  console.log(
5257
5258
  import_chalk4.default.cyan(
5258
5259
  import_figlet.default.textSync("Successful", { horizontalLayout: "full" })
@@ -5302,7 +5303,7 @@ var upload_default = async (options) => {
5302
5303
  try {
5303
5304
  const result = await uploadToIpfsSplit_default(absolutePath);
5304
5305
  if (result) {
5305
- const encryptedCID = encryptHash(result.contentHash, secretKey);
5306
+ const encryptedCID = encryptHash(result.contentHash, secretKey, result.shortUrl);
5306
5307
  console.log(
5307
5308
  import_chalk4.default.cyan(
5308
5309
  import_figlet.default.textSync("Successful", { horizontalLayout: "full" })
@@ -5534,28 +5535,28 @@ var remove_default = async (options) => {
5534
5535
  }
5535
5536
  };
5536
5537
 
5537
- // bin/set-token.ts
5538
+ // bin/set-appkey.ts
5538
5539
  var import_chalk7 = __toESM(require("chalk"));
5539
5540
  var import_inquirer3 = __toESM(require("inquirer"));
5540
- async function setTokenCmd() {
5541
+ async function setAppKeyCmd() {
5541
5542
  try {
5542
- const argCombined = process.argv[3];
5543
- let combined = argCombined;
5544
- if (!combined) {
5543
+ const argAppKey = process.argv[3];
5544
+ let appKey = argAppKey;
5545
+ if (!appKey) {
5545
5546
  const ans = await import_inquirer3.default.prompt([
5546
5547
  {
5547
5548
  type: "input",
5548
- name: "combined",
5549
- message: "Enter address-token (format: 0xabc...-<jwt>): "
5549
+ name: "appKey",
5550
+ message: "Enter AppKey: "
5550
5551
  }
5551
5552
  ]);
5552
- combined = ans.combined;
5553
+ appKey = ans.appKey;
5553
5554
  }
5554
- if (!combined) {
5555
- console.log(import_chalk7.default.red("Token not provided."));
5555
+ if (!appKey) {
5556
+ console.log(import_chalk7.default.red("AppKey not provided."));
5556
5557
  return;
5557
5558
  }
5558
- const saved = setAuthToken(combined);
5559
+ const saved = setAuthToken(appKey);
5559
5560
  console.log(import_chalk7.default.green(`Auth set for address: ${saved.address}`));
5560
5561
  const deviceId = getDeviceId();
5561
5562
  const ok = await bindAnonymousDevice(deviceId);
@@ -5565,7 +5566,7 @@ async function setTokenCmd() {
5565
5566
  console.log(import_chalk7.default.yellow("Anonymous history merge not confirmed. You may retry later."));
5566
5567
  }
5567
5568
  } catch (e) {
5568
- console.log(import_chalk7.default.red(`Failed to set token: ${(e == null ? void 0 : e.message) || e}`));
5569
+ console.log(import_chalk7.default.red(`Failed to set AppKey: ${(e == null ? void 0 : e.message) || e}`));
5569
5570
  }
5570
5571
  }
5571
5572
 
@@ -5613,8 +5614,9 @@ var program = new import_commander.Command();
5613
5614
  program.name("pinme").version(version).option("-v, --version", "output the current version");
5614
5615
  program.command("upload").description("upload a file or directory to IPFS. Supports --domain to bind after upload").option("-d, --domain <name>", "Pinme subdomain").action(() => upload_default());
5615
5616
  program.command("rm").description("remove a file from IPFS network").action(() => remove_default());
5616
- program.command("set-token").description("Set auth token: <address>-<jwt>, and auto-merge anonymous history").action(() => setTokenCmd());
5617
- program.command("my-domains").description("List domains owned by current account").action(() => myDomainsCmd());
5617
+ program.command("set-appkey").description("Set AppKey for authentication, and auto-merge anonymous history").action(() => setAppKeyCmd());
5618
+ program.command("my-domains").alias("domain").description("List domains owned by current account").action(() => myDomainsCmd());
5619
+ program.command("domain").description("Alias for 'my-domains' command").action(() => myDomainsCmd());
5618
5620
  program.command("list").description("show upload history").option("-l, --limit <number>", "limit the number of records to show", parseInt).option("-c, --clear", "clear all upload history").action((options) => {
5619
5621
  if (options.clear) {
5620
5622
  clearUploadHistory();
@@ -5639,8 +5641,9 @@ program.on("--help", () => {
5639
5641
  console.log(" $ pinme upload");
5640
5642
  console.log(" $ pinme upload <path> --domain <name>");
5641
5643
  console.log(" $ pinme rm <hash>");
5642
- console.log(" $ pinme set-token <address-token>");
5644
+ console.log(" $ pinme set-appkey <AppKey>");
5643
5645
  console.log(" $ pinme my-domains");
5646
+ console.log(" $ pinme domain");
5644
5647
  console.log(" $ pinme list -l 5");
5645
5648
  console.log(" $ pinme ls");
5646
5649
  console.log(" $ pinme help");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinme",
3
- "version": "1.1.6-alpha.1",
3
+ "version": "1.1.6-alpha.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },