tglfs 0.1.0

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 (81) hide show
  1. package/README.md +216 -0
  2. package/dist/auth.d.ts +58 -0
  3. package/dist/auth.js +187 -0
  4. package/dist/auth.js.map +1 -0
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +627 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/crypto.d.ts +8 -0
  9. package/dist/crypto.js +45 -0
  10. package/dist/crypto.js.map +1 -0
  11. package/dist/download.d.ts +26 -0
  12. package/dist/download.js +228 -0
  13. package/dist/download.js.map +1 -0
  14. package/dist/errors.d.ts +18 -0
  15. package/dist/errors.js +35 -0
  16. package/dist/errors.js.map +1 -0
  17. package/dist/file-ops.d.ts +71 -0
  18. package/dist/file-ops.js +234 -0
  19. package/dist/file-ops.js.map +1 -0
  20. package/dist/gramjs.d.ts +14 -0
  21. package/dist/gramjs.js +70 -0
  22. package/dist/gramjs.js.map +1 -0
  23. package/dist/interactive.d.ts +11 -0
  24. package/dist/interactive.js +81 -0
  25. package/dist/interactive.js.map +1 -0
  26. package/dist/json.d.ts +2 -0
  27. package/dist/json.js +4 -0
  28. package/dist/json.js.map +1 -0
  29. package/dist/progress.d.ts +16 -0
  30. package/dist/progress.js +62 -0
  31. package/dist/progress.js.map +1 -0
  32. package/dist/protocol.d.ts +5 -0
  33. package/dist/protocol.js +27 -0
  34. package/dist/protocol.js.map +1 -0
  35. package/dist/search.d.ts +23 -0
  36. package/dist/search.js +81 -0
  37. package/dist/search.js.map +1 -0
  38. package/dist/secrets.d.ts +12 -0
  39. package/dist/secrets.js +29 -0
  40. package/dist/secrets.js.map +1 -0
  41. package/dist/shared/archive.d.ts +9 -0
  42. package/dist/shared/archive.js +95 -0
  43. package/dist/shared/archive.js.map +1 -0
  44. package/dist/shared/constants.d.ts +5 -0
  45. package/dist/shared/constants.js +6 -0
  46. package/dist/shared/constants.js.map +1 -0
  47. package/dist/shared/file-cards.d.ts +31 -0
  48. package/dist/shared/file-cards.js +103 -0
  49. package/dist/shared/file-cards.js.map +1 -0
  50. package/dist/shared/telegram-files.d.ts +84 -0
  51. package/dist/shared/telegram-files.js +137 -0
  52. package/dist/shared/telegram-files.js.map +1 -0
  53. package/dist/shared/upload.d.ts +44 -0
  54. package/dist/shared/upload.js +181 -0
  55. package/dist/shared/upload.js.map +1 -0
  56. package/dist/store.d.ts +15 -0
  57. package/dist/store.js +97 -0
  58. package/dist/store.js.map +1 -0
  59. package/dist/types.d.ts +18 -0
  60. package/dist/types.js +2 -0
  61. package/dist/types.js.map +1 -0
  62. package/dist/ufid.d.ts +8 -0
  63. package/dist/ufid.js +65 -0
  64. package/dist/ufid.js.map +1 -0
  65. package/dist/upload.d.ts +19 -0
  66. package/dist/upload.js +101 -0
  67. package/dist/upload.js.map +1 -0
  68. package/man/tglfs-delete.1 +19 -0
  69. package/man/tglfs-download.1 +42 -0
  70. package/man/tglfs-inspect.1 +34 -0
  71. package/man/tglfs-login.1 +53 -0
  72. package/man/tglfs-logout.1 +17 -0
  73. package/man/tglfs-receive.1 +26 -0
  74. package/man/tglfs-rename.1 +8 -0
  75. package/man/tglfs-search.1 +37 -0
  76. package/man/tglfs-send.1 +22 -0
  77. package/man/tglfs-status.1 +12 -0
  78. package/man/tglfs-unsend.1 +37 -0
  79. package/man/tglfs-upload.1 +28 -0
  80. package/man/tglfs.1 +70 -0
  81. package/package.json +66 -0
