spd-lib 1.3.2 → 1.3.4
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 +6 -3
- package/index.d.mts +5 -0
- package/index.d.ts +5 -0
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -219,17 +219,20 @@ const spd = await SPD.loadFromString(b64, 'MyStr0ng!Passphrase#2024');
|
|
|
219
219
|
Split a payload into chunks for HTTP uploads or any transport with a body-size limit.
|
|
220
220
|
|
|
221
221
|
```ts
|
|
222
|
-
// Sender
|
|
223
|
-
const chunks = await spd.saveDataChunked('MyStr0ng!Passphrase#2024'
|
|
222
|
+
// Sender — chunk size is chosen automatically
|
|
223
|
+
const chunks = await spd.saveDataChunked('MyStr0ng!Passphrase#2024');
|
|
224
224
|
// chunks is string[] — send each element, then the manifest (last element) last
|
|
225
225
|
|
|
226
|
+
// Override chunk size when you have a strict body limit (e.g. 256 KB per request)
|
|
227
|
+
const chunks = await spd.saveDataChunked('MyStr0ng!Passphrase#2024', 256 * 1024);
|
|
228
|
+
|
|
226
229
|
// Receiver — pass all chunks in order including the manifest
|
|
227
230
|
const spd = await SPD.loadFromChunks(chunks, 'MyStr0ng!Passphrase#2024');
|
|
228
231
|
```
|
|
229
232
|
|
|
230
233
|
The last element of the array is always a JSON manifest (`{ totalChunks, chunkSize, totalBytes, version }`). The receiver validates chunk count and byte count before decrypting.
|
|
231
234
|
|
|
232
|
-
|
|
235
|
+
**Auto chunk size** (when `chunkSize` is omitted): targets ~32 chunks, clamped between 64 KB and 8 MB, rounded to the nearest 64 KB boundary. Pass an explicit `chunkSize` to override (e.g. `256 * 1024` for strict API body limits).
|
|
233
236
|
|
|
234
237
|
---
|
|
235
238
|
|
package/index.d.mts
CHANGED
|
@@ -134,6 +134,11 @@ declare class SPD {
|
|
|
134
134
|
* Splits the payload into base64 chunks for chunked internet transfer.
|
|
135
135
|
* The manifest (last element) records totalChunks/totalBytes for validation.
|
|
136
136
|
* Reassemble with `SPD.loadFromChunks(chunks, passcode)`.
|
|
137
|
+
*
|
|
138
|
+
* If `chunkSize` is omitted (or 0), a size is computed automatically:
|
|
139
|
+
* - Targets ~32 chunks so the manifest stays small
|
|
140
|
+
* - Clamped between 64 KB (min) and 8 MB (max)
|
|
141
|
+
* - Rounded up to the nearest 64 KB boundary for alignment
|
|
137
142
|
*/
|
|
138
143
|
saveDataChunked(passcode: string, chunkSize?: number): Promise<string[]>;
|
|
139
144
|
static loadFromFile(filePath: string, passcode: string): Promise<SPD>;
|
package/index.d.ts
CHANGED
|
@@ -134,6 +134,11 @@ declare class SPD {
|
|
|
134
134
|
* Splits the payload into base64 chunks for chunked internet transfer.
|
|
135
135
|
* The manifest (last element) records totalChunks/totalBytes for validation.
|
|
136
136
|
* Reassemble with `SPD.loadFromChunks(chunks, passcode)`.
|
|
137
|
+
*
|
|
138
|
+
* If `chunkSize` is omitted (or 0), a size is computed automatically:
|
|
139
|
+
* - Targets ~32 chunks so the manifest stays small
|
|
140
|
+
* - Clamped between 64 KB (min) and 8 MB (max)
|
|
141
|
+
* - Rounded up to the nearest 64 KB boundary for alignment
|
|
137
142
|
*/
|
|
138
143
|
saveDataChunked(passcode: string, chunkSize?: number): Promise<string[]>;
|
|
139
144
|
static loadFromFile(filePath: string, passcode: string): Promise<SPD>;
|