@social-mail/social-mail-web-server 1.8.473 → 1.8.476
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 +5 -1
- package/dist/server/services/puppeteer/PuppeteerService.d.ts.map +1 -1
- package/dist/server/services/puppeteer/PuppeteerService.js +16 -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 +4 -2
- 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 +18 -4
- package/src/wwwroot/routes/store/journals/[journalID]/pdf/get.tsx +5 -2
|
@@ -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;CAwBZ"}
|
|
@@ -18,10 +18,12 @@ export default class default_1 extends Page {
|
|
|
18
18
|
const { journalID } = this;
|
|
19
19
|
const journal = await this.db.storeJournals.statements.select({}, { journalID });
|
|
20
20
|
const fileName = `${journal.invoiceID}.pdf`;
|
|
21
|
+
const domain = this.request.URL.hostname;
|
|
21
22
|
const file = await this.puppeteerService.generate({
|
|
22
|
-
url: `https://${
|
|
23
|
+
url: `https://${domain}/store/journals/${journalID}`,
|
|
23
24
|
output: "pdf",
|
|
24
|
-
test: "window.pageReady"
|
|
25
|
+
test: "window.pageReady",
|
|
26
|
+
page: this
|
|
25
27
|
});
|
|
26
28
|
return new TempFileResult(file, {
|
|
27
29
|
contentDisposition: "inline",
|
|
@@ -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,KAAK,CAAC,GAAG;QAEL,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAE3B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,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ACR,WAAW,EAAE,iBAAiB;SACjC,CAAC,CAAC;IACP,CAAC;CACJ;AAhCG;IADC,MAAM;8BACH,iBAAiB;qCAAC;AAGtB;IADC,MAAM;8BACW,gBAAgB;mDAAC;AAGnC;IADC,KAAK,CAAC,WAAW,CAAC;;4CACJ"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
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 AuthorizationService from "@entity-access/server-pages/dist/services/AuthorizationService.js";
|
|
9
|
+
import Page from "@entity-access/server-pages/dist/Page.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
|
+
authService: AuthorizationService;
|
|
24
|
+
|
|
20
25
|
async generate({
|
|
21
26
|
url,
|
|
22
27
|
mobile = false,
|
|
@@ -27,10 +32,18 @@ export default class PuppeteerService {
|
|
|
27
32
|
packageHash = globalEnv.serverID,
|
|
28
33
|
test = "true" as ("true" | "window.pageReady"),
|
|
29
34
|
testDelay = 1000,
|
|
30
|
-
timeout = 15000
|
|
35
|
+
timeout = 15000,
|
|
36
|
+
page = void 0 as Page
|
|
31
37
|
}) {
|
|
32
38
|
|
|
33
|
-
const
|
|
39
|
+
const pageCookies = page?.request?.cookies;
|
|
40
|
+
let cookies = void 0;
|
|
41
|
+
if (pageCookies) {
|
|
42
|
+
const domain = page.request.URL.hostname;
|
|
43
|
+
cookies = JSON.stringify(Object.entries(pageCookies).map(([name, value]) => ({ name, value, domain, httpOnly: true, secure: true })));
|
|
44
|
+
}
|
|
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
|
|
|
@@ -24,10 +24,13 @@ export default class extends Page {
|
|
|
24
24
|
|
|
25
25
|
const fileName = `${journal.invoiceID}.pdf`;
|
|
26
26
|
|
|
27
|
+
const domain = this.request.URL.hostname;
|
|
28
|
+
|
|
27
29
|
const file = await this.puppeteerService.generate({
|
|
28
|
-
url: `https://${
|
|
30
|
+
url: `https://${domain}/store/journals/${journalID}`,
|
|
29
31
|
output: "pdf",
|
|
30
|
-
test: "window.pageReady"
|
|
32
|
+
test: "window.pageReady",
|
|
33
|
+
page: this
|
|
31
34
|
});
|
|
32
35
|
|
|
33
36
|
|