@contember/engine-s3-plugin 2.1.0-alpha.37 → 2.1.0-alpha.39
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/development/index.cjs +27 -0
- package/dist/development/index.cjs.map +1 -0
- package/dist/development/index.js +28 -0
- package/dist/development/index.js.map +1 -0
- package/dist/development/src/Config.cjs +73 -0
- package/dist/development/src/Config.cjs.map +1 -0
- package/dist/development/src/Config.js +56 -0
- package/dist/development/src/Config.js.map +1 -0
- package/dist/development/src/S3ConfigProcessor.cjs +60 -0
- package/dist/development/src/S3ConfigProcessor.cjs.map +1 -0
- package/dist/development/src/S3ConfigProcessor.js +43 -0
- package/dist/development/src/S3ConfigProcessor.js.map +1 -0
- package/dist/development/src/S3ObjectAuthorizator.cjs +46 -0
- package/dist/development/src/S3ObjectAuthorizator.cjs.map +1 -0
- package/dist/development/src/S3ObjectAuthorizator.js +46 -0
- package/dist/development/src/S3ObjectAuthorizator.js.map +1 -0
- package/dist/development/src/S3SchemaContributor.cjs +105 -0
- package/dist/development/src/S3SchemaContributor.cjs.map +1 -0
- package/dist/development/src/S3SchemaContributor.js +105 -0
- package/dist/development/src/S3SchemaContributor.js.map +1 -0
- package/dist/development/src/S3SchemaTypes.cjs +71 -0
- package/dist/development/src/S3SchemaTypes.cjs.map +1 -0
- package/dist/development/src/S3SchemaTypes.js +71 -0
- package/dist/development/src/S3SchemaTypes.js.map +1 -0
- package/dist/development/src/S3Service.cjs +105 -0
- package/dist/development/src/S3Service.cjs.map +1 -0
- package/dist/development/src/S3Service.js +105 -0
- package/dist/development/src/S3Service.js.map +1 -0
- package/dist/development/src/S3Signer.cjs +84 -0
- package/dist/development/src/S3Signer.cjs.map +1 -0
- package/dist/development/src/S3Signer.js +84 -0
- package/dist/development/src/S3Signer.js.map +1 -0
- package/dist/production/index.cjs +27 -0
- package/dist/production/index.cjs.map +1 -0
- package/dist/production/index.js +28 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/src/Config.cjs +73 -0
- package/dist/production/src/Config.cjs.map +1 -0
- package/dist/production/src/Config.js +56 -0
- package/dist/production/src/Config.js.map +1 -0
- package/dist/production/src/S3ConfigProcessor.cjs +60 -0
- package/dist/production/src/S3ConfigProcessor.cjs.map +1 -0
- package/dist/production/src/S3ConfigProcessor.js +43 -0
- package/dist/production/src/S3ConfigProcessor.js.map +1 -0
- package/dist/production/src/S3ObjectAuthorizator.cjs +46 -0
- package/dist/production/src/S3ObjectAuthorizator.cjs.map +1 -0
- package/dist/production/src/S3ObjectAuthorizator.js +46 -0
- package/dist/production/src/S3ObjectAuthorizator.js.map +1 -0
- package/dist/production/src/S3SchemaContributor.cjs +105 -0
- package/dist/production/src/S3SchemaContributor.cjs.map +1 -0
- package/dist/production/src/S3SchemaContributor.js +105 -0
- package/dist/production/src/S3SchemaContributor.js.map +1 -0
- package/dist/production/src/S3SchemaTypes.cjs +71 -0
- package/dist/production/src/S3SchemaTypes.cjs.map +1 -0
- package/dist/production/src/S3SchemaTypes.js +71 -0
- package/dist/production/src/S3SchemaTypes.js.map +1 -0
- package/dist/production/src/S3Service.cjs +105 -0
- package/dist/production/src/S3Service.cjs.map +1 -0
- package/dist/production/src/S3Service.js +105 -0
- package/dist/production/src/S3Service.js.map +1 -0
- package/dist/production/src/S3Signer.cjs +84 -0
- package/dist/production/src/S3Signer.cjs.map +1 -0
- package/dist/production/src/S3Signer.js +84 -0
- package/dist/production/src/S3Signer.js.map +1 -0
- package/dist/tests/cases/authorizator.test.d.ts +2 -0
- package/dist/tests/cases/authorizator.test.d.ts.map +1 -0
- package/dist/tests/cases/signRequest.test.d.ts +2 -0
- package/dist/tests/cases/signRequest.test.d.ts.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -0
- package/dist/types/Config.d.ts +33 -0
- package/dist/types/Config.d.ts.map +1 -0
- package/dist/types/S3ConfigProcessor.d.ts +9 -0
- package/dist/types/S3ConfigProcessor.d.ts.map +1 -0
- package/dist/types/S3ObjectAuthorizator.d.ts +22 -0
- package/dist/types/S3ObjectAuthorizator.d.ts.map +1 -0
- package/dist/types/S3SchemaContributor.d.ts +21 -0
- package/dist/types/S3SchemaContributor.d.ts.map +1 -0
- package/dist/types/S3SchemaTypes.d.ts +21 -0
- package/dist/types/S3SchemaTypes.d.ts.map +1 -0
- package/dist/types/S3Service.d.ts +44 -0
- package/dist/types/S3Service.d.ts.map +1 -0
- package/dist/types/S3Signer.d.ts +22 -0
- package/dist/types/S3Signer.d.ts.map +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +13 -13
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { GraphQLObjectType, GraphQLString, GraphQLInt, GraphQLNonNull, GraphQLError } from "graphql";
|
|
2
|
+
import { resolveS3Config } from "./Config.js";
|
|
3
|
+
import { S3SignedRead, S3Acl, S3GenerateSignedUploadInput, S3SignedUpload } from "./S3SchemaTypes.js";
|
|
4
|
+
import { S3ObjectAuthorizator } from "./S3ObjectAuthorizator.js";
|
|
5
|
+
class S3SchemaContributor {
|
|
6
|
+
constructor(s3Factory, providers) {
|
|
7
|
+
this.s3Factory = s3Factory;
|
|
8
|
+
this.providers = providers;
|
|
9
|
+
}
|
|
10
|
+
getCacheKey({ project }) {
|
|
11
|
+
return project.s3 ? "yes" : "no";
|
|
12
|
+
}
|
|
13
|
+
createSchema(context) {
|
|
14
|
+
if (!context.project.s3) {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
const rules = context.identity.projectRoles.flatMap((it) => Object.entries(context.schema.acl.roles[it]?.s3 || {}));
|
|
18
|
+
const uploadRules = rules.filter(([, it]) => it.upload).map(([it, val]) => ({
|
|
19
|
+
pattern: it,
|
|
20
|
+
...typeof val.upload !== "boolean" ? val.upload : {}
|
|
21
|
+
}));
|
|
22
|
+
const readRules = rules.filter(([, it]) => it.read).map(([it]) => ({
|
|
23
|
+
pattern: it
|
|
24
|
+
}));
|
|
25
|
+
if (uploadRules.length === 0 && readRules.length === 0) {
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
const authorizator = new S3ObjectAuthorizator(uploadRules, readRules);
|
|
29
|
+
const uploadMutation = this.createUploadMutation(authorizator);
|
|
30
|
+
const readMutation = this.createReadMutation(authorizator);
|
|
31
|
+
const mutation = {
|
|
32
|
+
generateUploadUrl: uploadMutation,
|
|
33
|
+
generateReadUrl: readMutation
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
mutation: new GraphQLObjectType({
|
|
37
|
+
name: "Mutation",
|
|
38
|
+
fields: () => mutation
|
|
39
|
+
}),
|
|
40
|
+
query: new GraphQLObjectType({
|
|
41
|
+
name: "Query",
|
|
42
|
+
fields: () => ({
|
|
43
|
+
s3DummyQuery: {
|
|
44
|
+
type: GraphQLString
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
createReadMutation(authorizator) {
|
|
51
|
+
return {
|
|
52
|
+
type: new GraphQLNonNull(S3SignedRead),
|
|
53
|
+
args: {
|
|
54
|
+
objectKey: {
|
|
55
|
+
type: new GraphQLNonNull(GraphQLString)
|
|
56
|
+
},
|
|
57
|
+
expiration: {
|
|
58
|
+
type: GraphQLInt
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
resolve: async (parent, args, ctx) => {
|
|
62
|
+
if (!ctx.project.s3) {
|
|
63
|
+
throw new GraphQLError("S3 is not configured for this project");
|
|
64
|
+
}
|
|
65
|
+
const s3Config = resolveS3Config(ctx.project.s3);
|
|
66
|
+
const s3 = this.s3Factory.create(s3Config, this.providers, authorizator);
|
|
67
|
+
return s3.getSignedReadUrl({ objectKey: args.objectKey, expiration: args.expiration ?? null });
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
createUploadMutation(authorizator) {
|
|
72
|
+
return {
|
|
73
|
+
type: new GraphQLNonNull(S3SignedUpload),
|
|
74
|
+
args: {
|
|
75
|
+
input: { type: S3GenerateSignedUploadInput },
|
|
76
|
+
contentType: { type: GraphQLString, deprecationReason: "Use input.contentType" },
|
|
77
|
+
expiration: { type: GraphQLInt, deprecationReason: "Use input.expiration" },
|
|
78
|
+
prefix: { type: GraphQLString, deprecationReason: "Use input.prefix" },
|
|
79
|
+
acl: { type: S3Acl, deprecationReason: "Use input.acl" }
|
|
80
|
+
},
|
|
81
|
+
resolve: async (parent, args, ctx) => {
|
|
82
|
+
if (!ctx.project.s3) {
|
|
83
|
+
throw new GraphQLError("S3 is not configured for this project");
|
|
84
|
+
}
|
|
85
|
+
const s3Config = resolveS3Config(ctx.project.s3);
|
|
86
|
+
const s3 = this.s3Factory.create(s3Config, this.providers, authorizator);
|
|
87
|
+
return s3.getSignedUploadUrl({
|
|
88
|
+
acl: args.input?.acl ?? args.acl ?? null,
|
|
89
|
+
contentDisposition: args.input?.contentDisposition ?? null,
|
|
90
|
+
contentType: args.input?.contentType ?? args.contentType ?? null,
|
|
91
|
+
expiration: args.input?.expiration ?? args.expiration ?? null,
|
|
92
|
+
extension: args.input?.extension ?? null,
|
|
93
|
+
fileName: args.input?.fileName ?? null,
|
|
94
|
+
prefix: args.input?.prefix ?? args.prefix ?? null,
|
|
95
|
+
suffix: args.input?.suffix ?? null,
|
|
96
|
+
size: args.input?.size ?? null
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
S3SchemaContributor
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=S3SchemaContributor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"S3SchemaContributor.js","sources":["../../../../packages/engine-s3-plugin/src/S3SchemaContributor.ts"],"sourcesContent":["import {\n\tGraphQLError,\n\tGraphQLFieldConfig,\n\tGraphQLInt,\n\tGraphQLNonNull,\n\tGraphQLObjectType,\n\tGraphQLSchema,\n\tGraphQLSchemaConfig,\n\tGraphQLString,\n} from 'graphql'\nimport { S3Service, S3ServiceFactory } from './S3Service'\nimport { Project3Config, resolveS3Config, S3Config } from './Config'\nimport { GraphQLSchemaContributor, GraphQLSchemaContributorContext, Providers } from '@contember/engine-plugins'\nimport * as types from './S3SchemaTypes'\nimport { S3Acl, S3GenerateSignedUploadInput, S3SignedRead, S3SignedUpload } from './S3SchemaTypes'\nimport { S3ObjectAuthorizator } from './S3ObjectAuthorizator'\n\ninterface Identity {\n\tprojectRoles: string[]\n}\n\nexport type S3SchemaUploadAcl =\n\t| boolean\n\t| {\n\t\tmaxSize?: number\n\t}\n\nexport type S3SchemaAcl = Record<\n\tstring, // public/*.jpg\n\t{\n\t\tread?: boolean\n\t\tupload?: S3SchemaUploadAcl\n\t}\n>\n\nexport class S3SchemaContributor implements GraphQLSchemaContributor {\n\tconstructor(\n\t\tprivate readonly s3Factory: S3ServiceFactory,\n\t\tprivate readonly providers: Providers,\n\t) {}\n\n\tgetCacheKey?({ project }: GraphQLSchemaContributorContext): string {\n\t\treturn project.s3 ? 'yes' : 'no'\n\t}\n\n\tcreateSchema(context: GraphQLSchemaContributorContext): GraphQLSchemaConfig | undefined {\n\t\tif (!context.project.s3) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst rules = context.identity.projectRoles.flatMap(it => Object.entries((context.schema.acl.roles[it]?.s3 as S3SchemaAcl) || {}))\n\n\t\tconst uploadRules = rules.filter(([, it]) => it.upload).map(([it, val]) => ({\n\t\t\tpattern: it,\n\t\t\t...(typeof val.upload !== 'boolean' ? val.upload : {}),\n\t\t}))\n\t\tconst readRules = rules.filter(([, it]) => it.read).map(([it]) => ({\n\t\t\tpattern: it,\n\t\t}))\n\n\t\tif (uploadRules.length === 0 && readRules.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst authorizator = new S3ObjectAuthorizator(uploadRules, readRules)\n\t\tconst uploadMutation = this.createUploadMutation(authorizator)\n\t\tconst readMutation = this.createReadMutation(authorizator)\n\t\tconst mutation = {\n\t\t\tgenerateUploadUrl: uploadMutation as GraphQLFieldConfig<any, any, any>,\n\t\t\tgenerateReadUrl: readMutation,\n\t\t}\n\t\treturn {\n\t\t\tmutation: new GraphQLObjectType({\n\t\t\t\tname: 'Mutation',\n\t\t\t\tfields: () => mutation,\n\t\t\t}),\n\t\t\tquery: new GraphQLObjectType({\n\t\t\t\tname: 'Query',\n\t\t\t\tfields: () => ({\n\t\t\t\t\ts3DummyQuery: {\n\t\t\t\t\t\ttype: GraphQLString,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t}),\n\t\t}\n\t}\n\n\tprivate createReadMutation(authorizator: S3ObjectAuthorizator): GraphQLFieldConfig<any, { project: Project3Config }, any> {\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(S3SignedRead),\n\t\t\targs: {\n\t\t\t\tobjectKey: {\n\t\t\t\t\ttype: new GraphQLNonNull(GraphQLString),\n\t\t\t\t},\n\t\t\t\texpiration: {\n\t\t\t\t\ttype: GraphQLInt,\n\t\t\t\t},\n\t\t\t},\n\t\t\tresolve: async (parent: any, args: { objectKey: string; expiration?: number }, ctx: { project: Project3Config }) => {\n\t\t\t\tif (!ctx.project.s3) {\n\t\t\t\t\tthrow new GraphQLError('S3 is not configured for this project')\n\t\t\t\t}\n\t\t\t\tconst s3Config = resolveS3Config(ctx.project.s3)\n\t\t\t\tconst s3 = this.s3Factory.create(s3Config, this.providers, authorizator)\n\t\t\t\treturn s3.getSignedReadUrl({ objectKey: args.objectKey, expiration: args.expiration ?? null })\n\t\t\t},\n\t\t} as GraphQLFieldConfig<any, any, any>\n\t}\n\n\tprivate createUploadMutation(authorizator: S3ObjectAuthorizator): GraphQLFieldConfig<any, any, any> {\n\t\treturn {\n\t\t\ttype: new GraphQLNonNull(S3SignedUpload),\n\t\t\targs: {\n\t\t\t\tinput: { type: types.S3GenerateSignedUploadInput },\n\t\t\t\tcontentType: { type: GraphQLString, deprecationReason: 'Use input.contentType' },\n\t\t\t\texpiration: { type: GraphQLInt, deprecationReason: 'Use input.expiration' },\n\t\t\t\tprefix: { type: GraphQLString, deprecationReason: 'Use input.prefix' },\n\t\t\t\tacl: { type: types.S3Acl, deprecationReason: 'Use input.acl' },\n\t\t\t},\n\t\t\tresolve: async (\n\t\t\t\tparent: any,\n\t\t\t\targs: { input?: Partial<S3GenerateSignedUploadInput>; contentType?: string; acl?: S3Acl; expiration?: number; prefix?: string },\n\t\t\t\tctx: { project: Project3Config },\n\t\t\t) => {\n\t\t\t\tif (!ctx.project.s3) {\n\t\t\t\t\tthrow new GraphQLError('S3 is not configured for this project')\n\t\t\t\t}\n\t\t\t\tconst s3Config = resolveS3Config(ctx.project.s3)\n\t\t\t\tconst s3 = this.s3Factory.create(s3Config, this.providers, authorizator)\n\t\t\t\treturn s3.getSignedUploadUrl({\n\t\t\t\t\tacl: args.input?.acl ?? args.acl ?? null,\n\t\t\t\t\tcontentDisposition: args.input?.contentDisposition ?? null,\n\t\t\t\t\tcontentType: args.input?.contentType ?? args.contentType ?? null,\n\t\t\t\t\texpiration: args.input?.expiration ?? args.expiration ?? null,\n\t\t\t\t\textension: args.input?.extension ?? null,\n\t\t\t\t\tfileName: args.input?.fileName ?? null,\n\t\t\t\t\tprefix: args.input?.prefix ?? args.prefix ?? null,\n\t\t\t\t\tsuffix: args.input?.suffix ?? null,\n\t\t\t\t\tsize: args.input?.size ?? null,\n\t\t\t\t})\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["types.S3GenerateSignedUploadInput","types.S3Acl"],"mappings":";;;;AAmCO,MAAM,oBAAwD;AAAA,EACpE,YACkB,WACA,WAChB;AAFgB,SAAA,YAAA;AACA,SAAA,YAAA;AAAA,EACf;AAAA,EAEH,YAAa,EAAE,WAAoD;AAClE,WAAO,QAAQ,KAAK,QAAQ;AAAA,EAC7B;AAAA,EAEA,aAAa,SAA2E;AACvF,QAAI,CAAC,QAAQ,QA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U,KAAK,OAAO,YAAY;AAAA,UAClC,QAAQ,KAAK,OAAO,UAAU,KAAK,UAAU;AAAA,UAC7C,QAAQ,KAAK,OAAO,UAAU;AAAA,UAC9B,MAAM,KAAK,OAAO,QAAQ;AAAA,QAAA,CAC1B;AAAA,MACF;AAAA,IAAA;AAAA,EAEF;AACD;"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const graphql = require("graphql");
|
|
4
|
+
const S3Header = new graphql.GraphQLObjectType({
|
|
5
|
+
name: "S3Header",
|
|
6
|
+
fields: {
|
|
7
|
+
key: { type: new graphql.GraphQLNonNull(graphql.GraphQLString) },
|
|
8
|
+
value: { type: new graphql.GraphQLNonNull(graphql.GraphQLString) }
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const S3ContentDisposition = new graphql.GraphQLEnumType({
|
|
12
|
+
name: "S33ContentDisposition",
|
|
13
|
+
values: {
|
|
14
|
+
ATTACHMENT: {},
|
|
15
|
+
INLINE: {}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const S3SignedRead = new graphql.GraphQLObjectType({
|
|
19
|
+
name: "S3SignedRead",
|
|
20
|
+
fields: {
|
|
21
|
+
url: { type: new graphql.GraphQLNonNull(graphql.GraphQLString) },
|
|
22
|
+
headers: {
|
|
23
|
+
type: new graphql.GraphQLNonNull(new graphql.GraphQLList(new graphql.GraphQLNonNull(S3Header)))
|
|
24
|
+
},
|
|
25
|
+
method: { type: new graphql.GraphQLNonNull(graphql.GraphQLString) },
|
|
26
|
+
objectKey: { type: new graphql.GraphQLNonNull(graphql.GraphQLString) },
|
|
27
|
+
bucket: { type: new graphql.GraphQLNonNull(graphql.GraphQLString) }
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const S3SignedUpload = new graphql.GraphQLObjectType({
|
|
31
|
+
name: "S3SignedUpload",
|
|
32
|
+
fields: {
|
|
33
|
+
url: { type: new graphql.GraphQLNonNull(graphql.GraphQLString) },
|
|
34
|
+
headers: {
|
|
35
|
+
type: new graphql.GraphQLNonNull(new graphql.GraphQLList(new graphql.GraphQLNonNull(S3Header)))
|
|
36
|
+
},
|
|
37
|
+
method: { type: new graphql.GraphQLNonNull(graphql.GraphQLString) },
|
|
38
|
+
objectKey: { type: new graphql.GraphQLNonNull(graphql.GraphQLString) },
|
|
39
|
+
bucket: { type: new graphql.GraphQLNonNull(graphql.GraphQLString) },
|
|
40
|
+
publicUrl: { type: new graphql.GraphQLNonNull(graphql.GraphQLString) }
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const S3Acl = new graphql.GraphQLEnumType({
|
|
44
|
+
name: "S3Acl",
|
|
45
|
+
values: {
|
|
46
|
+
PUBLIC_READ: {},
|
|
47
|
+
PRIVATE: {},
|
|
48
|
+
NONE: {}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const S3GenerateSignedUploadInput = new graphql.GraphQLInputObjectType({
|
|
52
|
+
name: "S3GenerateSignedUploadInput",
|
|
53
|
+
fields: {
|
|
54
|
+
contentType: { type: graphql.GraphQLString },
|
|
55
|
+
extension: { type: graphql.GraphQLString, description: "If not provided, extension is detected from a content-type." },
|
|
56
|
+
expiration: { type: graphql.GraphQLInt, description: "Signed URL expiration." },
|
|
57
|
+
size: { type: graphql.GraphQLInt, description: "Uploaded file size. Required when you enable ACL size limits." },
|
|
58
|
+
prefix: { type: graphql.GraphQLString, description: 'Can be used as a "directory".' },
|
|
59
|
+
suffix: { type: graphql.GraphQLString, description: "Suffix after generated id and before the extension." },
|
|
60
|
+
fileName: { type: graphql.GraphQLString, description: "This only affects Content-disposition header. Does not affect actual object key." },
|
|
61
|
+
contentDisposition: { type: S3ContentDisposition },
|
|
62
|
+
acl: { type: S3Acl, description: "If not supported by S3 provider, an error is thrown." }
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
exports.S3Acl = S3Acl;
|
|
66
|
+
exports.S3ContentDisposition = S3ContentDisposition;
|
|
67
|
+
exports.S3GenerateSignedUploadInput = S3GenerateSignedUploadInput;
|
|
68
|
+
exports.S3Header = S3Header;
|
|
69
|
+
exports.S3SignedRead = S3SignedRead;
|
|
70
|
+
exports.S3SignedUpload = S3SignedUpload;
|
|
71
|
+
//# sourceMappingURL=S3SchemaTypes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"S3SchemaTypes.cjs","sources":["../../../../packages/engine-s3-plugin/src/S3SchemaTypes.ts"],"sourcesContent":["import { GraphQLEnumType, GraphQLInputObjectType, GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'\n\nexport const S3Header = new GraphQLObjectType({\n\tname: 'S3Header',\n\tfields: {\n\t\tkey: { type: new GraphQLNonNull(GraphQLString) },\n\t\tvalue: { type: new GraphQLNonNull(GraphQLString) },\n\t},\n})\n\nexport const S3ContentDisposition = new GraphQLEnumType({\n\tname: 'S33ContentDisposition',\n\tvalues: {\n\t\tATTACHMENT: {},\n\t\tINLINE: {},\n\t},\n})\nexport type S3ContentDisposition = 'ATTACHMENT' | 'INLINE'\n\nexport const S3SignedRead = new GraphQLObjectType({\n\tname: 'S3SignedRead',\n\tfields: {\n\t\turl: { type: new GraphQLNonNull(GraphQLString) },\n\t\theaders: {\n\t\t\ttype: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(S3Header))),\n\t\t},\n\t\tmethod: { type: new GraphQLNonNull(GraphQLString) },\n\t\tobjectKey: { type: new GraphQLNonNull(GraphQLString) },\n\t\tbucket: { type: new GraphQLNonNull(GraphQLString) },\n\t},\n})\n\nexport const S3SignedUpload = new GraphQLObjectType({\n\tname: 'S3SignedUpload',\n\tfields: {\n\t\turl: { type: new GraphQLNonNull(GraphQLString) },\n\t\theaders: {\n\t\t\ttype: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(S3Header))),\n\t\t},\n\t\tmethod: { type: new GraphQLNonNull(GraphQLString) },\n\t\tobjectKey: { type: new GraphQLNonNull(GraphQLString) },\n\t\tbucket: { type: new GraphQLNonNull(GraphQLString) },\n\t\tpublicUrl: { type: new GraphQLNonNull(GraphQLString) },\n\t},\n})\n\nexport const S3Acl = new GraphQLEnumType({\n\tname: 'S3Acl',\n\tvalues: {\n\t\tPUBLIC_READ: {},\n\t\tPRIVATE: {},\n\t\tNONE: {},\n\t},\n})\n\nexport type S3Acl = 'PUBLIC_READ' | 'PRIVATE' | 'NONE'\n\nexport const S3GenerateSignedUploadInput = new GraphQLInputObjectType({\n\tname: 'S3GenerateSignedUploadInput',\n\tfields: {\n\t\tcontentType: { type: GraphQLString },\n\t\textension: { type: GraphQLString, description: 'If not provided, extension is detected from a content-type.' },\n\t\texpiration: { type: GraphQLInt, description: 'Signed URL expiration.' },\n\t\tsize: { type: GraphQLInt, description: 'Uploaded file size. Required when you enable ACL size limits.' },\n\t\tprefix: { type: GraphQLString, description: 'Can be used as a \"directory\".' },\n\t\tsuffix: { type: GraphQLString, description: 'Suffix after generated id and before the extension.' },\n\t\tfileName: { type: GraphQLString, description: 'This only affects Content-disposition header. Does not affect actual object key.' },\n\t\tcontentDisposition: { type: S3ContentDisposition },\n\t\tacl: { type: S3Acl, description: 'If not supported by S3 provider, an error is thrown.' },\n\t},\n})\nexport interface S3GenerateSignedUploadInput {\n\tcontentType: null | string\n\textension: null | string\n\texpiration: null | number\n\tsize: null | number\n\tprefix: null | string\n\tsuffix: null | string\n\tfileName: null | string\n\tcontentDisposition: null | S3ContentDisposition\n\tacl: null | S3Acl\n}\n"],"names":["GraphQLObjectType","GraphQLNonNull","GraphQLString","GraphQLEnumType","GraphQLList","GraphQLInputObjectType","GraphQLInt"],"mappings":";;;AAEO,MAAM,WAAW,IAAIA,QAAAA,kBAAkB;AAAA,EAC7C,MAAM;AAAA,EACN,QAAQ;AAAA,IACP,KAAK,EAAE,MAAM,IAAIC,QAAAA,eAAeC,QAAAA,aAAa,EAAA;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,QAAAA,aAAa,EAAA;AAAA,IAChD,WAAW,EAAE,MAAM,IAAID,QAAAA,eAAeC,QAAAA,aAAa,EAAA;AAAA,EAAE;AAEvD,CAAC;AAEM,MAAM,QAAQ,IAAIC,QAAAA,gBAAgB;AAAA,EACxC,MAAM;AAAA,EACN,QAAQ;AAAA,IACP,aAAa,CAAA;AAAA,IACb,SAAS,CAAA;AAAA,IACT,MAAM,CAAA;AAAA,EAAC;AAET,CAAC;AAIM,MAAM,8BAA8B,IAAIE,QAAAA,uBAAuB;AAAA,EACrE,MAAM;AAAA,EACN,QAAQ;AAAA,IACP,aAAa,EAAE,MAAMH,sBAAA;AAAA,IACrB,WAAW,EAAE,MAAMA,uBAAe,aAAa,8DAAA;AAAA,IAC/C,YAAY,EAAE,MAAMI,oBAAY,aAAa,yBAAA;AAAA,IAC7C,MAAM,EAAE,MAAMA,oBAAY,aAAa,gEAAA;AAAA,IACvC,QAAQ,EAAE,MAAMJ,uBAAe,aAAa,gCAAA;AAAA,IAC5C,QAAQ,EAAE,MAAMA,uBAAe,aAAa,sDAAA;AAAA,IAC5C,UAAU,EAAE,MAAMA,uBAAe,aAAa,mFAAA;AAAA,IAC9C,oBAAoB,EAAE,MAAM,qBAAA;AAAA,IAC5B,KAAK,EAAE,MAAM,OAAO,aAAa,uDAAA;AAAA,EAAuD;AAE1F,CAAC;;;;;;;"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLEnumType, GraphQLList, GraphQLInputObjectType, GraphQLInt } from "graphql";
|
|
2
|
+
const S3Header = new GraphQLObjectType({
|
|
3
|
+
name: "S3Header",
|
|
4
|
+
fields: {
|
|
5
|
+
key: { type: new GraphQLNonNull(GraphQLString) },
|
|
6
|
+
value: { type: new GraphQLNonNull(GraphQLString) }
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
const S3ContentDisposition = new GraphQLEnumType({
|
|
10
|
+
name: "S33ContentDisposition",
|
|
11
|
+
values: {
|
|
12
|
+
ATTACHMENT: {},
|
|
13
|
+
INLINE: {}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const S3SignedRead = new GraphQLObjectType({
|
|
17
|
+
name: "S3SignedRead",
|
|
18
|
+
fields: {
|
|
19
|
+
url: { type: new GraphQLNonNull(GraphQLString) },
|
|
20
|
+
headers: {
|
|
21
|
+
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(S3Header)))
|
|
22
|
+
},
|
|
23
|
+
method: { type: new GraphQLNonNull(GraphQLString) },
|
|
24
|
+
objectKey: { type: new GraphQLNonNull(GraphQLString) },
|
|
25
|
+
bucket: { type: new GraphQLNonNull(GraphQLString) }
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const S3SignedUpload = new GraphQLObjectType({
|
|
29
|
+
name: "S3SignedUpload",
|
|
30
|
+
fields: {
|
|
31
|
+
url: { type: new GraphQLNonNull(GraphQLString) },
|
|
32
|
+
headers: {
|
|
33
|
+
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(S3Header)))
|
|
34
|
+
},
|
|
35
|
+
method: { type: new GraphQLNonNull(GraphQLString) },
|
|
36
|
+
objectKey: { type: new GraphQLNonNull(GraphQLString) },
|
|
37
|
+
bucket: { type: new GraphQLNonNull(GraphQLString) },
|
|
38
|
+
publicUrl: { type: new GraphQLNonNull(GraphQLString) }
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const S3Acl = new GraphQLEnumType({
|
|
42
|
+
name: "S3Acl",
|
|
43
|
+
values: {
|
|
44
|
+
PUBLIC_READ: {},
|
|
45
|
+
PRIVATE: {},
|
|
46
|
+
NONE: {}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const S3GenerateSignedUploadInput = new GraphQLInputObjectType({
|
|
50
|
+
name: "S3GenerateSignedUploadInput",
|
|
51
|
+
fields: {
|
|
52
|
+
contentType: { type: GraphQLString },
|
|
53
|
+
extension: { type: GraphQLString, description: "If not provided, extension is detected from a content-type." },
|
|
54
|
+
expiration: { type: GraphQLInt, description: "Signed URL expiration." },
|
|
55
|
+
size: { type: GraphQLInt, description: "Uploaded file size. Required when you enable ACL size limits." },
|
|
56
|
+
prefix: { type: GraphQLString, description: 'Can be used as a "directory".' },
|
|
57
|
+
suffix: { type: GraphQLString, description: "Suffix after generated id and before the extension." },
|
|
58
|
+
fileName: { type: GraphQLString, description: "This only affects Content-disposition header. Does not affect actual object key." },
|
|
59
|
+
contentDisposition: { type: S3ContentDisposition },
|
|
60
|
+
acl: { type: S3Acl, description: "If not supported by S3 provider, an error is thrown." }
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
export {
|
|
64
|
+
S3Acl,
|
|
65
|
+
S3ContentDisposition,
|
|
66
|
+
S3GenerateSignedUploadInput,
|
|
67
|
+
S3Header,
|
|
68
|
+
S3SignedRead,
|
|
69
|
+
S3SignedUpload
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=S3SchemaTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"S3SchemaTypes.js","sources":["../../../../packages/engine-s3-plugin/src/S3SchemaTypes.ts"],"sourcesContent":["import { GraphQLEnumType, GraphQLInputObjectType, GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'\n\nexport const S3Header = new GraphQLObjectType({\n\tname: 'S3Header',\n\tfields: {\n\t\tkey: { type: new GraphQLNonNull(GraphQLString) },\n\t\tvalue: { type: new GraphQLNonNull(GraphQLString) },\n\t},\n})\n\nexport const S3ContentDisposition = new GraphQLEnumType({\n\tname: 'S33ContentDisposition',\n\tvalues: {\n\t\tATTACHMENT: {},\n\t\tINLINE: {},\n\t},\n})\nexport type S3ContentDisposition = 'ATTACHMENT' | 'INLINE'\n\nexport const S3SignedRead = new GraphQLObjectType({\n\tname: 'S3SignedRead',\n\tfields: {\n\t\turl: { type: new GraphQLNonNull(GraphQLString) },\n\t\theaders: {\n\t\t\ttype: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(S3Header))),\n\t\t},\n\t\tmethod: { type: new GraphQLNonNull(GraphQLString) },\n\t\tobjectKey: { type: new GraphQLNonNull(GraphQLString) },\n\t\tbucket: { type: new GraphQLNonNull(GraphQLString) },\n\t},\n})\n\nexport const S3SignedUpload = new GraphQLObjectType({\n\tname: 'S3SignedUpload',\n\tfields: {\n\t\turl: { type: new GraphQLNonNull(GraphQLString) },\n\t\theaders: {\n\t\t\ttype: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(S3Header))),\n\t\t},\n\t\tmethod: { type: new GraphQLNonNull(GraphQLString) },\n\t\tobjectKey: { type: new GraphQLNonNull(GraphQLString) },\n\t\tbucket: { type: new GraphQLNonNull(GraphQLString) },\n\t\tpublicUrl: { type: new GraphQLNonNull(GraphQLString) },\n\t},\n})\n\nexport const S3Acl = new GraphQLEnumType({\n\tname: 'S3Acl',\n\tvalues: {\n\t\tPUBLIC_READ: {},\n\t\tPRIVATE: {},\n\t\tNONE: {},\n\t},\n})\n\nexport type S3Acl = 'PUBLIC_READ' | 'PRIVATE' | 'NONE'\n\nexport const S3GenerateSignedUploadInput = new GraphQLInputObjectType({\n\tname: 'S3GenerateSignedUploadInput',\n\tfields: {\n\t\tcontentType: { type: GraphQLString },\n\t\textension: { type: GraphQLString, description: 'If not provided, extension is detected from a content-type.' },\n\t\texpiration: { type: GraphQLInt, description: 'Signed URL expiration.' },\n\t\tsize: { type: GraphQLInt, description: 'Uploaded file size. Required when you enable ACL size limits.' },\n\t\tprefix: { type: GraphQLString, description: 'Can be used as a \"directory\".' },\n\t\tsuffix: { type: GraphQLString, description: 'Suffix after generated id and before the extension.' },\n\t\tfileName: { type: GraphQLString, description: 'This only affects Content-disposition header. Does not affect actual object key.' },\n\t\tcontentDisposition: { type: S3ContentDisposition },\n\t\tacl: { type: S3Acl, description: 'If not supported by S3 provider, an error is thrown.' },\n\t},\n})\nexport interface S3GenerateSignedUploadInput {\n\tcontentType: null | string\n\textension: null | string\n\texpiration: null | number\n\tsize: null | number\n\tprefix: null | string\n\tsuffix: null | string\n\tfileName: null | string\n\tcontentDisposition: null | S3ContentDisposition\n\tacl: null | S3Acl\n}\n"],"names":[],"mappings":";AAEO,MAAM,WAAW,IAAI,kBAAkB;AAAA,EAC7C,MAAM;AAAA,EACN,QAAQ;AAAA,IACP,KAAK,EAAE,MAAM,IAAI,eAAe,aAAa,EAAA;AAAA,IAC7C,OAAO,EAAE,MAAM,IAAI,eAAe,aAAa,EAAA;AAAA,EAAE;AAEnD,CAAC;AAEM,MAAM,uBAAuB,IAAI,gBAAgB;AAAA,EACvD,MAAM;AAAA,EACN,QAAQ;AAAA,IACP,YAAY,CAAA;AAAA,IACZ,QAAQ,CAAA;AAAA,EAAC;AAEX,CAAC;AAGM,MAAM,eAAe,IAAI,kBAAkB;AAAA,EACjD,MAAM;AAAA,EACN,QAAQ;AAAA,IACP,KAAK,EAAE,MAAM,IAAI,eAAe,aAAa,EAAA;AAAA,IAC7C,SAAS;AAAA,MACR,MAAM,IAAI,eAAe,IAAI,YAAY,IAAI,eAAe,QAAQ,CAAC,CAAC;AAAA,IAAA;AAAA,IAEvE,QAAQ,EAAE,MAAM,IAAI,eAAe,aAAa,EAAA;AAAA,IAChD,WAAW,EAAE,MAAM,IAAI,eAAe,aAAa,EAAA;AAAA,IACnD,QAAQ,EAAE,MAAM,IAAI,eAAe,aAAa,EAAA;AAAA,EAAE;AAEpD,CAAC;AAEM,MAAM,iBAAiB,IAAI,kBAAkB;AAAA,EACnD,MAAM;AAAA,EACN,QAAQ;AAAA,IACP,KAAK,EAAE,MAAM,IAAI,eAAe,aAAa,EAAA;AAAA,IAC7C,SAAS;AAAA,MACR,MAAM,IAAI,eAAe,IAAI,YAAY,IAAI,eAAe,QAAQ,CAAC,CAAC;AAAA,IAAA;AAAA,IAEvE,QAAQ,EAAE,MAAM,IAAI,eAAe,aAAa,EAAA;AAAA,IAChD,WAAW,EAAE,MAAM,IAAI,eAAe,aAAa,EAAA;AAAA,IACnD,QAAQ,EAAE,MAAM,IAAI,eAAe,aAAa,EAAA;AAAA,IAChD,WAAW,EAAE,MAAM,IAAI,eAAe,aAAa,EAAA;AAAA,EAAE;AAEvD,CAAC;AAEM,MAAM,QAAQ,IAAI,gBAAgB;AAAA,EACxC,MAAM;AAAA,EACN,QAAQ;AAAA,IACP,aAAa,CAAA;AAAA,IACb,SAAS,CAAA;AAAA,IACT,MAAM,CAAA;AAAA,EAAC;AAET,CAAC;AAIM,MAAM,8BAA8B,IAAI,uBAAuB;AAAA,EACrE,MAAM;AAAA,EACN,QAAQ;AAAA,IACP,aAAa,EAAE,MAAM,cAAA;AAAA,IACrB,WAAW,EAAE,MAAM,eAAe,aAAa,8DAAA;AAAA,IAC/C,YAAY,EAAE,MAAM,YAAY,aAAa,yBAAA;AAAA,IAC7C,MAAM,EAAE,MAAM,YAAY,aAAa,gEAAA;AAAA,IACvC,QAAQ,EAAE,MAAM,eAAe,aAAa,gCAAA;AAAA,IAC5C,QAAQ,EAAE,MAAM,eAAe,aAAa,sDAAA;AAAA,IAC5C,UAAU,EAAE,MAAM,eAAe,aAAa,mFAAA;AAAA,IAC9C,oBAAoB,EAAE,MAAM,qBAAA;AAAA,IAC5B,KAAK,EAAE,MAAM,OAAO,aAAa,uDAAA;AAAA,EAAuD;AAE1F,CAAC;"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const mimeTypes = require("mime-types");
|
|
4
|
+
const Config = require("./Config.cjs");
|
|
5
|
+
const graphqlUtils = require("@contember/graphql-utils");
|
|
6
|
+
const S3Signer = require("./S3Signer.cjs");
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
10
|
+
class S3Service {
|
|
11
|
+
constructor(config, providers, authorizator) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.providers = providers;
|
|
14
|
+
this.authorizator = authorizator;
|
|
15
|
+
__publicField(this, "publicBaseUrl");
|
|
16
|
+
__publicField(this, "signer");
|
|
17
|
+
this.publicBaseUrl = Config.resolveS3PublicBaseUrl(config);
|
|
18
|
+
this.signer = new S3Signer.S3Signer(config, providers);
|
|
19
|
+
}
|
|
20
|
+
getSignedUploadUrl({ acl, contentDisposition, contentType, expiration, prefix, suffix, fileName, extension, size }) {
|
|
21
|
+
const ext = extension ?? ((contentType ? mimeTypes.extension(contentType) : null) || "bin");
|
|
22
|
+
const id = this.providers.uuid();
|
|
23
|
+
const localObjectKey = (prefix ? prefix + "/" : "") + `${id}${suffix ?? ""}.${ext}`;
|
|
24
|
+
this.authorizator.verifyUploadAccess({ key: localObjectKey, size });
|
|
25
|
+
const objectKey = (this.config.prefix ? this.config.prefix + "/" : "") + localObjectKey;
|
|
26
|
+
const bucket = this.config.bucket;
|
|
27
|
+
if (acl && this.config.noAcl) {
|
|
28
|
+
throw new graphqlUtils.UserInputError("ACL is not supported");
|
|
29
|
+
}
|
|
30
|
+
const headers = {
|
|
31
|
+
"Cache-Control": "immutable"
|
|
32
|
+
};
|
|
33
|
+
if (contentType) {
|
|
34
|
+
headers["Content-Type"] = contentType;
|
|
35
|
+
}
|
|
36
|
+
if (!this.config.noAcl && acl !== "NONE") {
|
|
37
|
+
const mapping = { PUBLIC_READ: "public-read", PRIVATE: "private" };
|
|
38
|
+
headers["x-amz-acl"] = mapping[acl ?? "PUBLIC_READ"];
|
|
39
|
+
}
|
|
40
|
+
if (fileName || contentDisposition) {
|
|
41
|
+
let contentDispositionHeader = contentDisposition?.toLowerCase() ?? "inline";
|
|
42
|
+
if (fileName) {
|
|
43
|
+
contentDispositionHeader += `; filename*=UTF-8''${encodeURIComponent(fileName)}`;
|
|
44
|
+
}
|
|
45
|
+
headers["Content-Disposition"] = contentDispositionHeader;
|
|
46
|
+
}
|
|
47
|
+
const headersToSend = Object.entries(headers).map(([key, value]) => ({ key, value }));
|
|
48
|
+
if (size) {
|
|
49
|
+
headers["Content-Length"] = String(size);
|
|
50
|
+
}
|
|
51
|
+
const url = this.signer.sign({
|
|
52
|
+
action: "upload",
|
|
53
|
+
expiration: expiration ?? 3600,
|
|
54
|
+
key: objectKey,
|
|
55
|
+
headers: { ...headers }
|
|
56
|
+
});
|
|
57
|
+
const publicUrl = this.formatPublicUrl(objectKey);
|
|
58
|
+
return {
|
|
59
|
+
bucket,
|
|
60
|
+
objectKey,
|
|
61
|
+
url,
|
|
62
|
+
publicUrl,
|
|
63
|
+
headers: headersToSend,
|
|
64
|
+
method: "PUT"
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
getSignedReadUrl({ objectKey, expiration }) {
|
|
68
|
+
const bucket = this.config.bucket;
|
|
69
|
+
const publicPrefix = this.formatPublicUrl("");
|
|
70
|
+
if (objectKey.startsWith(publicPrefix)) {
|
|
71
|
+
objectKey = objectKey.substring(publicPrefix.length);
|
|
72
|
+
}
|
|
73
|
+
if (this.config.prefix && !objectKey.startsWith(this.config.prefix)) {
|
|
74
|
+
throw new graphqlUtils.ForbiddenError(
|
|
75
|
+
`Given object key "${objectKey}" does not start with a project prefix "${this.config.prefix}"`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
const localObjectKey = this.config.prefix ? objectKey.substring(this.config.prefix.length + 1) : objectKey;
|
|
79
|
+
this.authorizator.verifyReadAccess({ key: localObjectKey });
|
|
80
|
+
const url = this.signer.sign({
|
|
81
|
+
action: "read",
|
|
82
|
+
expiration: expiration ?? 3600,
|
|
83
|
+
key: objectKey,
|
|
84
|
+
headers: {}
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
bucket,
|
|
88
|
+
objectKey,
|
|
89
|
+
url,
|
|
90
|
+
headers: [],
|
|
91
|
+
method: "GET"
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
formatPublicUrl(key) {
|
|
95
|
+
return `${this.publicBaseUrl}/${key}`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
class S3ServiceFactory {
|
|
99
|
+
create(config, providers, authorizator) {
|
|
100
|
+
return new S3Service(config, providers, authorizator);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.S3Service = S3Service;
|
|
104
|
+
exports.S3ServiceFactory = S3ServiceFactory;
|
|
105
|
+
//# sourceMappingURL=S3Service.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"S3Service.cjs","sources":["../../../../packages/engine-s3-plugin/src/S3Service.ts"],"sourcesContent":["import { extension as resolveExtension } from 'mime-types'\nimport { resolveS3PublicBaseUrl, S3Config } from './Config'\nimport { ForbiddenError, UserInputError } from '@contember/graphql-utils'\nimport { Providers } from '@contember/engine-plugins'\nimport { S3Signer } from './S3Signer'\nimport { S3GenerateSignedUploadInput } from './S3SchemaTypes'\nimport { S3ObjectAuthorizator } from './S3ObjectAuthorizator'\n\ntype SignedReadUrl = {\n\turl: string\n\tbucket: string\n\tobjectKey: string\n\theaders: { key: string; value: string }[]\n\tmethod: string\n}\n\ntype SignedUploadUrl = {\n\tobjectKey: string\n\turl: string\n\tbucket: string\n\tpublicUrl: string\n\theaders: { key: string; value: string }[]\n\tmethod: string\n}\n\nexport class S3Service {\n\tprivate readonly publicBaseUrl: string\n\n\tprivate readonly signer: S3Signer\n\n\tconstructor(\n\t\tpublic readonly config: S3Config,\n\t\tprivate readonly providers: Pick<Providers, 'uuid' | 'now'>,\n\t\tprivate readonly authorizator: S3ObjectAuthorizator,\n\t) {\n\t\tthis.publicBaseUrl = resolveS3PublicBaseUrl(config)\n\t\tthis.signer = new S3Signer(config, providers)\n\t}\n\n\tpublic getSignedUploadUrl(\n\t\t{ acl, contentDisposition, contentType, expiration, prefix, suffix, fileName, extension, size }: S3GenerateSignedUploadInput,\n\t): SignedUploadUrl {\n\t\tconst ext = extension ?? ((contentType ? resolveExtension(contentType) : null) || 'bin')\n\t\tconst id = this.providers.uuid()\n\t\tconst localObjectKey = (prefix ? prefix + '/' : '') + `${id}${suffix ?? ''}.${ext}`\n\t\tthis.authorizator.verifyUploadAccess({ key: localObjectKey, size })\n\n\t\tconst objectKey = (this.config.prefix ? this.config.prefix + '/' : '') + localObjectKey\n\n\t\tconst bucket = this.config.bucket\n\t\tif (acl && this.config.noAcl) {\n\t\t\tthrow new UserInputError('ACL is not supported')\n\t\t}\n\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Cache-Control': 'immutable',\n\t\t}\n\t\tif (contentType) {\n\t\t\theaders['Content-Type'] = contentType\n\t\t}\n\n\t\tif (!this.config.noAcl && acl !== 'NONE') {\n\t\t\tconst mapping = { PUBLIC_READ: 'public-read', PRIVATE: 'private' }\n\t\t\theaders['x-amz-acl'] = mapping[acl ?? 'PUBLIC_READ']\n\t\t}\n\t\tif (fileName || contentDisposition) {\n\t\t\tlet contentDispositionHeader = contentDisposition?.toLowerCase() ?? 'inline'\n\t\t\tif (fileName) {\n\t\t\t\tcontentDispositionHeader += `; filename*=UTF-8''${encodeURIComponent(fileName)}`\n\t\t\t}\n\t\t\theaders['Content-Disposition'] = contentDispositionHeader\n\t\t}\n\t\tconst headersToSend = Object.entries(headers).map(([key, value]) => ({ key, value }))\n\n\t\t// intentionally not sending following headers\n\t\tif (size) {\n\t\t\theaders['Content-Length'] = String(size)\n\t\t}\n\n\t\tconst url = this.signer.sign({\n\t\t\taction: 'upload',\n\t\t\texpiration: expiration ?? 3600,\n\t\t\tkey: objectKey,\n\t\t\theaders: { ...headers },\n\t\t})\n\n\t\tconst publicUrl = this.formatPublicUrl(objectKey)\n\t\treturn {\n\t\t\tbucket,\n\t\t\tobjectKey,\n\t\t\turl,\n\t\t\tpublicUrl,\n\t\t\theaders: headersToSend,\n\t\t\tmethod: 'PUT',\n\t\t}\n\t}\n\n\tpublic getSignedReadUrl({ objectKey, expiration }: { objectKey: string; expiration: number | null }): SignedReadUrl {\n\t\tconst bucket = this.config.bucket\n\n\t\tconst publicPrefix = this.formatPublicUrl('')\n\t\tif (objectKey.startsWith(publicPrefix)) {\n\t\t\tobjectKey = objectKey.substring(publicPrefix.length)\n\t\t}\n\t\tif (this.config.prefix && !objectKey.startsWith(this.config.prefix)) {\n\t\t\tthrow new ForbiddenError(\n\t\t\t\t`Given object key \"${objectKey}\" does not start with a project prefix \"${this.config.prefix}\"`,\n\t\t\t)\n\t\t}\n\t\tconst localObjectKey = this.config.prefix ? objectKey.substring(this.config.prefix.length + 1) : objectKey\n\t\tthis.authorizator.verifyReadAccess({ key: localObjectKey })\n\n\t\tconst url = this.signer.sign({\n\t\t\taction: 'read',\n\t\t\texpiration: expiration ?? 3600,\n\t\t\tkey: objectKey,\n\t\t\theaders: {},\n\t\t})\n\n\t\treturn {\n\t\t\tbucket,\n\t\t\tobjectKey,\n\t\t\turl,\n\t\t\theaders: [],\n\t\t\tmethod: 'GET',\n\t\t}\n\t}\n\n\tpublic formatPublicUrl(key: string): string {\n\t\treturn `${this.publicBaseUrl}/${key}`\n\t}\n}\n\nexport class S3ServiceFactory {\n\tpublic create(config: S3Config, providers: Providers, authorizator: S3ObjectAuthorizator) {\n\t\treturn new S3Service(config, providers, authorizator)\n\t}\n}\n"],"names":["resolveS3PublicBaseUrl","S3Signer","resolveExtension","UserInputError","ForbiddenError"],"mappings":";;;;;;;;;AAyBO,MAAM,UAAU;AAAA,EAKtB,YACiB,QACC,WACA,cAChB;AAHe,SAAA,SAAA;AACC,SAAA,YAAA;AACA,SAAA,eAAA;AAPlB,kBAAA,MAAiB,eAAA;AAEjB,kBAAA,MAAiB,QAAA;AAOhB,SAAK,gBAAgBA,OAAAA,uBAAuB,MAAM;AAClD,SAAK,SAAS,IAAIC,kBAAS,QAAQ,SAAS;AAAA,EAC7C;AAAA,EAEO,mBACN,EAAE,KAAK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Config.js";
|
|
3
|
+
import { UserInputError, ForbiddenError } from "@contember/graphql-utils";
|
|
4
|
+
import { S3Signer } from "./S3Signer.js";
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
+
class S3Service {
|
|
9
|
+
constructor(config, providers, authorizator) {
|
|
10
|
+
this.config = config;
|
|
11
|
+
this.providers = providers;
|
|
12
|
+
this.authorizator = authorizator;
|
|
13
|
+
__publicField(this, "publicBaseUrl");
|
|
14
|
+
__publicField(this, "signer");
|
|
15
|
+
this.publicBaseUrl = resolveS3PublicBaseUrl(config);
|
|
16
|
+
this.signer = new S3Signer(config, providers);
|
|
17
|
+
}
|
|
18
|
+
getSignedUploadUrl({ acl, contentDisposition, contentType, expiration, prefix, suffix, fileName, extension: extension$1, size }) {
|
|
19
|
+
const ext = extension$1 ?? ((contentType ? extension(contentType) : null) || "bin");
|
|
20
|
+
const id = this.providers.uuid();
|
|
21
|
+
const localObjectKey = (prefix ? prefix + "/" : "") + `${id}${suffix ?? ""}.${ext}`;
|
|
22
|
+
this.authorizator.verifyUploadAccess({ key: localObjectKey, size });
|
|
23
|
+
const objectKey = (this.config.prefix ? this.config.prefix + "/" : "") + localObjectKey;
|
|
24
|
+
const bucket = this.config.bucket;
|
|
25
|
+
if (acl && this.config.noAcl) {
|
|
26
|
+
throw new UserInputError("ACL is not supported");
|
|
27
|
+
}
|
|
28
|
+
const headers = {
|
|
29
|
+
"Cache-Control": "immutable"
|
|
30
|
+
};
|
|
31
|
+
if (contentType) {
|
|
32
|
+
headers["Content-Type"] = contentType;
|
|
33
|
+
}
|
|
34
|
+
if (!this.config.noAcl && acl !== "NONE") {
|
|
35
|
+
const mapping = { PUBLIC_READ: "public-read", PRIVATE: "private" };
|
|
36
|
+
headers["x-amz-acl"] = mapping[acl ?? "PUBLIC_READ"];
|
|
37
|
+
}
|
|
38
|
+
if (fileName || contentDisposition) {
|
|
39
|
+
let contentDispositionHeader = contentDisposition?.toLowerCase() ?? "inline";
|
|
40
|
+
if (fileName) {
|
|
41
|
+
contentDispositionHeader += `; filename*=UTF-8''${encodeURIComponent(fileName)}`;
|
|
42
|
+
}
|
|
43
|
+
headers["Content-Disposition"] = contentDispositionHeader;
|
|
44
|
+
}
|
|
45
|
+
const headersToSend = Object.entries(headers).map(([key, value]) => ({ key, value }));
|
|
46
|
+
if (size) {
|
|
47
|
+
headers["Content-Length"] = String(size);
|
|
48
|
+
}
|
|
49
|
+
const url = this.signer.sign({
|
|
50
|
+
action: "upload",
|
|
51
|
+
expiration: expiration ?? 3600,
|
|
52
|
+
key: objectKey,
|
|
53
|
+
headers: { ...headers }
|
|
54
|
+
});
|
|
55
|
+
const publicUrl = this.formatPublicUrl(objectKey);
|
|
56
|
+
return {
|
|
57
|
+
bucket,
|
|
58
|
+
objectKey,
|
|
59
|
+
url,
|
|
60
|
+
publicUrl,
|
|
61
|
+
headers: headersToSend,
|
|
62
|
+
method: "PUT"
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
getSignedReadUrl({ objectKey, expiration }) {
|
|
66
|
+
const bucket = this.config.bucket;
|
|
67
|
+
const publicPrefix = this.formatPublicUrl("");
|
|
68
|
+
if (objectKey.startsWith(publicPrefix)) {
|
|
69
|
+
objectKey = objectKey.substring(publicPrefix.length);
|
|
70
|
+
}
|
|
71
|
+
if (this.config.prefix && !objectKey.startsWith(this.config.prefix)) {
|
|
72
|
+
throw new ForbiddenError(
|
|
73
|
+
`Given object key "${objectKey}" does not start with a project prefix "${this.config.prefix}"`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
const localObjectKey = this.config.prefix ? objectKey.substring(this.config.prefix.length + 1) : objectKey;
|
|
77
|
+
this.authorizator.verifyReadAccess({ key: localObjectKey });
|
|
78
|
+
const url = this.signer.sign({
|
|
79
|
+
action: "read",
|
|
80
|
+
expiration: expiration ?? 3600,
|
|
81
|
+
key: objectKey,
|
|
82
|
+
headers: {}
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
bucket,
|
|
86
|
+
objectKey,
|
|
87
|
+
url,
|
|
88
|
+
headers: [],
|
|
89
|
+
method: "GET"
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
formatPublicUrl(key) {
|
|
93
|
+
return `${this.publicBaseUrl}/${key}`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
class S3ServiceFactory {
|
|
97
|
+
create(config, providers, authorizator) {
|
|
98
|
+
return new S3Service(config, providers, authorizator);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
S3Service,
|
|
103
|
+
S3ServiceFactory
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=S3Service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"S3Service.js","sources":["../../../../packages/engine-s3-plugin/src/S3Service.ts"],"sourcesContent":["import { extension as resolveExtension } from 'mime-types'\nimport { resolveS3PublicBaseUrl, S3Config } from './Config'\nimport { ForbiddenError, UserInputError } from '@contember/graphql-utils'\nimport { Providers } from '@contember/engine-plugins'\nimport { S3Signer } from './S3Signer'\nimport { S3GenerateSignedUploadInput } from './S3SchemaTypes'\nimport { S3ObjectAuthorizator } from './S3ObjectAuthorizator'\n\ntype SignedReadUrl = {\n\turl: string\n\tbucket: string\n\tobjectKey: string\n\theaders: { key: string; value: string }[]\n\tmethod: string\n}\n\ntype SignedUploadUrl = {\n\tobjectKey: string\n\turl: string\n\tbucket: string\n\tpublicUrl: string\n\theaders: { key: string; value: string }[]\n\tmethod: string\n}\n\nexport class S3Service {\n\tprivate readonly publicBaseUrl: string\n\n\tprivate readonly signer: S3Signer\n\n\tconstructor(\n\t\tpublic readonly config: S3Config,\n\t\tprivate readonly providers: Pick<Providers, 'uuid' | 'now'>,\n\t\tprivate readonly authorizator: S3ObjectAuthorizator,\n\t) {\n\t\tthis.publicBaseUrl = resolveS3PublicBaseUrl(config)\n\t\tthis.signer = new S3Signer(config, providers)\n\t}\n\n\tpublic getSignedUploadUrl(\n\t\t{ acl, contentDisposition, contentType, expiration, prefix, suffix, fileName, extension, size }: S3GenerateSignedUploadInput,\n\t): SignedUploadUrl {\n\t\tconst ext = extension ?? ((contentType ? resolveExtension(contentType) : null) || 'bin')\n\t\tconst id = this.providers.uuid()\n\t\tconst localObjectKey = (prefix ? prefix + '/' : '') + `${id}${suffix ?? ''}.${ext}`\n\t\tthis.authorizator.verifyUploadAccess({ key: localObjectKey, size })\n\n\t\tconst objectKey = (this.config.prefix ? this.config.prefix + '/' : '') + localObjectKey\n\n\t\tconst bucket = this.config.bucket\n\t\tif (acl && this.config.noAcl) {\n\t\t\tthrow new UserInputError('ACL is not supported')\n\t\t}\n\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Cache-Control': 'immutable',\n\t\t}\n\t\tif (contentType) {\n\t\t\theaders['Content-Type'] = contentType\n\t\t}\n\n\t\tif (!this.config.noAcl && acl !== 'NONE') {\n\t\t\tconst mapping = { PUBLIC_READ: 'public-read', PRIVATE: 'private' }\n\t\t\theaders['x-amz-acl'] = mapping[acl ?? 'PUBLIC_READ']\n\t\t}\n\t\tif (fileName || contentDisposition) {\n\t\t\tlet contentDispositionHeader = contentDisposition?.toLowerCase() ?? 'inline'\n\t\t\tif (fileName) {\n\t\t\t\tcontentDispositionHeader += `; filename*=UTF-8''${encodeURIComponent(fileName)}`\n\t\t\t}\n\t\t\theaders['Content-Disposition'] = contentDispositionHeader\n\t\t}\n\t\tconst headersToSend = Object.entries(headers).map(([key, value]) => ({ key, value }))\n\n\t\t// intentionally not sending following headers\n\t\tif (size) {\n\t\t\theaders['Content-Length'] = String(size)\n\t\t}\n\n\t\tconst url = this.signer.sign({\n\t\t\taction: 'upload',\n\t\t\texpiration: expiration ?? 3600,\n\t\t\tkey: objectKey,\n\t\t\theaders: { ...headers },\n\t\t})\n\n\t\tconst publicUrl = this.formatPublicUrl(objectKey)\n\t\treturn {\n\t\t\tbucket,\n\t\t\tobjectKey,\n\t\t\turl,\n\t\t\tpublicUrl,\n\t\t\theaders: headersToSend,\n\t\t\tmethod: 'PUT',\n\t\t}\n\t}\n\n\tpublic getSignedReadUrl({ objectKey, expiration }: { objectKey: string; expiration: number | null }): SignedReadUrl {\n\t\tconst bucket = this.config.bucket\n\n\t\tconst publicPrefix = this.formatPublicUrl('')\n\t\tif (objectKey.startsWith(publicPrefix)) {\n\t\t\tobjectKey = objectKey.substring(publicPrefix.length)\n\t\t}\n\t\tif (this.config.prefix && !objectKey.startsWith(this.config.prefix)) {\n\t\t\tthrow new ForbiddenError(\n\t\t\t\t`Given object key \"${objectKey}\" does not start with a project prefix \"${this.config.prefix}\"`,\n\t\t\t)\n\t\t}\n\t\tconst localObjectKey = this.config.prefix ? objectKey.substring(this.config.prefix.length + 1) : objectKey\n\t\tthis.authorizator.verifyReadAccess({ key: localObjectKey })\n\n\t\tconst url = this.signer.sign({\n\t\t\taction: 'read',\n\t\t\texpiration: expiration ?? 3600,\n\t\t\tkey: objectKey,\n\t\t\theaders: {},\n\t\t})\n\n\t\treturn {\n\t\t\tbucket,\n\t\t\tobjectKey,\n\t\t\turl,\n\t\t\theaders: [],\n\t\t\tmethod: 'GET',\n\t\t}\n\t}\n\n\tpublic formatPublicUrl(key: string): string {\n\t\treturn `${this.publicBaseUrl}/${key}`\n\t}\n}\n\nexport class S3ServiceFactory {\n\tpublic create(config: S3Config, providers: Providers, authorizator: S3ObjectAuthorizator) {\n\t\treturn new S3Service(config, providers, authorizator)\n\t}\n}\n"],"names":["extension","resolveExtension"],"mappings":";;;;;;;AAyBO,MAAM,UAAU;AAAA,EAKtB,YACiB,QACC,WACA,cAChB;AAHe,SAAA,SAAA;AACC,SAAA,YAAA;AACA,SAAA,eAAA;AAPlB,kBAAA,MAAiB,e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,QAAQ,WAAW,YAAY;AAAA,EACrD;AACD;"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const Config = require("./Config.cjs");
|
|
4
|
+
const qs = require("qs");
|
|
5
|
+
const crypto = require("node:crypto");
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
9
|
+
const hmac = (secret, data) => crypto.createHmac("sha256", secret).update(data).digest();
|
|
10
|
+
const hash = (data) => crypto.createHash("sha256").update(data).digest("hex");
|
|
11
|
+
const unsignableHeaders = ["authorization", "user-agent", "content-type", "expect", "x-amzn-trace-id"];
|
|
12
|
+
const sortMap = (input) => {
|
|
13
|
+
return Object.fromEntries(Object.entries(input).sort((a, b) => a[0] < b[0] ? -1 : 1));
|
|
14
|
+
};
|
|
15
|
+
class S3Signer {
|
|
16
|
+
constructor(config, providers) {
|
|
17
|
+
this.config = config;
|
|
18
|
+
this.providers = providers;
|
|
19
|
+
__publicField(this, "region");
|
|
20
|
+
this.region = config.region || "eu-west-1";
|
|
21
|
+
}
|
|
22
|
+
sign(request) {
|
|
23
|
+
const uris = Config.resolveS3Endpoint(this.config);
|
|
24
|
+
request.headers.host = uris.endpoint.substring(uris.endpoint.indexOf("://") + 3);
|
|
25
|
+
const nowFormatted = this.providers.now().toISOString().replace(/[:-]|\.\d{3}/g, "");
|
|
26
|
+
const queryString = this.getQueryParams(request, nowFormatted);
|
|
27
|
+
const path = uris.basePath + "/" + request.key;
|
|
28
|
+
const lines = [
|
|
29
|
+
request.action === "read" ? "GET" : "PUT",
|
|
30
|
+
path,
|
|
31
|
+
queryString,
|
|
32
|
+
this.getSignedHeaders(request),
|
|
33
|
+
this.getSignedHeaderNames(Object.keys(request.headers)),
|
|
34
|
+
"UNSIGNED-PAYLOAD"
|
|
35
|
+
];
|
|
36
|
+
const canonicalRequest = lines.join("\n");
|
|
37
|
+
const parts = ["AWS4-HMAC-SHA256", nowFormatted, this.getScope(nowFormatted), hash(canonicalRequest)];
|
|
38
|
+
const signature = [nowFormatted.substring(0, 8), this.region, "s3", "aws4_request", parts.join("\n")].reduce((acc, x) => hmac(acc, x), Buffer.from("AWS4" + this.config.credentials.secret)).toString("hex");
|
|
39
|
+
return uris.endpoint + path + "?" + (queryString + "&X-Amz-Signature=" + signature).split("&").sort().join("&");
|
|
40
|
+
}
|
|
41
|
+
getQueryParams(request, dateFormatted) {
|
|
42
|
+
const scope = this.getScope(dateFormatted);
|
|
43
|
+
const queryString = {
|
|
44
|
+
"X-Amz-Date": dateFormatted,
|
|
45
|
+
"X-Amz-Algorithm": "AWS4-HMAC-SHA256",
|
|
46
|
+
"X-Amz-Credential": this.config.credentials.key + "/" + scope,
|
|
47
|
+
"X-Amz-Expires": String(request.expiration),
|
|
48
|
+
"X-Amz-SignedHeaders": this.getSignedHeaderNames(Object.keys(request.headers))
|
|
49
|
+
};
|
|
50
|
+
const headersToQs = ["content-type", "content-md5", "cache-control"];
|
|
51
|
+
for (const header in request.headers) {
|
|
52
|
+
const headerLc = header.toLowerCase();
|
|
53
|
+
if (headersToQs.includes(headerLc) || headerLc.startsWith("x-amz-")) {
|
|
54
|
+
queryString[headerLc.startsWith("x-amz-meta-") ? headerLc : header] = request.headers[header];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const qsSorted = sortMap(queryString);
|
|
58
|
+
return qs.stringify(qsSorted);
|
|
59
|
+
}
|
|
60
|
+
getScope(dateFormatted) {
|
|
61
|
+
return dateFormatted.substring(0, 8) + "/" + this.region + "/s3/aws4_request";
|
|
62
|
+
}
|
|
63
|
+
getSignedHeaders(request) {
|
|
64
|
+
const lines = [];
|
|
65
|
+
for (const header in request.headers) {
|
|
66
|
+
const headerNameLc = header.toLowerCase();
|
|
67
|
+
if (!this.isHeaderSignable(headerNameLc)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const value = request.headers[header].replace(/\s+/g, " ").replace(/^\s+|\s+$/g, "");
|
|
71
|
+
lines.push(`${headerNameLc}:${value}
|
|
72
|
+
`);
|
|
73
|
+
}
|
|
74
|
+
return lines.sort().join("");
|
|
75
|
+
}
|
|
76
|
+
isHeaderSignable(headerName) {
|
|
77
|
+
return headerName.toLowerCase().startsWith("x-amz") || !unsignableHeaders.includes(headerName.toLowerCase());
|
|
78
|
+
}
|
|
79
|
+
getSignedHeaderNames(headers) {
|
|
80
|
+
return headers.map((it) => it.toLowerCase()).filter(this.isHeaderSignable).sort().join(";");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.S3Signer = S3Signer;
|
|
84
|
+
//# sourceMappingURL=S3Signer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"S3Signer.cjs","sources":["../../../../packages/engine-s3-plugin/src/S3Signer.ts"],"sourcesContent":["import { resolveS3Endpoint, S3Config } from './Config'\nimport { Providers } from '@contember/engine-plugins'\nimport qs from 'qs'\nimport { BinaryLike, createHash, createHmac } from 'node:crypto'\n\ninterface S3Request {\n\taction: 'read' | 'upload'\n\tkey: string\n\texpiration: number\n\theaders: Record<string, string>\n}\n\nconst hmac = (secret: BinaryLike, data: BinaryLike) => createHmac('sha256', secret).update(data).digest()\n\nconst hash = (data: BinaryLike) => createHash('sha256').update(data).digest('hex')\n\nconst unsignableHeaders = ['authorization', 'user-agent', 'content-type', 'expect', 'x-amzn-trace-id']\n\nconst sortMap = <T extends Record<string, any>>(input: T): T => {\n\treturn Object.fromEntries(Object.entries(input).sort((a, b) => (a[0] < b[0] ? -1 : 1))) as T\n}\nexport class S3Signer {\n\tprivate region: string\n\n\tconstructor(private readonly config: S3Config, private readonly providers: Pick<Providers, 'now'>) {\n\t\tthis.region = config.region || 'eu-west-1'\n\t}\n\n\tpublic sign(request: S3Request) {\n\t\tconst uris = resolveS3Endpoint(this.config)\n\t\trequest.headers.host = uris.endpoint.substring(uris.endpoint.indexOf('://') + 3)\n\t\tconst nowFormatted = this.providers\n\t\t\t.now()\n\t\t\t.toISOString()\n\t\t\t.replace(/[:-]|\\.\\d{3}/g, '')\n\t\tconst queryString = this.getQueryParams(request, nowFormatted)\n\t\tconst path = uris.basePath + '/' + request.key\n\t\tconst lines = [\n\t\t\trequest.action === 'read' ? 'GET' : 'PUT',\n\t\t\tpath,\n\t\t\tqueryString,\n\t\t\tthis.getSignedHeaders(request),\n\t\t\tthis.getSignedHeaderNames(Object.keys(request.headers)),\n\t\t\t'UNSIGNED-PAYLOAD',\n\t\t]\n\t\tconst canonicalRequest = lines.join('\\n')\n\n\t\tconst parts = ['AWS4-HMAC-SHA256', nowFormatted, this.getScope(nowFormatted), hash(canonicalRequest)]\n\n\t\tconst signature = [nowFormatted.substring(0, 8), this.region, 's3', 'aws4_request', parts.join('\\n')]\n\t\t\t.reduce<Buffer>((acc, x) => hmac(acc, x), Buffer.from('AWS4' + this.config.credentials.secret))\n\t\t\t.toString('hex')\n\t\treturn uris.endpoint + path + '?' + (queryString + '&X-Amz-Signature=' + signature).split('&').sort().join('&')\n\t}\n\n\tprivate getQueryParams(request: S3Request, dateFormatted: string) {\n\t\tconst scope = this.getScope(dateFormatted)\n\t\tconst queryString: Record<string, string> = {\n\t\t\t'X-Amz-Date': dateFormatted,\n\t\t\t'X-Amz-Algorithm': 'AWS4-HMAC-SHA256',\n\t\t\t'X-Amz-Credential': this.config.credentials.key + '/' + scope,\n\t\t\t'X-Amz-Expires': String(request.expiration),\n\t\t\t'X-Amz-SignedHeaders': this.getSignedHeaderNames(Object.keys(request.headers)),\n\t\t}\n\n\t\tconst headersToQs = ['content-type', 'content-md5', 'cache-control']\n\t\tfor (const header in request.headers) {\n\t\t\tconst headerLc = header.toLowerCase()\n\t\t\tif (headersToQs.includes(headerLc) || headerLc.startsWith('x-amz-')) {\n\t\t\t\tqueryString[headerLc.startsWith('x-amz-meta-') ? headerLc : header] = request.headers[header]\n\t\t\t}\n\t\t}\n\t\tconst qsSorted = sortMap(queryString)\n\t\treturn qs.stringify(qsSorted)\n\t}\n\n\tprivate getScope(dateFormatted: string) {\n\t\treturn dateFormatted.substring(0, 8) + '/' + this.region + '/s3/aws4_request'\n\t}\n\n\tprivate getSignedHeaders(request: S3Request): string {\n\t\tconst lines = []\n\t\tfor (const header in request.headers) {\n\t\t\tconst headerNameLc = header.toLowerCase()\n\t\t\tif (!this.isHeaderSignable(headerNameLc)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst value = request.headers[header].replace(/\\s+/g, ' ').replace(/^\\s+|\\s+$/g, '')\n\t\t\tlines.push(`${headerNameLc}:${value}\\n`)\n\t\t}\n\t\treturn lines.sort().join('')\n\t}\n\n\tprivate isHeaderSignable(headerName: string) {\n\t\treturn headerName.toLowerCase().startsWith('x-amz') || !unsignableHeaders.includes(headerName.toLowerCase())\n\t}\n\n\tprivate getSignedHeaderNames(headers: string[]) {\n\t\treturn headers\n\t\t\t.map(it => it.toLowerCase())\n\t\t\t.filter(this.isHeaderSignable)\n\t\t\t.sort()\n\t\t\t.join(';')\n\t}\n}\n"],"names":["createHmac","createHash","resolveS3Endpoint"],"mappings":";;;;;;;;AAYA,MAAM,OAAO,CAAC,QAAoB,SAAqBA,kBAAW,UAAU,MAAM,EAAE,OAAO,IAAI,EAAE,OAAA;AAEjG,MAAM,OAAO,CAAC,SAAqBC,OAAAA,WAAW,QAAQ,EAAE,OAAO,IAAI,EAAE,OAAO,KAAK;AAEjF,MAAM,oBAAoB,CAAC,iBAAiB,cAAc,gBAAgB,UAAU,iBAAiB;AAErG,MAAM,UAAU,CAAgC,UAAgB;AAC/D,SAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,EAAE,KAAK,CAAC,GAAG,MAAO,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,KAAK,CAAE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