@nocobase/plugin-file-manager 2.2.0-beta.13 → 2.2.0-beta.15
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/client/index.js +1 -1
- package/dist/client-v2/125.9cdb7cf3ef4712ef.js +10 -0
- package/dist/client-v2/450.d49b00f3c0388c74.js +10 -0
- package/dist/client-v2/index.d.ts +1 -1
- package/dist/client-v2/index.js +1 -1
- package/dist/client-v2/models/DisplayPreviewFieldModel.d.ts +22 -0
- package/dist/client-v2/models/UploadActionModel.d.ts +26 -0
- package/dist/client-v2/previewer/filePreviewTypes.d.ts +15 -1
- package/dist/externalVersion.js +12 -9
- package/dist/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +59 -116
- package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
- package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/index.js +59 -116
- package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -1
- package/dist/node_modules/@aws-sdk/s3-request-presigner/LICENSE +201 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/index.js +11113 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-es/constants.js +9 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-es/getSignedUrl.js +66 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-es/index.js +2 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-es/presigner.js +58 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-types/constants.d.ts +9 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-types/getSignedUrl.d.ts +6 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-types/index.d.ts +2 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-types/presigner.d.ts +15 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-types/ts3.4/constants.d.ts +9 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-types/ts3.4/getSignedUrl.d.ts +11 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-types/ts3.4/index.d.ts +2 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/dist-types/ts3.4/presigner.d.ts +40 -0
- package/dist/node_modules/@aws-sdk/s3-request-presigner/package.json +1 -0
- package/dist/node_modules/ali-oss/package.json +1 -1
- package/dist/node_modules/cos-nodejs-sdk-v5/package.json +1 -1
- package/dist/node_modules/mime-match/package.json +1 -1
- package/dist/node_modules/mime-types/package.json +1 -1
- package/dist/node_modules/mkdirp/package.json +1 -1
- package/dist/node_modules/url-join/package.json +1 -1
- package/dist/server/actions/get-file.d.ts +13 -0
- package/dist/server/actions/get-file.js +133 -0
- package/dist/server/actions/index.d.ts +1 -3
- package/dist/server/actions/index.js +8 -1
- package/dist/server/commands/repair-filenames.js +34 -14
- package/dist/server/file-access.d.ts +11 -0
- package/dist/server/file-access.js +134 -0
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +7 -1
- package/dist/server/resolve-file-access-filter.d.ts +11 -0
- package/dist/server/resolve-file-access-filter.js +63 -0
- package/dist/server/server.d.ts +23 -2
- package/dist/server/server.js +102 -10
- package/dist/server/storages/ali-oss.d.ts +2 -1
- package/dist/server/storages/ali-oss.js +12 -0
- package/dist/server/storages/index.d.ts +15 -2
- package/dist/server/storages/index.js +28 -5
- package/dist/server/storages/local.d.ts +2 -2
- package/dist/server/storages/local.js +9 -3
- package/dist/server/storages/s3.d.ts +2 -1
- package/dist/server/storages/s3.js +14 -0
- package/dist/server/storages/tx-cos.d.ts +2 -1
- package/dist/server/storages/tx-cos.js +27 -0
- package/dist/server/temporary-access.d.ts +31 -0
- package/dist/server/temporary-access.js +169 -0
- package/dist/server/utils.d.ts +27 -0
- package/dist/server/utils.js +83 -2
- package/package.json +5 -3
- package/dist/client-v2/125.0b8eef1f19b87042.js +0 -10
- package/dist/client-v2/450.c060947ac34d26e1.js +0 -10
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const UNSIGNED_PAYLOAD = "UNSIGNED-PAYLOAD";
|
|
2
|
+
export const SHA256_HEADER = "X-Amz-Content-Sha256";
|
|
3
|
+
export const ALGORITHM_QUERY_PARAM = "X-Amz-Algorithm";
|
|
4
|
+
export const CREDENTIAL_QUERY_PARAM = "X-Amz-Credential";
|
|
5
|
+
export const AMZ_DATE_QUERY_PARAM = "X-Amz-Date";
|
|
6
|
+
export const SIGNED_HEADERS_QUERY_PARAM = "X-Amz-SignedHeaders";
|
|
7
|
+
export const EXPIRES_QUERY_PARAM = "X-Amz-Expires";
|
|
8
|
+
export const HOST_HEADER = "host";
|
|
9
|
+
export const ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { formatUrl } from "@aws-sdk/util-format-url";
|
|
2
|
+
import { getEndpointFromInstructions } from "@smithy/middleware-endpoint";
|
|
3
|
+
import { HttpRequest } from "@smithy/protocol-http";
|
|
4
|
+
import { S3RequestPresigner } from "./presigner";
|
|
5
|
+
export const getSignedUrl = async (client, command, options = {}) => {
|
|
6
|
+
let s3Presigner;
|
|
7
|
+
let region;
|
|
8
|
+
if (typeof client.config.endpointProvider === "function") {
|
|
9
|
+
const endpointV2 = await getEndpointFromInstructions(command.input, command.constructor, client.config);
|
|
10
|
+
const authScheme = endpointV2.properties?.authSchemes?.[0];
|
|
11
|
+
if (authScheme?.name === "sigv4a") {
|
|
12
|
+
region = authScheme?.signingRegionSet?.join(",");
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
region = authScheme?.signingRegion;
|
|
16
|
+
}
|
|
17
|
+
s3Presigner = new S3RequestPresigner({
|
|
18
|
+
...client.config,
|
|
19
|
+
signingName: authScheme?.signingName,
|
|
20
|
+
region: async () => region,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
s3Presigner = new S3RequestPresigner(client.config);
|
|
25
|
+
}
|
|
26
|
+
const presignInterceptMiddleware = (next, context) => async (args) => {
|
|
27
|
+
const { request } = args;
|
|
28
|
+
if (!HttpRequest.isInstance(request)) {
|
|
29
|
+
throw new Error("Request to be presigned is not an valid HTTP request.");
|
|
30
|
+
}
|
|
31
|
+
delete request.headers["amz-sdk-invocation-id"];
|
|
32
|
+
delete request.headers["amz-sdk-request"];
|
|
33
|
+
delete request.headers["x-amz-user-agent"];
|
|
34
|
+
let presigned;
|
|
35
|
+
const presignerOptions = {
|
|
36
|
+
...options,
|
|
37
|
+
signingRegion: options.signingRegion ?? context["signing_region"] ?? region,
|
|
38
|
+
signingService: options.signingService ?? context["signing_service"],
|
|
39
|
+
};
|
|
40
|
+
if (context.s3ExpressIdentity) {
|
|
41
|
+
presigned = await s3Presigner.presignWithCredentials(request, context.s3ExpressIdentity, presignerOptions);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
presigned = await s3Presigner.presign(request, presignerOptions);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
response: {},
|
|
48
|
+
output: {
|
|
49
|
+
$metadata: { httpStatusCode: 200 },
|
|
50
|
+
presigned,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
const middlewareName = "presignInterceptMiddleware";
|
|
55
|
+
const clientStack = client.middlewareStack.clone();
|
|
56
|
+
clientStack.addRelativeTo(presignInterceptMiddleware, {
|
|
57
|
+
name: middlewareName,
|
|
58
|
+
relation: "before",
|
|
59
|
+
toMiddleware: "awsAuthMiddleware",
|
|
60
|
+
override: true,
|
|
61
|
+
});
|
|
62
|
+
const handler = command.resolveMiddleware(clientStack, client.config, {});
|
|
63
|
+
const { output } = await handler({ input: command.input });
|
|
64
|
+
const { presigned } = output;
|
|
65
|
+
return formatUrl(presigned);
|
|
66
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { SignatureV4MultiRegion } from "@aws-sdk/signature-v4-multi-region";
|
|
2
|
+
import { SHA256_HEADER, UNSIGNED_PAYLOAD } from "./constants";
|
|
3
|
+
export class S3RequestPresigner {
|
|
4
|
+
signer;
|
|
5
|
+
constructor(options) {
|
|
6
|
+
const resolvedOptions = {
|
|
7
|
+
service: options.signingName || options.service || "s3",
|
|
8
|
+
uriEscapePath: options.uriEscapePath || false,
|
|
9
|
+
applyChecksum: options.applyChecksum || false,
|
|
10
|
+
...options,
|
|
11
|
+
};
|
|
12
|
+
this.signer = new SignatureV4MultiRegion(resolvedOptions);
|
|
13
|
+
}
|
|
14
|
+
presign(requestToSign, { unsignableHeaders = new Set(), hoistableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) {
|
|
15
|
+
this.prepareRequest(requestToSign, {
|
|
16
|
+
unsignableHeaders,
|
|
17
|
+
unhoistableHeaders,
|
|
18
|
+
hoistableHeaders,
|
|
19
|
+
});
|
|
20
|
+
return this.signer.presign(requestToSign, {
|
|
21
|
+
expiresIn: 900,
|
|
22
|
+
unsignableHeaders,
|
|
23
|
+
unhoistableHeaders,
|
|
24
|
+
...options,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
presignWithCredentials(requestToSign, credentials, { unsignableHeaders = new Set(), hoistableHeaders = new Set(), unhoistableHeaders = new Set(), ...options } = {}) {
|
|
28
|
+
this.prepareRequest(requestToSign, {
|
|
29
|
+
unsignableHeaders,
|
|
30
|
+
unhoistableHeaders,
|
|
31
|
+
hoistableHeaders,
|
|
32
|
+
});
|
|
33
|
+
return this.signer.presignWithCredentials(requestToSign, credentials, {
|
|
34
|
+
expiresIn: 900,
|
|
35
|
+
unsignableHeaders,
|
|
36
|
+
unhoistableHeaders,
|
|
37
|
+
...options,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
prepareRequest(requestToSign, { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), hoistableHeaders = new Set(), } = {}) {
|
|
41
|
+
unsignableHeaders.add("content-type");
|
|
42
|
+
Object.keys(requestToSign.headers)
|
|
43
|
+
.map((header) => header.toLowerCase())
|
|
44
|
+
.filter((header) => header.startsWith("x-amz-server-side-encryption"))
|
|
45
|
+
.forEach((header) => {
|
|
46
|
+
if (!hoistableHeaders.has(header)) {
|
|
47
|
+
unhoistableHeaders.add(header);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
requestToSign.headers[SHA256_HEADER] = UNSIGNED_PAYLOAD;
|
|
51
|
+
const currentHostHeader = requestToSign.headers.host;
|
|
52
|
+
const port = requestToSign.port;
|
|
53
|
+
const expectedHostHeader = `${requestToSign.hostname}${requestToSign.port != null ? ":" + port : ""}`;
|
|
54
|
+
if (!currentHostHeader || (currentHostHeader === requestToSign.hostname && requestToSign.port != null)) {
|
|
55
|
+
requestToSign.headers.host = expectedHostHeader;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const UNSIGNED_PAYLOAD = "UNSIGNED-PAYLOAD";
|
|
2
|
+
export declare const SHA256_HEADER = "X-Amz-Content-Sha256";
|
|
3
|
+
export declare const ALGORITHM_QUERY_PARAM = "X-Amz-Algorithm";
|
|
4
|
+
export declare const CREDENTIAL_QUERY_PARAM = "X-Amz-Credential";
|
|
5
|
+
export declare const AMZ_DATE_QUERY_PARAM = "X-Amz-Date";
|
|
6
|
+
export declare const SIGNED_HEADERS_QUERY_PARAM = "X-Amz-SignedHeaders";
|
|
7
|
+
export declare const EXPIRES_QUERY_PARAM = "X-Amz-Expires";
|
|
8
|
+
export declare const HOST_HEADER = "host";
|
|
9
|
+
export declare const ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Client, Command } from "@smithy/smithy-client";
|
|
2
|
+
import { MetadataBearer, RequestPresigningArguments } from "@smithy/types";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare const getSignedUrl: <InputTypesUnion extends object, InputType extends InputTypesUnion, OutputType extends MetadataBearer = MetadataBearer>(client: Client<any, InputTypesUnion, MetadataBearer, any>, command: Command<InputType, OutputType, any, InputTypesUnion, MetadataBearer>, options?: RequestPresigningArguments) => Promise<string>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SignatureV4MultiRegionInit } from "@aws-sdk/signature-v4-multi-region";
|
|
2
|
+
import { AwsCredentialIdentity, RequestPresigner, RequestPresigningArguments } from "@smithy/types";
|
|
3
|
+
import { HttpRequest as IHttpRequest } from "@smithy/types";
|
|
4
|
+
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
5
|
+
export type S3RequestPresignerOptions = PartialBy<SignatureV4MultiRegionInit, "service" | "uriEscapePath"> & {
|
|
6
|
+
signingName?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class S3RequestPresigner implements RequestPresigner {
|
|
9
|
+
private readonly signer;
|
|
10
|
+
constructor(options: S3RequestPresignerOptions);
|
|
11
|
+
presign(requestToSign: IHttpRequest, { unsignableHeaders, hoistableHeaders, unhoistableHeaders, ...options }?: RequestPresigningArguments): Promise<IHttpRequest>;
|
|
12
|
+
presignWithCredentials(requestToSign: IHttpRequest, credentials: AwsCredentialIdentity, { unsignableHeaders, hoistableHeaders, unhoistableHeaders, ...options }?: RequestPresigningArguments): Promise<IHttpRequest>;
|
|
13
|
+
private prepareRequest;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const UNSIGNED_PAYLOAD = "UNSIGNED-PAYLOAD";
|
|
2
|
+
export declare const SHA256_HEADER = "X-Amz-Content-Sha256";
|
|
3
|
+
export declare const ALGORITHM_QUERY_PARAM = "X-Amz-Algorithm";
|
|
4
|
+
export declare const CREDENTIAL_QUERY_PARAM = "X-Amz-Credential";
|
|
5
|
+
export declare const AMZ_DATE_QUERY_PARAM = "X-Amz-Date";
|
|
6
|
+
export declare const SIGNED_HEADERS_QUERY_PARAM = "X-Amz-SignedHeaders";
|
|
7
|
+
export declare const EXPIRES_QUERY_PARAM = "X-Amz-Expires";
|
|
8
|
+
export declare const HOST_HEADER = "host";
|
|
9
|
+
export declare const ALGORITHM_IDENTIFIER = "AWS4-HMAC-SHA256";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Client, Command } from "@smithy/smithy-client";
|
|
2
|
+
import { MetadataBearer, RequestPresigningArguments } from "@smithy/types";
|
|
3
|
+
export declare const getSignedUrl: <
|
|
4
|
+
InputTypesUnion extends object,
|
|
5
|
+
InputType extends InputTypesUnion,
|
|
6
|
+
OutputType extends MetadataBearer = MetadataBearer
|
|
7
|
+
>(
|
|
8
|
+
client: Client<any, InputTypesUnion, MetadataBearer, any>,
|
|
9
|
+
command: Command<InputType, OutputType, any, InputTypesUnion, MetadataBearer>,
|
|
10
|
+
options?: RequestPresigningArguments
|
|
11
|
+
) => Promise<string>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SignatureV4MultiRegionInit } from "@aws-sdk/signature-v4-multi-region";
|
|
2
|
+
import {
|
|
3
|
+
AwsCredentialIdentity,
|
|
4
|
+
RequestPresigner,
|
|
5
|
+
RequestPresigningArguments,
|
|
6
|
+
} from "@smithy/types";
|
|
7
|
+
import { HttpRequest as IHttpRequest } from "@smithy/types";
|
|
8
|
+
type PartialBy<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> &
|
|
9
|
+
Partial<Pick<T, K>>;
|
|
10
|
+
export type S3RequestPresignerOptions = PartialBy<
|
|
11
|
+
SignatureV4MultiRegionInit,
|
|
12
|
+
"service" | "uriEscapePath"
|
|
13
|
+
> & {
|
|
14
|
+
signingName?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare class S3RequestPresigner implements RequestPresigner {
|
|
17
|
+
private readonly signer;
|
|
18
|
+
constructor(options: S3RequestPresignerOptions);
|
|
19
|
+
presign(
|
|
20
|
+
requestToSign: IHttpRequest,
|
|
21
|
+
{
|
|
22
|
+
unsignableHeaders,
|
|
23
|
+
hoistableHeaders,
|
|
24
|
+
unhoistableHeaders,
|
|
25
|
+
...options
|
|
26
|
+
}?: RequestPresigningArguments
|
|
27
|
+
): Promise<IHttpRequest>;
|
|
28
|
+
presignWithCredentials(
|
|
29
|
+
requestToSign: IHttpRequest,
|
|
30
|
+
credentials: AwsCredentialIdentity,
|
|
31
|
+
{
|
|
32
|
+
unsignableHeaders,
|
|
33
|
+
hoistableHeaders,
|
|
34
|
+
unhoistableHeaders,
|
|
35
|
+
...options
|
|
36
|
+
}?: RequestPresigningArguments
|
|
37
|
+
): Promise<IHttpRequest>;
|
|
38
|
+
private prepareRequest;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@aws-sdk/s3-request-presigner","version":"3.750.0","scripts":{"build":"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'","build:cjs":"node ../../scripts/compilation/inline s3-request-presigner","build:es":"tsc -p tsconfig.es.json","build:include:deps":"lerna run --scope $npm_package_name --include-dependencies build","build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4","clean":"rimraf ./dist-* && rimraf *.tsbuildinfo","extract:docs":"api-extractor run --local","test":"yarn g:vitest run","test:watch":"yarn g:vitest watch"},"main":"./dist-cjs/index.js","module":"./dist-es/index.js","types":"./dist-types/index.d.ts","author":{"name":"AWS SDK for JavaScript Team","url":"https://aws.amazon.com/javascript/"},"license":"Apache-2.0","dependencies":{"@aws-sdk/signature-v4-multi-region":"3.750.0","@aws-sdk/types":"3.734.0","@aws-sdk/util-format-url":"3.734.0","@smithy/middleware-endpoint":"^4.0.5","@smithy/protocol-http":"^5.0.1","@smithy/smithy-client":"^4.1.5","@smithy/types":"^4.1.0","tslib":"^2.6.2"},"devDependencies":{"@aws-sdk/client-s3":"3.750.0","@smithy/hash-node":"^4.0.1","@tsconfig/recommended":"1.0.1","@types/node":"^18.19.69","concurrently":"7.0.0","downlevel-dts":"0.10.1","rimraf":"3.0.2","typescript":"~5.2.2"},"engines":{"node":">=18.0.0"},"typesVersions":{"<4.0":{"dist-types/*":["dist-types/ts3.4/*"]}},"files":["dist-*/**"],"homepage":"https://github.com/aws/aws-sdk-js-v3/tree/main/packages/s3-request-presigner","repository":{"type":"git","url":"https://github.com/aws/aws-sdk-js-v3.git","directory":"packages/s3-request-presigner"},"_lastModified":"2026-07-16T13:28:39.122Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"ali-oss","version":"6.20.0","description":"aliyun oss(object storage service) node client","main":"./lib/client.js","files":["lib","shims","dist"],"browser":{"./lib/client.js":"./dist/aliyun-oss-sdk.js","mime":"mime/lite","urllib":"./shims/xhr.js","utility":"./shims/utility.js","crypto":"./shims/crypto/crypto.js","debug":"./shims/debug","fs":false,"child_process":false,"is-type-of":"./shims/is-type-of.js"},"scripts":{"build-change-log":"standard-version","test":"npm run tsc && mocha -t 120000 -r should -r dotenv/config test/node/*.test.js test/node/**/*.test.js","test-cov":"npm run tsc && nyc --reporter=lcov node_modules/.bin/_mocha -t 120000 -r should test/node/*.test.js test/node/**/*.test.js","jshint":"jshint .","build-test":"MINIFY=1 node browser-build.js > test/browser/build/aliyun-oss-sdk.min.js && node -r dotenv/config task/browser-test-build.js > test/browser/build/tests.js","browser-test":"npm run build-test && karma start","build-dist":"npm run tsc && node browser-build.js > dist/aliyun-oss-sdk.js && MINIFY=1 node browser-build.js > dist/aliyun-oss-sdk.min.js","publish-to-npm":"node publish-npm-check.js && npm publish","publish-to-cdn":"node publish.js","snyk-protect":"snyk-protect","lint-staged":"lint-staged","detect-secrets":"node task/detect-secrets","tsc":"npm run tsc:clean && npm run tsc:build","tsc:build":"tsc -b tsconfig.json tsconfig-cjs.json","tsc:watch":"tsc -b tsconfig.json tsconfig-cjs.json --watch","tsc:clean":"tsc -b tsconfig.json tsconfig-cjs.json --clean ","prepare":"husky install"},"git-pre-hooks":{"pre-release":"npm run build-dist","post-release":["npm run publish-to-npm","npm run publish-to-cdn"]},"homepage":"https://github.com/ali-sdk/ali-oss","bugs":{"url":"https://github.com/ali-sdk/ali-oss/issues"},"publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"},"repository":{"type":"git","url":"https://github.com/ali-sdk/ali-oss.git"},"keywords":["oss","client","file","aliyun"],"author":"dead_horse","license":"MIT","engines":{"node":">=8"},"devDependencies":{"@babel/core":"^7.11.6","@babel/plugin-transform-regenerator":"^7.10.4","@babel/plugin-transform-runtime":"^7.11.5","@babel/preset-env":"^7.11.5","@babel/runtime":"^7.11.2","@commitlint/cli":"^17.6.7","@commitlint/config-conventional":"^16.2.4","@octokit/core":"^5.0.0","@semantic-release/exec":"^6.0.3","@semantic-release/git":"^10.0.1","@semantic-release/npm":"^10.0.5","@snyk/protect":"^1.1196.0","@types/node":"^14.0.12","@typescript-eslint/eslint-plugin":"^5.0.0","@typescript-eslint/parser":"^5.0.0","aliasify":"^2.0.0","axios":"0.27.2","babelify":"^10.0.0","beautify-benchmark":"^0.2.4","benchmark":"^2.1.1","bluebird":"^3.1.5","browserify":"^17.0.0","core-js":"^3.6.5","crypto-js":"^3.1.9-1","dotenv":"^8.2.0","eslint":"^8.44.0","eslint-config-airbnb":"^19.0.4","eslint-config-ali":"^13.0.0","eslint-config-prettier":"^8.8.0","eslint-plugin-import":"^2.21.1","eslint-plugin-jsx-a11y":"^6.0.3","eslint-plugin-prettier":"^4.2.1","filereader":"^0.10.3","form-data":"^4.0.0","git-pre-hooks":"^1.2.0","husky":"^7.0.4","immediate":"^3.3.0","karma":"^6.3.4","karma-browserify":"^8.1.0","karma-chrome-launcher":"^2.2.0","karma-firefox-launcher":"^1.0.1","karma-ie-launcher":"^1.0.0","karma-mocha":"^2.0.1","karma-safari-launcher":"^1.0.0","lint-staged":"^12.4.1","mm":"^2.0.0","mocha":"^9.1.2","nyc":"^15.1.0","prettier":"^3.0.0","promise-polyfill":"^6.0.2","puppeteer":"19.0.0","semantic-release":"^21.1.1","should":"^11.0.0","sinon":"^15.2.0","standard-version":"^9.3.1","stream-equal":"^1.1.0","timemachine":"^0.3.0","typescript":"^3.9.5","uglify-js":"^3.14.2","watchify":"^4.0.0"},"dependencies":{"address":"^1.2.2","agentkeepalive":"^3.4.1","bowser":"^1.6.0","copy-to":"^2.0.1","dateformat":"^2.0.0","debug":"^4.3.4","destroy":"^1.0.4","end-or-error":"^1.0.1","get-ready":"^1.0.0","humanize-ms":"^1.2.0","is-type-of":"^1.4.0","js-base64":"^2.5.2","jstoxml":"^2.0.0","lodash":"^4.17.21","merge-descriptors":"^1.0.1","mime":"^2.4.5","platform":"^1.3.1","pump":"^3.0.0","qs":"^6.4.0","sdk-base":"^2.0.1","stream-http":"2.8.2","stream-wormhole":"^1.0.4","urllib":"2.41.0","utility":"^1.18.0","xml2js":"^0.6.2"},"snyk":true,"lint-staged":{"**/!(dist)/*":["npm run detect-secrets --"],"**/*.{js,ts}":["eslint --cache --fix --ext .js,.ts","prettier --write","git add"]},"_lastModified":"2026-07-
|
|
1
|
+
{"name":"ali-oss","version":"6.20.0","description":"aliyun oss(object storage service) node client","main":"./lib/client.js","files":["lib","shims","dist"],"browser":{"./lib/client.js":"./dist/aliyun-oss-sdk.js","mime":"mime/lite","urllib":"./shims/xhr.js","utility":"./shims/utility.js","crypto":"./shims/crypto/crypto.js","debug":"./shims/debug","fs":false,"child_process":false,"is-type-of":"./shims/is-type-of.js"},"scripts":{"build-change-log":"standard-version","test":"npm run tsc && mocha -t 120000 -r should -r dotenv/config test/node/*.test.js test/node/**/*.test.js","test-cov":"npm run tsc && nyc --reporter=lcov node_modules/.bin/_mocha -t 120000 -r should test/node/*.test.js test/node/**/*.test.js","jshint":"jshint .","build-test":"MINIFY=1 node browser-build.js > test/browser/build/aliyun-oss-sdk.min.js && node -r dotenv/config task/browser-test-build.js > test/browser/build/tests.js","browser-test":"npm run build-test && karma start","build-dist":"npm run tsc && node browser-build.js > dist/aliyun-oss-sdk.js && MINIFY=1 node browser-build.js > dist/aliyun-oss-sdk.min.js","publish-to-npm":"node publish-npm-check.js && npm publish","publish-to-cdn":"node publish.js","snyk-protect":"snyk-protect","lint-staged":"lint-staged","detect-secrets":"node task/detect-secrets","tsc":"npm run tsc:clean && npm run tsc:build","tsc:build":"tsc -b tsconfig.json tsconfig-cjs.json","tsc:watch":"tsc -b tsconfig.json tsconfig-cjs.json --watch","tsc:clean":"tsc -b tsconfig.json tsconfig-cjs.json --clean ","prepare":"husky install"},"git-pre-hooks":{"pre-release":"npm run build-dist","post-release":["npm run publish-to-npm","npm run publish-to-cdn"]},"homepage":"https://github.com/ali-sdk/ali-oss","bugs":{"url":"https://github.com/ali-sdk/ali-oss/issues"},"publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"},"repository":{"type":"git","url":"https://github.com/ali-sdk/ali-oss.git"},"keywords":["oss","client","file","aliyun"],"author":"dead_horse","license":"MIT","engines":{"node":">=8"},"devDependencies":{"@babel/core":"^7.11.6","@babel/plugin-transform-regenerator":"^7.10.4","@babel/plugin-transform-runtime":"^7.11.5","@babel/preset-env":"^7.11.5","@babel/runtime":"^7.11.2","@commitlint/cli":"^17.6.7","@commitlint/config-conventional":"^16.2.4","@octokit/core":"^5.0.0","@semantic-release/exec":"^6.0.3","@semantic-release/git":"^10.0.1","@semantic-release/npm":"^10.0.5","@snyk/protect":"^1.1196.0","@types/node":"^14.0.12","@typescript-eslint/eslint-plugin":"^5.0.0","@typescript-eslint/parser":"^5.0.0","aliasify":"^2.0.0","axios":"0.27.2","babelify":"^10.0.0","beautify-benchmark":"^0.2.4","benchmark":"^2.1.1","bluebird":"^3.1.5","browserify":"^17.0.0","core-js":"^3.6.5","crypto-js":"^3.1.9-1","dotenv":"^8.2.0","eslint":"^8.44.0","eslint-config-airbnb":"^19.0.4","eslint-config-ali":"^13.0.0","eslint-config-prettier":"^8.8.0","eslint-plugin-import":"^2.21.1","eslint-plugin-jsx-a11y":"^6.0.3","eslint-plugin-prettier":"^4.2.1","filereader":"^0.10.3","form-data":"^4.0.0","git-pre-hooks":"^1.2.0","husky":"^7.0.4","immediate":"^3.3.0","karma":"^6.3.4","karma-browserify":"^8.1.0","karma-chrome-launcher":"^2.2.0","karma-firefox-launcher":"^1.0.1","karma-ie-launcher":"^1.0.0","karma-mocha":"^2.0.1","karma-safari-launcher":"^1.0.0","lint-staged":"^12.4.1","mm":"^2.0.0","mocha":"^9.1.2","nyc":"^15.1.0","prettier":"^3.0.0","promise-polyfill":"^6.0.2","puppeteer":"19.0.0","semantic-release":"^21.1.1","should":"^11.0.0","sinon":"^15.2.0","standard-version":"^9.3.1","stream-equal":"^1.1.0","timemachine":"^0.3.0","typescript":"^3.9.5","uglify-js":"^3.14.2","watchify":"^4.0.0"},"dependencies":{"address":"^1.2.2","agentkeepalive":"^3.4.1","bowser":"^1.6.0","copy-to":"^2.0.1","dateformat":"^2.0.0","debug":"^4.3.4","destroy":"^1.0.4","end-or-error":"^1.0.1","get-ready":"^1.0.0","humanize-ms":"^1.2.0","is-type-of":"^1.4.0","js-base64":"^2.5.2","jstoxml":"^2.0.0","lodash":"^4.17.21","merge-descriptors":"^1.0.1","mime":"^2.4.5","platform":"^1.3.1","pump":"^3.0.0","qs":"^6.4.0","sdk-base":"^2.0.1","stream-http":"2.8.2","stream-wormhole":"^1.0.4","urllib":"2.41.0","utility":"^1.18.0","xml2js":"^0.6.2"},"snyk":true,"lint-staged":{"**/!(dist)/*":["npm run detect-secrets --"],"**/*.{js,ts}":["eslint --cache --fix --ext .js,.ts","prettier --write","git add"]},"_lastModified":"2026-07-16T13:28:35.838Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"cos-nodejs-sdk-v5","version":"2.12.6","description":"cos nodejs sdk v5","main":"index.js","types":"index.d.ts","scripts":{"prettier":"prettier --write sdk demo/demo.js test/test.js index.d.ts","demo":"node demo/demo.js","demo-sts":"node demo/demo-sts.js","demo-sts-scope":"node demo/demo-sts-scope.js","test":"mocha test/test.js","cov":"istanbul cover _mocha -- -u exports 'test/test.js'","nyc":"nyc --reporter=clover --reporter=cobertura mocha --reporter xunit --reporter-options output=mocha.xml test/test.js","csp":"mocha test/csp.js"},"repository":{"type":"git","url":"git+https://github.com/tencentyun/cos-nodejs-sdk-v5.git"},"keywords":["tencent","tencent cloud","qcloud","cos","cos-sdk"],"author":"carsonxu","license":"ISC","bugs":{"url":"https://github.com/tencentyun/cos-nodejs-sdk-v5/issues"},"homepage":"https://github.com/tencentyun/cos-nodejs-sdk-v5#readme","dependencies":{"conf":"^9.0.0","fast-xml-parser":"4.2.5","mime-types":"^2.1.24","request":"^2.88.2"},"devDependencies":{"@types/node":"^14.14.20","batch":"^0.6.1","crc64-ecma182.js":"^1.0.0","mocha":"^4.0.1","nyc":"^15.1.0","prettier":"^3.0.1","qcloud-cos-sts":"^3.0.0"},"engines":{"node":">= 6"},"_lastModified":"2026-07-
|
|
1
|
+
{"name":"cos-nodejs-sdk-v5","version":"2.12.6","description":"cos nodejs sdk v5","main":"index.js","types":"index.d.ts","scripts":{"prettier":"prettier --write sdk demo/demo.js test/test.js index.d.ts","demo":"node demo/demo.js","demo-sts":"node demo/demo-sts.js","demo-sts-scope":"node demo/demo-sts-scope.js","test":"mocha test/test.js","cov":"istanbul cover _mocha -- -u exports 'test/test.js'","nyc":"nyc --reporter=clover --reporter=cobertura mocha --reporter xunit --reporter-options output=mocha.xml test/test.js","csp":"mocha test/csp.js"},"repository":{"type":"git","url":"git+https://github.com/tencentyun/cos-nodejs-sdk-v5.git"},"keywords":["tencent","tencent cloud","qcloud","cos","cos-sdk"],"author":"carsonxu","license":"ISC","bugs":{"url":"https://github.com/tencentyun/cos-nodejs-sdk-v5/issues"},"homepage":"https://github.com/tencentyun/cos-nodejs-sdk-v5#readme","dependencies":{"conf":"^9.0.0","fast-xml-parser":"4.2.5","mime-types":"^2.1.24","request":"^2.88.2"},"devDependencies":{"@types/node":"^14.14.20","batch":"^0.6.1","crc64-ecma182.js":"^1.0.0","mocha":"^4.0.1","nyc":"^15.1.0","prettier":"^3.0.1","qcloud-cos-sts":"^3.0.0"},"engines":{"node":">= 6"},"_lastModified":"2026-07-16T13:28:42.743Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mime-match","version":"1.0.2","description":"A simple function to check whether a mimetype matches the specified mimetype (with wildcard support)","main":"index.js","scripts":{"test":"node test.js","gendocs":"gendocs > README.md"},"repository":{"type":"git","url":"https://github.com/DamonOehlman/mime-match.git"},"keywords":["mime","wildcard"],"author":"Damon Oehlman <damon.oehlman@gmail.com>","license":"ISC","bugs":{"url":"https://github.com/DamonOehlman/mime-match/issues"},"homepage":"https://github.com/DamonOehlman/mime-match","dependencies":{"wildcard":"^1.1.0"},"devDependencies":{"tape":"^4.5.1"},"_lastModified":"2026-07-
|
|
1
|
+
{"name":"mime-match","version":"1.0.2","description":"A simple function to check whether a mimetype matches the specified mimetype (with wildcard support)","main":"index.js","scripts":{"test":"node test.js","gendocs":"gendocs > README.md"},"repository":{"type":"git","url":"https://github.com/DamonOehlman/mime-match.git"},"keywords":["mime","wildcard"],"author":"Damon Oehlman <damon.oehlman@gmail.com>","license":"ISC","bugs":{"url":"https://github.com/DamonOehlman/mime-match/issues"},"homepage":"https://github.com/DamonOehlman/mime-match","dependencies":{"wildcard":"^1.1.0"},"devDependencies":{"tape":"^4.5.1"},"_lastModified":"2026-07-16T13:28:30.864Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mime-types","description":"The ultimate javascript content-type utility.","version":"3.0.1","contributors":["Douglas Christopher Wilson <doug@somethingdoug.com>","Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)","Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"],"license":"MIT","keywords":["mime","types"],"repository":"jshttp/mime-types","dependencies":{"mime-db":"^1.54.0"},"devDependencies":{"eslint":"8.33.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.27.5","eslint-plugin-markdown":"3.0.0","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"6.1.1","eslint-plugin-standard":"4.1.0","mocha":"10.2.0","nyc":"15.1.0"},"files":["HISTORY.md","LICENSE","index.js","mimeScore.js"],"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_lastModified":"2026-07-
|
|
1
|
+
{"name":"mime-types","description":"The ultimate javascript content-type utility.","version":"3.0.1","contributors":["Douglas Christopher Wilson <doug@somethingdoug.com>","Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)","Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"],"license":"MIT","keywords":["mime","types"],"repository":"jshttp/mime-types","dependencies":{"mime-db":"^1.54.0"},"devDependencies":{"eslint":"8.33.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.27.5","eslint-plugin-markdown":"3.0.0","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"6.1.1","eslint-plugin-standard":"4.1.0","mocha":"10.2.0","nyc":"15.1.0"},"files":["HISTORY.md","LICENSE","index.js","mimeScore.js"],"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_lastModified":"2026-07-16T13:28:31.194Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"0.5.6","publishConfig":{"tag":"legacy"},"author":"James Halliday <mail@substack.net> (http://substack.net)","main":"index.js","keywords":["mkdir","directory"],"repository":{"type":"git","url":"https://github.com/substack/node-mkdirp.git"},"scripts":{"test":"tap test/*.js"},"dependencies":{"minimist":"^1.2.6"},"devDependencies":{"tap":"^16.0.1"},"bin":"bin/cmd.js","license":"MIT","files":["bin","index.js"],"_lastModified":"2026-07-
|
|
1
|
+
{"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"0.5.6","publishConfig":{"tag":"legacy"},"author":"James Halliday <mail@substack.net> (http://substack.net)","main":"index.js","keywords":["mkdir","directory"],"repository":{"type":"git","url":"https://github.com/substack/node-mkdirp.git"},"scripts":{"test":"tap test/*.js"},"dependencies":{"minimist":"^1.2.6"},"devDependencies":{"tap":"^16.0.1"},"bin":"bin/cmd.js","license":"MIT","files":["bin","index.js"],"_lastModified":"2026-07-16T13:28:36.254Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"url-join","version":"4.0.1","description":"Join urls and normalize as in path.join.","main":"lib/url-join.js","scripts":{"test":"mocha --require should"},"repository":{"type":"git","url":"git://github.com/jfromaniello/url-join.git"},"keywords":["url","join"],"author":"José F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)","license":"MIT","devDependencies":{"conventional-changelog":"^1.1.10","mocha":"^3.2.0","should":"~1.2.1"},"_lastModified":"2026-07-
|
|
1
|
+
{"name":"url-join","version":"4.0.1","description":"Join urls and normalize as in path.join.","main":"lib/url-join.js","scripts":{"test":"mocha --require should"},"repository":{"type":"git","url":"git://github.com/jfromaniello/url-join.git"},"keywords":["url","join"],"author":"José F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)","license":"MIT","devDependencies":{"conventional-changelog":"^1.1.10","mocha":"^3.2.0","should":"~1.2.1"},"_lastModified":"2026-07-16T13:28:30.973Z"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import type { Context, Next } from '@nocobase/actions';
|
|
10
|
+
import type { DataSource } from '@nocobase/data-source-manager';
|
|
11
|
+
export declare function getFile(ctx: Context, next: Next): Promise<never>;
|
|
12
|
+
export declare function registerGetFileAccess(dataSource: DataSource): void;
|
|
13
|
+
export declare function skipGetFileAcl(ctx: Context, next: Next): Promise<void>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var get_file_exports = {};
|
|
28
|
+
__export(get_file_exports, {
|
|
29
|
+
getFile: () => getFile,
|
|
30
|
+
registerGetFileAccess: () => registerGetFileAccess,
|
|
31
|
+
skipGetFileAcl: () => skipGetFileAcl
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(get_file_exports);
|
|
34
|
+
var import_temporary_access = require("../temporary-access");
|
|
35
|
+
var import_utils = require("../utils");
|
|
36
|
+
var import_resolve_file_access_filter = require("../resolve-file-access-filter");
|
|
37
|
+
const GET_FILE_ACTION = "getFile";
|
|
38
|
+
async function getFile(ctx, next) {
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
40
|
+
const collection = ctx.dataSource.collectionManager.getCollection(ctx.action.resourceName);
|
|
41
|
+
if (!collection || collection.name !== "attachments" && ((_a = collection.options) == null ? void 0 : _a.template) !== "file") {
|
|
42
|
+
return ctx.throw(404);
|
|
43
|
+
}
|
|
44
|
+
if (!(0, import_utils.hasStandardFileId)(collection)) {
|
|
45
|
+
ctx.logger.error("file collection is missing standard id field", {
|
|
46
|
+
method: "file-manager.getFile",
|
|
47
|
+
collection: collection.name
|
|
48
|
+
});
|
|
49
|
+
return ctx.throw(500);
|
|
50
|
+
}
|
|
51
|
+
const plugin = ctx.app.pm.get("file-manager");
|
|
52
|
+
const id = ((_b = ctx.state.fileAccess) == null ? void 0 : _b.id) ?? ctx.action.params.filterByTk;
|
|
53
|
+
const temporaryAccess = Boolean((_c = ctx.state.fileAccess) == null ? void 0 : _c.temporaryAccess);
|
|
54
|
+
let temporaryAccessPayload;
|
|
55
|
+
if (temporaryAccess) {
|
|
56
|
+
ctx.set("Cache-Control", "private, no-store");
|
|
57
|
+
ctx.set("Referrer-Policy", "no-referrer");
|
|
58
|
+
const token = (_d = ctx.state.fileAccess) == null ? void 0 : _d.temporaryAccessToken;
|
|
59
|
+
if (typeof token !== "string" || !token) {
|
|
60
|
+
return ctx.throw(403);
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
temporaryAccessPayload = (0, import_temporary_access.verifyTemporaryFileAccessToken)(plugin, token);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return ctx.throw(403);
|
|
66
|
+
}
|
|
67
|
+
const expectedResource = {
|
|
68
|
+
app: ctx.state.fileAccess.appName,
|
|
69
|
+
dataSource: ctx.state.fileAccess.dataSourceKey,
|
|
70
|
+
collection: collection.name,
|
|
71
|
+
id: String(id)
|
|
72
|
+
};
|
|
73
|
+
if (temporaryAccessPayload.app !== expectedResource.app || temporaryAccessPayload.dataSource !== expectedResource.dataSource || temporaryAccessPayload.collection !== expectedResource.collection || String(temporaryAccessPayload.id) !== expectedResource.id) {
|
|
74
|
+
return ctx.throw(403);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const fileAccessParams = ctx.state.fileAccess ? {
|
|
78
|
+
appName: ctx.state.fileAccess.appName,
|
|
79
|
+
dataSourceKey: ctx.state.fileAccess.dataSourceKey,
|
|
80
|
+
collectionName: collection.name,
|
|
81
|
+
id: String(id),
|
|
82
|
+
preview: Boolean(ctx.state.fileAccess.preview)
|
|
83
|
+
} : null;
|
|
84
|
+
const authorizedByExtension = fileAccessParams && !temporaryAccess ? await plugin.authorizeFileAccess(ctx, fileAccessParams) : false;
|
|
85
|
+
let filter = { id };
|
|
86
|
+
if (!temporaryAccess && !authorizedByExtension && ctx.app.options.acl !== false && ((_e = ctx.dataSource.options) == null ? void 0 : _e.useACL) !== false && ((_f = ctx.dataSource.options) == null ? void 0 : _f.acl) !== false) {
|
|
87
|
+
filter = await (0, import_resolve_file_access_filter.resolveFileAccessFilter)(ctx, collection, filter);
|
|
88
|
+
}
|
|
89
|
+
const file = await ctx.getCurrentRepository().findOne({
|
|
90
|
+
filter,
|
|
91
|
+
fields: ["id", "storageId", "path", "filename", "extname", "mimetype", "url", "meta"],
|
|
92
|
+
context: ctx
|
|
93
|
+
});
|
|
94
|
+
const storageId = (0, import_utils.getFileRecordValue)(file, "storageId");
|
|
95
|
+
if (!file || !storageId) {
|
|
96
|
+
return ctx.throw(404);
|
|
97
|
+
}
|
|
98
|
+
if (temporaryAccessPayload && String(temporaryAccessPayload.storageId) !== String(storageId)) {
|
|
99
|
+
return ctx.throw(403);
|
|
100
|
+
}
|
|
101
|
+
if (((_g = ctx.state.fileAccess) == null ? void 0 : _g.extname) && ctx.state.fileAccess.extname !== (0, import_utils.getFileRecordValue)(file, "extname")) {
|
|
102
|
+
return ctx.throw(404);
|
|
103
|
+
}
|
|
104
|
+
const download = !temporaryAccess && ctx.method === "GET" && ctx.query.download === "1";
|
|
105
|
+
const preview = download ? false : temporaryAccess ? false : Boolean((_h = ctx.state.fileAccess) == null ? void 0 : _h.preview);
|
|
106
|
+
const dataSource = ctx.dataSource;
|
|
107
|
+
const finalUrl = await ((_i = dataSource.resolveStorageFileURL) == null ? void 0 : _i.call(dataSource, {
|
|
108
|
+
collectionName: collection.name,
|
|
109
|
+
file: (0, import_utils.getFilePlainObject)(file),
|
|
110
|
+
preview,
|
|
111
|
+
download
|
|
112
|
+
})) || await plugin.getFileURL(file, preview, { download });
|
|
113
|
+
ctx.status = 302;
|
|
114
|
+
ctx.redirect(finalUrl);
|
|
115
|
+
await next();
|
|
116
|
+
}
|
|
117
|
+
function registerGetFileAccess(dataSource) {
|
|
118
|
+
dataSource.resourceManager.registerActionHandler(GET_FILE_ACTION, getFile);
|
|
119
|
+
dataSource.acl.use(skipGetFileAcl, { tag: "skipGetFileAcl", before: "core" });
|
|
120
|
+
}
|
|
121
|
+
async function skipGetFileAcl(ctx, next) {
|
|
122
|
+
var _a;
|
|
123
|
+
if (((_a = ctx.action) == null ? void 0 : _a.actionName) === GET_FILE_ACTION) {
|
|
124
|
+
ctx.permission.skip = true;
|
|
125
|
+
}
|
|
126
|
+
await next();
|
|
127
|
+
}
|
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
+
0 && (module.exports = {
|
|
130
|
+
getFile,
|
|
131
|
+
registerGetFileAccess,
|
|
132
|
+
skipGetFileAcl
|
|
133
|
+
});
|
|
@@ -6,6 +6,4 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
export default function (
|
|
10
|
-
app: any;
|
|
11
|
-
}): void;
|
|
9
|
+
export default function (plugin: any): void;
|
|
@@ -41,9 +41,16 @@ __export(actions_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(actions_exports);
|
|
42
42
|
var import_actions = __toESM(require("@nocobase/actions"));
|
|
43
43
|
var import_attachments = require("./attachments");
|
|
44
|
+
var import_get_file = require("./get-file");
|
|
44
45
|
var import_storage_validation = require("./storage-validation");
|
|
45
46
|
var storageActions = __toESM(require("./storages"));
|
|
46
|
-
|
|
47
|
+
var import_temporary_access = require("../temporary-access");
|
|
48
|
+
function actions_default(plugin) {
|
|
49
|
+
const { app } = plugin;
|
|
50
|
+
app.dataSourceManager.afterAddDataSource((dataSource) => {
|
|
51
|
+
(0, import_get_file.registerGetFileAccess)(dataSource);
|
|
52
|
+
(0, import_temporary_access.registerTemporaryFileAccess)(dataSource);
|
|
53
|
+
});
|
|
47
54
|
app.resourcer.define({
|
|
48
55
|
name: "storages",
|
|
49
56
|
actions: storageActions,
|
|
@@ -102,6 +102,28 @@ async function loadFileCollections(app) {
|
|
|
102
102
|
await ((_a = repository.setApp) == null ? void 0 : _a.call(repository, app));
|
|
103
103
|
await ((_b = repository.load) == null ? void 0 : _b.call(repository));
|
|
104
104
|
}
|
|
105
|
+
function getColumnName(model, attribute) {
|
|
106
|
+
var _a;
|
|
107
|
+
return ((_a = model.rawAttributes[attribute]) == null ? void 0 : _a.field) || attribute;
|
|
108
|
+
}
|
|
109
|
+
function quotedColumn(app, model, attribute) {
|
|
110
|
+
return app.db.quoteIdentifier(getColumnName(model, attribute));
|
|
111
|
+
}
|
|
112
|
+
function quotedAlias(app, attribute) {
|
|
113
|
+
return app.db.quoteIdentifier(attribute);
|
|
114
|
+
}
|
|
115
|
+
async function findAttachmentRows(app, model, lastId, limit) {
|
|
116
|
+
const tableName = app.db.utils.quoteTable(model.getTableName());
|
|
117
|
+
const idColumn = quotedColumn(app, model, "id");
|
|
118
|
+
const columns = ["id", "path", "filename", "storageId", "url"].map((attribute) => `${quotedColumn(app, model, attribute)} as ${quotedAlias(app, attribute)}`).join(", ");
|
|
119
|
+
return await app.db.sequelize.query(
|
|
120
|
+
`select ${columns} from ${tableName}${lastId == null ? "" : ` where ${idColumn} > :lastId`} order by ${idColumn} asc limit ${limit}`,
|
|
121
|
+
{
|
|
122
|
+
replacements: { lastId },
|
|
123
|
+
type: import_sequelize.QueryTypes.SELECT
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}
|
|
105
127
|
async function repairCollectionAttachmentFilenames({
|
|
106
128
|
app,
|
|
107
129
|
fileManager,
|
|
@@ -115,22 +137,17 @@ async function repairCollectionAttachmentFilenames({
|
|
|
115
137
|
if (!collection) {
|
|
116
138
|
return;
|
|
117
139
|
}
|
|
118
|
-
const
|
|
140
|
+
const FileModel = collection.model;
|
|
119
141
|
let lastId = null;
|
|
120
142
|
while (result.scanned < limit) {
|
|
121
|
-
const rows = await
|
|
122
|
-
attributes: ["id", "path", "filename", "storageId", "url"],
|
|
123
|
-
where: lastId ? { id: { [import_sequelize.Op.gt]: lastId } } : void 0,
|
|
124
|
-
order: [["id", "ASC"]],
|
|
125
|
-
limit: Math.min(batchSize, limit - result.scanned)
|
|
126
|
-
});
|
|
143
|
+
const rows = await findAttachmentRows(app, FileModel, lastId, Math.min(batchSize, limit - result.scanned));
|
|
127
144
|
if (!rows.length) {
|
|
128
145
|
break;
|
|
129
146
|
}
|
|
130
147
|
for (const row of rows) {
|
|
131
148
|
result.scanned += 1;
|
|
132
|
-
lastId = row.
|
|
133
|
-
const record = row
|
|
149
|
+
lastId = row.id;
|
|
150
|
+
const record = row;
|
|
134
151
|
if (!containsInvisibleChars(record.path) && !containsInvisibleChars(record.filename)) {
|
|
135
152
|
continue;
|
|
136
153
|
}
|
|
@@ -190,11 +207,14 @@ async function repairCollectionAttachmentFilenames({
|
|
|
190
207
|
}
|
|
191
208
|
if (apply) {
|
|
192
209
|
await storageInstance.copy(record, newRecord);
|
|
193
|
-
await
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
210
|
+
await FileModel.update(
|
|
211
|
+
{
|
|
212
|
+
path: newPath,
|
|
213
|
+
filename: newFilename,
|
|
214
|
+
url: updateUrlValue(record.url, oldKey, newKey)
|
|
215
|
+
},
|
|
216
|
+
{ where: { id: lastId } }
|
|
217
|
+
);
|
|
198
218
|
try {
|
|
199
219
|
const [deleted] = await storageInstance.delete([record]);
|
|
200
220
|
if (!deleted) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import type { Context, Next } from '@nocobase/actions';
|
|
10
|
+
import type { PluginFileManagerServer } from './server';
|
|
11
|
+
export declare function createFileAccessMiddleware(plugin: PluginFileManagerServer): (ctx: Context, next: Next) => Promise<any>;
|