@ironsoftware/ironpdf 2026.5.1 → 2026.7.2
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/package.json +8 -5
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/index.ts +1 -0
- package/src/internal/IronPdfEngine.ProtoFiles/iron_pdf_service.proto +5 -0
- package/src/internal/IronPdfEngine.ProtoFiles/pdfium_compress.proto +1 -0
- package/src/internal/IronPdfEngine.ProtoFiles/pdfium_form.proto +32 -0
- package/src/internal/IronPdfEngine.ProtoFiles/qpdf.proto +35 -0
- package/src/internal/access.d.ts.map +1 -1
- package/src/internal/access.js +3 -0
- package/src/internal/access.js.map +1 -1
- package/src/internal/access.ts +4 -0
- package/src/internal/generated_proto/iron_pdf_service.d.ts +14 -0
- package/src/internal/generated_proto/iron_pdf_service.d.ts.map +1 -1
- package/src/internal/generated_proto/iron_pdf_service.ts +14 -0
- package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.d.ts +38 -0
- package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.d.ts.map +1 -1
- package/src/internal/generated_proto/ironpdfengineproto/IronPdfService.ts +46 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumCompressImagesRequestP.d.ts +2 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumCompressImagesRequestP.d.ts.map +1 -1
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumCompressImagesRequestP.ts +2 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.d.ts +8 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackRequestP.ts +11 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.d.ts +12 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP.ts +15 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.d.ts +25 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP.ts +28 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.d.ts +12 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP.ts +15 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.d.ts +23 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedFromBytesRequestStreamP.ts +26 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.d.ts +15 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressAndSaveAsAdvancedRequestP.ts +18 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.d.ts +30 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.d.ts.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.js +4 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.js.map +1 -0
- package/src/internal/generated_proto/ironpdfengineproto/QPdfCompressionFlagsP.ts +33 -0
- package/src/internal/grpc_layer/pdfium/compress.d.ts +41 -1
- package/src/internal/grpc_layer/pdfium/compress.d.ts.map +1 -1
- package/src/internal/grpc_layer/pdfium/compress.js +220 -9
- package/src/internal/grpc_layer/pdfium/compress.js.map +1 -1
- package/src/internal/grpc_layer/pdfium/compress.ts +264 -2
- package/src/internal/grpc_layer/pdfium/form.d.ts +15 -0
- package/src/internal/grpc_layer/pdfium/form.d.ts.map +1 -0
- package/src/internal/grpc_layer/pdfium/form.js +99 -0
- package/src/internal/grpc_layer/pdfium/form.js.map +1 -0
- package/src/internal/grpc_layer/pdfium/form.ts +119 -0
- package/src/internal/grpc_layer/pdfium/formFontValidator.d.ts +26 -0
- package/src/internal/grpc_layer/pdfium/formFontValidator.d.ts.map +1 -0
- package/src/internal/grpc_layer/pdfium/formFontValidator.js +81 -0
- package/src/internal/grpc_layer/pdfium/formFontValidator.js.map +1 -0
- package/src/internal/grpc_layer/pdfium/formFontValidator.ts +86 -0
- package/src/internal/grpc_layer/pdfium/io.d.ts +2 -1
- package/src/internal/grpc_layer/pdfium/io.d.ts.map +1 -1
- package/src/internal/grpc_layer/pdfium/io.js +41 -36
- package/src/internal/grpc_layer/pdfium/io.js.map +1 -1
- package/src/internal/grpc_layer/pdfium/io.ts +43 -36
- package/src/internal/grpc_layer/pdfium/signing.d.ts +29 -2
- package/src/internal/grpc_layer/pdfium/signing.d.ts.map +1 -1
- package/src/internal/grpc_layer/pdfium/signing.js +28 -10
- package/src/internal/grpc_layer/pdfium/signing.js.map +1 -1
- package/src/internal/grpc_layer/pdfium/signing.ts +51 -11
- package/src/internal/image_codec.d.ts +20 -0
- package/src/internal/image_codec.d.ts.map +1 -0
- package/src/internal/image_codec.js +127 -0
- package/src/internal/image_codec.js.map +1 -0
- package/src/internal/image_codec.ts +108 -0
- package/src/public/compression.d.ts +92 -0
- package/src/public/compression.d.ts.map +1 -0
- package/src/public/compression.js +26 -0
- package/src/public/compression.js.map +1 -0
- package/src/public/compression.ts +107 -0
- package/src/public/ironpdfglobalconfig.d.ts +12 -0
- package/src/public/ironpdfglobalconfig.d.ts.map +1 -1
- package/src/public/ironpdfglobalconfig.js +7 -0
- package/src/public/ironpdfglobalconfig.js.map +1 -1
- package/src/public/ironpdfglobalconfig.ts +19 -0
- package/src/public/pdfDocument.d.ts +81 -0
- package/src/public/pdfDocument.d.ts.map +1 -1
- package/src/public/pdfDocument.js +212 -24
- package/src/public/pdfDocument.js.map +1 -1
- package/src/public/pdfDocument.ts +228 -28
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.disableFormFontFallback = exports.setFormFont = void 0;
|
|
13
|
+
const access_1 = require("../../access");
|
|
14
|
+
const util_1 = require("../util");
|
|
15
|
+
const formFontValidator_1 = require("./formFontValidator");
|
|
16
|
+
/**
|
|
17
|
+
* Stream a font (or just a name reference) to the engine so subsequent
|
|
18
|
+
* form-field fills with non-ASCII values use the supplied font instead of
|
|
19
|
+
* triggering the automatic Tahoma/Arial fallback embed.
|
|
20
|
+
*/
|
|
21
|
+
function setFormFont(id, fontName, fontData, forceEmbed) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
(0, formFontValidator_1.validateFormFontName)(fontName);
|
|
24
|
+
// Distinguish between "name-only mode" (caller passed undefined/null) and
|
|
25
|
+
// "caller passed bytes". An explicit Buffer — even an empty one — runs the
|
|
26
|
+
// data validator, which rejects empty/oversize/non-sfnt payloads. Mirrors
|
|
27
|
+
// .NET FormFontValidator behaviour where an empty byte[] is a caller error.
|
|
28
|
+
if (fontData !== undefined && fontData !== null) {
|
|
29
|
+
(0, formFontValidator_1.validateFormFontData)(fontData);
|
|
30
|
+
}
|
|
31
|
+
const client = yield access_1.Access.ensureConnection();
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
let resolved = false;
|
|
34
|
+
const stream = client.Pdfium_Form_SetFormFont((err, value) => {
|
|
35
|
+
if (resolved)
|
|
36
|
+
return;
|
|
37
|
+
resolved = true;
|
|
38
|
+
if (err) {
|
|
39
|
+
reject(`${err.name}/n${err.message}`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!value) {
|
|
43
|
+
reject("No response from IronPdfEngine for setFormFont");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (value.exception) {
|
|
47
|
+
(0, util_1.handleRemoteException)(value.exception, reject);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
resolve();
|
|
51
|
+
});
|
|
52
|
+
// Send Info first.
|
|
53
|
+
stream.write({
|
|
54
|
+
info: {
|
|
55
|
+
document: { documentId: id },
|
|
56
|
+
fontName: fontName,
|
|
57
|
+
fontBytesSize: fontData ? fontData.length : 0,
|
|
58
|
+
forceEmbed: forceEmbed,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
// Stream bytes (if any).
|
|
62
|
+
if (fontData && fontData.length > 0) {
|
|
63
|
+
for (const chunk of (0, util_1.chunkBuffer)(fontData)) {
|
|
64
|
+
stream.write({ fontBytesChunk: chunk });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
stream.end();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
exports.setFormFont = setFormFont;
|
|
72
|
+
/**
|
|
73
|
+
* Suppress the engine's automatic Tahoma/Arial fallback embed for non-ASCII
|
|
74
|
+
* form-field values without registering a replacement font.
|
|
75
|
+
*/
|
|
76
|
+
function disableFormFontFallback(id) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const client = yield access_1.Access.ensureConnection();
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
client.Pdfium_Form_DisableFormFontFallback({ document: { documentId: id } }, (err, value) => {
|
|
81
|
+
if (err) {
|
|
82
|
+
reject(`${err.name}/n${err.message}`);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!value) {
|
|
86
|
+
reject("No response from IronPdfEngine for disableFormFontFallback");
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (value.exception) {
|
|
90
|
+
(0, util_1.handleRemoteException)(value.exception, reject);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
resolve();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
exports.disableFormFontFallback = disableFormFontFallback;
|
|
99
|
+
//# sourceMappingURL=form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.js","sourceRoot":"","sources":["form.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAAoC;AAWpC,kCAA2D;AAC3D,2DAA+E;AAE/E;;;;GAIG;AACH,SAAsB,WAAW,CAChC,EAAU,EACV,QAAgB,EAChB,QAA4B,EAC5B,UAAmB;;QAEnB,IAAA,wCAAoB,EAAC,QAAQ,CAAC,CAAC;QAC/B,0EAA0E;QAC1E,2EAA2E;QAC3E,0EAA0E;QAC1E,4EAA4E;QAC5E,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE;YAChD,IAAA,wCAAoB,EAAC,QAAQ,CAAC,CAAC;SAC/B;QAED,MAAM,MAAM,GAAyB,MAAM,eAAM,CAAC,gBAAgB,EAAE,CAAC;QAErE,OAAO,IAAI,OAAO,CACjB,CAAC,OAAmB,EAAE,MAAkC,EAAE,EAAE;YAC3D,IAAI,QAAQ,GAAG,KAAK,CAAC;YACrB,MAAM,MAAM,GACX,MAAM,CAAC,uBAAuB,CAC7B,CACC,GAA6B,EAC7B,KAAmD,EAClD,EAAE;gBACH,IAAI,QAAQ;oBAAE,OAAO;gBACrB,QAAQ,GAAG,IAAI,CAAC;gBAChB,IAAI,GAAG,EAAE;oBACR,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;oBACtC,OAAO;iBACP;gBACD,IAAI,CAAC,KAAK,EAAE;oBACX,MAAM,CAAC,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CAAC;oBACtC,OAAO;iBACP;gBACD,IAAI,CAAC,KAAK,EAAE;oBACX,MAAM,CAAC,4DAA4D,CAAC,CAAC;oBACrE,OAAO;iBACP;gBACD,IAAI,KAAK,CAAC,SAAS,EAAE;oBACpB,IAAA,4BAAqB,EAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;oBAC/C,OAAO;iBACP;gBACD,OAAO,EAAE,CAAC;YACX,CAAC,CACD,CAAC;QACH,CAAC,CACD,CAAC;IACH,CAAC;CAAA;AA5BD,0DA4BC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as grpc from "@grpc/grpc-js";
|
|
2
|
+
import {Buffer} from "buffer";
|
|
3
|
+
import {Access} from "../../access";
|
|
4
|
+
import {IronPdfServiceClient} from "../../generated_proto/ironpdfengineproto/IronPdfService";
|
|
5
|
+
import {
|
|
6
|
+
PdfiumSetFormFontRequestStreamP
|
|
7
|
+
} from "../../generated_proto/ironpdfengineproto/PdfiumSetFormFontRequestStreamP";
|
|
8
|
+
import {
|
|
9
|
+
PdfiumSetFormFontResultP__Output
|
|
10
|
+
} from "../../generated_proto/ironpdfengineproto/PdfiumSetFormFontResultP";
|
|
11
|
+
import {
|
|
12
|
+
PdfiumDisableFormFontFallbackResultP__Output
|
|
13
|
+
} from "../../generated_proto/ironpdfengineproto/PdfiumDisableFormFontFallbackResultP";
|
|
14
|
+
import {chunkBuffer, handleRemoteException} from "../util";
|
|
15
|
+
import {validateFormFontData, validateFormFontName} from "./formFontValidator";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Stream a font (or just a name reference) to the engine so subsequent
|
|
19
|
+
* form-field fills with non-ASCII values use the supplied font instead of
|
|
20
|
+
* triggering the automatic Tahoma/Arial fallback embed.
|
|
21
|
+
*/
|
|
22
|
+
export async function setFormFont(
|
|
23
|
+
id: string,
|
|
24
|
+
fontName: string,
|
|
25
|
+
fontData: Buffer | undefined,
|
|
26
|
+
forceEmbed: boolean
|
|
27
|
+
): Promise<void> {
|
|
28
|
+
validateFormFontName(fontName);
|
|
29
|
+
// Distinguish between "name-only mode" (caller passed undefined/null) and
|
|
30
|
+
// "caller passed bytes". An explicit Buffer — even an empty one — runs the
|
|
31
|
+
// data validator, which rejects empty/oversize/non-sfnt payloads. Mirrors
|
|
32
|
+
// .NET FormFontValidator behaviour where an empty byte[] is a caller error.
|
|
33
|
+
if (fontData !== undefined && fontData !== null) {
|
|
34
|
+
validateFormFontData(fontData);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const client: IronPdfServiceClient = await Access.ensureConnection();
|
|
38
|
+
|
|
39
|
+
return new Promise(
|
|
40
|
+
(resolve: () => void, reject: (errorMsg: string) => void) => {
|
|
41
|
+
let resolved = false;
|
|
42
|
+
const stream: grpc.ClientWritableStream<PdfiumSetFormFontRequestStreamP> =
|
|
43
|
+
client.Pdfium_Form_SetFormFont(
|
|
44
|
+
(
|
|
45
|
+
err: grpc.ServiceError | null,
|
|
46
|
+
value: PdfiumSetFormFontResultP__Output | undefined
|
|
47
|
+
) => {
|
|
48
|
+
if (resolved) return;
|
|
49
|
+
resolved = true;
|
|
50
|
+
if (err) {
|
|
51
|
+
reject(`${err.name}/n${err.message}`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (!value) {
|
|
55
|
+
reject("No response from IronPdfEngine for setFormFont");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (value.exception) {
|
|
59
|
+
handleRemoteException(value.exception, reject);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
resolve();
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// Send Info first.
|
|
67
|
+
stream.write({
|
|
68
|
+
info: {
|
|
69
|
+
document: {documentId: id},
|
|
70
|
+
fontName: fontName,
|
|
71
|
+
fontBytesSize: fontData ? fontData.length : 0,
|
|
72
|
+
forceEmbed: forceEmbed,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Stream bytes (if any).
|
|
77
|
+
if (fontData && fontData.length > 0) {
|
|
78
|
+
for (const chunk of chunkBuffer(fontData)) {
|
|
79
|
+
stream.write({fontBytesChunk: chunk});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
stream.end();
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Suppress the engine's automatic Tahoma/Arial fallback embed for non-ASCII
|
|
89
|
+
* form-field values without registering a replacement font.
|
|
90
|
+
*/
|
|
91
|
+
export async function disableFormFontFallback(id: string): Promise<void> {
|
|
92
|
+
const client: IronPdfServiceClient = await Access.ensureConnection();
|
|
93
|
+
|
|
94
|
+
return new Promise(
|
|
95
|
+
(resolve: () => void, reject: (errorMsg: string) => void) => {
|
|
96
|
+
client.Pdfium_Form_DisableFormFontFallback(
|
|
97
|
+
{document: {documentId: id}},
|
|
98
|
+
(
|
|
99
|
+
err: grpc.ServiceError | null,
|
|
100
|
+
value: PdfiumDisableFormFontFallbackResultP__Output | undefined
|
|
101
|
+
) => {
|
|
102
|
+
if (err) {
|
|
103
|
+
reject(`${err.name}/n${err.message}`);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!value) {
|
|
107
|
+
reject("No response from IronPdfEngine for disableFormFontFallback");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (value.exception) {
|
|
111
|
+
handleRemoteException(value.exception, reject);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
resolve();
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side validation for {@link setFormFont} arguments. Mirrors the
|
|
3
|
+
* Java FormFontValidator and .NET FormFontValidator added for PDF-2184.
|
|
4
|
+
*
|
|
5
|
+
* The engine validates again on receipt — this client check is the
|
|
6
|
+
* fail-fast layer that surfaces obvious mistakes before any network I/O.
|
|
7
|
+
*/
|
|
8
|
+
/// <reference types="node" />
|
|
9
|
+
/// <reference types="node" />
|
|
10
|
+
/**
|
|
11
|
+
* Validate a PDF font name. Allowed characters: letters, digits, '_', '-',
|
|
12
|
+
* '.', '+'. The '+' is permitted to accept subset prefixes like
|
|
13
|
+
* "AAAAAA+Poppins-Regular". Names must be 1-63 characters.
|
|
14
|
+
*
|
|
15
|
+
* @throws Error when the name fails validation.
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateFormFontName(fontName: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Validate raw font bytes look like a TrueType / OpenType / TTC sfnt
|
|
20
|
+
* container. Catches the obvious cases: empty payload, oversize payload,
|
|
21
|
+
* ASCII text passed instead of bytes, and all-zero payloads.
|
|
22
|
+
*
|
|
23
|
+
* @throws Error when the data fails validation.
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateFormFontData(fontData: Buffer): void;
|
|
26
|
+
//# sourceMappingURL=formFontValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formFontValidator.d.ts","sourceRoot":"","sources":["formFontValidator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;AAMH;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAc3D;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CA2C3D"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Client-side validation for {@link setFormFont} arguments. Mirrors the
|
|
4
|
+
* Java FormFontValidator and .NET FormFontValidator added for PDF-2184.
|
|
5
|
+
*
|
|
6
|
+
* The engine validates again on receipt — this client check is the
|
|
7
|
+
* fail-fast layer that surfaces obvious mistakes before any network I/O.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.validateFormFontData = exports.validateFormFontName = void 0;
|
|
11
|
+
const MAX_NAME_LENGTH = 63;
|
|
12
|
+
const MAX_FONT_BYTES = 50 * 1024 * 1024; // 50 MB
|
|
13
|
+
const ALLOWED_NAME = /^[A-Za-z0-9_\-.+]+$/;
|
|
14
|
+
/**
|
|
15
|
+
* Validate a PDF font name. Allowed characters: letters, digits, '_', '-',
|
|
16
|
+
* '.', '+'. The '+' is permitted to accept subset prefixes like
|
|
17
|
+
* "AAAAAA+Poppins-Regular". Names must be 1-63 characters.
|
|
18
|
+
*
|
|
19
|
+
* @throws Error when the name fails validation.
|
|
20
|
+
*/
|
|
21
|
+
function validateFormFontName(fontName) {
|
|
22
|
+
if (fontName == null || typeof fontName !== "string" || fontName.length === 0) {
|
|
23
|
+
throw new Error("fontName must be a non-empty string");
|
|
24
|
+
}
|
|
25
|
+
if (fontName.length > MAX_NAME_LENGTH) {
|
|
26
|
+
throw new Error(`fontName must be at most ${MAX_NAME_LENGTH} characters (got ${fontName.length})`);
|
|
27
|
+
}
|
|
28
|
+
if (!ALLOWED_NAME.test(fontName)) {
|
|
29
|
+
throw new Error("fontName may only contain letters, digits, and the characters '_', '-', '.', '+'");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.validateFormFontName = validateFormFontName;
|
|
33
|
+
/**
|
|
34
|
+
* Validate raw font bytes look like a TrueType / OpenType / TTC sfnt
|
|
35
|
+
* container. Catches the obvious cases: empty payload, oversize payload,
|
|
36
|
+
* ASCII text passed instead of bytes, and all-zero payloads.
|
|
37
|
+
*
|
|
38
|
+
* @throws Error when the data fails validation.
|
|
39
|
+
*/
|
|
40
|
+
function validateFormFontData(fontData) {
|
|
41
|
+
var _a;
|
|
42
|
+
if (!fontData || fontData.length === 0) {
|
|
43
|
+
throw new Error("fontData must not be empty");
|
|
44
|
+
}
|
|
45
|
+
if (fontData.length > MAX_FONT_BYTES) {
|
|
46
|
+
throw new Error(`fontData exceeds the ${MAX_FONT_BYTES} byte limit (got ${fontData.length})`);
|
|
47
|
+
}
|
|
48
|
+
if (fontData.length < 4) {
|
|
49
|
+
throw new Error("fontData is too small to be a valid font file");
|
|
50
|
+
}
|
|
51
|
+
// Reject obviously-non-font payloads: all-zero buffer or a pure ASCII text
|
|
52
|
+
// payload. We don't try to fully parse the sfnt header here — the engine
|
|
53
|
+
// does that — but we do catch the common mistakes.
|
|
54
|
+
let nonZero = false;
|
|
55
|
+
let asciiOnly = true;
|
|
56
|
+
for (let i = 0; i < Math.min(fontData.length, 4096); i++) {
|
|
57
|
+
const b = (_a = fontData[i]) !== null && _a !== void 0 ? _a : 0;
|
|
58
|
+
if (b !== 0)
|
|
59
|
+
nonZero = true;
|
|
60
|
+
if (b > 0x7e || (b < 0x20 && b !== 0x09 && b !== 0x0a && b !== 0x0d)) {
|
|
61
|
+
asciiOnly = false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!nonZero) {
|
|
65
|
+
throw new Error("fontData is all zeros — not a valid font file");
|
|
66
|
+
}
|
|
67
|
+
if (asciiOnly) {
|
|
68
|
+
throw new Error("fontData looks like ASCII text — not a valid font file");
|
|
69
|
+
}
|
|
70
|
+
// sfnt magic — TTF (0x00010000), OTF ('OTTO'), TTC ('ttcf'), or 'true'.
|
|
71
|
+
const m0 = fontData[0], m1 = fontData[1], m2 = fontData[2], m3 = fontData[3];
|
|
72
|
+
const isTtfV1 = m0 === 0x00 && m1 === 0x01 && m2 === 0x00 && m3 === 0x00;
|
|
73
|
+
const isOtto = m0 === 0x4f && m1 === 0x54 && m2 === 0x54 && m3 === 0x4f;
|
|
74
|
+
const isTtcf = m0 === 0x74 && m1 === 0x74 && m2 === 0x63 && m3 === 0x66;
|
|
75
|
+
const isTrue = m0 === 0x74 && m1 === 0x72 && m2 === 0x75 && m3 === 0x65;
|
|
76
|
+
if (!(isTtfV1 || isOtto || isTtcf || isTrue)) {
|
|
77
|
+
throw new Error("fontData does not have a recognised TTF/OTF/TTC sfnt magic");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.validateFormFontData = validateFormFontData;
|
|
81
|
+
//# sourceMappingURL=formFontValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formFontValidator.js","sourceRoot":"","sources":["formFontValidator.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ;AACjD,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAE3C;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,QAAgB;IACpD,IAAI,QAAQ,IAAI,IAAI,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAC9E,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACvD;IACD,IAAI,QAAQ,CAAC,MAAM,GAAG,eAAe,EAAE;QACtC,MAAM,IAAI,KAAK,CACd,4BAA4B,eAAe,oBAAoB,QAAQ,CAAC,MAAM,GAAG,CACjF,CAAC;KACF;IACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACjC,MAAM,IAAI,KAAK,CACd,kFAAkF,CAClF,CAAC;KACF;AACF,CAAC;AAdD,oDAcC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,QAAgB;;IACpD,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;KAC9C;IACD,IAAI,QAAQ,CAAC,MAAM,GAAG,cAAc,EAAE;QACrC,MAAM,IAAI,KAAK,CACd,wBAAwB,cAAc,oBAAoB,QAAQ,CAAC,MAAM,GAAG,CAC5E,CAAC;KACF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,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,CAAC;IACxE,MAAM,MAAM,GAAG,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,CAAC;IACxE,MAAM,MAAM,GAAG,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,CAAC;IACxE,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,CAAC,EAAE;QAC7C,MAAM,IAAI,KAAK,CACd,4DAA4D,CAC5D,CAAC;KACF;AACF,CAAC;AA3CD,oDA2CC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side validation for {@link setFormFont} arguments. Mirrors the
|
|
3
|
+
* Java FormFontValidator and .NET FormFontValidator added for PDF-2184.
|
|
4
|
+
*
|
|
5
|
+
* The engine validates again on receipt — this client check is the
|
|
6
|
+
* fail-fast layer that surfaces obvious mistakes before any network I/O.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const MAX_NAME_LENGTH = 63;
|
|
10
|
+
const MAX_FONT_BYTES = 50 * 1024 * 1024; // 50 MB
|
|
11
|
+
const ALLOWED_NAME = /^[A-Za-z0-9_\-.+]+$/;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Validate a PDF font name. Allowed characters: letters, digits, '_', '-',
|
|
15
|
+
* '.', '+'. The '+' is permitted to accept subset prefixes like
|
|
16
|
+
* "AAAAAA+Poppins-Regular". Names must be 1-63 characters.
|
|
17
|
+
*
|
|
18
|
+
* @throws Error when the name fails validation.
|
|
19
|
+
*/
|
|
20
|
+
export function validateFormFontName(fontName: string): void {
|
|
21
|
+
if (fontName == null || typeof fontName !== "string" || fontName.length === 0) {
|
|
22
|
+
throw new Error("fontName must be a non-empty string");
|
|
23
|
+
}
|
|
24
|
+
if (fontName.length > MAX_NAME_LENGTH) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`fontName must be at most ${MAX_NAME_LENGTH} characters (got ${fontName.length})`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
if (!ALLOWED_NAME.test(fontName)) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
"fontName may only contain letters, digits, and the characters '_', '-', '.', '+'"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Validate raw font bytes look like a TrueType / OpenType / TTC sfnt
|
|
38
|
+
* container. Catches the obvious cases: empty payload, oversize payload,
|
|
39
|
+
* ASCII text passed instead of bytes, and all-zero payloads.
|
|
40
|
+
*
|
|
41
|
+
* @throws Error when the data fails validation.
|
|
42
|
+
*/
|
|
43
|
+
export function validateFormFontData(fontData: Buffer): void {
|
|
44
|
+
if (!fontData || fontData.length === 0) {
|
|
45
|
+
throw new Error("fontData must not be empty");
|
|
46
|
+
}
|
|
47
|
+
if (fontData.length > MAX_FONT_BYTES) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`fontData exceeds the ${MAX_FONT_BYTES} byte limit (got ${fontData.length})`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
if (fontData.length < 4) {
|
|
53
|
+
throw new Error("fontData is too small to be a valid font file");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Reject obviously-non-font payloads: all-zero buffer or a pure ASCII text
|
|
57
|
+
// payload. We don't try to fully parse the sfnt header here — the engine
|
|
58
|
+
// does that — but we do catch the common mistakes.
|
|
59
|
+
let nonZero = false;
|
|
60
|
+
let asciiOnly = true;
|
|
61
|
+
for (let i = 0; i < Math.min(fontData.length, 4096); i++) {
|
|
62
|
+
const b = fontData[i] ?? 0;
|
|
63
|
+
if (b !== 0) nonZero = true;
|
|
64
|
+
if (b > 0x7e || (b < 0x20 && b !== 0x09 && b !== 0x0a && b !== 0x0d)) {
|
|
65
|
+
asciiOnly = false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!nonZero) {
|
|
69
|
+
throw new Error("fontData is all zeros — not a valid font file");
|
|
70
|
+
}
|
|
71
|
+
if (asciiOnly) {
|
|
72
|
+
throw new Error("fontData looks like ASCII text — not a valid font file");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// sfnt magic — TTF (0x00010000), OTF ('OTTO'), TTC ('ttcf'), or 'true'.
|
|
76
|
+
const m0 = fontData[0], m1 = fontData[1], m2 = fontData[2], m3 = fontData[3];
|
|
77
|
+
const isTtfV1 = m0 === 0x00 && m1 === 0x01 && m2 === 0x00 && m3 === 0x00;
|
|
78
|
+
const isOtto = m0 === 0x4f && m1 === 0x54 && m2 === 0x54 && m3 === 0x4f;
|
|
79
|
+
const isTtcf = m0 === 0x74 && m1 === 0x74 && m2 === 0x63 && m3 === 0x66;
|
|
80
|
+
const isTrue = m0 === 0x74 && m1 === 0x72 && m2 === 0x75 && m3 === 0x65;
|
|
81
|
+
if (!(isTtfV1 || isOtto || isTtcf || isTrue)) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
"fontData does not have a recognised TTF/OTF/TTC sfnt magic"
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { ChangeTrackingModes, SaveOptions } from "../../../public/types";
|
|
4
|
+
import { PendingSignature } from "./signing";
|
|
4
5
|
export declare function openPdfFileBuffer(buffer: Buffer, option?: {
|
|
5
6
|
userPassword?: string | undefined;
|
|
6
7
|
ownerPassword?: string | undefined;
|
|
7
8
|
trackChanges?: ChangeTrackingModes | undefined;
|
|
8
9
|
} | undefined): Promise<string>;
|
|
9
|
-
export declare function getBinaryData(pdfDocumentId: string, saveOptions?: SaveOptions | undefined): Promise<Buffer>;
|
|
10
|
+
export declare function getBinaryData(pdfDocumentId: string, saveOptions?: SaveOptions | undefined, signatures?: PendingSignature[] | undefined): Promise<Buffer>;
|
|
10
11
|
export declare function disposePdf(pdfDocumentId: string): Promise<void>;
|
|
11
12
|
//# sourceMappingURL=io.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["io.ts"],"names":[],"mappings":";;AASA,OAAO,EAAC,mBAAmB,EAAE,WAAW,EAAC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["io.ts"],"names":[],"mappings":";;AASA,OAAO,EAAC,mBAAmB,EAAE,WAAW,EAAC,MAAM,uBAAuB,CAAC;AAKvE,OAAO,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAE3C,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,YAAY,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,GAC5I,OAAO,CAAC,MAAM,CAAC,CAqCjB;AAED,wBAAsB,aAAa,CAClC,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,EACrC,UAAU,CAAC,EAAE,gBAAgB,EAAE,GAAG,SAAS,GACzC,OAAO,CAAC,MAAM,CAAC,CAkFjB;AAED,wBAAsB,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBrE"}
|
|
@@ -41,7 +41,7 @@ function openPdfFileBuffer(buffer, option) {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
exports.openPdfFileBuffer = openPdfFileBuffer;
|
|
44
|
-
function getBinaryData(pdfDocumentId, saveOptions) {
|
|
44
|
+
function getBinaryData(pdfDocumentId, saveOptions, signatures) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
const client = yield access_1.Access.ensureConnection();
|
|
47
47
|
return new Promise((resolve, reject) => {
|
|
@@ -69,41 +69,46 @@ function getBinaryData(pdfDocumentId, saveOptions) {
|
|
|
69
69
|
isIncremental: (_a = saveOptions === null || saveOptions === void 0 ? void 0 : saveOptions.incremental) !== null && _a !== void 0 ? _a : false,
|
|
70
70
|
},
|
|
71
71
|
});
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
72
|
+
// Digital signatures are added as placeholder fields by signPdf(), but the actual
|
|
73
|
+
// cryptographic signing only happens here, at save time. The signature descriptors
|
|
74
|
+
// (index/password/timestamp) and the raw certificate bytes must therefore be re-sent
|
|
75
|
+
// so the engine can fill in the reserved byte range. Skipping this leaves an empty
|
|
76
|
+
// placeholder and produces a PDF with an invalid signature.
|
|
77
|
+
if (signatures && signatures.length > 0) {
|
|
78
|
+
// The engine pairs each certificate with its reserved placeholder using two
|
|
79
|
+
// distinct indices (this matches the C# client, GrpcPdfClient.GetBytes):
|
|
80
|
+
//
|
|
81
|
+
// * rawSignaturesChunk.signatureIndex = the certificate's position in the
|
|
82
|
+
// `signatures` collection below. The engine groups the chunks by this value and
|
|
83
|
+
// looks the descriptor up positionally (`signatures.Signature[signatureIndex]`),
|
|
84
|
+
// so it must be the 0..n-1 array index, NOT the engine signature index.
|
|
85
|
+
// * PdfiumPdfSignatureP.index = the engine signature index returned by
|
|
86
|
+
// signPdf when the placeholder was reserved. The engine uses it to know which
|
|
87
|
+
// placeholder field this certificate fills. For an already-signed document this
|
|
88
|
+
// differs from the array position, which is exactly why the two are separate.
|
|
89
|
+
//
|
|
90
|
+
// Keep the collection order and the chunk order identical so position i in the
|
|
91
|
+
// collection always corresponds to signatureIndex i in the chunks.
|
|
92
|
+
stream.write({
|
|
93
|
+
signatures: {
|
|
94
|
+
signature: signatures.map((signature) => ({
|
|
95
|
+
index: signature.index,
|
|
96
|
+
password: signature.password,
|
|
97
|
+
timestampUrl: signature.timeStampUrl,
|
|
98
|
+
})),
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
signatures.forEach((signature, signatureIndex) => {
|
|
102
|
+
(0, util_1.chunkBuffer)(signature.certificate).forEach((chunk) => {
|
|
103
|
+
stream.write({
|
|
104
|
+
rawSignaturesChunk: {
|
|
105
|
+
rawSignatureChunk: chunk,
|
|
106
|
+
signatureIndex,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
|
107
112
|
//request finished
|
|
108
113
|
stream.end();
|
|
109
114
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"io.js","sourceRoot":"","sources":["io.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,yCAAoC;AAKpC,kCAAsE;AACtE,iDAAuE;
|
|
1
|
+
{"version":3,"file":"io.js","sourceRoot":"","sources":["io.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,yCAAoC;AAKpC,kCAAsE;AACtE,iDAAuE;AAOvE,SAAsB,iBAAiB,CACtC,MAAc,EACd,MAA8I;;QAE9I,MAAM,MAAM,GAAyB,MAAM,eAAM,CAAC,gBAAgB,EAAE,CAAC;QACrE,OAAO,IAAI,OAAO,CACjB,CAAC,OAA4B,EAAE,MAAkC,EAAE,EAAE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