@social-mail/social-mail-web-server 1.7.548 → 1.7.549

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.
Files changed (33) hide show
  1. package/dist/server/model/entities/StoreItem.d.ts.map +1 -1
  2. package/dist/server/model/entities/StoreItem.js.map +1 -1
  3. package/dist/server/model/entities/StoreMediaFile.d.ts.map +1 -1
  4. package/dist/server/model/entities/StoreMediaFile.js.map +1 -1
  5. package/dist/server/model/events/StoreItemEvents.d.ts +4 -1
  6. package/dist/server/model/events/StoreItemEvents.d.ts.map +1 -1
  7. package/dist/server/model/events/StoreItemEvents.js +6 -6
  8. package/dist/server/model/events/StoreItemEvents.js.map +1 -1
  9. package/dist/server/model/events/StoreMediaFileEvents.d.ts +2 -2
  10. package/dist/server/model/events/StoreMediaFileEvents.d.ts.map +1 -1
  11. package/dist/server/model/events/StoreMediaFileEvents.js +9 -46
  12. package/dist/server/model/events/StoreMediaFileEvents.js.map +1 -1
  13. package/dist/server/services/SignerService.d.ts +1 -15
  14. package/dist/server/services/SignerService.d.ts.map +1 -1
  15. package/dist/server/services/SignerService.js +46 -54
  16. package/dist/server/services/SignerService.js.map +1 -1
  17. package/dist/tsconfig.tsbuildinfo +1 -1
  18. package/dist/wwwroot/routes/api/signed/get1.d.ts +2 -0
  19. package/dist/wwwroot/routes/api/signed/get1.d.ts.map +1 -0
  20. package/dist/wwwroot/routes/api/signed/get1.js +68 -0
  21. package/dist/wwwroot/routes/api/signed/get1.js.map +1 -0
  22. package/package.json +2 -2
  23. package/src/server/model/entities/StoreItem.ts +0 -4
  24. package/src/server/model/entities/StoreMediaFile.ts +0 -3
  25. package/src/server/model/events/StoreItemEvents.ts +7 -7
  26. package/src/server/model/events/StoreMediaFileEvents.ts +8 -46
  27. package/src/server/services/SignerService.ts +45 -45
  28. package/src/wwwroot/routes/api/signed/get1.tsx +79 -0
  29. package/dist/wwwroot/routes/api/signed/get.d.ts +0 -10
  30. package/dist/wwwroot/routes/api/signed/get.d.ts.map +0 -1
  31. package/dist/wwwroot/routes/api/signed/get.js +0 -81
  32. package/dist/wwwroot/routes/api/signed/get.js.map +0 -1
  33. package/src/wwwroot/routes/api/signed/get.tsx +0 -80
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=get1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get1.d.ts","sourceRoot":"","sources":["../../../../../src/wwwroot/routes/api/signed/get1.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,68 @@
1
+ // import Inject, { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
2
+ // import SocialMailContext from "../../../../server/model/SocialMailContext.js";
3
+ // import TempFileService from "../../../../server/storage/TempFileService.js";
4
+ // import ImageConverterService from "../../../../server/services/image-converter/ImageConverterService.js";
5
+ // import { TempFileResult } from "@entity-access/server-pages/dist/Content.js";
6
+ // import Page from "@entity-access/server-pages/dist/Page.js";
7
+ // import CacheService from "../../../../server/services/cache/CacheService.js";
8
+ // import TimeSpan from "@entity-access/entity-access/dist/types/TimeSpan.js";
9
+ // import FileConversionService from "../../../../server/services/convert/FileConversionService.js";
10
+ // import AppFile from "../../../../server/model/entities/AppFile.js";
11
+ export {};
12
+ // export default class extends Page {
13
+ // @Inject
14
+ // private tfs: TempFileService;
15
+ // @Inject
16
+ // private cacheService: CacheService;
17
+ // @Inject
18
+ // private db: SocialMailContext;
19
+ // @Inject
20
+ // private signerService: SignerService;
21
+ // async run() {
22
+ // const type = this.childPath[0];
23
+ // // we will not convert as BigInt might have loss of data
24
+ // const fileID = this.childPath[1] as unknown as number;
25
+ // const fileContentID = this.childPath[2] as unknown as number;
26
+ // const signature = this.childPath[3];
27
+ // const expiry = this.childPath[4];
28
+ // // verify hash ....
29
+ // this.signerService.signer<AppFile>().verify({ appFileID: fileID , fileContentID }, signature, expiry);
30
+ // this.db.verifyFilters = true;
31
+ // const fc = await this.db.appFiles
32
+ // .where({ fileID, fileContentID },
33
+ // (p) => (x) => x.fileContentID === p.fileContentID
34
+ // && x.appFileID === p.fileID)
35
+ // .include((x) => x.fileContent)
36
+ // .firstOrFail();
37
+ // this.db.verifyFilters = false;
38
+ // this.db.raiseEvents = false;
39
+ // this.cacheControl = "public, max-age=2592000, immutable";
40
+ // let file = await this.tfs.downloadFileContent(fc.fileContent, fc);
41
+ // const key = this.request.path;
42
+ // const ttl = TimeSpan.fromDays(30);
43
+ // // transform here...
44
+ // if (/^(size|jpg|png|webp|gif|face\-circle)\(/i.test(type)) {
45
+ // file = await this.cacheService.get({ key, ttl, factory: async () => {
46
+ // // resize...
47
+ // const ics = ServiceProvider.resolve(this, ImageConverterService);
48
+ // return await ics.transform(type, file, this.childPath[this.childPath.length-1] );
49
+ // } });
50
+ // } else if (/^(pdf|html|webm)$/i.test(type)) {
51
+ // file = await this.cacheService.get({ key, ttl, factory: async () => {
52
+ // const ics = ServiceProvider.resolve(this, FileConversionService);
53
+ // return await ics[type.toLowerCase()](file, this.childPath[this.childPath.length-1] );
54
+ // } });
55
+ // }
56
+ // return new TempFileResult(
57
+ // file,
58
+ // {
59
+ // contentDisposition: type === "download"
60
+ // ? "attachment"
61
+ // : "inline",
62
+ // immutable: true,
63
+ // etag: false
64
+ // }
65
+ // );
66
+ // }
67
+ // }
68
+ //# sourceMappingURL=get1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get1.js","sourceRoot":"","sources":["../../../../../src/wwwroot/routes/api/signed/get1.tsx"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,iFAAiF;AACjF,+EAA+E;AAC/E,4GAA4G;AAC5G,gFAAgF;AAChF,+DAA+D;AAC/D,gFAAgF;AAChF,8EAA8E;AAC9E,oGAAoG;AACpG,sEAAsE;;AAEtE,sCAAsC;AAEtC,cAAc;AACd,oCAAoC;AAEpC,cAAc;AACd,0CAA0C;AAE1C,cAAc;AACd,qCAAqC;AAErC,cAAc;AACd,4CAA4C;AAE5C,oBAAoB;AAEpB,0CAA0C;AAC1C,mEAAmE;AACnE,iEAAiE;AACjE,wEAAwE;AACxE,+CAA+C;AAC/C,4CAA4C;AAE5C,8BAA8B;AAC9B,iHAAiH;AAEjH,wCAAwC;AACxC,4CAA4C;AAC5C,gDAAgD;AAChD,oEAAoE;AACpE,mDAAmD;AACnD,6CAA6C;AAC7C,8BAA8B;AAC9B,yCAAyC;AACzC,uCAAuC;AACvC,oEAAoE;AACpE,6EAA6E;AAE7E,yCAAyC;AAEzC,6CAA6C;AAE7C,+BAA+B;AAC/B,uEAAuE;AACvE,oFAAoF;AACpF,+BAA+B;AAC/B,oFAAoF;AACpF,oGAAoG;AACpG,oBAAoB;AACpB,wDAAwD;AACxD,oFAAoF;AACpF,oFAAoF;AACpF,wGAAwG;AACxG,oBAAoB;AACpB,YAAY;AAEZ,qCAAqC;AACrC,oBAAoB;AACpB,gBAAgB;AAChB,0DAA0D;AAC1D,qCAAqC;AACrC,kCAAkC;AAClC,mCAAmC;AACnC,8BAA8B;AAC9B,gBAAgB;AAChB,aAAa;AACb,QAAQ;AACR,IAAI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-web-server",
3
- "version": "1.7.548",
3
+ "version": "1.7.549",
4
4
  "description": "## Phase 1",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "@aws-sdk/client-s3": "^3.717.0",
