@finueva/drive 0.2.0 → 0.3.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.
- package/CHANGELOG.md +6 -0
- package/README.md +40 -8
- package/THIRD_PARTY_NOTICES.md +26 -0
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1071 -22
- package/dist/contract.d.ts +792 -65
- package/dist/core.d.ts +2 -1
- package/dist/core.js +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1071 -22
- package/dist/server.d.ts +3 -3
- package/dist/server.js +329 -24
- package/dist/types.d.ts +2 -2
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @finueva/drive
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 90e29ff: Add all six strict upload controls and resumable browser direct-`Blob` orchestration with zero-byte completion, bounded incremental SHA-256 hashing, isolated archive PUTs, lost-response reconciliation, progress, and cancellation cleanup.
|
|
8
|
+
|
|
3
9
|
## 0.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -6,13 +6,13 @@ The package is ESM-only. Node.js 22 is the exact minimum; package CI qualifies N
|
|
|
6
6
|
|
|
7
7
|
## Exports
|
|
8
8
|
|
|
9
|
-
| Import | Runtime
|
|
10
|
-
| ----------------------- |
|
|
11
|
-
| `@finueva/drive` | Browser-safe client factory, errors, and curated types
|
|
12
|
-
| `@finueva/drive/client` | Browser-safe client factory
|
|
13
|
-
| `@finueva/drive/server` | Request-scoped Worker and Node client factory
|
|
14
|
-
| `@finueva/drive/core` | Reviewed error values only
|
|
15
|
-
| `@finueva/drive/types` | Curated workspace, folder, permission, and upload
|
|
9
|
+
| Import | Runtime |
|
|
10
|
+
| ----------------------- | ------------------------------------------------------- |
|
|
11
|
+
| `@finueva/drive` | Browser-safe client factory, errors, and curated types |
|
|
12
|
+
| `@finueva/drive/client` | Browser-safe client factory |
|
|
13
|
+
| `@finueva/drive/server` | Request-scoped Worker and Node low-level client factory |
|
|
14
|
+
| `@finueva/drive/core` | Reviewed error values only |
|
|
15
|
+
| `@finueva/drive/types` | Curated workspace, folder, permission, and upload types |
|
|
16
16
|
|
|
17
17
|
## Browser
|
|
18
18
|
|
|
@@ -31,6 +31,19 @@ const page = await drive.listFolderChildren({
|
|
|
31
31
|
itemId: workspace.rootItemId,
|
|
32
32
|
limit: 50,
|
|
33
33
|
});
|
|
34
|
+
|
|
35
|
+
const uploaded = await drive.uploadFile({
|
|
36
|
+
workspaceId: workspace.workspaceId,
|
|
37
|
+
parentItemId: workspace.rootItemId,
|
|
38
|
+
source: file, // Blob; File is supported without being required
|
|
39
|
+
displayFilename: file.name,
|
|
40
|
+
mediaType: file.type || "application/octet-stream",
|
|
41
|
+
idempotencyKey: crypto.randomUUID(),
|
|
42
|
+
completionIdempotencyKey: crypto.randomUUID(),
|
|
43
|
+
onProgress: ({ phase, confirmedByteLength, totalByteLength }) => {
|
|
44
|
+
renderProgress(phase, confirmedByteLength, totalByteLength);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
34
47
|
```
|
|
35
48
|
|
|
36
49
|
The provider runs once for every request. The SDK sends its result only as `Authorization: Bearer`, always sets `credentials: "omit"` and `cache: "no-store"`, and never reads cookies. Configuration does not accept default headers. Credential acquisition, Fetch, and response handling share one bounded request deadline: 30 seconds by default, configurable from 1 millisecond through 120 seconds.
|
|
@@ -48,6 +61,8 @@ const drive = createDriveServerClient({
|
|
|
48
61
|
|
|
49
62
|
Create a client per request when using user authority. A fixed `credential` string is accepted for an explicitly scoped credential, but the SDK does not create, refresh, persist, or infer sessions, cookies, provider tokens, or service authority.
|
|
50
63
|
|
|
64
|
+
The server client exposes the Native Drive operations, including all six upload controls, but intentionally has no Blob-only `uploadFile` method. Browser upload orchestration is available from the package root and `@finueva/drive/client` only.
|
|
65
|
+
|
|
51
66
|
## Operations
|
|
52
67
|
|
|
53
68
|
Methods use the Native API operation IDs:
|
|
@@ -61,7 +76,12 @@ Methods use the Native API operation IDs:
|
|
|
61
76
|
- `updateItemPermission`
|
|
62
77
|
- `revokeItemPermission`
|
|
63
78
|
- `createUpload`
|
|
79
|
+
- `getUploadStatus`
|
|
80
|
+
- `createUploadPartDescriptor`
|
|
81
|
+
- `recordUploadPart`
|
|
82
|
+
- `completeUpload`
|
|
64
83
|
- `abortUpload`
|
|
84
|
+
- `uploadFile` (high-level orchestration)
|
|
65
85
|
|
|
66
86
|
`getCurrentWorkspace` maps the credential's selected Auth context to the provisioned Drive workspace and canonical managed root. It accepts only an optional `{ signal }` input, never provisions as a side effect, and returns no entitlement, credential, or private persistence fields.
|
|
67
87
|
|
|
@@ -69,7 +89,19 @@ Every mutation requires the API's explicit idempotency key when the operation de
|
|
|
69
89
|
|
|
70
90
|
Successful calls return `{ data, status, requestId, validators }`. A successful response must carry one valid `X-Request-ID`; canonical API errors must carry the same request ID in their header and body. Any missing, malformed, or mismatched value is an `invalid_response`. The only exposed validators are `etag`, `permissionCollectionEtag`, and `permissionGrantEtag`.
|
|
71
91
|
|
|
72
|
-
`createUpload`
|
|
92
|
+
The six low-level upload methods map directly to the Native API. `createUpload` accepts `callerDeclaredContentDigest`, an ordinary whole-file `sha256:{64 lowercase hex}` value calculated or supplied by the caller. It is untrusted metadata, not provider verification evidence. `getUploadStatus` returns one bounded confirmed-part page and the current lifecycle/revision. Descriptor issuance accepts one base64 SHA-256 part checksum, `recordUploadPart` records exact provider ETag/checksum evidence and revision, `completeUpload` returns only a server-verified `ready` result, and `abortUpload` returns bodyless `204` success.
|
|
93
|
+
|
|
94
|
+
Provider part checksums and the provider's multipart composite checksum are verified server-side before publication. They are deliberately distinct from `callerDeclaredContentDigest`: multipart composite SHA-256 is not the ordinary SHA-256 of the complete file. Every low-level control obtains one credential, sends one request, validates exact IDs, checksums, ETags, and safe-integer bounds at runtime, and never retries automatically. `upload_recovery_required` is preserved as a canonical `DriveError` code.
|
|
95
|
+
|
|
96
|
+
`uploadFile` is the browser-safe direct-byte path for a Web `Blob` or `File`. It accepts zero-byte input, hashes the empty input correctly, accepts the server-mediated zero-byte mode, skips part transfer, and completes normally. Nonempty input is incrementally hashed in slices no larger than 32 MiB and is never materialized as a complete `ArrayBuffer`, Blob copy, base64 string, or SDK request body. The fixed policy permits at most 10,000 parts and 312.5 GiB.
|
|
97
|
+
|
|
98
|
+
Each nonempty slice is sent directly to the exact descriptor URL. The request includes only descriptor-required headers, uses `credentials: "omit"`, `cache: "no-store"`, `redirect: "error"`, and `referrerPolicy: "no-referrer"`, and shares the configured cancellation/deadline bound. The archive CORS policy must expose both `ETag` and `x-amz-checksum-sha256`; missing, malformed, or mismatched values fail closed. Drive authorization, cookies, default headers, and file metadata never enter the archive request.
|
|
99
|
+
|
|
100
|
+
Repeating `uploadFile` with the same creation and completion idempotency keys explicitly resumes the retained session. After create/replay, the SDK reads status in pages of 100, bounded to 100 pages and 10,000 parts; validates session identity, mode, policy, lifecycle, revision, and pagination; re-hashes the supplied source; compares every confirmed part checksum; skips exact confirmed parts; and continues from the current revision. A matching `ready` status returns its exact ready projection. `completing` and `provider-completed` replay completion. Recovery-required and aborted states fail without pretending to resume.
|
|
101
|
+
|
|
102
|
+
There is no automatic network or provider retry. If a part-record callback response may have been lost, the SDK performs one bounded status reconciliation before either accepting the confirmed part or recording the same provider evidence once more; it never blindly re-uploads the bytes. If a completion response may have been lost, one status reconciliation returns success only when `ready` is proven. Other transient failures preserve the session for an explicit repeat until server expiry.
|
|
103
|
+
|
|
104
|
+
Progress values are frozen and limited to `preparing`, `uploading`, and `completing`, with truthful server-confirmed bytes and part counts, including resumed parts. Observer exceptions are isolated from transfer state. Reaching all confirmed bytes enters `completing`; only a resolved or status-proven `ready` result is success. Caller cancellation after session creation makes one bounded best-effort abort with fresh control-plane authority. Ordinary API or archive failures do not auto-abort.
|
|
73
105
|
|
|
74
106
|
## Errors
|
|
75
107
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
`@finueva/drive` bundles runtime code from these packages.
|
|
4
4
|
|
|
5
|
+
## @noble/hashes 2.3.0
|
|
6
|
+
|
|
7
|
+
Source: https://github.com/paulmillr/noble-hashes
|
|
8
|
+
|
|
9
|
+
MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2022 Paul Miller (https://paulmillr.com)
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in
|
|
21
|
+
all copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
29
|
+
THE SOFTWARE.
|
|
30
|
+
|
|
5
31
|
## openapi-fetch 0.17.0
|
|
6
32
|
|
|
7
33
|
Source: https://github.com/openapi-ts/openapi-typescript
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as ProtectionClassification, B as UploadFileProgressCallback, C as ListFolderChildrenInput, H as UploadPartResult, I as UploadConfirmedPart, L as UploadFileInput, M as ReadyUpload, N as RecordUploadPartInput, R as UploadFilePhase, S as GetUploadStatusInput, U as UploadSession, V as UploadPartDescriptor, W as UploadStatus, a as CreateUploadInput, b as FolderPage, c as DriveClient, d as DriveCredentialProvider, l as DriveClientConfig, n as CompleteUploadInput, o as CreateUploadPartDescriptorInput, s as CurrentWorkspace, t as AbortUploadInput, x as GetCurrentWorkspaceInput, y as FolderItem, z as UploadFileProgress } from "./contract.js";
|
|
2
2
|
//#region src/client.d.ts
|
|
3
3
|
declare function createDriveClient(config: DriveClientConfig): DriveClient;
|
|
4
4
|
//#endregion
|
|
5
|
-
export { type AbortUploadInput, type
|
|
5
|
+
export { type AbortUploadInput, type CompleteUploadInput, type CreateUploadInput, type CreateUploadPartDescriptorInput, type CurrentWorkspace, type DriveClient, type DriveClientConfig, type DriveCredentialProvider, type FolderItem, type FolderPage, type GetCurrentWorkspaceInput, type GetUploadStatusInput, type ListFolderChildrenInput, type ProtectionClassification, type ReadyUpload, type RecordUploadPartInput, type UploadConfirmedPart, type UploadFileInput, type UploadFilePhase, type UploadFileProgress, type UploadFileProgressCallback, type UploadPartDescriptor, type UploadPartResult, type UploadSession, type UploadStatus, createDriveClient };
|