@fluxfiles/node 0.1.7 → 0.1.8

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/dist/index.d.mts CHANGED
@@ -5,7 +5,7 @@ type FluxPermission = 'read' | 'write' | 'delete' | 'audit';
5
5
  * decrypted only at runtime by the FluxFiles server. Only S3-compatible
6
6
  * storage is allowed — the server rejects the `local` driver.
7
7
  */
8
- interface ByobDiskConfig {
8
+ interface ByobS3DiskConfig {
9
9
  driver: 's3';
10
10
  key: string;
11
11
  secret: string;
@@ -17,6 +17,22 @@ interface ByobDiskConfig {
17
17
  /** Public base URL for direct (unsigned) object links on a public disk. */
18
18
  public_url?: string;
19
19
  }
20
+ /**
21
+ * A BYOB SFTP disk — a user's own SFTP server (e.g. a VPS). Auth is a password OR
22
+ * a private key. The server SSRF-checks the host (no loopback/private/metadata
23
+ * targets). SFTP files are streamed through the app (no static/presigned URL).
24
+ */
25
+ interface ByobSftpDiskConfig {
26
+ driver: 'sftp';
27
+ host: string;
28
+ username: string;
29
+ password?: string;
30
+ private_key?: string;
31
+ private_key_passphrase?: string;
32
+ port?: number;
33
+ root?: string;
34
+ }
35
+ type ByobDiskConfig = ByobS3DiskConfig | ByobSftpDiskConfig;
20
36
  /** Options shared by all token builders. */
21
37
  interface BaseTokenOptions {
22
38
  /** HS256 signing secret. Defaults to `process.env.FLUXFILES_SECRET`. Must be ≥ 32 bytes. */
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ type FluxPermission = 'read' | 'write' | 'delete' | 'audit';
5
5
  * decrypted only at runtime by the FluxFiles server. Only S3-compatible
6
6
  * storage is allowed — the server rejects the `local` driver.
7
7
  */
8
- interface ByobDiskConfig {
8
+ interface ByobS3DiskConfig {
9
9
  driver: 's3';
10
10
  key: string;
11
11
  secret: string;
@@ -17,6 +17,22 @@ interface ByobDiskConfig {
17
17
  /** Public base URL for direct (unsigned) object links on a public disk. */
18
18
  public_url?: string;
19
19
  }
20
+ /**
21
+ * A BYOB SFTP disk — a user's own SFTP server (e.g. a VPS). Auth is a password OR
22
+ * a private key. The server SSRF-checks the host (no loopback/private/metadata
23
+ * targets). SFTP files are streamed through the app (no static/presigned URL).
24
+ */
25
+ interface ByobSftpDiskConfig {
26
+ driver: 'sftp';
27
+ host: string;
28
+ username: string;
29
+ password?: string;
30
+ private_key?: string;
31
+ private_key_passphrase?: string;
32
+ port?: number;
33
+ root?: string;
34
+ }
35
+ type ByobDiskConfig = ByobS3DiskConfig | ByobSftpDiskConfig;
20
36
  /** Options shared by all token builders. */
21
37
  interface BaseTokenOptions {
22
38
  /** HS256 signing secret. Defaults to `process.env.FLUXFILES_SECRET`. Must be ≥ 32 bytes. */
package/dist/index.js CHANGED
@@ -174,8 +174,19 @@ function applyTenantOverrides(payload, opts) {
174
174
  if (opts.usageFolderDepth && opts.usageFolderDepth > 0) payload.usage_folder_depth = Math.trunc(opts.usageFolderDepth);
175
175
  }
176
176
  function validateByobDisk(name, config) {
177
- if (!config || config.driver !== "s3") {
178
- throw new Error(`FluxFiles BYOB disk "${name}": driver must be "s3" (the server rejects "local").`);
177
+ if (!config || config.driver !== "s3" && config.driver !== "sftp") {
178
+ throw new Error(`FluxFiles BYOB disk "${name}": driver must be "s3" or "sftp" (the server rejects "local").`);
179
+ }
180
+ if (config.driver === "sftp") {
181
+ for (const field of ["host", "username"]) {
182
+ if (!config[field]) {
183
+ throw new Error(`FluxFiles BYOB disk "${name}": missing required "${field}".`);
184
+ }
185
+ }
186
+ if (!config.password && !config.private_key) {
187
+ throw new Error(`FluxFiles BYOB disk "${name}": needs a "password" or "private_key".`);
188
+ }
189
+ return;
179
190
  }
180
191
  for (const field of ["key", "secret", "bucket"]) {
181
192
  if (!config[field]) {
package/dist/index.mjs CHANGED
@@ -152,8 +152,19 @@ function applyTenantOverrides(payload, opts) {
152
152
  if (opts.usageFolderDepth && opts.usageFolderDepth > 0) payload.usage_folder_depth = Math.trunc(opts.usageFolderDepth);
153
153
  }
154
154
  function validateByobDisk(name, config) {
155
- if (!config || config.driver !== "s3") {
156
- throw new Error(`FluxFiles BYOB disk "${name}": driver must be "s3" (the server rejects "local").`);
155
+ if (!config || config.driver !== "s3" && config.driver !== "sftp") {
156
+ throw new Error(`FluxFiles BYOB disk "${name}": driver must be "s3" or "sftp" (the server rejects "local").`);
157
+ }
158
+ if (config.driver === "sftp") {
159
+ for (const field of ["host", "username"]) {
160
+ if (!config[field]) {
161
+ throw new Error(`FluxFiles BYOB disk "${name}": missing required "${field}".`);
162
+ }
163
+ }
164
+ if (!config.password && !config.private_key) {
165
+ throw new Error(`FluxFiles BYOB disk "${name}": needs a "password" or "private_key".`);
166
+ }
167
+ return;
157
168
  }
158
169
  for (const field of ["key", "secret", "bucket"]) {
159
170
  if (!config[field]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluxfiles/node",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Server-side Node/TypeScript SDK for minting FluxFiles JWTs (plain + BYOB), byte-compatible with the PHP core",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
package/src/token.ts CHANGED
@@ -151,8 +151,19 @@ function applyTenantOverrides(payload: Record<string, unknown>, opts: BaseTokenO
151
151
  * SSRF checks on the endpoint), so this only catches obvious mistakes early.
152
152
  */
153
153
  function validateByobDisk(name: string, config: ByobDiskConfig): void {
154
- if (!config || config.driver !== 's3') {
155
- throw new Error(`FluxFiles BYOB disk "${name}": driver must be "s3" (the server rejects "local").`);
154
+ if (!config || (config.driver !== 's3' && config.driver !== 'sftp')) {
155
+ throw new Error(`FluxFiles BYOB disk "${name}": driver must be "s3" or "sftp" (the server rejects "local").`);
156
+ }
157
+ if (config.driver === 'sftp') {
158
+ for (const field of ['host', 'username'] as const) {
159
+ if (!config[field]) {
160
+ throw new Error(`FluxFiles BYOB disk "${name}": missing required "${field}".`);
161
+ }
162
+ }
163
+ if (!config.password && !config.private_key) {
164
+ throw new Error(`FluxFiles BYOB disk "${name}": needs a "password" or "private_key".`);
165
+ }
166
+ return;
156
167
  }
157
168
  for (const field of ['key', 'secret', 'bucket'] as const) {
158
169
  if (!config[field]) {
package/src/types.ts CHANGED
@@ -6,7 +6,7 @@ export type FluxPermission = 'read' | 'write' | 'delete' | 'audit';
6
6
  * decrypted only at runtime by the FluxFiles server. Only S3-compatible
7
7
  * storage is allowed — the server rejects the `local` driver.
8
8
  */
9
- export interface ByobDiskConfig {
9
+ export interface ByobS3DiskConfig {
10
10
  driver: 's3';
11
11
  key: string;
12
12
  secret: string;
@@ -19,6 +19,24 @@ export interface ByobDiskConfig {
19
19
  public_url?: string;
20
20
  }
21
21
 
22
+ /**
23
+ * A BYOB SFTP disk — a user's own SFTP server (e.g. a VPS). Auth is a password OR
24
+ * a private key. The server SSRF-checks the host (no loopback/private/metadata
25
+ * targets). SFTP files are streamed through the app (no static/presigned URL).
26
+ */
27
+ export interface ByobSftpDiskConfig {
28
+ driver: 'sftp';
29
+ host: string;
30
+ username: string;
31
+ password?: string;
32
+ private_key?: string;
33
+ private_key_passphrase?: string;
34
+ port?: number;
35
+ root?: string;
36
+ }
37
+
38
+ export type ByobDiskConfig = ByobS3DiskConfig | ByobSftpDiskConfig;
39
+
22
40
  /** Options shared by all token builders. */
23
41
  export interface BaseTokenOptions {
24
42
  /** HS256 signing secret. Defaults to `process.env.FLUXFILES_SECRET`. Must be ≥ 32 bytes. */