@social-mail/social-mail-web-server 1.8.472 → 1.8.474
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/server/services/puppeteer/PuppeteerService.d.ts +7 -1
- package/dist/server/services/puppeteer/PuppeteerService.d.ts.map +1 -1
- package/dist/server/services/puppeteer/PuppeteerService.js +24 -4
- package/dist/server/services/puppeteer/PuppeteerService.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/wwwroot/routes/store/journals/[journalID]/pdf/get.d.ts.map +1 -1
- package/dist/wwwroot/routes/store/journals/[journalID]/pdf/get.js +2 -6
- package/dist/wwwroot/routes/store/journals/[journalID]/pdf/get.js.map +1 -1
- package/package.json +1 -1
- package/src/server/services/puppeteer/PuppeteerService.ts +26 -4
- package/src/wwwroot/routes/store/journals/[journalID]/pdf/get.tsx +2 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../../../../src/wwwroot/routes/store/journals/[journalID]/pdf/get.tsx"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,0CAA0C,CAAC;AAC5D,OAAO,iBAAiB,MAAM,qDAAqD,CAAC;AACpF,OAAO,gBAAgB,MAAM,iEAAiE,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAE7E,MAAM,CAAC,OAAO,MAAO,SAAQ,IAAI;IAG7B,EAAE,EAAE,iBAAiB,CAAC;IAGtB,gBAAgB,EAAE,gBAAgB,CAAC;IAGnC,SAAS,EAAE,GAAG,CAAC;IAET,GAAG;
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../../../../src/wwwroot/routes/store/journals/[journalID]/pdf/get.tsx"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,0CAA0C,CAAC;AAC5D,OAAO,iBAAiB,MAAM,qDAAqD,CAAC;AACpF,OAAO,gBAAgB,MAAM,iEAAiE,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAE7E,MAAM,CAAC,OAAO,MAAO,SAAQ,IAAI;IAG7B,EAAE,EAAE,iBAAiB,CAAC;IAGtB,gBAAgB,EAAE,gBAAgB,CAAC;IAGnC,SAAS,EAAE,GAAG,CAAC;IAET,GAAG;CAqBZ"}
|
|
@@ -16,14 +16,10 @@ import { TempFileResult } from "@entity-access/server-pages/dist/Content.js";
|
|
|
16
16
|
export default class default_1 extends Page {
|
|
17
17
|
async run() {
|
|
18
18
|
const { journalID } = this;
|
|
19
|
-
const journal = await this.db.storeJournals
|
|
20
|
-
.where({ journalID }, (p) => (x) => x.journalID === p.journalID)
|
|
21
|
-
.include((x) => [x.store.hosts])
|
|
22
|
-
.first();
|
|
23
|
-
const host = journal.store.hosts[0].host;
|
|
19
|
+
const journal = await this.db.storeJournals.statements.select({}, { journalID });
|
|
24
20
|
const fileName = `${journal.invoiceID}.pdf`;
|
|
25
21
|
const file = await this.puppeteerService.generate({
|
|
26
|
-
url: `https://${
|
|
22
|
+
url: `https://${this.request.URL.hostname}/store/journals/${journalID}`,
|
|
27
23
|
output: "pdf",
|
|
28
24
|
test: "window.pageReady"
|
|
29
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../../../../src/wwwroot/routes/store/journals/[journalID]/pdf/get.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,4CAA4C,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,gDAAgD,CAAC;AACvE,OAAO,IAAI,MAAM,0CAA0C,CAAC;AAC5D,OAAO,iBAAiB,MAAM,qDAAqD,CAAC;AACpF,OAAO,gBAAgB,MAAM,iEAAiE,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAE7E,MAAM,CAAC,OAAO,gBAAO,SAAQ,IAAI;IAW7B,K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AAGtB;IADC,MAAM;8BACW,gBAAgB;mDAAC;AAGnC;IADC,KAAK,CAAC,WAAW,CAAC;;4CACJ"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import Inject, {
|
|
2
|
+
import Inject, { RegisterScoped } from "@entity-access/entity-access/dist/di/di.js";
|
|
3
3
|
import { fetch } from "undici";
|
|
4
4
|
import { hash } from "crypto";
|
|
5
5
|
import { globalEnv } from "../../../common/globalEnv.js";
|
|
6
6
|
import LockFile from "../../storage/LockFile.js";
|
|
7
7
|
import SiteDiskContentCache from "../files/SiteDiskContentCache.js";
|
|
8
|
+
import Page from "@entity-access/server-pages/dist/Page.js";
|
|
9
|
+
import AuthorizationService from "@entity-access/server-pages/dist/services/AuthorizationService.js";
|
|
8
10
|
|
|
9
11
|
let port = globalEnv.puppeteer.port as any;
|
|
10
12
|
if (/^\d+$/i.test(port)) {
|
|
11
13
|
port = Number(port);
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
@
|
|
16
|
+
@RegisterScoped
|
|
15
17
|
export default class PuppeteerService {
|
|
16
18
|
|
|
17
19
|
@Inject
|
|
18
20
|
siteCache: SiteDiskContentCache;
|
|
19
21
|
|
|
22
|
+
@Inject
|
|
23
|
+
page: Page;
|
|
24
|
+
|
|
25
|
+
@Inject
|
|
26
|
+
authService: AuthorizationService;
|
|
27
|
+
|
|
20
28
|
async generate({
|
|
21
29
|
url,
|
|
22
30
|
mobile = false,
|
|
@@ -27,10 +35,15 @@ export default class PuppeteerService {
|
|
|
27
35
|
packageHash = globalEnv.serverID,
|
|
28
36
|
test = "true" as ("true" | "window.pageReady"),
|
|
29
37
|
testDelay = 1000,
|
|
30
|
-
timeout = 15000
|
|
38
|
+
timeout = 15000,
|
|
39
|
+
sendCookies = true,
|
|
31
40
|
}) {
|
|
32
41
|
|
|
33
|
-
const
|
|
42
|
+
const u = new URL(url);
|
|
43
|
+
|
|
44
|
+
const cookies = sendCookies ? this.getCookies(u.hostname) : "";
|
|
45
|
+
|
|
46
|
+
const key = `previews/${packageHash}/${mobile? "mobile" : "desktop"}/preview-${hash("sha256", url + "&cookies=" + cookies, "hex")}.${output}`;
|
|
34
47
|
|
|
35
48
|
const file = await this.siteCache.htmlCache.getOrCreateAsync(key, async (lf) => {
|
|
36
49
|
|
|
@@ -45,6 +58,7 @@ export default class PuppeteerService {
|
|
|
45
58
|
test,
|
|
46
59
|
testDelay: testDelay as any,
|
|
47
60
|
timeout: timeout as any,
|
|
61
|
+
cookies,
|
|
48
62
|
output
|
|
49
63
|
});
|
|
50
64
|
|
|
@@ -82,4 +96,12 @@ export default class PuppeteerService {
|
|
|
82
96
|
|
|
83
97
|
}
|
|
84
98
|
|
|
99
|
+
getCookies(domain): string {
|
|
100
|
+
const cookies = this.page?.request.cookies;
|
|
101
|
+
if (!cookies) {
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
return JSON.stringify(Object.entries(cookies).map(([name, value]) => ({ name, value, domain, httpOnly: true, secure: true })));
|
|
105
|
+
}
|
|
106
|
+
|
|
85
107
|
}
|
|
@@ -20,19 +20,12 @@ export default class extends Page {
|
|
|
20
20
|
|
|
21
21
|
const { journalID } = this;
|
|
22
22
|
|
|
23
|
-
const journal = await this.db.storeJournals
|
|
24
|
-
.where({ journalID }, (p) => (x) =>
|
|
25
|
-
x.journalID === p.journalID
|
|
26
|
-
)
|
|
27
|
-
.include((x) => [x.store.hosts])
|
|
28
|
-
.first();
|
|
29
|
-
|
|
30
|
-
const host = journal.store.hosts[0].host;
|
|
23
|
+
const journal = await this.db.storeJournals.statements.select({} , { journalID });
|
|
31
24
|
|
|
32
25
|
const fileName = `${journal.invoiceID}.pdf`;
|
|
33
26
|
|
|
34
27
|
const file = await this.puppeteerService.generate({
|
|
35
|
-
url: `https://${
|
|
28
|
+
url: `https://${this.request.URL.hostname}/store/journals/${journalID}`,
|
|
36
29
|
output: "pdf",
|
|
37
30
|
test: "window.pageReady"
|
|
38
31
|
});
|