@conloca/content-api 0.2.1 → 0.2.3
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/.build-inputs.json +71 -0
- package/dist/address-site.d.ts +6 -0
- package/dist/address-site.d.ts.map +1 -0
- package/dist/address-site.js +15 -0
- package/dist/address-site.js.map +1 -0
- package/dist/asset-operations.d.ts +15 -2
- package/dist/asset-operations.d.ts.map +1 -1
- package/dist/asset-operations.js +216 -78
- package/dist/asset-operations.js.map +1 -1
- package/dist/cf-access.d.ts +4 -2
- package/dist/cf-access.d.ts.map +1 -1
- package/dist/cf-access.js +29 -13
- package/dist/cf-access.js.map +1 -1
- package/dist/content-file-id.d.ts +9 -0
- package/dist/content-file-id.d.ts.map +1 -0
- package/dist/content-file-id.js +33 -0
- package/dist/content-file-id.js.map +1 -0
- package/dist/content-utils.d.ts +4 -1
- package/dist/content-utils.d.ts.map +1 -1
- package/dist/content-utils.js +14 -1
- package/dist/content-utils.js.map +1 -1
- package/dist/editor-host.d.ts +121 -0
- package/dist/editor-host.d.ts.map +1 -0
- package/dist/editor-host.js +212 -0
- package/dist/editor-host.js.map +1 -0
- package/dist/filesystem-content-api.d.ts.map +1 -1
- package/dist/filesystem-content-api.js +3 -2
- package/dist/filesystem-content-api.js.map +1 -1
- package/dist/git-operations.d.ts.map +1 -1
- package/dist/git-operations.js +162 -34
- package/dist/git-operations.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +5 -0
- package/dist/middleware.js.map +1 -1
- package/dist/schemas/index.d.ts +9 -97
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +8 -83
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/normalize.d.ts +101 -0
- package/dist/schemas/normalize.d.ts.map +1 -0
- package/dist/schemas/normalize.js +168 -0
- package/dist/schemas/normalize.js.map +1 -0
- package/dist/schemas/types.d.ts +135 -0
- package/dist/schemas/types.d.ts.map +1 -0
- package/dist/schemas/types.js +17 -0
- package/dist/schemas/types.js.map +1 -0
- package/dist/schemas/validators.d.ts +46 -0
- package/dist/schemas/validators.d.ts.map +1 -0
- package/dist/schemas/validators.js +938 -0
- package/dist/schemas/validators.js.map +1 -0
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +3 -1
- package/dist/site.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +17 -5
- package/src/address-site.ts +19 -0
- package/src/asset-operations.ts +256 -83
- package/src/cf-access.ts +30 -14
- package/src/content-file-id.ts +31 -0
- package/src/content-utils.ts +18 -2
- package/src/editor-host.ts +268 -0
- package/src/filesystem-content-api.ts +3 -2
- package/src/git-operations.ts +188 -41
- package/src/index.ts +19 -1
- package/src/middleware.ts +5 -0
- package/src/schemas/index.ts +34 -108
- package/src/schemas/normalize.ts +194 -0
- package/src/schemas/types.ts +154 -0
- package/src/schemas/validators.ts +176 -0
- package/src/site.ts +3 -1
- package/src/types.ts +9 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"files": {
|
|
4
|
+
"packages/content-api/src/address-site.ts": "4d6fae957085abd136ab454f47add2b2d30a995d198c040c038fb6a16e017392",
|
|
5
|
+
"packages/content-api/src/asset-constraints.ts": "4051c076e623b8ced3c637da74edb82a5e742048ca15ceb0777eb590af86f22c",
|
|
6
|
+
"packages/content-api/src/asset-metadata-store.ts": "0def3610569151e50c34113dc642757eb500cd5165baa86745ca33b80bb50493",
|
|
7
|
+
"packages/content-api/src/asset-operations.ts": "3245e5f42bfe822c3514e335403edb1e7bc786e2b21f964a4752da5805145746",
|
|
8
|
+
"packages/content-api/src/asset-types.ts": "9204bc6a3b488841a59831e61469418d2786010ae33c8f1f9b94afb69e451cb6",
|
|
9
|
+
"packages/content-api/src/asset-usage.ts": "c7f4fc7d40c68ea318c1e3a72a4860fc66f2b9fb54a9cd95580dfad45d76244c",
|
|
10
|
+
"packages/content-api/src/base-content-index.ts": "8dcfabc1865cfdc0dc17759d1d19ce0530ca622c10b1f05c59799723182bbc64",
|
|
11
|
+
"packages/content-api/src/cf-access.ts": "a4c0fb24a053f12e423f1211d7114a93ee7612242838ca609fecfac2e35b0b27",
|
|
12
|
+
"packages/content-api/src/component-registry.ts": "0757b9f93465ee687898b30efd0c2696f7f0eef8664b080bc44769fb0a4de95a",
|
|
13
|
+
"packages/content-api/src/component-registry.types.ts": "920596f605fc956e1aaab7d0ebe9ad2bf006ec7f9b32482b6cd4d0ccc27d616a",
|
|
14
|
+
"packages/content-api/src/component-vocabulary.ts": "41c2cd9c12769387a226d7aad8f2ed33d8e4c775ee516141cc877dba4603d2c1",
|
|
15
|
+
"packages/content-api/src/content-api.interface.ts": "adafae21056f5aad728e8c2805cace2ada723a484df838455380897d9b7a9c3c",
|
|
16
|
+
"packages/content-api/src/content-file-id.ts": "0c99bcc954ec6a47c60efd749d01fea3a16b15cc386bf2d7a8ab7ee0461ee271",
|
|
17
|
+
"packages/content-api/src/content-filters.ts": "88e34d50d2ccaa2bf7d9b45fb1b181cc3df269b185bcf6f55954f3357fffb26c",
|
|
18
|
+
"packages/content-api/src/content-index.ts": "f7f2e89cb47c41c797dc6992565da6ea138abe2a7f750801757f8c893302ac55",
|
|
19
|
+
"packages/content-api/src/content-operations.ts": "bb2d4848b43a33d21eed7e030abcb1cb737c665f47f3d78f89fc65007126e92c",
|
|
20
|
+
"packages/content-api/src/content-path.ts": "b73a1e91943e06b52956e2135c7d0fbc429a106140195cd65c1d0d0126705624",
|
|
21
|
+
"packages/content-api/src/content-reader.ts": "084cbbc3ce246174542c5e0561ec13ebb2b6ab84b2b1ca6cdf82e2fb606d8e0b",
|
|
22
|
+
"packages/content-api/src/content-utils.ts": "f7e315e49274270382ba822872899e6ba007e0ef8d6d208a6b2377351b35194e",
|
|
23
|
+
"packages/content-api/src/content-watcher.ts": "98fa13767e131ba4d2f7de613667c00705f8e52d173d527beafc0e022b0e2e17",
|
|
24
|
+
"packages/content-api/src/data-index.ts": "1b06d042e25bf76e839517da6f4b9f7c8d0fd0c952638db1e28d9671c5f88541",
|
|
25
|
+
"packages/content-api/src/data.ts": "1f42d99276c7044c61e81d4a65d1af2e513ab6bea939a8f704375b00d756a99a",
|
|
26
|
+
"packages/content-api/src/editor-data-bindings.ts": "4dbae8e022989b6b5ebae129d2b2b600455d6b167ebcb6d3ab6b8a46539938b9",
|
|
27
|
+
"packages/content-api/src/editor-host.ts": "aa209b05b060b999190c9d19c2507cdbbf19513897035c2476ffb7e24ae4335f",
|
|
28
|
+
"packages/content-api/src/etag-utils.ts": "478159ec5458b6fd8f34391af8950aa752f2154cf7183eea4b72ba9b00ebb809",
|
|
29
|
+
"packages/content-api/src/filesystem-content-api.ts": "d2ac9fb5f01c22adf147333b316bdb11fb69054adfd5b3a42daf4682eb17646c",
|
|
30
|
+
"packages/content-api/src/filesystem-reader-backend.ts": "366a2dd34c8dff3bd6e154c73795a93c67544dd52949248dce458eb5f541b229",
|
|
31
|
+
"packages/content-api/src/fragment-index.ts": "0cbebdd73e529e24fb1d066733475b5f062f3c9d831dd0cd602fce79c4f59b20",
|
|
32
|
+
"packages/content-api/src/fragments.ts": "b6d2fbc7d48f7f586c5f4baa95cf09abe6ec14d776d1bc05094b40d7dc8b4c64",
|
|
33
|
+
"packages/content-api/src/git-operations.ts": "ef9b96188cda35df9750da2bc72ac75829285aadc5f0732951b7c26412ebdda3",
|
|
34
|
+
"packages/content-api/src/header-parser.ts": "948d519a798c6ed439a9d1396a7c6030971779b8e5d235f10a637c0098c7d9c0",
|
|
35
|
+
"packages/content-api/src/in-memory-content-api.ts": "e693bd9959285a262eafff9b8d762ddab57b911ee780997109ce1b87252dc386",
|
|
36
|
+
"packages/content-api/src/index.ts": "84c0d6aee99075a05bd6e6f4354166693c05e4d504fcb33e8da56de87f9479b2",
|
|
37
|
+
"packages/content-api/src/indexing.ts": "e0b9ce86d3aeed835d40029fbcd65cc8f0f05cf627746516bf2ff0f2b8bfb483",
|
|
38
|
+
"packages/content-api/src/json-whitespace-view.ts": "bc8b7227a8032c122544f02ded4f6914c49e9a7c812dd8fd48885f83d6965ac7",
|
|
39
|
+
"packages/content-api/src/middleware.ts": "556b289e1511f822899303c6a2db80aa57a6651607c50d2852a02baa49ebdc05",
|
|
40
|
+
"packages/content-api/src/node.ts": "70552bef52cdb60a6b9cd6b68dd3614cf194271da1550f136ec70634a1c01253",
|
|
41
|
+
"packages/content-api/src/page-references.ts": "ec4b2200ca0b7edeaee4e54c39b86835704e27ce53be9eee1879d337f5793ec6",
|
|
42
|
+
"packages/content-api/src/read-date.ts": "ce9a0775515734272ecd8058d2d120edadb2e9b07cc8fabf42b1f7f3a989562e",
|
|
43
|
+
"packages/content-api/src/reader-backend.ts": "5b4e3af86838c1acb9fe1036af1f000e45fbafc684f65cfd1785b4315b479d79",
|
|
44
|
+
"packages/content-api/src/reader.ts": "d99bd3e5e2465b46ce9b5c5067a619c9f666d5cd5e914642c391edbbc9109b1a",
|
|
45
|
+
"packages/content-api/src/schemas/index.ts": "60024c657fa5ecc1d239420b5440799cf034367e0e88623467d72aaf7f8348bb",
|
|
46
|
+
"packages/content-api/src/schemas/normalize.ts": "650c4f8c1894b03773dc2a2fa5e1d752928dc7a798dd73967f1d5c75c28b3d0f",
|
|
47
|
+
"packages/content-api/src/schemas/types.ts": "8a421c368918c458f24a3f2144fc1e7033fd82c84d06f21eb080e67e1c0c5798",
|
|
48
|
+
"packages/content-api/src/schemas/validators.ts": "6b317a102151539c677225b41a605a4fc8e25a6f87cab3e8abbd009bca814400",
|
|
49
|
+
"packages/content-api/src/site-index.ts": "f29668ee173ef8af322b77717f4479b16345c7129bf0563aa61d409e4f71f1bb",
|
|
50
|
+
"packages/content-api/src/site.ts": "fb375c1bbf757dd3e177daca1be2915137f23427a8824746966ead63d280258a",
|
|
51
|
+
"packages/content-api/src/types.ts": "d7a1607c395f2002d69e9f71c8325e1bc51ba633a8be537c2768dcd1aa3daf07",
|
|
52
|
+
"packages/content-api/src/url-safe-base64.ts": "6cd8aded7ab103b8a985287a1eae0cb5517270b7f86eb883bd08c3c81b7b7153",
|
|
53
|
+
"packages/content-api/src/url-validation.ts": "b75a5111eda2aa5715f82e53bd436ce61014f8db0ef16777bdcf570461848829",
|
|
54
|
+
"packages/content-api/src/utils.ts": "22caa3b9a028592fa68596670b517822c5b587f18cfb2f9a68e0108bbabe5e6d",
|
|
55
|
+
"packages/content-api/src/utils/atomic-write.ts": "5b35a2f67a157ac3671aae6efd7d1e3d58a248a20f23b632a8c489133c82f5a1",
|
|
56
|
+
"packages/content-api/src/vite-plugin.ts": "e36750648a21f8610f674e39b6ab06a665f1e74b1591d89b998a47e848c3f827",
|
|
57
|
+
"packages/content-api/src/vxjson-serialize.ts": "d197065d4f1dad44b55a6912ff755ddde451cd48b627ce97bdb1f08867696256",
|
|
58
|
+
"packages/content-api/src/vxjson.ts": "e63949bd7515346e3202a44e913a80e22176d9cc108b181f2426e74b4b91e20e",
|
|
59
|
+
"packages/content-api/src/xxhash.ts": "3e1f6eeffdfcfbd9c8a41852bc17c6f3d1b57b13f8a26584dea3acd24c268ae0",
|
|
60
|
+
"packages/content-api/tsconfig.lib.json": "9538cff14ec1227aa883c1f7c766169935d250ed6d707955197f693edd0e5a2d"
|
|
61
|
+
},
|
|
62
|
+
"complete": [
|
|
63
|
+
":(glob)packages/content-api/src/**/*.ts",
|
|
64
|
+
":(exclude,glob)packages/content-api/src/**/*.test.ts",
|
|
65
|
+
":(exclude,glob)packages/content-api/src/__tests__/**/*"
|
|
66
|
+
],
|
|
67
|
+
"producer": {
|
|
68
|
+
"project": "content-api",
|
|
69
|
+
"target": "tsc-js"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SitesConfig } from './types.js';
|
|
2
|
+
/** The inner site whose `domains` and `base` give a project its address: `default`, else the only site; null otherwise. */
|
|
3
|
+
export declare function addressSiteName(config: SitesConfig): string | null;
|
|
4
|
+
/** True when `base` is a path Astro can serve a site under: `/`-delimited plain segments, never `.` or `..`. */
|
|
5
|
+
export declare function isValidSiteBase(base: string): boolean;
|
|
6
|
+
//# sourceMappingURL=address-site.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-site.d.ts","sourceRoot":"","sources":["../src/address-site.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,2HAA2H;AAC3H,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAIlE;AAID,gHAAgH;AAChH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMrD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The inner site whose `domains` and `base` give a project its address: `default`, else the only site; null otherwise. */
|
|
2
|
+
export function addressSiteName(config) {
|
|
3
|
+
if (Object.hasOwn(config.sites, 'default'))
|
|
4
|
+
return 'default';
|
|
5
|
+
const names = Object.keys(config.sites);
|
|
6
|
+
return names.length === 1 ? (names[0] ?? null) : null;
|
|
7
|
+
}
|
|
8
|
+
const SITE_BASE = /^(\/[A-Za-z0-9._~-]+)*\/$/;
|
|
9
|
+
/** True when `base` is a path Astro can serve a site under: `/`-delimited plain segments, never `.` or `..`. */
|
|
10
|
+
export function isValidSiteBase(base) {
|
|
11
|
+
return (base.length <= 256 &&
|
|
12
|
+
SITE_BASE.test(base) &&
|
|
13
|
+
!base.split('/').some((segment) => segment === '.' || segment === '..'));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=address-site.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-site.js","sourceRoot":"","sources":["../src/address-site.ts"],"names":[],"mappings":"AAEA,2HAA2H;AAC3H,MAAM,UAAU,eAAe,CAAC,MAAmB;IACjD,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC;QAAE,OAAO,SAAS,CAAC;IAC7D,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACxD,CAAC;AAED,MAAM,SAAS,GAAG,2BAA2B,CAAC;AAE9C,gHAAgH;AAChH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,CACL,IAAI,CAAC,MAAM,IAAI,GAAG;QAClB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;QACpB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,IAAI,CAAC,CACxE,CAAC;AACJ,CAAC"}
|
|
@@ -2,6 +2,8 @@ import type { AssetEntry, AssetMetadataPatch, FolderListing, FolderTreeNode } fr
|
|
|
2
2
|
export interface AssetConfig {
|
|
3
3
|
assetsPath: string;
|
|
4
4
|
maxFileSize?: number;
|
|
5
|
+
/** Wall-clock budget for a URL import: every redirect hop plus reading the whole body */
|
|
6
|
+
importTimeoutMs?: number;
|
|
5
7
|
acceptedFormats?: string[];
|
|
6
8
|
/** The content root: it holds each asset's metadata record */
|
|
7
9
|
contentRoot: string;
|
|
@@ -69,8 +71,8 @@ export declare class AssetOperations {
|
|
|
69
71
|
}>;
|
|
70
72
|
/**
|
|
71
73
|
* Import an image from a URL (server-side fetch, no CORS issues)
|
|
72
|
-
* Validates the URL and every redirect hop against SSRF,
|
|
73
|
-
* and
|
|
74
|
+
* Validates the URL and every redirect hop against SSRF, and bounds the whole
|
|
75
|
+
* transfer — headers and body — by one time budget and the max file size.
|
|
74
76
|
*/
|
|
75
77
|
importFromUrl(url: string, metadata?: {
|
|
76
78
|
alt?: string;
|
|
@@ -142,6 +144,7 @@ export declare class AssetOperations {
|
|
|
142
144
|
} | {
|
|
143
145
|
success: false;
|
|
144
146
|
error: string;
|
|
147
|
+
moved?: number;
|
|
145
148
|
}>;
|
|
146
149
|
/**
|
|
147
150
|
* Get the complete folder tree with asset counts
|
|
@@ -149,4 +152,14 @@ export declare class AssetOperations {
|
|
|
149
152
|
*/
|
|
150
153
|
getFolderTree(): Promise<FolderTreeNode[]>;
|
|
151
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Asset moves and deletes in this process run one at a time: between claiming a destination
|
|
157
|
+
* and dropping its source, a move holds the asset at two paths, and a delete or second move
|
|
158
|
+
* acting on either path then could split bytes from metadata or remove the only copy.
|
|
159
|
+
* Module-wide because the router builds a fresh AssetOperations per request, and kept on
|
|
160
|
+
* globalThis (as the metadata store's locks are) because a dev server can load this module twice.
|
|
161
|
+
*/
|
|
162
|
+
declare global {
|
|
163
|
+
var conlocaAssetMoveQueue: Promise<unknown> | undefined;
|
|
164
|
+
}
|
|
152
165
|
//# sourceMappingURL=asset-operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-operations.d.ts","sourceRoot":"","sources":["../src/asset-operations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"asset-operations.d.ts","sourceRoot":"","sources":["../src/asset-operations.ts"],"names":[],"mappings":"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"}
|
package/dist/asset-operations.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createReadStream } from 'node:fs';
|
|
2
|
+
import { link, lstat, mkdir, open, readdir, readFile, stat, unlink, writeFile, } from 'node:fs/promises';
|
|
3
|
+
import { basename, dirname, extname, join, parse, resolve, sep } from 'node:path';
|
|
4
|
+
import { pipeline } from 'node:stream/promises';
|
|
3
5
|
import { imageSizeFromFile } from 'image-size/fromFile';
|
|
4
6
|
import { DEFAULT_ACCEPTED_FORMATS, DEFAULT_MAX_FILE_SIZE, IMAGE_EXTENSION_MIME } from './asset-constraints.js';
|
|
5
7
|
import * as assetMetadata from './asset-metadata-store.js';
|
|
@@ -11,6 +13,7 @@ const RECOGNIZED_IMAGE_EXTENSIONS = new Set(DEFAULT_ACCEPTED_FORMATS);
|
|
|
11
13
|
const SYSTEM_FILES = new Set(['.ds_store', 'thumbs.db', '.gitkeep', 'desktop.ini', '.asset-manifest.json']);
|
|
12
14
|
/** Max redirect hops a URL import may follow (each re-validated before it is requested) */
|
|
13
15
|
const MAX_IMPORT_REDIRECTS = 5;
|
|
16
|
+
const DEFAULT_IMPORT_TIMEOUT_MS = 30_000;
|
|
14
17
|
/** Check if filename has a recognized web image extension */
|
|
15
18
|
function isRecognizedImageExtension(filename) {
|
|
16
19
|
const ext = extname(filename).slice(1).toLowerCase();
|
|
@@ -35,6 +38,7 @@ export class AssetOperations {
|
|
|
35
38
|
this.config = {
|
|
36
39
|
assetsPath: config.assetsPath,
|
|
37
40
|
maxFileSize: config.maxFileSize ?? DEFAULT_MAX_FILE_SIZE,
|
|
41
|
+
importTimeoutMs: config.importTimeoutMs ?? DEFAULT_IMPORT_TIMEOUT_MS,
|
|
38
42
|
// Copy: the shared default is frozen, but AssetConfig stays a plain string[]
|
|
39
43
|
acceptedFormats: config.acceptedFormats ?? [...DEFAULT_ACCEPTED_FORMATS],
|
|
40
44
|
contentRoot: config.contentRoot,
|
|
@@ -305,20 +309,23 @@ export class AssetOperations {
|
|
|
305
309
|
return { success: false, error: err instanceof Error ? err.message : 'Failed to migrate asset metadata' };
|
|
306
310
|
}
|
|
307
311
|
const relativePath = folder === '/' ? filename : `${folder.slice(1)}/${filename}`;
|
|
308
|
-
//
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
312
|
+
// Queued with moves: a delete landing mid-move could otherwise remove the only copy
|
|
313
|
+
// between the move's destination check and its removal of the source.
|
|
314
|
+
await withMoveQueue(async () => {
|
|
315
|
+
try {
|
|
316
|
+
await unlink(assetPath);
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
// File may already be gone, continue with metadata cleanup
|
|
320
|
+
}
|
|
321
|
+
await assetMetadata.remove(this.config, relativePath);
|
|
322
|
+
});
|
|
316
323
|
return { success: true };
|
|
317
324
|
}
|
|
318
325
|
/**
|
|
319
326
|
* Import an image from a URL (server-side fetch, no CORS issues)
|
|
320
|
-
* Validates the URL and every redirect hop against SSRF,
|
|
321
|
-
* and
|
|
327
|
+
* Validates the URL and every redirect hop against SSRF, and bounds the whole
|
|
328
|
+
* transfer — headers and body — by one time budget and the max file size.
|
|
322
329
|
*/
|
|
323
330
|
async importFromUrl(url, metadata) {
|
|
324
331
|
// Validate URL: block private IPs and non-http(s) schemes
|
|
@@ -328,74 +335,115 @@ export class AssetOperations {
|
|
|
328
335
|
catch (err) {
|
|
329
336
|
return { success: false, error: err instanceof Error ? err.message : 'Invalid URL' };
|
|
330
337
|
}
|
|
331
|
-
//
|
|
332
|
-
//
|
|
333
|
-
//
|
|
334
|
-
//
|
|
338
|
+
// One wall-clock budget covers every hop AND the body read: a server that
|
|
339
|
+
// sends headers promptly and then trickles bytes must not hold the import
|
|
340
|
+
// open. Redirects are followed MANUALLY so every hop's target runs through
|
|
341
|
+
// the SSRF guard BEFORE it is requested — otherwise a public URL can
|
|
342
|
+
// redirect into a loopback or link-local (cloud metadata) address that the
|
|
343
|
+
// initial check would have rejected.
|
|
335
344
|
const controller = new AbortController();
|
|
336
|
-
const timeout = setTimeout(() => controller.abort(),
|
|
337
|
-
let response;
|
|
338
|
-
let current = url;
|
|
345
|
+
const timeout = setTimeout(() => controller.abort(), this.config.importTimeoutMs);
|
|
339
346
|
try {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
347
|
+
let response;
|
|
348
|
+
let current = url;
|
|
349
|
+
try {
|
|
350
|
+
for (let hop = 0; hop <= MAX_IMPORT_REDIRECTS; hop += 1) {
|
|
351
|
+
const hopResponse = await fetch(current, { signal: controller.signal, redirect: 'manual' });
|
|
352
|
+
if (hopResponse.status < 300 || hopResponse.status >= 400) {
|
|
353
|
+
response = hopResponse;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
// A redirect body is never read; release its connection now.
|
|
357
|
+
await hopResponse.body?.cancel().catch(() => { });
|
|
358
|
+
const location = hopResponse.headers.get('location');
|
|
359
|
+
if (location === null) {
|
|
360
|
+
return { success: false, error: 'Redirect missing Location header' };
|
|
361
|
+
}
|
|
362
|
+
try {
|
|
363
|
+
// A relative Location is legal and common; resolve it against the URL
|
|
364
|
+
// that produced it, then validate the absolute result.
|
|
365
|
+
current = validateFetchUrl(new URL(location, current).toString()).toString();
|
|
366
|
+
}
|
|
367
|
+
catch (err) {
|
|
368
|
+
return { success: false, error: `Redirect blocked: ${err instanceof Error ? err.message : 'Invalid URL'}` };
|
|
369
|
+
}
|
|
349
370
|
}
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
return { success: false, error: controller.signal.aborted ? 'URL import timed out' : 'Failed to fetch URL' };
|
|
374
|
+
}
|
|
375
|
+
// Budget exhausted without a final response — fail closed rather than
|
|
376
|
+
// treating the last redirect as content
|
|
377
|
+
if (!response) {
|
|
378
|
+
return { success: false, error: 'Too many redirects' };
|
|
379
|
+
}
|
|
380
|
+
const maxMB = Math.round(this.config.maxFileSize / (1024 * 1024));
|
|
381
|
+
const tooLarge = { success: false, error: `Remote file too large. Maximum: ${maxMB}MB` };
|
|
382
|
+
if (!response.ok) {
|
|
383
|
+
await response.body?.cancel().catch(() => { });
|
|
384
|
+
return { success: false, error: `Fetch failed with status ${response.status}` };
|
|
385
|
+
}
|
|
386
|
+
// Early size check from Content-Length header
|
|
387
|
+
const contentLength = response.headers.get('content-length');
|
|
388
|
+
if (contentLength && Number.parseInt(contentLength, 10) > this.config.maxFileSize) {
|
|
389
|
+
await response.body?.cancel().catch(() => { });
|
|
390
|
+
return tooLarge;
|
|
391
|
+
}
|
|
392
|
+
const contentType = response.headers.get('content-type') || '';
|
|
393
|
+
const lastSegment = new URL(url).pathname.split('/').pop() || 'imported-image.jpg';
|
|
394
|
+
let urlFilename = lastSegment;
|
|
395
|
+
try {
|
|
396
|
+
const decoded = decodeURIComponent(lastSegment);
|
|
397
|
+
if (!/\p{Cc}/u.test(decoded))
|
|
398
|
+
urlFilename = decoded.split(/[/\\]/).pop() || lastSegment;
|
|
399
|
+
}
|
|
400
|
+
catch {
|
|
401
|
+
// A malformed escape keeps the filename as written in the address.
|
|
402
|
+
}
|
|
403
|
+
// Stream the body, stopping the moment it passes the limit: Content-Length
|
|
404
|
+
// is optional and may lie, so it cannot be trusted to bound memory.
|
|
405
|
+
const chunks = [];
|
|
406
|
+
let received = 0;
|
|
407
|
+
if (response.body) {
|
|
408
|
+
const reader = response.body.getReader();
|
|
409
|
+
// A body that ignores the abort signal must still stop at the deadline.
|
|
410
|
+
const onAbort = () => void reader.cancel().catch(() => { });
|
|
411
|
+
controller.signal.addEventListener('abort', onAbort, { once: true });
|
|
350
412
|
try {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
413
|
+
while (true) {
|
|
414
|
+
const { done, value } = await reader.read();
|
|
415
|
+
if (controller.signal.aborted)
|
|
416
|
+
return { success: false, error: 'URL import timed out' };
|
|
417
|
+
if (done)
|
|
418
|
+
break;
|
|
419
|
+
received += value.byteLength;
|
|
420
|
+
if (received > this.config.maxFileSize) {
|
|
421
|
+
await reader.cancel().catch(() => { });
|
|
422
|
+
return tooLarge;
|
|
423
|
+
}
|
|
424
|
+
chunks.push(value);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
catch {
|
|
428
|
+
await reader.cancel().catch(() => { });
|
|
429
|
+
return { success: false, error: controller.signal.aborted ? 'URL import timed out' : 'Failed to fetch URL' };
|
|
354
430
|
}
|
|
355
|
-
|
|
356
|
-
|
|
431
|
+
finally {
|
|
432
|
+
controller.signal.removeEventListener('abort', onAbort);
|
|
357
433
|
}
|
|
358
434
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
435
|
+
const bytes = new Uint8Array(received);
|
|
436
|
+
let offset = 0;
|
|
437
|
+
for (const chunk of chunks) {
|
|
438
|
+
bytes.set(chunk, offset);
|
|
439
|
+
offset += chunk.byteLength;
|
|
440
|
+
}
|
|
441
|
+
const file = new File([bytes], urlFilename, { type: contentType });
|
|
442
|
+
return this.upload(file, metadata);
|
|
362
443
|
}
|
|
363
444
|
finally {
|
|
364
445
|
clearTimeout(timeout);
|
|
365
446
|
}
|
|
366
|
-
// Budget exhausted without a final response — fail closed rather than
|
|
367
|
-
// treating the last redirect as content
|
|
368
|
-
if (!response) {
|
|
369
|
-
return { success: false, error: 'Too many redirects' };
|
|
370
|
-
}
|
|
371
|
-
if (!response.ok) {
|
|
372
|
-
return { success: false, error: `Fetch failed with status ${response.status}` };
|
|
373
|
-
}
|
|
374
|
-
// Early size check from Content-Length header
|
|
375
|
-
const contentLength = response.headers.get('content-length');
|
|
376
|
-
if (contentLength && Number.parseInt(contentLength, 10) > this.config.maxFileSize) {
|
|
377
|
-
const maxMB = Math.round(this.config.maxFileSize / (1024 * 1024));
|
|
378
|
-
return { success: false, error: `Remote file too large. Maximum: ${maxMB}MB` };
|
|
379
|
-
}
|
|
380
|
-
const contentType = response.headers.get('content-type') || '';
|
|
381
|
-
const lastSegment = new URL(url).pathname.split('/').pop() || 'imported-image.jpg';
|
|
382
|
-
let urlFilename = lastSegment;
|
|
383
|
-
try {
|
|
384
|
-
const decoded = decodeURIComponent(lastSegment);
|
|
385
|
-
if (!/\p{Cc}/u.test(decoded))
|
|
386
|
-
urlFilename = decoded.split(/[/\\]/).pop() || lastSegment;
|
|
387
|
-
}
|
|
388
|
-
catch {
|
|
389
|
-
// A malformed escape keeps the filename as written in the address.
|
|
390
|
-
}
|
|
391
|
-
// Read response body and verify actual size
|
|
392
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
393
|
-
if (arrayBuffer.byteLength > this.config.maxFileSize) {
|
|
394
|
-
const maxMB = Math.round(this.config.maxFileSize / (1024 * 1024));
|
|
395
|
-
return { success: false, error: `Remote file too large. Maximum: ${maxMB}MB` };
|
|
396
|
-
}
|
|
397
|
-
const file = new File([new Uint8Array(arrayBuffer)], urlFilename, { type: contentType });
|
|
398
|
-
return this.upload(file, metadata);
|
|
399
447
|
}
|
|
400
448
|
/**
|
|
401
449
|
* List assets and subfolders within a folder (filesystem-first)
|
|
@@ -602,6 +650,7 @@ export class AssetOperations {
|
|
|
602
650
|
// Move each file with its own record, so one failure cannot take the rest
|
|
603
651
|
// of the folder's metadata with it
|
|
604
652
|
let moved = 0;
|
|
653
|
+
const failed = [];
|
|
605
654
|
for (const filename of filenames) {
|
|
606
655
|
const oldRelativePath = normalizedSource === '/' ? filename : `${normalizedSource.slice(1)}/${filename}`;
|
|
607
656
|
const newRelativePath = normalizedTarget === '/' ? filename : `${normalizedTarget.slice(1)}/${filename}`;
|
|
@@ -615,19 +664,21 @@ export class AssetOperations {
|
|
|
615
664
|
}
|
|
616
665
|
catch {
|
|
617
666
|
console.error(`[AssetOperations] Refusing to move ${filename}: it points outside the media library`);
|
|
667
|
+
failed.push(`${filename} (outside the media library)`);
|
|
618
668
|
continue;
|
|
619
669
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
670
|
+
// oxlint-disable-next-line no-await-in-loop -- each move settles before the next; partial failure stays attributable to one filename.
|
|
671
|
+
const outcome = await moveOneWithoutOverwrite(this.config, from, to, oldRelativePath, newRelativePath);
|
|
672
|
+
if (outcome === 'moved') {
|
|
673
|
+
moved += 1;
|
|
623
674
|
}
|
|
624
|
-
|
|
625
|
-
console.error(`[AssetOperations] Failed to move ${filename}
|
|
626
|
-
|
|
675
|
+
else {
|
|
676
|
+
console.error(`[AssetOperations] Failed to move ${filename}: ${outcome}`);
|
|
677
|
+
failed.push(`${filename} (${outcome})`);
|
|
627
678
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
moved
|
|
679
|
+
}
|
|
680
|
+
if (failed.length > 0) {
|
|
681
|
+
return { success: false, moved, error: `Could not move: ${failed.join(', ')}` };
|
|
631
682
|
}
|
|
632
683
|
return { success: true, moved };
|
|
633
684
|
}
|
|
@@ -696,4 +747,91 @@ export class AssetOperations {
|
|
|
696
747
|
];
|
|
697
748
|
}
|
|
698
749
|
}
|
|
750
|
+
function withMoveQueue(operation) {
|
|
751
|
+
const result = (globalThis.conlocaAssetMoveQueue ?? Promise.resolve()).then(operation, operation);
|
|
752
|
+
globalThis.conlocaAssetMoveQueue = result.catch(() => undefined);
|
|
753
|
+
return result;
|
|
754
|
+
}
|
|
755
|
+
function isErrnoException(error) {
|
|
756
|
+
return error instanceof Error && 'code' in error;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Move one asset file and its metadata record without ever replacing a file at the destination.
|
|
760
|
+
* The listing check in moveAssets reports ordinary clashes up front; this closes the window in
|
|
761
|
+
* which an upload or another move claims the name afterwards. A hard link (or, where the
|
|
762
|
+
* filesystem has none, an exclusive copy) claims the destination name atomically, and the source
|
|
763
|
+
* stays until the metadata has followed. Any failure undoes what was done, leaving bytes and
|
|
764
|
+
* metadata where they were. Returns 'moved' or the reason the file stayed.
|
|
765
|
+
*/
|
|
766
|
+
function moveOneWithoutOverwrite(roots, from, to, oldRelativePath, newRelativePath) {
|
|
767
|
+
return withMoveQueue(() => moveOneNow(roots, from, to, oldRelativePath, newRelativePath));
|
|
768
|
+
}
|
|
769
|
+
async function moveOneNow(roots, from, to, oldRelativePath, newRelativePath) {
|
|
770
|
+
// Names differing only in letter case are one file on macOS and Windows. Moves run one at a
|
|
771
|
+
// time, so this re-check sees every earlier move, including earlier files of the same batch.
|
|
772
|
+
const wanted = basename(to).toLowerCase();
|
|
773
|
+
if ((await readdir(dirname(to))).some((name) => name.toLowerCase() === wanted)) {
|
|
774
|
+
return 'already in the target folder';
|
|
775
|
+
}
|
|
776
|
+
try {
|
|
777
|
+
await link(from, to);
|
|
778
|
+
}
|
|
779
|
+
catch (err) {
|
|
780
|
+
const code = isErrnoException(err) ? err.code : undefined;
|
|
781
|
+
if (code === 'EEXIST')
|
|
782
|
+
return 'already in the target folder';
|
|
783
|
+
if (code !== 'EPERM' && code !== 'ENOTSUP' && code !== 'EOPNOTSUPP' && code !== 'EXDEV' && code !== 'EMLINK') {
|
|
784
|
+
return err instanceof Error ? err.message : 'move failed';
|
|
785
|
+
}
|
|
786
|
+
// No hard links here: claim the name with an exclusive create first, so a failed copy
|
|
787
|
+
// only ever removes the file this move created, never one another request put there.
|
|
788
|
+
let claimed;
|
|
789
|
+
try {
|
|
790
|
+
claimed = await open(to, 'wx');
|
|
791
|
+
}
|
|
792
|
+
catch (openErr) {
|
|
793
|
+
if (isErrnoException(openErr) && openErr.code === 'EEXIST')
|
|
794
|
+
return 'already in the target folder';
|
|
795
|
+
return openErr instanceof Error ? openErr.message : 'move failed';
|
|
796
|
+
}
|
|
797
|
+
let copyError;
|
|
798
|
+
try {
|
|
799
|
+
// Streamed: an asset placed outside the upload route may be far larger than an upload.
|
|
800
|
+
await pipeline(createReadStream(from), claimed.createWriteStream({ autoClose: false }));
|
|
801
|
+
}
|
|
802
|
+
catch (pipelineErr) {
|
|
803
|
+
copyError = pipelineErr;
|
|
804
|
+
}
|
|
805
|
+
finally {
|
|
806
|
+
await claimed.close().catch(() => undefined);
|
|
807
|
+
}
|
|
808
|
+
if (copyError !== undefined) {
|
|
809
|
+
// Closed first: some platforms refuse to remove a file that is still open.
|
|
810
|
+
await unlink(to).catch(() => undefined);
|
|
811
|
+
return copyError instanceof Error ? copyError.message : 'move failed';
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
try {
|
|
815
|
+
await assetMetadata.move(roots, oldRelativePath, newRelativePath);
|
|
816
|
+
}
|
|
817
|
+
catch (err) {
|
|
818
|
+
await unlink(to).catch(() => undefined);
|
|
819
|
+
return err instanceof Error ? err.message : 'metadata move failed';
|
|
820
|
+
}
|
|
821
|
+
// A delete aimed at the new path may have removed it meanwhile; dropping the source now
|
|
822
|
+
// would lose the only copy, so keep the source and put its metadata back.
|
|
823
|
+
if (!(await lstat(to).then((s) => s.isFile(), () => false))) {
|
|
824
|
+
await assetMetadata.move(roots, newRelativePath, oldRelativePath).catch(() => undefined);
|
|
825
|
+
return 'removed from the target folder during the move';
|
|
826
|
+
}
|
|
827
|
+
try {
|
|
828
|
+
await unlink(from);
|
|
829
|
+
}
|
|
830
|
+
catch (err) {
|
|
831
|
+
await assetMetadata.move(roots, newRelativePath, oldRelativePath).catch(() => undefined);
|
|
832
|
+
await unlink(to).catch(() => undefined);
|
|
833
|
+
return err instanceof Error ? err.message : 'move failed';
|
|
834
|
+
}
|
|
835
|
+
return 'moved';
|
|
836
|
+
}
|
|
699
837
|
//# sourceMappingURL=asset-operations.js.map
|