@simplysm/storage 13.0.12 → 13.0.13
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 +41 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -45,10 +45,16 @@ interface StorageConnConfig {
|
|
|
45
45
|
host: string; // Server host
|
|
46
46
|
port?: number; // Port (FTP default: 21, SFTP default: 22)
|
|
47
47
|
user?: string; // Username
|
|
48
|
-
pass?: string; // Password
|
|
48
|
+
pass?: string; // Password (required for FTP/FTPS; optional for SFTP)
|
|
49
49
|
}
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
**SFTP SSH Key Authentication:**
|
|
53
|
+
- If `pass` is omitted for SFTP connections, the client automatically attempts authentication using:
|
|
54
|
+
1. SSH key file at `~/.ssh/id_ed25519`
|
|
55
|
+
2. SSH agent (if `SSH_AUTH_SOCK` environment variable is set)
|
|
56
|
+
- Both methods are tried in order; if the key file authentication fails (e.g., encrypted keys), the client falls back to agent-only authentication.
|
|
57
|
+
|
|
52
58
|
### FileInfo
|
|
53
59
|
|
|
54
60
|
File/directory information returned by `readdir()`.
|
|
@@ -134,7 +140,7 @@ await StorageFactory.connect("ftps", {
|
|
|
134
140
|
```
|
|
135
141
|
|
|
136
142
|
```typescript
|
|
137
|
-
// SFTP connection
|
|
143
|
+
// SFTP connection with password
|
|
138
144
|
await StorageFactory.connect("sftp", {
|
|
139
145
|
host: "sftp.example.com",
|
|
140
146
|
port: 22,
|
|
@@ -152,6 +158,19 @@ await StorageFactory.connect("sftp", {
|
|
|
152
158
|
});
|
|
153
159
|
```
|
|
154
160
|
|
|
161
|
+
```typescript
|
|
162
|
+
// SFTP connection with SSH key (if pass is omitted, uses ~/.ssh/id_ed25519 or SSH agent)
|
|
163
|
+
await StorageFactory.connect("sftp", {
|
|
164
|
+
host: "sftp.example.com",
|
|
165
|
+
port: 22,
|
|
166
|
+
user: "username",
|
|
167
|
+
// No password provided - uses SSH key authentication
|
|
168
|
+
}, async (client) => {
|
|
169
|
+
const files = await client.readdir("/remote/path");
|
|
170
|
+
await client.uploadDir("/local/dir", "/remote/dir");
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
155
174
|
### FtpStorageClient (Direct Usage)
|
|
156
175
|
|
|
157
176
|
Client that uses FTP or FTPS protocol. The `secure` parameter in the constructor determines whether to use FTPS.
|
|
@@ -216,6 +235,7 @@ import { SftpStorageClient } from "@simplysm/storage";
|
|
|
216
235
|
|
|
217
236
|
const client = new SftpStorageClient();
|
|
218
237
|
|
|
238
|
+
// Connection with password
|
|
219
239
|
await client.connect({
|
|
220
240
|
host: "sftp.example.com",
|
|
221
241
|
port: 22,
|
|
@@ -238,6 +258,25 @@ try {
|
|
|
238
258
|
}
|
|
239
259
|
```
|
|
240
260
|
|
|
261
|
+
```typescript
|
|
262
|
+
// Connection with SSH key (password omitted)
|
|
263
|
+
const client = new SftpStorageClient();
|
|
264
|
+
|
|
265
|
+
await client.connect({
|
|
266
|
+
host: "sftp.example.com",
|
|
267
|
+
port: 22,
|
|
268
|
+
user: "username",
|
|
269
|
+
// Uses ~/.ssh/id_ed25519 or SSH agent for authentication
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
try {
|
|
273
|
+
await client.put("/local/path/file.txt", "/remote/path/file.txt");
|
|
274
|
+
// ... other operations
|
|
275
|
+
} finally {
|
|
276
|
+
await client.close();
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
241
280
|
## Important Notes
|
|
242
281
|
|
|
243
282
|
### Connection Management
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/storage",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "13.0.
|
|
4
|
+
"version": "13.0.13",
|
|
5
5
|
"description": "심플리즘 패키지 - 스토리지 모듈 (node)",
|
|
6
6
|
"author": "김석래",
|
|
7
7
|
"repository": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"basic-ftp": "^5.1.0",
|
|
22
22
|
"ssh2-sftp-client": "^12.0.1",
|
|
23
|
-
"@simplysm/core-common": "13.0.
|
|
23
|
+
"@simplysm/core-common": "13.0.13"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/ssh2-sftp-client": "^9.0.6"
|