@@ -0,0 +1,34 @@
1
+ .TH TGLFS-INSPECT 1 "March 2026" "tglfs 0.1.0" "User Commands"
2
+ .SH NAME
3
+ tglfs-inspect \- inspect file-card metadata and chunk references
4
+ .SH SYNOPSIS
5
+ .B tglfs inspect
6
+ [\fIOPTIONS\fR] \fIufid\fR
7
+ .SH DESCRIPTION
8
+ Shows the file-card metadata and checks whether each referenced chunk message exists and is a Telegram document. Use
9
+ .B --probe
10
+ to run the expensive full current-vs-legacy integrity probe, which downloads, decrypts, and validates the file data.
11
+ .SH OPTIONS
12
+ .TP
13
+ .B --peer <peer>
14
+ Peer to inspect instead of Saved Messages.
15
+ .TP
16
+ .B --probe
17
+ Run the full current-vs-legacy integrity probe.
18
+ .TP
19
+ .B --password <password>
20
+ Password to use for current-vs-legacy probing.
21
+ .TP
22
+ .B --password-env [name]
23
+ Read the probe password from an environment variable. If no name is provided, the command uses
24
+ .B TGLFS_INSPECT_PASSWORD.
25
+ .TP
26
+ .B --password-stdin
27
+ Read the probe password from standard input.
28
+ .TP
29
+ .B --json
30
+ Emit machine-readable JSON.
31
+ .SH ENVIRONMENT
32
+ .TP
33
+ .B TGLFS_INSPECT_PASSWORD
34
+ Default environment variable for the probe password.
@@ -0,0 +1,53 @@
1
+ .TH TGLFS-LOGIN 1 "March 2026" "tglfs 0.1.0" "User Commands"
2
+ .SH NAME
3
+ tglfs-login \- authenticate with Telegram and persist a TGLFS session
4
+ .SH SYNOPSIS
5
+ .B tglfs login
6
+ [\fIOPTIONS\fR]
7
+ .SH DESCRIPTION
8
+ Authenticates with Telegram as a user account and stores both TGLFS config and the Telegram session for later commands.
9
+ .PP
10
+ If no API ID or API hash is supplied, the CLI uses the same bundled Telegram app credentials as the web client. Explicit flags and environment variables still override those defaults.
11
+ .SH OPTIONS
12
+ .TP
13
+ .B --api-id <id>
14
+ Telegram API ID.
15
+ .TP
16
+ .B --api-hash <hash>
17
+ Telegram API hash.
18
+ .TP
19
+ .B --phone <phone>
20
+ Telegram phone number.
21
+ .TP
22
+ .B --code <code>
23
+ Telegram login code.
24
+ .TP
25
+ .B --code-stdin
26
+ Read the Telegram login code from standard input.
27
+ .TP
28
+ .B --password <password>
29
+ Telegram two-factor password.
30
+ .TP
31
+ .B --password-stdin
32
+ Read the Telegram two-factor password from standard input.
33
+ .TP
34
+ .B --json
35
+ Emit machine-readable JSON.
36
+ .SH ENVIRONMENT
37
+ .TP
38
+ .B TGLFS_API_ID
39
+ Telegram API ID.
40
+ .TP
41
+ .B TGLFS_API_HASH
42
+ Telegram API hash.
43
+ .TP
44
+ .B TGLFS_PHONE
45
+ Telegram phone number.
46
+ .TP
47
+ .B TGLFS_LOGIN_CODE
48
+ Telegram login code.
49
+ .TP
50
+ .B TGLFS_2FA_PASSWORD
51
+ Telegram two-factor password.
52
+ .SH AI AGENT NOTES
53
+ If no login code or two-factor password source is supplied and the command is attached to a TTY, the CLI prompts for the missing value. In a non-interactive session, the agent must provide the secret via flags, environment variables, or standard input.
@@ -0,0 +1,17 @@
1
+ .TH TGLFS-LOGOUT 1 "March 2026" "tglfs 0.1.0" "User Commands"
2
+ .SH NAME
3
+ tglfs-logout \- remove persisted TGLFS auth state
4
+ .SH SYNOPSIS
5
+ .B tglfs logout
6
+ [\fB--all\fR] [\fB--json\fR]
7
+ .SH DESCRIPTION
8
+ Removes the saved Telegram session. With
9
+ .B --all
10
+ it also removes the persisted TGLFS config.
11
+ .SH OPTIONS
12
+ .TP
13
+ .B --all
14
+ Delete config as well as the session.
15
+ .TP
16
+ .B --json
17
+ Emit machine-readable JSON.
@@ -0,0 +1,26 @@
1
+ .TH TGLFS-RECEIVE 1 "March 2026" "tglfs 0.1.0" "User Commands"
2
+ .SH NAME
3
+ tglfs-receive \- receive one or more TGLFS files from another peer into Saved Messages
4
+ .SH SYNOPSIS
5
+ .B tglfs receive
6
+ [\fB--json\fR] \fIsource\fR \fIufids...\fR
7
+ .SH DESCRIPTION
8
+ For each UFID, forwards the source peer's chunk messages into Saved Messages, rewrites the chunk ids in a new local file card, and stores that new file card in Saved Messages.
9
+ .SH SOURCE RESOLUTION
10
+ The
11
+ .I source
12
+ value is passed directly to Telegram/GramJS entity resolution. Users, groups, and channels can all work. In practice, use a public username such as
13
+ .B alice
14
+ or
15
+ .BR @alice ,
16
+ .BR @mygroup ,
17
+ or
18
+ .BR @mychannel ,
19
+ .B me
20
+ for Saved Messages, or a phone number that the current Telegram account can already resolve, typically a saved contact. If Telegram cannot resolve the value, the command fails.
21
+ .PP
22
+ Private users, groups, and channels can also work if Telegram can already resolve them for the current account, which usually means that account already has access to the dialog or entity.
23
+ .PP
24
+ The
25
+ .I source
26
+ identifies the chat or mailbox that currently contains the TGLFS file card and chunk messages you want to receive. It is not necessarily the original uploader's personal account.
@@ -0,0 +1,8 @@
1
+ .TH TGLFS-RENAME 1 "March 2026" "tglfs 0.1.0" "User Commands"
2
+ .SH NAME
3
+ tglfs-rename \- rename an owned TGLFS file card in Saved Messages
4
+ .SH SYNOPSIS
5
+ .B tglfs rename
6
+ [\fB--json\fR] \fIufid\fR \fInew-name\fR
7
+ .SH DESCRIPTION
8
+ Renames the Saved Messages file card for the given UFID. Chunk messages are not modified.
@@ -0,0 +1,37 @@
1
+ .TH TGLFS-SEARCH 1 "March 2026" "tglfs 0.1.0" "User Commands"
2
+ .SH NAME
3
+ tglfs-search \- search TGLFS file cards in Saved Messages or another peer mailbox
4
+ .SH SYNOPSIS
5
+ .B tglfs search
6
+ [\fIOPTIONS\fR] [\fIquery\fR]
7
+ .SH DESCRIPTION
8
+ Looks up TGLFS file cards in Telegram Saved Messages or another peer mailbox. With no query, the command lists the first page of all file cards. Search results include complete and incomplete file cards.
9
+ .SH OPTIONS
10
+ .TP
11
+ .B --peer <peer>
12
+ Peer to search instead of Saved Messages.
13
+ .TP
14
+ .B --limit <n>
15
+ Maximum number of file cards to fetch. Default:
16
+ .B 50.
17
+ .TP
18
+ .B --offset-id <msgId>
19
+ Resume from a Telegram message-id cursor returned by a previous search page.
20
+ .TP
21
+ .B --sort <sort>
22
+ Sort the current result window. Values:
23
+ .BR date_desc ,
24
+ .BR date_asc ,
25
+ .BR name_asc ,
26
+ .BR name_desc ,
27
+ .BR size_desc ,
28
+ .BR size_asc .
29
+ .TP
30
+ .B --json
31
+ Emit machine-readable JSON.
32
+ .SH AI AGENT NOTES
33
+ The plain-text output is for humans. Agents should prefer
34
+ .B --json
35
+ and can paginate statelessly with
36
+ .B --offset-id.
37
+ The search cursor follows Telegram message order, even when the displayed page is client-side sorted.
@@ -0,0 +1,22 @@
1
+ .TH TGLFS-SEND 1 "March 2026" "tglfs 0.1.0" "User Commands"
2
+ .SH NAME
3
+ tglfs-send \- send one or more owned TGLFS files to another peer
4
+ .SH SYNOPSIS
5
+ .B tglfs send
6
+ [\fB--json\fR] \fIufids...\fR \fB--to\fR \fIpeer\fR
7
+ .SH DESCRIPTION
8
+ Forwards the referenced chunk messages in batches to the target peer, rewrites the chunk ids in a new file card, and sends the rewritten file card to that peer.
9
+ .SH PEER RESOLUTION
10
+ The
11
+ .I peer
12
+ value is passed directly to Telegram/GramJS entity resolution. Users, groups, and channels can all work. In practice, use a public username such as
13
+ .B alice
14
+ or
15
+ .BR @alice ,
16
+ .BR @mygroup ,
17
+ or
18
+ .BR @mychannel ,
19
+ .B me
20
+ for Saved Messages, or a phone number that the current Telegram account can already resolve, typically a saved contact. If Telegram cannot resolve the value, the command fails.
21
+ .PP
22
+ Private users, groups, and channels can also work if Telegram can already resolve them for the current account, which usually means that account already has access to the dialog or entity.
@@ -0,0 +1,12 @@
1
+ .TH TGLFS-STATUS 1 "March 2026" "tglfs 0.1.0" "User Commands"
2
+ .SH NAME
3
+ tglfs-status \- show persisted TGLFS config and Telegram authorization status
4
+ .SH SYNOPSIS
5
+ .B tglfs status
6
+ [\fB--json\fR]
7
+ .SH DESCRIPTION
8
+ Shows whether TGLFS config exists, whether a Telegram session file exists, and whether the saved session is currently authorized.
9
+ .SH OPTIONS
10
+ .TP
11
+ .B --json
12
+ Emit machine-readable JSON.
@@ -0,0 +1,37 @@
1
+ .TH TGLFS-UNSEND 1 "March 2026" "tglfs 0.1.0" "User Commands"
2
+ .SH NAME
3
+ tglfs-unsend \- delete one or more received TGLFS files from another peer mailbox
4
+ .SH SYNOPSIS
5
+ .B tglfs unsend
6
+ [\fB--yes\fR] [\fB--json\fR] \fIsource\fR \fIufids...\fR
7
+ .SH DESCRIPTION
8
+ Deletes the referenced chunk messages from the source peer mailbox in batches, then deletes the matching file card message.
9
+ .SH SOURCE RESOLUTION
10
+ The
11
+ .I source
12
+ value is passed directly to Telegram/GramJS entity resolution. Users, groups, and channels can all work. In practice, use a public username such as
13
+ .B alice
14
+ or
15
+ .BR @alice ,
16
+ .BR @mygroup ,
17
+ or
18
+ .BR @mychannel ,
19
+ .B me
20
+ for Saved Messages, or a phone number that the current Telegram account can already resolve, typically a saved contact. If Telegram cannot resolve the value, the command fails.
21
+ .PP
22
+ Private users, groups, and channels can also work if Telegram can already resolve them for the current account, which usually means that account already has access to the dialog or entity.
23
+ .PP
24
+ The
25
+ .I source
26
+ identifies the chat or mailbox that currently contains the received TGLFS file card and chunk messages you want to remove. It is not necessarily the original uploader's personal account.
27
+ .SH OPTIONS
28
+ .TP
29
+ .B --yes
30
+ Skip the confirmation prompt.
31
+ .TP
32
+ .B --json
33
+ Emit machine-readable JSON.
34
+ .SH AI AGENT NOTES
35
+ Agents should pass
36
+ .B --yes
37
+ in non-interactive sessions.
@@ -0,0 +1,28 @@
1
+ .TH TGLFS-UPLOAD 1 "March 2026" "tglfs 0.1.0" "User Commands"
2
+ .SH NAME
3
+ tglfs-upload \- upload one file, or archive multiple files, into Telegram Saved Messages
4
+ .SH SYNOPSIS
5
+ .B tglfs upload
6
+ [\fIOPTIONS\fR] \fIpaths...\fR
7
+ .SH DESCRIPTION
8
+ Uploads one file directly into Saved Messages, or packages multiple files into a tar archive using the same naming convention as the web app before uploading.
9
+ .SH OPTIONS
10
+ .TP
11
+ .B --password <password>
12
+ Encryption password.
13
+ .TP
14
+ .B --password-env [name]
15
+ Read the encryption password from an environment variable. If no name is provided, the command uses
16
+ .B TGLFS_UPLOAD_PASSWORD.
17
+ .TP
18
+ .B --password-stdin
19
+ Read the encryption password from standard input.
20
+ .TP
21
+ .B --json
22
+ Emit machine-readable JSON.
23
+ .SH ENVIRONMENT
24
+ .TP
25
+ .B TGLFS_UPLOAD_PASSWORD
26
+ Default environment variable for the upload encryption password.
27
+ .SH AI AGENT NOTES
28
+ TTY uploads render separate UFID and upload progress bars. In non-interactive sessions, agents should provide the encryption password via flags, environment variables, or standard input when needed.
package/man/tglfs.1 ADDED
@@ -0,0 +1,70 @@
1
+ .TH TGLFS 1 "March 2026" "tglfs 0.1.0" "User Commands"
2
+ .SH NAME
3
+ tglfs \- authenticate with Telegram, manage TGLFS file cards, transfer files, and download TGLFS files by UFID
4
+ .SH SYNOPSIS
5
+ .B tglfs
6
+ [\fIOPTIONS\fR] [\fICOMMAND\fR]
7
+ .SH DESCRIPTION
8
+ .B tglfs
9
+ is a global command-line client for authenticating with Telegram, uploading files, managing TGLFS file cards, transferring files between peers, searching mailboxes, and downloading current-format or legacy TGLFS files by UFID.
10
+ .PP
11
+ Run
12
+ .B tglfs help <command>
13
+ for subcommand-specific help.
14
+ .SH COMMANDS
15
+ .TP
16
+ .B upload <paths...>
17
+ Upload one file, or archive multiple files, into Saved Messages.
18
+ .TP
19
+ .B login
20
+ Authenticate with Telegram and persist the resulting session.
21
+ .TP
22
+ .B status
23
+ Show current config and Telegram authorization state.
24
+ .TP
25
+ .B logout
26
+ Remove the saved Telegram session.
27
+ .TP
28
+ .B search [query]
29
+ Search TGLFS file cards in Saved Messages or another peer mailbox.
30
+ .TP
31
+ .B download <ufid>
32
+ Download a current-format or legacy TGLFS file by UFID.
33
+ .TP
34
+ .B rename <ufid> <new-name>
35
+ Rename an owned TGLFS file card.
36
+ .TP
37
+ .B delete <ufid...>
38
+ Delete one or more owned TGLFS files.
39
+ .TP
40
+ .B send <ufid...> --to <peer>
41
+ Send one or more owned TGLFS files to another peer. Users, groups, and channels can all work if Telegram/GramJS can resolve the value, including public usernames and many already-accessible private dialogs.
42
+ .TP
43
+ .B receive <source> <ufid...>
44
+ Receive one or more TGLFS files from another peer into Saved Messages. The source value names the mailbox to search, not necessarily the original uploader.
45
+ .TP
46
+ .B unsend <source> <ufid...>
47
+ Delete one or more received TGLFS files from another peer mailbox. The source value names the mailbox to modify, not necessarily the original uploader.
48
+ .TP
49
+ .B inspect <ufid>
50
+ Inspect file-card metadata and chunk references; use
51
+ .B --probe
52
+ for a full current-vs-legacy integrity check.
53
+ .TP
54
+ .B help [command]
55
+ Display help for a command.
56
+ .SH FILES
57
+ The CLI stores config and session files in OS-standard per-user app directories.
58
+ .SH SEE ALSO
59
+ .BR tglfs-login (1),
60
+ .BR tglfs-status (1),
61
+ .BR tglfs-logout (1),
62
+ .BR tglfs-upload (1),
63
+ .BR tglfs-search (1),
64
+ .BR tglfs-download (1),
65
+ .BR tglfs-rename (1),
66
+ .BR tglfs-delete (1),
67
+ .BR tglfs-send (1),
68
+ .BR tglfs-receive (1),
69
+ .BR tglfs-unsend (1),
70
+ .BR tglfs-inspect (1)
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "tglfs",
3
+ "version": "0.1.0",
4
+ "description": "Global CLI for authenticating with Telegram, uploading and managing TGLFS files, transferring them between Telegram chats, and downloading them by UFID.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/hinsley/tglfs.git",
9
+ "directory": "packages/tglfs-cli"
10
+ },
11
+ "homepage": "https://github.com/hinsley/tglfs#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/hinsley/tglfs/issues"
14
+ },
15
+ "keywords": [
16
+ "telegram",
17
+ "cli",
18
+ "files",
19
+ "storage",
20
+ "backup",
21
+ "tui",
22
+ "gramjs",
23
+ "npm"
24
+ ],
25
+ "type": "module",
26
+ "bin": {
27
+ "tglfs": "./dist/cli.js"
28
+ },
29
+ "man": [
30
+ "./man/tglfs.1",
31
+ "./man/tglfs-login.1",
32
+ "./man/tglfs-status.1",
33
+ "./man/tglfs-logout.1",
34
+ "./man/tglfs-upload.1",
35
+ "./man/tglfs-search.1",
36
+ "./man/tglfs-download.1",
37
+ "./man/tglfs-rename.1",
38
+ "./man/tglfs-delete.1",
39
+ "./man/tglfs-send.1",
40
+ "./man/tglfs-receive.1",
41
+ "./man/tglfs-unsend.1",
42
+ "./man/tglfs-inspect.1"
43
+ ],
44
+ "files": ["dist", "man", "README.md"],
45
+ "engines": {
46
+ "node": ">=22.0.0"
47
+ },
48
+ "scripts": {
49
+ "clean": "rm -rf dist",
50
+ "build": "tsc -p tsconfig.build.json",
51
+ "prepack": "npm run clean && npm run build",
52
+ "test": "node --import tsx --test test/**/*.test.ts"
53
+ },
54
+ "dependencies": {
55
+ "commander": "^14.0.3",
56
+ "env-paths": "^4.0.0",
57
+ "prompts": "^2.4.2",
58
+ "telegram": "^2.21.2"
59
+ },
60
+ "devDependencies": {
61
+ "@types/node": "^25.5.0",
62
+ "@types/prompts": "^2.4.9",
63
+ "tsx": "^4.21.0",
64
+ "typescript": "^5.4.3"
65
+ }
66
+ }