23
23
  "@azure/storage-blob": "^12.25.0",
24
24
  "@entity-access/entity-access": "^1.0.433",
25
- "@entity-access/server-pages": "^1.1.439",
25
+ "@entity-access/server-pages": "^1.1.441",
26
26
  "@ffmpeg/core-mt": "^0.12.6",
27
27
  "@ffmpeg/ffmpeg": "^0.12.10",
28
28
  "@ffmpeg/util": "^0.12.1",
@@ -1,13 +1,10 @@
1
1
  import Column from "@entity-access/entity-access/dist/decorators/Column.js";
2
2
  import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js";
3
3
  import Table from "@entity-access/entity-access/dist/decorators/Table.js";
4
- import { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
5
4
  import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
6
5
  import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
7
6
  import { JsonProperty, ReadOnlyJsonProperty } from "@entity-access/server-pages/dist/services/ModelService.js";
8
- import SignerService from "../../services/SignerService.js";
9
7
  import AppFile from "./AppFile.js";
10
- import Contact from "./Contact.js";
11
8
  import type { StoreInsight } from "./StoreInsight.js";
12
9
  import { StoreItemFolder } from "./StoreItemFolder.js";
13
10
  import type { StoreItemPrice } from "./StoreItemPrice.js";
@@ -16,7 +13,6 @@ import type { StoreItemTax } from "./StoreItemTax.js";
16
13
  import type { StoreJournalLineItem } from "./StoreJournalLineItem.js";
17
14
  import { StoreAccount } from "./StoreAccount.js";
18
15
  import type { StoreMediaFile } from "./StoreMediaFile.js";
19
- import Page from "@entity-access/server-pages/dist/Page.js";
20
16
  import WebSite from "./WebSite.js";
21
17
  import type StoreCoupon from "./StoreCoupon.js";
22
18
  import type WebHook from "./WebHook.js";
@@ -2,12 +2,9 @@ import CheckConstraint from "@entity-access/entity-access/dist/decorators/CheckC
2
2
  import Column from "@entity-access/entity-access/dist/decorators/Column.js";
3
3
  import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js";
4
4
  import Table from "@entity-access/entity-access/dist/decorators/Table.js";
5
- import { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
6
5
  import { ReadOnlyJsonProperty } from "@entity-access/server-pages/dist/services/ModelService.js";
7
- import SignerService from "../../services/SignerService.js";
8
6
  import AppFile from "./AppFile.js";
9
7
  import { StoreItem } from "./StoreItem.js";
10
- import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
11
8
 
12
9
  @Table("StoreMediaFiles")
13
10
  @CheckConstraint({
@@ -11,15 +11,19 @@ import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
11
11
  import StoreTagCountService from "../../services/store/StoreTagCountService.js";
12
12
  import StoreFileService from "../../services/StoreFileService.js";
13
13
  import EncryptionService from "../../services/encryption/EncryptionService.js";
14
- import SignerService from "../../services/SignerService.js";
15
14
  import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
15
+ import SessionSecurity from "@entity-access/server-pages/dist/services/SessionSecurity.js";
16
16
 
17
17
  const till = new DateTime(DateTime.today.year + 2, 1, 1);
18
18
 
19
19
  export default class StoreItemEvents extends AuthenticatedEvents<StoreItem> {
20
20
 
21
21
  @Inject
22
- private encryptionService: EncryptionService;
22
+ encryptionService: EncryptionService;
23
+
24
+ @Inject
25
+ sessionSecurity: SessionSecurity;
26
+
23
27
 
24
28
  @ExternalQuery
25
29
  storeQuery() {
@@ -117,11 +121,7 @@ export default class StoreItemEvents extends AuthenticatedEvents<StoreItem> {
117
121
 
118
122
  preJson(entity: StoreItem): StoreItem {
119
123
  entity.publicFolderID = this.encryptionService.general.encrypt(entity.storeID.toString());
120
- const ss = ServiceProvider.resolve(this, SignerService);
121
- const page = ServiceProvider.resolve(this, Page as any) as Page;
122
- const host = page?.request?.hostName ?? "";
123
- const { signature, expiry } = ss.signer().sign({ storeItemID: entity.storeItemID, host }, { till });
124
- entity.signed = signature + "/" + expiry;
124
+ this.sessionSecurity.injectPublicKey(entity);
125
125
  return entity;
126
126
  }
127
127
 
@@ -4,60 +4,21 @@ import EntityAccessError from "@entity-access/entity-access/dist/common/EntityAc
4
4
  import { StoreMediaFile } from "../entities/StoreMediaFile.js";
5
5
  import ChangeEntry from "@entity-access/entity-access/dist/model/changes/ChangeEntry.js";
6
6
  import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
7
- import { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
8
- import SignerService from "../../services/SignerService.js";
7
+ import Inject, { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
9
8
  import AppFile from "../entities/AppFile.js";
10
9
  import SocialMailContext from "../SocialMailContext.js";
11
10
  import ExternalQuery from "@entity-access/server-pages/dist/decorators/ExternalQuery.js";
12
11
  import Page from "@entity-access/server-pages/dist/Page.js";
13
12
  import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
14
13
  import EncryptionService from "../../services/encryption/EncryptionService.js";
14
+ import SessionSecurity from "@entity-access/server-pages/dist/services/SessionSecurity.js";
15
15
 
16
16
  const till = new DateTime(DateTime.today.year + 2, 1, 1);
17
17
 
18
18
  export default class StoreMediaFileEvents extends AuthenticatedEvents<StoreMediaFile> {
19
19
 
20
- @ExternalQuery
21
- siteQuery(publicFolderID) {
22
-
23
- if (!publicFolderID) {
24
- throw new EntityAccessError(`publicFolderID is required`);
25
- }
26
-
27
- const ecs = ServiceProvider.resolve(this, EncryptionService);
28
- const root = ecs.general.decrypt(publicFolderID);
29
-
30
- const rootPath = root + "/%";
31
-
32
- const db = ServiceProvider.resolve(this, SocialMailContext);
33
- const q = db.storeMediaFiles.where({ rootPath }, (p) => (x) =>
34
- Sql.text.like(x.appFile.path, p.rootPath)
35
- );
36
- return q;
37
- }
38
-
39
- @ExternalQuery
40
- storeQuery(storeItemID, signed) {
41
-
42
- if (!storeItemID) {
43
- throw new EntityAccessError(`storeItemID is required`);
44
- }
45
- if (!signed) {
46
- throw new EntityAccessError(`signed is required`);
47
- }
48
-
49
- const page = ServiceProvider.resolve(this, Page as any) as Page;
50
- const host = page.request.host;
51
-
52
- const ss = ServiceProvider.resolve(this, SignerService);
53
- const [ signature, expiry ] = signed.split("/");
54
-
55
- ss.signer().verify({ storeItemID, host }, signature, expiry);
56
-
57
- const db = ServiceProvider.resolve(this, SocialMailContext);
58
- const q = db.storeMediaFiles.where({ host, storeItemID }, (p) => (x) => x.storeItemID === p.storeItemID);
59
- return q;
60
- }
20
+ @Inject
21
+ sessionSecurity: SessionSecurity;
61
22
 
62
23
  filter(query: IEntityQuery<StoreMediaFile>) {
63
24
  if (!this.verify) {
@@ -112,9 +73,10 @@ export default class StoreMediaFileEvents extends AuthenticatedEvents<StoreMedia
112
73
  }
113
74
 
114
75
  preJson(entity: StoreMediaFile): StoreMediaFile {
115
- const ss = ServiceProvider.resolve(this, SignerService);
116
- const { signature, expiry } = ss.signer<AppFile>().sign({ appFileID: entity.appFileID, fileContentID: entity.fileContentID }, { till });
117
- entity.signed = signature + "/" + expiry;
76
+ this.sessionSecurity.injectPublicKey(entity);
77
+ // const ss = ServiceProvider.resolve(this, SignerService);
78
+ // const { signature, expiry } = ss.signer<AppFile>().sign({ appFileID: entity.appFileID, fileContentID: entity.fileContentID }, { till });
79
+ // entity.signed = signature + "/" + expiry;
118
80
  return entity;
119
81
  }
120
82
  }
@@ -1,49 +1,49 @@
1
- import { RegisterSingleton, RegisterTransient } from "@entity-access/entity-access/dist/di/di.js";
2
- import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
3
- import TimeSpan from "@entity-access/entity-access/dist/types/TimeSpan.js";
4
- import { globalEnv } from "../../common/globalEnv.js";
5
- import crypto, { sign } from "node:crypto";
6
- import EntityAccessError from "@entity-access/entity-access/dist/common/EntityAccessError.js";
7
- import { Base36 } from "../../common/Base36.js";
1
+ // import { RegisterSingleton, RegisterTransient } from "@entity-access/entity-access/dist/di/di.js";
2
+ // import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
3
+ // import TimeSpan from "@entity-access/entity-access/dist/types/TimeSpan.js";
4
+ // import { globalEnv } from "../../common/globalEnv.js";
5
+ // import crypto, { sign } from "node:crypto";
6
+ // import EntityAccessError from "@entity-access/entity-access/dist/common/EntityAccessError.js";
7
+ // import { Base36 } from "../../common/Base36.js";
8
8
 
9
- @RegisterTransient
10
- export default class SignerService {
9
+ // @RegisterTransient
10
+ // export default class SignerService {
11
11
 
12
- public signer<T = any>() {
13
- return {
14
- sign: (data: Partial<T>, { ttl = TimeSpan.fromDays(365), till }: { ttl?: TimeSpan, till?: DateTime } = {}) => {
15
- till ??= DateTime.now.add(ttl);
16
- const expiry = Math.ceil(till.msSinceEpoch).toString(36);
17
- const signature = this.signInternal(data, expiry);
18
- return { signature, expiry };
19
- },
20
- verify: (data: Partial<T>, signature, expiry) => {
21
- const date = DateTime.from(Base36.decode(expiry));
22
- if (date.msSinceEpoch < Date.now()) {
23
- throw new EntityAccessError("Signature expired");
24
- }
25
- const s1 = this.signInternal(data, expiry);
26
- if (s1 !== signature) {
27
- throw new EntityAccessError("Invalid signature");
28
- }
29
- }
30
- };
31
- }
12
+ // public signer<T = any>() {
13
+ // return {
14
+ // sign: (data: Partial<T>, { ttl = TimeSpan.fromDays(365), till }: { ttl?: TimeSpan, till?: DateTime } = {}) => {
15
+ // till ??= DateTime.now.add(ttl);
16
+ // const expiry = Math.ceil(till.msSinceEpoch).toString(36);
17
+ // const signature = this.signInternal(data, expiry);
18
+ // return { signature, expiry };
19
+ // },
20
+ // verify: (data: Partial<T>, signature, expiry) => {
21
+ // const date = DateTime.from(Base36.decode(expiry));
22
+ // if (date.msSinceEpoch < Date.now()) {
23
+ // throw new EntityAccessError("Signature expired");
24
+ // }
25
+ // const s1 = this.signInternal(data, expiry);
26
+ // if (s1 !== signature) {
27
+ // throw new EntityAccessError("Invalid signature");
28
+ // }
29
+ // }
30
+ // };
31
+ // }
32
32
 
33
- private signInternal(data: any, expiry: any) {
33
+ // private signInternal(data: any, expiry: any) {
34
34
 
35
- const keys = Object.keys(data).sort((a, b) => a.localeCompare(b));
36
- const finalObject = {};
37
- for (const iterator of keys) {
38
- finalObject[iterator] = data[iterator];
39
- }
40
- const key = `social-mail-${JSON.stringify(finalObject)}-${globalEnv.secretKey}-${globalEnv.serverID}-${expiry}`;
41
- const sha256 = crypto.createHash("sha256");
42
- let signature = sha256.update(key).digest("base64url");
43
- const lastIndex = signature.lastIndexOf("=");
44
- if (lastIndex !== -1) {
45
- signature = signature.substring(0, lastIndex);
46
- }
47
- return signature;
48
- }
49
- }
35
+ // const keys = Object.keys(data).sort((a, b) => a.localeCompare(b));
36
+ // const finalObject = {};
37
+ // for (const iterator of keys) {
38
+ // finalObject[iterator] = data[iterator];
39
+ // }
40
+ // const key = `social-mail-${JSON.stringify(finalObject)}-${globalEnv.secretKey}-${globalEnv.serverID}-${expiry}`;
41
+ // const sha256 = crypto.createHash("sha256");
42
+ // let signature = sha256.update(key).digest("base64url");
43
+ // const lastIndex = signature.lastIndexOf("=");
44
+ // if (lastIndex !== -1) {
45
+ // signature = signature.substring(0, lastIndex);
46
+ // }
47
+ // return signature;
48
+ // }
49
+ // }
@@ -0,0 +1,79 @@
1
+ // import Inject, { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
2
+ // import SocialMailContext from "../../../../server/model/SocialMailContext.js";
3
+ // import TempFileService from "../../../../server/storage/TempFileService.js";
4
+ // import ImageConverterService from "../../../../server/services/image-converter/ImageConverterService.js";
5
+ // import { TempFileResult } from "@entity-access/server-pages/dist/Content.js";
6
+ // import Page from "@entity-access/server-pages/dist/Page.js";
7
+ // import CacheService from "../../../../server/services/cache/CacheService.js";
8
+ // import TimeSpan from "@entity-access/entity-access/dist/types/TimeSpan.js";
9
+ // import FileConversionService from "../../../../server/services/convert/FileConversionService.js";
10
+ // import AppFile from "../../../../server/model/entities/AppFile.js";
11
+
12
+ // export default class extends Page {
13
+
14
+ // @Inject
15
+ // private tfs: TempFileService;
16
+
17
+ // @Inject
18
+ // private cacheService: CacheService;
19
+
20
+ // @Inject
21
+ // private db: SocialMailContext;
22
+
23
+ // @Inject
24
+ // private signerService: SignerService;
25
+
26
+ // async run() {
27
+
28
+ // const type = this.childPath[0];
29
+ // // we will not convert as BigInt might have loss of data
30
+ // const fileID = this.childPath[1] as unknown as number;
31
+ // const fileContentID = this.childPath[2] as unknown as number;
32
+ // const signature = this.childPath[3];
33
+ // const expiry = this.childPath[4];
34
+
35
+ // // verify hash ....
36
+ // this.signerService.signer<AppFile>().verify({ appFileID: fileID , fileContentID }, signature, expiry);
37
+
38
+ // this.db.verifyFilters = true;
39
+ // const fc = await this.db.appFiles
40
+ // .where({ fileID, fileContentID },
41
+ // (p) => (x) => x.fileContentID === p.fileContentID
42
+ // && x.appFileID === p.fileID)
43
+ // .include((x) => x.fileContent)
44
+ // .firstOrFail();
45
+ // this.db.verifyFilters = false;
46
+ // this.db.raiseEvents = false;
47
+ // this.cacheControl = "public, max-age=2592000, immutable";
48
+ // let file = await this.tfs.downloadFileContent(fc.fileContent, fc);
49
+
50
+ // const key = this.request.path;
51
+
52
+ // const ttl = TimeSpan.fromDays(30);
53
+
54
+ // // transform here...
55
+ // if (/^(size|jpg|png|webp|gif|face\-circle)\(/i.test(type)) {
56
+ // file = await this.cacheService.get({ key, ttl, factory: async () => {
57
+ // // resize...
58
+ // const ics = ServiceProvider.resolve(this, ImageConverterService);
59
+ // return await ics.transform(type, file, this.childPath[this.childPath.length-1] );
60
+ // } });
61
+ // } else if (/^(pdf|html|webm)$/i.test(type)) {
62
+ // file = await this.cacheService.get({ key, ttl, factory: async () => {
63
+ // const ics = ServiceProvider.resolve(this, FileConversionService);
64
+ // return await ics[type.toLowerCase()](file, this.childPath[this.childPath.length-1] );
65
+ // } });
66
+ // }
67
+
68
+ // return new TempFileResult(
69
+ // file,
70
+ // {
71
+ // contentDisposition: type === "download"
72
+ // ? "attachment"
73
+ // : "inline",
74
+ // immutable: true,
75
+ // etag: false
76
+ // }
77
+ // );
78
+ // }
79
+ // }
@@ -1,10 +0,0 @@
1
- import { TempFileResult } from "@entity-access/server-pages/dist/Content.js";
2
- import Page from "@entity-access/server-pages/dist/Page.js";
3
- export default class extends Page {
4
- private tfs;
5
- private cacheService;
6
- private db;
7
- private signerService;
8
- run(): Promise<TempFileResult>;
9
- }
10
- //# sourceMappingURL=get.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../../src/wwwroot/routes/api/signed/get.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAC7E,OAAO,IAAI,MAAM,0CAA0C,CAAC;AAO5D,MAAM,CAAC,OAAO,MAAO,SAAQ,IAAI;IAG7B,OAAO,CAAC,GAAG,CAAkB;IAG7B,OAAO,CAAC,YAAY,CAAe;IAGnC,OAAO,CAAC,EAAE,CAAoB;IAG9B,OAAO,CAAC,aAAa,CAAgB;IAE/B,GAAG;CAqDZ"}
@@ -1,81 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import Inject, { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
11
- import SocialMailContext from "../../../../server/model/SocialMailContext.js";
12
- import TempFileService from "../../../../server/storage/TempFileService.js";
13
- import ImageConverterService from "../../../../server/services/image-converter/ImageConverterService.js";
14
- import { TempFileResult } from "@entity-access/server-pages/dist/Content.js";
15
- import Page from "@entity-access/server-pages/dist/Page.js";
16
- import CacheService from "../../../../server/services/cache/CacheService.js";
17
- import TimeSpan from "@entity-access/entity-access/dist/types/TimeSpan.js";
18
- import FileConversionService from "../../../../server/services/convert/FileConversionService.js";
19
- import SignerService from "../../../../server/services/SignerService.js";
20
- export default class default_1 extends Page {
21
- async run() {
22
- const type = this.childPath[0];
23
- // we will not convert as BigInt might have loss of data
24
- const fileID = this.childPath[1];
25
- const fileContentID = this.childPath[2];
26
- const signature = this.childPath[3];
27
- const expiry = this.childPath[4];
28
- // verify hash ....
29
- this.signerService.signer().verify({ appFileID: fileID, fileContentID }, signature, expiry);
30
- this.db.verifyFilters = true;
31
- const fc = await this.db.appFiles
32
- .where({ fileID, fileContentID }, (p) => (x) => x.fileContentID === p.fileContentID
33
- && x.appFileID === p.fileID)
34
- .include((x) => x.fileContent)
35
- .firstOrFail();
36
- this.db.verifyFilters = false;
37
- this.db.raiseEvents = false;
38
- this.cacheControl = "public, max-age=2592000, immutable";
39
- let file = await this.tfs.downloadFileContent(fc.fileContent, fc);
40
- const key = this.request.path;
41
- const ttl = TimeSpan.fromDays(30);
42
- // transform here...
43
- if (/^(size|jpg|png|webp|gif|face\-circle)\(/i.test(type)) {
44
- file = await this.cacheService.get({ key, ttl, factory: async () => {
45
- // resize...
46
- const ics = ServiceProvider.resolve(this, ImageConverterService);
47
- return await ics.transform(type, file, this.childPath[this.childPath.length - 1]);
48
- } });
49
- }
50
- else if (/^(pdf|html|webm)$/i.test(type)) {
51
- file = await this.cacheService.get({ key, ttl, factory: async () => {
52
- const ics = ServiceProvider.resolve(this, FileConversionService);
53
- return await ics[type.toLowerCase()](file, this.childPath[this.childPath.length - 1]);
54
- } });
55
- }
56
- return new TempFileResult(file, {
57
- contentDisposition: type === "download"
58
- ? "attachment"
59
- : "inline",
60
- immutable: true,
61
- etag: false
62
- });
63
- }
64
- }
65
- __decorate([
66
- Inject,
67
- __metadata("design:type", TempFileService)
68
- ], default_1.prototype, "tfs", void 0);
69
- __decorate([
70
- Inject,
71
- __metadata("design:type", CacheService)
72
- ], default_1.prototype, "cacheService", void 0);
73
- __decorate([
74
- Inject,
75
- __metadata("design:type", SocialMailContext)
76
- ], default_1.prototype, "db", void 0);
77
- __decorate([
78
- Inject,
79
- __metadata("design:type", SignerService)
80
- ], default_1.prototype, "signerService", void 0);
81
- //# sourceMappingURL=get.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../../src/wwwroot/routes/api/signed/get.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,EAAE,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,iBAAiB,MAAM,+CAA+C,CAAC;AAC9E,OAAO,eAAe,MAAM,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ACjE,OAAO,MAAM,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAC,CAAC,CAAC,CAAE,CAAC;gBACzF,CAAC,EAAE,CAAC,CAAC;QACT,CAAC;QAED,OAAO,IAAI,cAAc,CACrB,IAAI,EACJ;YACI,kBAAkB,EAAE,IAAI,KAAK,UAAU;gBACnC,CAAC,CAAC,YAAY;gBACd,CAAC,CAAC,QAAQ;YACd,SAAS,EAAE,IAAI;YACf,IAAI,EAAE,KAAK;SACd,CACJ,CAAC;IACN,CAAC;CACJ;AAhEW;IADP,MAAM;8BACM,eAAe;sCAAC;AAGrB;IADP,MAAM;8BACe,YAAY;+CAAC;AAG3B;IADP,MAAM;8BACK,iBAAiB;qCAAC;AAGtB;IADP,MAAM;8BACgB,aAAa;gDAAC"}
@@ -1,80 +0,0 @@
1
- import Inject, { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js";
2
- import SocialMailContext from "../../../../server/model/SocialMailContext.js";
3
- import TempFileService from "../../../../server/storage/TempFileService.js";
4
- import ImageConverterService from "../../../../server/services/image-converter/ImageConverterService.js";
5
- import { TempFileResult } from "@entity-access/server-pages/dist/Content.js";
6
- import Page from "@entity-access/server-pages/dist/Page.js";
7
- import CacheService from "../../../../server/services/cache/CacheService.js";
8
- import TimeSpan from "@entity-access/entity-access/dist/types/TimeSpan.js";
9
- import FileConversionService from "../../../../server/services/convert/FileConversionService.js";
10
- import SignerService from "../../../../server/services/SignerService.js";
11
- import AppFile from "../../../../server/model/entities/AppFile.js";
12
-
13
- export default class extends Page {
14
-
15
- @Inject
16
- private tfs: TempFileService;
17
-
18
- @Inject
19
- private cacheService: CacheService;
20
-
21
- @Inject
22
- private db: SocialMailContext;
23
-
24
- @Inject
25
- private signerService: SignerService;
26
-
27
- async run() {
28
-
29
- const type = this.childPath[0];
30
- // we will not convert as BigInt might have loss of data
31
- const fileID = this.childPath[1] as unknown as number;
32
- const fileContentID = this.childPath[2] as unknown as number;
33
- const signature = this.childPath[3];
34
- const expiry = this.childPath[4];
35
-
36
- // verify hash ....
37
- this.signerService.signer<AppFile>().verify({ appFileID: fileID , fileContentID }, signature, expiry);
38
-
39
- this.db.verifyFilters = true;
40
- const fc = await this.db.appFiles
41
- .where({ fileID, fileContentID },
42
- (p) => (x) => x.fileContentID === p.fileContentID
43
- && x.appFileID === p.fileID)
44
- .include((x) => x.fileContent)
45
- .firstOrFail();
46
- this.db.verifyFilters = false;
47
- this.db.raiseEvents = false;
48
- this.cacheControl = "public, max-age=2592000, immutable";
49
- let file = await this.tfs.downloadFileContent(fc.fileContent, fc);
50
-
51
- const key = this.request.path;
52
-
53
- const ttl = TimeSpan.fromDays(30);
54
-
55
- // transform here...
56
- if (/^(size|jpg|png|webp|gif|face\-circle)\(/i.test(type)) {
57
- file = await this.cacheService.get({ key, ttl, factory: async () => {
58
- // resize...
59
- const ics = ServiceProvider.resolve(this, ImageConverterService);
60
- return await ics.transform(type, file, this.childPath[this.childPath.length-1] );
61
- } });
62
- } else if (/^(pdf|html|webm)$/i.test(type)) {
63
- file = await this.cacheService.get({ key, ttl, factory: async () => {
64
- const ics = ServiceProvider.resolve(this, FileConversionService);
65
- return await ics[type.toLowerCase()](file, this.childPath[this.childPath.length-1] );
66
- } });
67
- }
68
-
69
- return new TempFileResult(
70
- file,
71
- {
72
- contentDisposition: type === "download"
73
- ? "attachment"
74
- : "inline",
75
- immutable: true,
76
- etag: false
77
- }
78
- );
79
- }
80
- }