upfilesh 0.1.0 → 0.2.1

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/README.md CHANGED
@@ -7,20 +7,31 @@ Upload any file from your terminal. Get a permanent URL instantly.
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- yarn global add upfile-cli
10
+ yarn global add upfilesh
11
11
  ```
12
12
 
13
13
  ## Setup
14
14
 
15
+ ### Self-signup (get an API key)
16
+
15
17
  ```bash
16
- upfile config set api-key YOUR_API_KEY
18
+ upfile signup --email your@email.com
17
19
  ```
18
20
 
19
- Get your API key at [upfile.sh](https://upfile.sh).
21
+ This creates an account and saves your API key to `~/.upfile/config.json`.
22
+
23
+ ### Existing API key
24
+
25
+ ```bash
26
+ upfile config set api-key YOUR_API_KEY
27
+ ```
20
28
 
21
29
  ## Usage
22
30
 
23
31
  ```bash
32
+ # Check storage status
33
+ upfile status
34
+
24
35
  # Public — permanent URL, anyone can access
25
36
  upfile screenshot.png
26
37
  # https://cdn.upfile.sh/xK9mZ.png
@@ -39,6 +50,16 @@ screencapture -x - | upfile
39
50
  cat file.txt | upfile --json
40
51
  ```
41
52
 
53
+ ## Upgrade
54
+
55
+ When you hit the 1GB storage limit, upgrade to Pro:
56
+
57
+ ```bash
58
+ upfile upgrade
59
+ ```
60
+
61
+ You'll receive an email with a checkout link.
62
+
42
63
  ## Options
43
64
 
44
65
  | Flag | Description |
@@ -76,3 +97,9 @@ Config stored at `~/.upfile/config.json`.
76
97
  | Var | Description |
77
98
  |-----|-------------|
78
99
  | `UPFILE_API_KEY` | API key (overrides config file) |
100
+
101
+ ## Self-hosting
102
+
103
+ Deploy your own upfile instance on Cloudflare Workers:
104
+
105
+ [github.com/upfilesh/worker](https://github.com/upfilesh/worker)
package/dist/index.js CHANGED
@@ -48,12 +48,38 @@ async function main() {
48
48
  console.log(`Storage: ${status.storage_used_gb}GB / ${status.storage_limit_gb}GB`);
49
49
  return;
50
50
  }
51
- // upfile upgrade
51
+ // upfile upgrade [--self-pay|--notify|--verify <session>]
52
52
  if (cmd === "upgrade") {
53
- const result = await (0, upload_js_1.getUpgradeUrl)();
53
+ const selfPay = hasFlag("self-pay");
54
+ const notify = hasFlag("notify");
55
+ const verifySession = flag("verify");
56
+ if (verifySession) {
57
+ // Verify payment completed
58
+ const result = await (0, upload_js_1.verifyUpgrade)(verifySession);
59
+ if (result.verified) {
60
+ console.log(`✓ ${result.message}`);
61
+ console.log(`Tier: ${result.tier}`);
62
+ }
63
+ else {
64
+ console.log(`⏳ ${result.message}`);
65
+ console.log(`Status: ${result.status}`);
66
+ }
67
+ return;
68
+ }
69
+ // Get checkout URL
70
+ const result = await (0, upload_js_1.getUpgradeUrl)(notify);
54
71
  if (result.checkout_url) {
55
- console.log(`Upgrade link: ${result.checkout_url}`);
56
- console.log(`Sent to: ${result.message}`);
72
+ console.log(`Checkout URL: ${result.checkout_url}`);
73
+ if (result.self_pay) {
74
+ console.log("\n👉 Self-pay mode:");
75
+ console.log(" 1. Open the URL above in your browser");
76
+ console.log(" 2. Fill in your payment details");
77
+ console.log(" 3. After payment, run:");
78
+ console.log(` upfile upgrade --verify ${result.checkout_id}`);
79
+ }
80
+ else if (notify) {
81
+ console.log(`\n📧 Owner notified: ${result.message}`);
82
+ }
57
83
  }
58
84
  else {
59
85
  console.log("Manual upgrade:");
@@ -133,7 +159,7 @@ async function main() {
133
159
  "Usage:",
134
160
  " upfile signup --email <email> [--owner-email <email>] create account",
135
161
  " upfile status check storage",
136
- " upfile upgrade get upgrade link",
162
+ " upfile upgrade [--self-pay|--notify|--verify <id>] get upgrade link",
137
163
  " upfile <file> upload file (public)",
138
164
  " upfile <file> --private private file",
139
165
  " upfile <file> --expiry <seconds> expiring URL",
package/dist/upload.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.signup = signup;
7
7
  exports.getStatus = getStatus;
8
8
  exports.getUpgradeUrl = getUpgradeUrl;
9
+ exports.verifyUpgrade = verifyUpgrade;
9
10
  exports.uploadFile = uploadFile;
10
11
  exports.uploadStdin = uploadStdin;
11
12
  exports.listFiles = listFiles;
@@ -18,13 +19,17 @@ const config_js_1 = require("./config.js");
18
19
  function getAuth() {
19
20
  const config = (0, config_js_1.loadConfig)();
20
21
  const apiKey = config.apiKey || process.env.UPFILE_API_KEY;
21
- const endpoint = config.endpoint || config_js_1.DEFAULT_ENDPOINT;
22
+ const endpoint = getEndpoint();
22
23
  if (!apiKey)
23
24
  throw new Error("No API key. Run: upfile signup --email your@email.com");
24
25
  return { apiKey, endpoint };
25
26
  }
27
+ function getEndpoint() {
28
+ const config = (0, config_js_1.loadConfig)();
29
+ return config.endpoint || config_js_1.DEFAULT_ENDPOINT;
30
+ }
26
31
  async function signup(email, ownerEmail) {
27
- const { endpoint } = getAuth();
32
+ const endpoint = getEndpoint();
28
33
  const res = await (0, node_fetch_1.default)(`${endpoint}/signup`, {
29
34
  method: "POST",
30
35
  headers: { "Content-Type": "application/json" },
@@ -44,15 +49,25 @@ async function getStatus() {
44
49
  const data = await res.json();
45
50
  return data;
46
51
  }
47
- async function getUpgradeUrl() {
52
+ async function getUpgradeUrl(notify = false) {
48
53
  const { apiKey, endpoint } = getAuth();
49
- const res = await (0, node_fetch_1.default)(`${endpoint}/upgrade`, {
54
+ const url = notify ? `${endpoint}/upgrade?notify=true` : `${endpoint}/upgrade`;
55
+ const res = await (0, node_fetch_1.default)(url, {
50
56
  headers: { Authorization: `Bearer ${apiKey}` },
51
57
  });
52
58
  if (!res.ok)
53
59
  throw new Error(`Upgrade check failed (${res.status}): ${await res.text()}`);
54
60
  return res.json();
55
61
  }
62
+ async function verifyUpgrade(sessionId) {
63
+ const { apiKey, endpoint } = getAuth();
64
+ const res = await (0, node_fetch_1.default)(`${endpoint}/upgrade/verify?session=${sessionId}`, {
65
+ headers: { Authorization: `Bearer ${apiKey}` },
66
+ });
67
+ if (!res.ok)
68
+ throw new Error(`Verify failed (${res.status}): ${await res.text()}`);
69
+ return res.json();
70
+ }
56
71
  async function uploadFile(filePath, opts) {
57
72
  const { apiKey, endpoint } = getAuth();
58
73
  const form = new form_data_1.default();
@@ -69,7 +84,10 @@ async function uploadFile(filePath, opts) {
69
84
  const err = await res.json().catch(async () => ({ error: await res.text() }));
70
85
  const errorObj = err;
71
86
  if (errorObj.error?.includes("Storage limit")) {
72
- throw new Error(`Storage limit reached (${errorObj.storage_used_gb}GB / ${errorObj.limit_gb}GB). ${errorObj.message}`);
87
+ throw new Error(`Storage limit reached (${errorObj.storage_used_gb}GB / ${errorObj.limit_gb}GB).\n` +
88
+ `Options:\n` +
89
+ ` • upfile upgrade --self-pay # Pay with your AgentCard\n` +
90
+ ` • upfile upgrade --notify # Ask owner to pay`);
73
91
  }
74
92
  throw new Error(`Upload failed (${res.status}): ${errorObj.error || await res.text()}`);
75
93
  }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "upfilesh",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Instant file uploads from the command line — upfile.sh",
5
5
  "bin": {
6
- "upfile": "./bin/upfile"
6
+ "upfile": "bin/upfile"
7
7
  },
8
8
  "main": "dist/index.js",
9
+ "packageManager": "yarn@1.22.22",
9
10
  "files": [
10
11
  "bin/",
11
12
  "dist/",
@@ -29,7 +30,7 @@
29
30
  "license": "MIT",
30
31
  "repository": {
31
32
  "type": "git",
32
- "url": "https://github.com/upfilesh/cli.git"
33
+ "url": "git+https://github.com/upfilesh/cli.git"
33
34
  },
34
35
  "bugs": {
35
36
  "url": "https://github.com/upfilesh/cli/issues"