pptx-viewer-core 1.0.7 → 1.0.9
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/cli/index.js +3 -1
- package/dist/cli/index.mjs +3 -1
- package/dist/index.d.mts +3 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.js +181 -1
- package/dist/index.mjs +160 -2
- package/dist/signature-inspection-status-BcJSdOvb.d.mts +209 -0
- package/dist/signature-inspection-status-BcJSdOvb.d.ts +209 -0
- package/dist/signature-node/index.d.mts +177 -0
- package/dist/signature-node/index.d.ts +177 -0
- package/dist/signature-node/index.js +1192 -0
- package/dist/signature-node/index.mjs +1131 -0
- package/package.json +26 -3
package/dist/index.mjs
CHANGED
|
@@ -10160,6 +10160,38 @@ ${nextText}` : nextText;
|
|
|
10160
10160
|
}
|
|
10161
10161
|
};
|
|
10162
10162
|
|
|
10163
|
+
// src/core/utils/signature-constants.ts
|
|
10164
|
+
var DIGITAL_SIGNATURE_ORIGIN_REL_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin";
|
|
10165
|
+
var DIGITAL_SIGNATURE_REL_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature";
|
|
10166
|
+
var PPTX_VIEWER_MANIFEST_NS = "urn:pptx-viewer:ooxml-signature:v1";
|
|
10167
|
+
var XMLDSIG_NS = "http://www.w3.org/2000/09/xmldsig#";
|
|
10168
|
+
var OPC_RELATIONSHIP_TRANSFORM = "http://schemas.openxmlformats.org/package/2006/RelationshipTransform";
|
|
10169
|
+
var XML_TRANSFORM_ENVELOPED_SIGNATURE = "http://www.w3.org/2000/09/xmldsig#enveloped-signature";
|
|
10170
|
+
var SUPPORTED_XML_CANON_TRANSFORMS = /* @__PURE__ */ new Set([
|
|
10171
|
+
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315",
|
|
10172
|
+
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments",
|
|
10173
|
+
"http://www.w3.org/2001/10/xml-exc-c14n#",
|
|
10174
|
+
"http://www.w3.org/2001/10/xml-exc-c14n#WithComments",
|
|
10175
|
+
XML_TRANSFORM_ENVELOPED_SIGNATURE
|
|
10176
|
+
]);
|
|
10177
|
+
var ENTERPRISE_TRUST_ROOTS_FILE_ENV = "PPTX_VIEWER_TRUST_ROOTS_FILE";
|
|
10178
|
+
var ENTERPRISE_TRUST_ROOTS_PEM_ENV = "PPTX_VIEWER_TRUST_ROOTS_PEM";
|
|
10179
|
+
var ENTERPRISE_REQUIRE_REVOCATION_ENV = "PPTX_VIEWER_REQUIRE_REVOCATION_CHECK";
|
|
10180
|
+
var ENTERPRISE_FAIL_ON_REVOCATION_UNKNOWN_ENV = "PPTX_VIEWER_FAIL_ON_REVOCATION_UNKNOWN";
|
|
10181
|
+
var ENTERPRISE_REQUIRE_TIMESTAMP_ENV = "PPTX_VIEWER_REQUIRE_TIMESTAMP";
|
|
10182
|
+
var DIGEST_ALGORITHM_TO_HASH = {
|
|
10183
|
+
"http://www.w3.org/2000/09/xmldsig#sha1": "sha1",
|
|
10184
|
+
"http://www.w3.org/2001/04/xmlenc#sha256": "sha256",
|
|
10185
|
+
"http://www.w3.org/2001/04/xmlenc#sha384": "sha384",
|
|
10186
|
+
"http://www.w3.org/2001/04/xmlenc#sha512": "sha512"
|
|
10187
|
+
};
|
|
10188
|
+
var DIGEST_ALGORITHM_TO_WEB_CRYPTO = {
|
|
10189
|
+
"http://www.w3.org/2000/09/xmldsig#sha1": "SHA-1",
|
|
10190
|
+
"http://www.w3.org/2001/04/xmlenc#sha256": "SHA-256",
|
|
10191
|
+
"http://www.w3.org/2001/04/xmlenc#sha384": "SHA-384",
|
|
10192
|
+
"http://www.w3.org/2001/04/xmlenc#sha512": "SHA-512"
|
|
10193
|
+
};
|
|
10194
|
+
|
|
10163
10195
|
// src/core/utils/signature-detection.ts
|
|
10164
10196
|
var SIGNATURE_PREFIX = "_xmlsignatures/";
|
|
10165
10197
|
function detectDigitalSignatures(zipEntryPaths) {
|
|
@@ -10175,7 +10207,6 @@ function detectDigitalSignatures(zipEntryPaths) {
|
|
|
10175
10207
|
function getSignaturePathsToStrip(zipEntryPaths) {
|
|
10176
10208
|
return zipEntryPaths.filter((p) => p.startsWith(SIGNATURE_PREFIX));
|
|
10177
10209
|
}
|
|
10178
|
-
var DIGITAL_SIGNATURE_ORIGIN_REL_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin";
|
|
10179
10210
|
function findByLocalName(parent, localName) {
|
|
10180
10211
|
if (!parent) {
|
|
10181
10212
|
return void 0;
|
|
@@ -18433,6 +18464,133 @@ async function createModifyVerifier(password, options) {
|
|
|
18433
18464
|
};
|
|
18434
18465
|
}
|
|
18435
18466
|
|
|
18467
|
+
// src/core/utils/signature-xml-utils.ts
|
|
18468
|
+
function escapeXmlAttr(value) {
|
|
18469
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
18470
|
+
}
|
|
18471
|
+
function extractTagAttribute(xml, tagName, attributeName) {
|
|
18472
|
+
const pattern = new RegExp(
|
|
18473
|
+
`<${tagName}\\b[^>]*\\b${attributeName}="(?<attributeValue>[^"]+)"`,
|
|
18474
|
+
"i"
|
|
18475
|
+
);
|
|
18476
|
+
const match = xml.match(pattern);
|
|
18477
|
+
return match?.groups?.["attributeValue"]?.trim();
|
|
18478
|
+
}
|
|
18479
|
+
function extractFirstTagText(xml, localName) {
|
|
18480
|
+
const pattern = new RegExp(
|
|
18481
|
+
`<([\\w.-]+:)?${localName}\\b[^>]*>([\\s\\S]*?)<\\/([\\w.-]+:)?${localName}>`,
|
|
18482
|
+
"i"
|
|
18483
|
+
);
|
|
18484
|
+
const match = xml.match(pattern);
|
|
18485
|
+
return match?.[2]?.replace(/\s+/g, "").trim() || void 0;
|
|
18486
|
+
}
|
|
18487
|
+
function extractAllTagText(xml, localName) {
|
|
18488
|
+
const result = [];
|
|
18489
|
+
const regex = new RegExp(
|
|
18490
|
+
`<([\\w.-]+:)?${localName}\\b[^>]*>([\\s\\S]*?)<\\/([\\w.-]+:)?${localName}>`,
|
|
18491
|
+
"gi"
|
|
18492
|
+
);
|
|
18493
|
+
let match = regex.exec(xml);
|
|
18494
|
+
while (match) {
|
|
18495
|
+
const value = match[2]?.replace(/\s+/g, "").trim();
|
|
18496
|
+
if (value) {
|
|
18497
|
+
result.push(value);
|
|
18498
|
+
}
|
|
18499
|
+
match = regex.exec(xml);
|
|
18500
|
+
}
|
|
18501
|
+
return result;
|
|
18502
|
+
}
|
|
18503
|
+
|
|
18504
|
+
// src/core/utils/signature-reference-utils.ts
|
|
18505
|
+
function normalizePartPath(partPath) {
|
|
18506
|
+
return partPath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
18507
|
+
}
|
|
18508
|
+
function resolveReferenceUriToPart(uri) {
|
|
18509
|
+
const trimmed = uri.trim();
|
|
18510
|
+
if (trimmed.length === 0 || trimmed.startsWith("#")) {
|
|
18511
|
+
return void 0;
|
|
18512
|
+
}
|
|
18513
|
+
const decoded = decodeURIComponent(trimmed);
|
|
18514
|
+
return normalizePartPath(decoded.startsWith("/") ? decoded.slice(1) : decoded);
|
|
18515
|
+
}
|
|
18516
|
+
|
|
18517
|
+
// src/core/utils/signature-digest.ts
|
|
18518
|
+
async function computeDigestBase64(content, digestAlgorithmUri) {
|
|
18519
|
+
const webCryptoAlgo = DIGEST_ALGORITHM_TO_WEB_CRYPTO[digestAlgorithmUri];
|
|
18520
|
+
if (!webCryptoAlgo) {
|
|
18521
|
+
return void 0;
|
|
18522
|
+
}
|
|
18523
|
+
if (typeof globalThis.crypto?.subtle === "undefined") {
|
|
18524
|
+
return void 0;
|
|
18525
|
+
}
|
|
18526
|
+
const buf = new ArrayBuffer(content.byteLength);
|
|
18527
|
+
new Uint8Array(buf).set(content);
|
|
18528
|
+
const digest = await globalThis.crypto.subtle.digest(webCryptoAlgo, buf);
|
|
18529
|
+
return uint8ArrayToBase64(new Uint8Array(digest));
|
|
18530
|
+
}
|
|
18531
|
+
function uint8ArrayToBase64(bytes) {
|
|
18532
|
+
let binary = "";
|
|
18533
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
18534
|
+
binary += String.fromCharCode(bytes[i]);
|
|
18535
|
+
}
|
|
18536
|
+
return btoa(binary);
|
|
18537
|
+
}
|
|
18538
|
+
|
|
18539
|
+
// src/core/utils/signature-inspection-status.ts
|
|
18540
|
+
function computeDetailStatus(detail, policy) {
|
|
18541
|
+
const hasDigestMismatch = detail.referenceChecks.some(
|
|
18542
|
+
(check) => check.digestStatus === "mismatch"
|
|
18543
|
+
);
|
|
18544
|
+
const hasMissingPart = detail.missingPartReferences.length > 0;
|
|
18545
|
+
const hasVerifiedDigest = detail.referenceChecks.some(
|
|
18546
|
+
(check) => check.digestStatus === "verified"
|
|
18547
|
+
);
|
|
18548
|
+
const revocationUnknown = detail.certificateRevocationStatus === "unknown" || detail.certificateRevocationStatus === "not-checked" || detail.certificateRevocationStatus === "error";
|
|
18549
|
+
const timestampMissingOrUntrusted = detail.timestampAuthorityStatus === "not-present" || detail.timestampAuthorityStatus === "not-checked" || detail.timestampAuthorityStatus === "error" || detail.timestampAuthorityStatus === "untrusted";
|
|
18550
|
+
if (detail.signatureValueStatus === "invalid") {
|
|
18551
|
+
return "signature-invalid";
|
|
18552
|
+
}
|
|
18553
|
+
if (hasMissingPart) {
|
|
18554
|
+
return "reference-missing";
|
|
18555
|
+
}
|
|
18556
|
+
if (hasDigestMismatch) {
|
|
18557
|
+
return "digest-mismatch";
|
|
18558
|
+
}
|
|
18559
|
+
if (detail.certificateRevocationStatus === "revoked") {
|
|
18560
|
+
return "certificate-revoked";
|
|
18561
|
+
}
|
|
18562
|
+
if (policy.requireRevocationCheck && (policy.failOnRevocationUnknown ? revocationUnknown : detail.certificateRevocationStatus !== "good")) {
|
|
18563
|
+
return "certificate-untrusted";
|
|
18564
|
+
}
|
|
18565
|
+
if (detail.timestampAuthorityStatus === "invalid") {
|
|
18566
|
+
return "timestamp-invalid";
|
|
18567
|
+
}
|
|
18568
|
+
if (policy.requireTimestamp && timestampMissingOrUntrusted) {
|
|
18569
|
+
return "timestamp-untrusted";
|
|
18570
|
+
}
|
|
18571
|
+
if (detail.timestampAuthorityStatus === "untrusted") {
|
|
18572
|
+
return "timestamp-untrusted";
|
|
18573
|
+
}
|
|
18574
|
+
if (detail.certificateTrustStatus === "untrusted" && detail.signatureValueStatus === "verified") {
|
|
18575
|
+
return "certificate-untrusted";
|
|
18576
|
+
}
|
|
18577
|
+
if (hasVerifiedDigest && detail.signatureValueStatus === "verified") {
|
|
18578
|
+
return "verified";
|
|
18579
|
+
}
|
|
18580
|
+
return "structural-only";
|
|
18581
|
+
}
|
|
18582
|
+
function computeVerificationStatus(details) {
|
|
18583
|
+
const hasInvalidSignature = details.some((detail) => detail.status === "signature-invalid");
|
|
18584
|
+
const hasMissing = details.some((detail) => detail.status === "reference-missing");
|
|
18585
|
+
const hasMismatch = details.some((detail) => detail.status === "digest-mismatch");
|
|
18586
|
+
const hasUntrusted = details.some((detail) => detail.status === "certificate-untrusted");
|
|
18587
|
+
const hasRevoked = details.some((detail) => detail.status === "certificate-revoked");
|
|
18588
|
+
const hasTimestampInvalid = details.some((detail) => detail.status === "timestamp-invalid");
|
|
18589
|
+
const hasTimestampUntrusted = details.some((detail) => detail.status === "timestamp-untrusted");
|
|
18590
|
+
const allVerified = details.every((detail) => detail.status === "verified");
|
|
18591
|
+
return hasInvalidSignature ? "signature-invalid" : hasRevoked ? "certificate-revoked" : hasTimestampInvalid ? "timestamp-invalid" : hasTimestampUntrusted ? "timestamp-untrusted" : hasMissing ? "reference-missing" : hasMismatch ? "digest-mismatch" : allVerified ? "verified-trusted" : hasUntrusted ? "verified-untrusted" : "present-not-verified";
|
|
18592
|
+
}
|
|
18593
|
+
|
|
18436
18594
|
// src/core/utils/chart-data-utils.ts
|
|
18437
18595
|
var XY_CHART_TYPES = /* @__PURE__ */ new Set(["scatter", "bubble"]);
|
|
18438
18596
|
var GROUPING_SUPPORTED_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -49267,4 +49425,4 @@ var SvgExporter = class _SvgExporter {
|
|
|
49267
49425
|
}
|
|
49268
49426
|
};
|
|
49269
49427
|
|
|
49270
|
-
export { COLOR_MAP_ALIAS_KEYS, CONNECTOR_ARROW_OPTIONS, CONNECTOR_GEOMETRY_OPTIONS, ChartBuilder, ConnectorBuilder, ConnectorXmlFactory, DEFAULT_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, DEFAULT_COLOR_MAP, DEFAULT_FILL_COLOR, DEFAULT_FONT_FAMILY, DEFAULT_SCHEME_COLOR_MAP, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_COLOR, DEFAULT_TEXT_FONT_SIZE, DIGITAL_SIGNATURE_ORIGIN_REL_TYPE, DataIntegrityError, DocumentConverter, EMU_PER_INCH, EMU_PER_PIXEL2 as EMU_PER_PIXEL, EMU_PER_POINT, EMU_PER_PX, EncryptedFileError, FONT_SUBSTITUTION_MAP, FreeformPathBuilder, GroupBuilder, ImageBuilder, IncorrectPasswordError, MIN_ELEMENT_SIZE, MediaBuilder, MediaContext, MediaGraphicFrameXmlFactory, Ole2ParseError, P14_GUIDE_URI, P15_GUIDE_URI, PANOSE_FAMILY_MAP, PANOSE_MONOSPACE_PROPORTION, PANOSE_SANS_SERIF_STYLES, PANOSE_WEIGHT_MAP, POWERPOINT_PRESENCE_KEY, PRESET_COLOR_MAP, PRESET_SHAPE_CATEGORY_LABELS, PRESET_SHAPE_CLIP_PATHS, PRESET_SHAPE_DEFINITIONS, PRESET_TO_OOXML, PictureXmlFactory, PptxAnimationWriteService, PptxColorStyleCodec, PptxCommentAuthorsXmlFactory, PptxCommentXmlFactoryProvider, PptxCompatibilityService, PptxConnectorParser, PptxContentTypesBuilder, PptxDocumentPropertiesUpdater, PptxEditorAnimationService, PptxElementTransformUpdater, PptxElementXmlBuilder, PptxGraphicFrameParser, PptxHandler, PptxHandlerRuntime75 as PptxHandlerRuntime, PptxHandlerRuntimeFactory, PptxLoadDataBuilder, PptxMarkdownConverter, PptxMediaDataParser, PptxNativeAnimationService, PptxPresentationSaveBuilder, PptxPresentationSlidesReconciler, PptxRuntimeDependencyFactory, PptxSaveConstantsFactory, PptxSaveState as PptxSaveSession, PptxSaveStateBuilder as PptxSaveSessionBuilder, PptxSaveState, PptxSaveStateBuilder, PptxShapeIdValidator, PptxShapeStyleExtractor, PptxSlideBackgroundBuilder, PptxSlideBuilder, PptxSlideCommentPartWriter, PptxSlideCommentsXmlFactory, PptxSlideElementsBuilder, PptxSlideLoaderService, PptxSlideMediaRelationshipBuilder, PptxSlideNotesBuilder, PptxSlideNotesPartUpdater, PptxSlideRelationshipRegistry, PptxSlideTransitionService, PptxTableDataParser, PptxTemplateBackgroundService, PptxXmlBuilder, PptxXmlFactoryProvider, PptxXmlLookupService, Presentation, PresentationBuilder, SHAPE_TREE_ELEMENT_TAGS, STROKE_DASH_OPTIONS, SWITCHABLE_LAYOUT_TYPES, SYSTEM_COLOR_MAP, ShapeBuilder, SlideBuilder, SlideProcessor, SlideSizes, SvgExporter, THEME_COLOR_SCHEME_KEYS, THEME_PRESETS, TRANSITION_VALID_DIRECTIONS, TableBuilder, TextBuilder, TextShapeXmlFactory, ThemePresets, VML_SHAPE_TAGS, addChartCategory, addChartSeries, addSection, addSmartArtNode, addSmartArtNodeAsChild, applyDrawingColorTransforms, applyKinsokuToXml, applyTemplate, applyThemeToData, areNamespacesSupported, buildCalloutLeaderLineSvgPath, buildClrMapOverrideXml, buildFontFamilyString, buildGuideListExtension, buildLinkedTextBoxChains, buildOle2, buildSingleEffectNode, buildThemeColorMap, catmullRomToBezier, chartDataAddCategory, chartDataAddSeries, chartDataChangeType, chartDataRemoveCategory, chartDataRemoveSeries, chartDataUpdatePoint, clampUnitInterval, classifyPanose, cloneElement, cloneShapeStyle, cloneSlide, cloneTemplateElementsBySlideId, cloneTextStyle, cloneXmlObject, cm, cmToEmu, colorWithOpacity, combineShapes, computeCycleLayout, computeHierarchyLayout, computeLinearLayout, computeMatrixLayout, computePyramidLayout, computeSmartArtLayout, computeSnakeLayout, convertEmfToDataUrl, convertWmfToDataUrl, convertXmlToStrict, createArrayBufferCopy, createBuiltinVariables, createChartElement, createConnectorElement, createDefaultPptxHandlerRuntime, createEditorId, createFreeformElement, createGroupElement, createImageElement, createLayout, createLayouts, createMediaElement, createModifyVerifier, createPptxSaveConstants, createShapeElement, createTableElement, createTemplateConnectorRawXml, createTemplateShapeRawXml, createTextElement, createUniformTextSegments, dataUrlToMediaBytes, decomposeSmartArt, decryptPptx, demoteSmartArtNode, deobfuscateFont, deriveOutputPath, detectDigitalSignatures, detectFileFormat, detectFontFormat, detectOleObjectType, detectStrictConformance, diffPresentations, diffSlides, distributeSegmentsAcrossChain, douglasPeucker, duplicateElement, duplicateSlide, elementActionToPptxAction, elementHasAction, emuToPixels, encryptPptx, ensureArrayValue, estimateTextBoxCapacity, evaluateGeometryPaths, evaluateGuides, extractGuidFromPartName, extractModel3DTransform, fetchUrlToBytes, findLayoutByName, findLayoutByType, findPlaceholders, findText, formatCommentTimestamp, fragmentShapes, generateFontGuid, generateLayoutXml, generateMediaFilename, getCalloutLeaderLineGeometry, getCalloutTier, getCalloutViewBoxBounds, getCommentMarkerPosition, getConnectorAdjustment, getConnectorPathGeometry, getCssBorderDashStyle, getDirectory, getElementLabel, getElementTextContent, getElementTransform, getImageMaskStyle, getLinkedTextBoxSegments, getOleObjectTypeLabel, getPanoseWeight, getPresetShapeClipPath, getRoundRectRadiusPx, getSectionForSlide, getSectionSlideRange, getShapeClipPath, getShapeType, getSignaturePathsToStrip, getSubstituteFontFamily, getSubstituteFonts, getSupportedNamespaces, getSvgStrokeDasharray, getTextCompensationTransform, getThemePreset, getZoomElements, getZoomTargetSlideIndexes, guidToKey, guideEmuToPx, guidePxToEmu, hasDirectSubstitution, hasNonTrivialOverride, hasShapeProperties, hasTextProperties, hexToRgbChannels, hslToRgb, inches, inchesToEmu, inferOleExtensionFromTarget, interpolateShapeGeometry, intersectPolygons, intersectShapes, intersectSvgPaths, isCalloutShape, isConnectorElement, isEditableTextElement, isImageLikeElement, isInkElement, isNamespaceSupported, isShapeElement, isStrictNamespaceUri, isSummaryZoomSlide, isSwitchableLayoutType, isTemplateElement, isTextElement, isTransitionalNamespaceUri, isZoomElement, isZoomElement2 as isZoomElementUtil, layoutEngineShapesToDrawingShapes, mailMerge, mergePresentation, mergeShapes, mergeThemeColorOverride, mm, moveSlidesToSection, normalizeHexColor, normalizeNamespaceUri, normalizePath, normalizeStrictXml, normalizeStrokeDashType, obfuscateFont, ooxmlArcToSvg, parseActiveXControlsFromSlide, parseAdjustmentValues, parseBodyPrBooleanAttrs, parseChart3DSurfaces, parseChartAxes, parseCondition, parseConditionList, parseCxChartSeries, parseDataTable, parseDataUrlToBytes, parseDrawingColor, parseDrawingColorChoice, parseDrawingColorOpacity, parseDrawingFraction, parseDrawingHueDegrees, parseDrawingPercent, parseEmbeddedXlsx, parseGuideDefinitions, parseKinsoku, parseLayoutDefinition, parseLineStyle, parseMarker, parseOle2, parsePanoseBytes, parsePanoseString, parsePresentationDrawingGuides, parseSeriesDataLabels, parseSeriesDataPoints, parseSeriesErrBars, parseSeriesExplosion, parseSeriesTrendlines, parseShapeProps, parseSignatureXml, parseSlideDrawingGuides, parseSvgPath, parseVmlElement, parseVmlElements, pixelsToEmu, polygonsToSvgPath, pptxActionToElementAction, promoteSmartArtNode, pt, reResolveSlideColors, readFileAsDataUrl, reflowSmartArtLayout, removeChartCategory, removeChartSeries, removeSection, removeSmartArtNode, reorderSections, reorderSmartArtNode, reorderSmartArtNodeToIndex, repairPptx, replaceShapeGeometry, replaceText, replaceTextInSlide, replaceWithCustomGeometry, resetCloneIdCounter, resetDecomposeCounter, resetIdCounter, resetSectionIdCounter, resetSmartArtEditCounter, resolveCoordinate, resolveModel3DMimeType, rgbToHsl, selectAlternateContentBranch, serializeCondition, serializeConditionList, serializeSvgPath, setChartCategories, setChartGrouping, setChartTitle, setChartType, shouldRenderFallbackLabel, shouldReturnToZoomSlide, subtractPolygons, subtractShapes, subtractSvgPaths, svgPathToPolygons, switchSmartArtLayout, toHex, toStrictNamespaceUri, unionPolygons, unionShapes, unionSvgPaths, unwrapAlternateContent, updateChartDataPoint, updateChartSeriesValues, updateSmartArtNodeText, validatePptx, verifyModifyPassword, verifyPassword, verifySignatureDigests, writeBodyPrBooleanAttrs };
|
|
49428
|
+
export { COLOR_MAP_ALIAS_KEYS, CONNECTOR_ARROW_OPTIONS, CONNECTOR_GEOMETRY_OPTIONS, ChartBuilder, ConnectorBuilder, ConnectorXmlFactory, DEFAULT_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, DEFAULT_COLOR_MAP, DEFAULT_FILL_COLOR, DEFAULT_FONT_FAMILY, DEFAULT_SCHEME_COLOR_MAP, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_COLOR, DEFAULT_TEXT_FONT_SIZE, DIGEST_ALGORITHM_TO_HASH, DIGEST_ALGORITHM_TO_WEB_CRYPTO, DIGITAL_SIGNATURE_ORIGIN_REL_TYPE, DIGITAL_SIGNATURE_REL_TYPE, DataIntegrityError, DocumentConverter, EMU_PER_INCH, EMU_PER_PIXEL2 as EMU_PER_PIXEL, EMU_PER_POINT, EMU_PER_PX, ENTERPRISE_FAIL_ON_REVOCATION_UNKNOWN_ENV, ENTERPRISE_REQUIRE_REVOCATION_ENV, ENTERPRISE_REQUIRE_TIMESTAMP_ENV, ENTERPRISE_TRUST_ROOTS_FILE_ENV, ENTERPRISE_TRUST_ROOTS_PEM_ENV, EncryptedFileError, FONT_SUBSTITUTION_MAP, FreeformPathBuilder, GroupBuilder, ImageBuilder, IncorrectPasswordError, MIN_ELEMENT_SIZE, MediaBuilder, MediaContext, MediaGraphicFrameXmlFactory, OPC_RELATIONSHIP_TRANSFORM, Ole2ParseError, P14_GUIDE_URI, P15_GUIDE_URI, PANOSE_FAMILY_MAP, PANOSE_MONOSPACE_PROPORTION, PANOSE_SANS_SERIF_STYLES, PANOSE_WEIGHT_MAP, POWERPOINT_PRESENCE_KEY, PPTX_VIEWER_MANIFEST_NS, PRESET_COLOR_MAP, PRESET_SHAPE_CATEGORY_LABELS, PRESET_SHAPE_CLIP_PATHS, PRESET_SHAPE_DEFINITIONS, PRESET_TO_OOXML, PictureXmlFactory, PptxAnimationWriteService, PptxColorStyleCodec, PptxCommentAuthorsXmlFactory, PptxCommentXmlFactoryProvider, PptxCompatibilityService, PptxConnectorParser, PptxContentTypesBuilder, PptxDocumentPropertiesUpdater, PptxEditorAnimationService, PptxElementTransformUpdater, PptxElementXmlBuilder, PptxGraphicFrameParser, PptxHandler, PptxHandlerRuntime75 as PptxHandlerRuntime, PptxHandlerRuntimeFactory, PptxLoadDataBuilder, PptxMarkdownConverter, PptxMediaDataParser, PptxNativeAnimationService, PptxPresentationSaveBuilder, PptxPresentationSlidesReconciler, PptxRuntimeDependencyFactory, PptxSaveConstantsFactory, PptxSaveState as PptxSaveSession, PptxSaveStateBuilder as PptxSaveSessionBuilder, PptxSaveState, PptxSaveStateBuilder, PptxShapeIdValidator, PptxShapeStyleExtractor, PptxSlideBackgroundBuilder, PptxSlideBuilder, PptxSlideCommentPartWriter, PptxSlideCommentsXmlFactory, PptxSlideElementsBuilder, PptxSlideLoaderService, PptxSlideMediaRelationshipBuilder, PptxSlideNotesBuilder, PptxSlideNotesPartUpdater, PptxSlideRelationshipRegistry, PptxSlideTransitionService, PptxTableDataParser, PptxTemplateBackgroundService, PptxXmlBuilder, PptxXmlFactoryProvider, PptxXmlLookupService, Presentation, PresentationBuilder, SHAPE_TREE_ELEMENT_TAGS, STROKE_DASH_OPTIONS, SUPPORTED_XML_CANON_TRANSFORMS, SWITCHABLE_LAYOUT_TYPES, SYSTEM_COLOR_MAP, ShapeBuilder, SlideBuilder, SlideProcessor, SlideSizes, SvgExporter, THEME_COLOR_SCHEME_KEYS, THEME_PRESETS, TRANSITION_VALID_DIRECTIONS, TableBuilder, TextBuilder, TextShapeXmlFactory, ThemePresets, VML_SHAPE_TAGS, XMLDSIG_NS, XML_TRANSFORM_ENVELOPED_SIGNATURE, addChartCategory, addChartSeries, addSection, addSmartArtNode, addSmartArtNodeAsChild, applyDrawingColorTransforms, applyKinsokuToXml, applyTemplate, applyThemeToData, areNamespacesSupported, buildCalloutLeaderLineSvgPath, buildClrMapOverrideXml, buildFontFamilyString, buildGuideListExtension, buildLinkedTextBoxChains, buildOle2, buildSingleEffectNode, buildThemeColorMap, catmullRomToBezier, chartDataAddCategory, chartDataAddSeries, chartDataChangeType, chartDataRemoveCategory, chartDataRemoveSeries, chartDataUpdatePoint, clampUnitInterval, classifyPanose, cloneElement, cloneShapeStyle, cloneSlide, cloneTemplateElementsBySlideId, cloneTextStyle, cloneXmlObject, cm, cmToEmu, colorWithOpacity, combineShapes, computeCycleLayout, computeDetailStatus, computeDigestBase64 as computeDigestBase64WebCrypto, computeHierarchyLayout, computeLinearLayout, computeMatrixLayout, computePyramidLayout, computeSmartArtLayout, computeSnakeLayout, computeVerificationStatus, convertEmfToDataUrl, convertWmfToDataUrl, convertXmlToStrict, createArrayBufferCopy, createBuiltinVariables, createChartElement, createConnectorElement, createDefaultPptxHandlerRuntime, createEditorId, createFreeformElement, createGroupElement, createImageElement, createLayout, createLayouts, createMediaElement, createModifyVerifier, createPptxSaveConstants, createShapeElement, createTableElement, createTemplateConnectorRawXml, createTemplateShapeRawXml, createTextElement, createUniformTextSegments, dataUrlToMediaBytes, decomposeSmartArt, decryptPptx, demoteSmartArtNode, deobfuscateFont, deriveOutputPath, detectDigitalSignatures, detectFileFormat, detectFontFormat, detectOleObjectType, detectStrictConformance, diffPresentations, diffSlides, distributeSegmentsAcrossChain, douglasPeucker, duplicateElement, duplicateSlide, elementActionToPptxAction, elementHasAction, emuToPixels, encryptPptx, ensureArrayValue, escapeXmlAttr, estimateTextBoxCapacity, evaluateGeometryPaths, evaluateGuides, extractAllTagText, extractFirstTagText, extractGuidFromPartName, extractModel3DTransform, extractTagAttribute, fetchUrlToBytes, findLayoutByName, findLayoutByType, findPlaceholders, findText, formatCommentTimestamp, fragmentShapes, generateFontGuid, generateLayoutXml, generateMediaFilename, getCalloutLeaderLineGeometry, getCalloutTier, getCalloutViewBoxBounds, getCommentMarkerPosition, getConnectorAdjustment, getConnectorPathGeometry, getCssBorderDashStyle, getDirectory, getElementLabel, getElementTextContent, getElementTransform, getImageMaskStyle, getLinkedTextBoxSegments, getOleObjectTypeLabel, getPanoseWeight, getPresetShapeClipPath, getRoundRectRadiusPx, getSectionForSlide, getSectionSlideRange, getShapeClipPath, getShapeType, getSignaturePathsToStrip, getSubstituteFontFamily, getSubstituteFonts, getSupportedNamespaces, getSvgStrokeDasharray, getTextCompensationTransform, getThemePreset, getZoomElements, getZoomTargetSlideIndexes, guidToKey, guideEmuToPx, guidePxToEmu, hasDirectSubstitution, hasNonTrivialOverride, hasShapeProperties, hasTextProperties, hexToRgbChannels, hslToRgb, inches, inchesToEmu, inferOleExtensionFromTarget, interpolateShapeGeometry, intersectPolygons, intersectShapes, intersectSvgPaths, isCalloutShape, isConnectorElement, isEditableTextElement, isImageLikeElement, isInkElement, isNamespaceSupported, isShapeElement, isStrictNamespaceUri, isSummaryZoomSlide, isSwitchableLayoutType, isTemplateElement, isTextElement, isTransitionalNamespaceUri, isZoomElement, isZoomElement2 as isZoomElementUtil, layoutEngineShapesToDrawingShapes, mailMerge, mergePresentation, mergeShapes, mergeThemeColorOverride, mm, moveSlidesToSection, normalizeHexColor, normalizeNamespaceUri, normalizePartPath, normalizePath, normalizeStrictXml, normalizeStrokeDashType, obfuscateFont, ooxmlArcToSvg, parseActiveXControlsFromSlide, parseAdjustmentValues, parseBodyPrBooleanAttrs, parseChart3DSurfaces, parseChartAxes, parseCondition, parseConditionList, parseCxChartSeries, parseDataTable, parseDataUrlToBytes, parseDrawingColor, parseDrawingColorChoice, parseDrawingColorOpacity, parseDrawingFraction, parseDrawingHueDegrees, parseDrawingPercent, parseEmbeddedXlsx, parseGuideDefinitions, parseKinsoku, parseLayoutDefinition, parseLineStyle, parseMarker, parseOle2, parsePanoseBytes, parsePanoseString, parsePresentationDrawingGuides, parseSeriesDataLabels, parseSeriesDataPoints, parseSeriesErrBars, parseSeriesExplosion, parseSeriesTrendlines, parseShapeProps, parseSignatureXml, parseSlideDrawingGuides, parseSvgPath, parseVmlElement, parseVmlElements, pixelsToEmu, polygonsToSvgPath, pptxActionToElementAction, promoteSmartArtNode, pt, reResolveSlideColors, readFileAsDataUrl, reflowSmartArtLayout, removeChartCategory, removeChartSeries, removeSection, removeSmartArtNode, reorderSections, reorderSmartArtNode, reorderSmartArtNodeToIndex, repairPptx, replaceShapeGeometry, replaceText, replaceTextInSlide, replaceWithCustomGeometry, resetCloneIdCounter, resetDecomposeCounter, resetIdCounter, resetSectionIdCounter, resetSmartArtEditCounter, resolveCoordinate, resolveModel3DMimeType, resolveReferenceUriToPart, rgbToHsl, selectAlternateContentBranch, serializeCondition, serializeConditionList, serializeSvgPath, setChartCategories, setChartGrouping, setChartTitle, setChartType, shouldRenderFallbackLabel, shouldReturnToZoomSlide, subtractPolygons, subtractShapes, subtractSvgPaths, svgPathToPolygons, switchSmartArtLayout, toHex, toStrictNamespaceUri, unionPolygons, unionShapes, unionSvgPaths, unwrapAlternateContent, updateChartDataPoint, updateChartSeriesValues, updateSmartArtNodeText, validatePptx, verifyModifyPassword, verifyPassword, verifySignatureDigests, writeBodyPrBooleanAttrs };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for OOXML digital signature processing.
|
|
3
|
+
*
|
|
4
|
+
* OPC URIs, algorithm URIs, digest mappings, and enterprise
|
|
5
|
+
* environment variable names used across both platform-agnostic
|
|
6
|
+
* and Node-only signature modules.
|
|
7
|
+
*/
|
|
8
|
+
/** The OOXML relationship type for the digital signature origin part. */
|
|
9
|
+
declare const DIGITAL_SIGNATURE_ORIGIN_REL_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin";
|
|
10
|
+
/** The OOXML relationship type for individual signature parts. */
|
|
11
|
+
declare const DIGITAL_SIGNATURE_REL_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature";
|
|
12
|
+
/** Custom pptx-viewer manifest namespace for extended signature references. */
|
|
13
|
+
declare const PPTX_VIEWER_MANIFEST_NS = "urn:pptx-viewer:ooxml-signature:v1";
|
|
14
|
+
/** W3C XML Digital Signature namespace. */
|
|
15
|
+
declare const XMLDSIG_NS = "http://www.w3.org/2000/09/xmldsig#";
|
|
16
|
+
/** OPC relationship transform algorithm URI. */
|
|
17
|
+
declare const OPC_RELATIONSHIP_TRANSFORM = "http://schemas.openxmlformats.org/package/2006/RelationshipTransform";
|
|
18
|
+
/** Enveloped signature transform algorithm URI. */
|
|
19
|
+
declare const XML_TRANSFORM_ENVELOPED_SIGNATURE = "http://www.w3.org/2000/09/xmldsig#enveloped-signature";
|
|
20
|
+
/** Set of supported XML canonicalization transform algorithm URIs. */
|
|
21
|
+
declare const SUPPORTED_XML_CANON_TRANSFORMS: Set<string>;
|
|
22
|
+
/** Environment variable: path to file containing enterprise trust root PEM certificates. */
|
|
23
|
+
declare const ENTERPRISE_TRUST_ROOTS_FILE_ENV = "PPTX_VIEWER_TRUST_ROOTS_FILE";
|
|
24
|
+
/** Environment variable: inline PEM trust roots. */
|
|
25
|
+
declare const ENTERPRISE_TRUST_ROOTS_PEM_ENV = "PPTX_VIEWER_TRUST_ROOTS_PEM";
|
|
26
|
+
/** Environment variable: require revocation check. */
|
|
27
|
+
declare const ENTERPRISE_REQUIRE_REVOCATION_ENV = "PPTX_VIEWER_REQUIRE_REVOCATION_CHECK";
|
|
28
|
+
/** Environment variable: fail on unknown revocation status. */
|
|
29
|
+
declare const ENTERPRISE_FAIL_ON_REVOCATION_UNKNOWN_ENV = "PPTX_VIEWER_FAIL_ON_REVOCATION_UNKNOWN";
|
|
30
|
+
/** Environment variable: require timestamp authority. */
|
|
31
|
+
declare const ENTERPRISE_REQUIRE_TIMESTAMP_ENV = "PPTX_VIEWER_REQUIRE_TIMESTAMP";
|
|
32
|
+
/**
|
|
33
|
+
* Mapping from XML Digital Signature digest algorithm URIs to hash function names.
|
|
34
|
+
* Used by Node-only code with `node:crypto` (lowercase names).
|
|
35
|
+
*/
|
|
36
|
+
declare const DIGEST_ALGORITHM_TO_HASH: Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* Mapping from XML Digital Signature digest algorithm URIs to Web Crypto algorithm names.
|
|
39
|
+
* Used by platform-agnostic code with `crypto.subtle.digest`.
|
|
40
|
+
*/
|
|
41
|
+
declare const DIGEST_ALGORITHM_TO_WEB_CRYPTO: Record<string, string>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Rich types for digital signature inspection, signing, and PKI validation.
|
|
45
|
+
*
|
|
46
|
+
* These are platform-agnostic — used by both browser-level detection
|
|
47
|
+
* and Node-only full verification modules.
|
|
48
|
+
*/
|
|
49
|
+
type CertificateRevocationStatus = 'good' | 'revoked' | 'unknown' | 'not-checked' | 'error';
|
|
50
|
+
type TimestampAuthorityStatus = 'valid' | 'invalid' | 'not-present' | 'not-checked' | 'error' | 'untrusted';
|
|
51
|
+
interface SignatureReferenceCheck {
|
|
52
|
+
uri: string;
|
|
53
|
+
resolvedPartPath?: string;
|
|
54
|
+
existsInPackage: boolean;
|
|
55
|
+
digestAlgorithm?: string;
|
|
56
|
+
digestExpectedBase64?: string;
|
|
57
|
+
digestActualBase64?: string;
|
|
58
|
+
digestStatus: 'verified' | 'mismatch' | 'missing-part' | 'unsupported-transform' | 'unsupported-algorithm' | 'insufficient-data';
|
|
59
|
+
transformAlgorithms: string[];
|
|
60
|
+
}
|
|
61
|
+
interface SignatureCertificateInfo {
|
|
62
|
+
subject?: string;
|
|
63
|
+
issuer?: string;
|
|
64
|
+
serialNumber?: string;
|
|
65
|
+
validFrom?: string;
|
|
66
|
+
validTo?: string;
|
|
67
|
+
}
|
|
68
|
+
type SignatureDetailStatus = 'verified' | 'digest-mismatch' | 'reference-missing' | 'signature-invalid' | 'certificate-untrusted' | 'certificate-revoked' | 'timestamp-invalid' | 'timestamp-untrusted' | 'structural-only';
|
|
69
|
+
interface SignatureDetail {
|
|
70
|
+
path: string;
|
|
71
|
+
signatureMethod?: string;
|
|
72
|
+
canonicalizationMethod?: string;
|
|
73
|
+
signingTime?: string;
|
|
74
|
+
referenceCount: number;
|
|
75
|
+
missingPartReferences: string[];
|
|
76
|
+
unsupportedTransforms: string[];
|
|
77
|
+
referenceChecks: SignatureReferenceCheck[];
|
|
78
|
+
certificate?: SignatureCertificateInfo;
|
|
79
|
+
signatureValueStatus: 'verified' | 'invalid' | 'not-checked';
|
|
80
|
+
certificateTrustStatus: 'trusted' | 'untrusted' | 'not-checked';
|
|
81
|
+
certificateTrustError?: string;
|
|
82
|
+
certificateRevocationStatus: CertificateRevocationStatus;
|
|
83
|
+
certificateRevocationError?: string;
|
|
84
|
+
timestampAuthorityStatus: TimestampAuthorityStatus;
|
|
85
|
+
timestampAuthorityError?: string;
|
|
86
|
+
certificateFingerprintSha256?: string;
|
|
87
|
+
status: SignatureDetailStatus;
|
|
88
|
+
}
|
|
89
|
+
type DigitalSignatureVerificationStatus = 'unsigned' | 'verified-trusted' | 'verified-untrusted' | 'certificate-revoked' | 'digest-mismatch' | 'reference-missing' | 'signature-invalid' | 'timestamp-invalid' | 'timestamp-untrusted' | 'present-not-verified' | 'invalid-package' | 'error';
|
|
90
|
+
interface DigitalSignatureReport {
|
|
91
|
+
supported: boolean;
|
|
92
|
+
hasSignature: boolean;
|
|
93
|
+
signatureCount: number;
|
|
94
|
+
signaturePaths: string[];
|
|
95
|
+
verificationStatus: DigitalSignatureVerificationStatus;
|
|
96
|
+
error?: string;
|
|
97
|
+
details?: SignatureDetail[];
|
|
98
|
+
hasOriginRelationship?: boolean;
|
|
99
|
+
}
|
|
100
|
+
interface SignOptions {
|
|
101
|
+
certificatePath: string;
|
|
102
|
+
certificatePassword?: string;
|
|
103
|
+
}
|
|
104
|
+
interface SignResult {
|
|
105
|
+
success: boolean;
|
|
106
|
+
signedData?: Uint8Array;
|
|
107
|
+
report: DigitalSignatureReport;
|
|
108
|
+
error?: string;
|
|
109
|
+
}
|
|
110
|
+
interface LoadedSigningMaterial {
|
|
111
|
+
privateKeyPem: string;
|
|
112
|
+
certificatePem: string;
|
|
113
|
+
}
|
|
114
|
+
interface ParsedReferenceTransform {
|
|
115
|
+
algorithm: string;
|
|
116
|
+
relationshipReferenceIds: string[];
|
|
117
|
+
}
|
|
118
|
+
interface ReferenceTransformResult {
|
|
119
|
+
data: Uint8Array;
|
|
120
|
+
unsupportedAlgorithms: string[];
|
|
121
|
+
}
|
|
122
|
+
interface SignatureValidationPolicy {
|
|
123
|
+
requireRevocationCheck: boolean;
|
|
124
|
+
failOnRevocationUnknown: boolean;
|
|
125
|
+
requireTimestamp: boolean;
|
|
126
|
+
}
|
|
127
|
+
interface OfficeSignatureReference {
|
|
128
|
+
uri: string;
|
|
129
|
+
digestMethod: string;
|
|
130
|
+
digestValue: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Pure regex-based XML extraction utilities for digital signature processing.
|
|
135
|
+
*
|
|
136
|
+
* These functions operate on raw XML strings without requiring a DOM parser,
|
|
137
|
+
* making them platform-agnostic (browser + Node).
|
|
138
|
+
*/
|
|
139
|
+
/** Escape special characters in an XML attribute value. */
|
|
140
|
+
declare function escapeXmlAttr(value: string): string;
|
|
141
|
+
/**
|
|
142
|
+
* Extract an attribute value from the first matching XML tag via regex.
|
|
143
|
+
* Namespace prefixes on the tag name are supported via the pattern.
|
|
144
|
+
*/
|
|
145
|
+
declare function extractTagAttribute(xml: string, tagName: string, attributeName: string): string | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Extract the text content of the first matching tag, ignoring namespace prefixes.
|
|
148
|
+
* Whitespace within the content is collapsed.
|
|
149
|
+
*/
|
|
150
|
+
declare function extractFirstTagText(xml: string, localName: string): string | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* Extract the text content of all matching tags, ignoring namespace prefixes.
|
|
153
|
+
* Whitespace within each match is collapsed.
|
|
154
|
+
*/
|
|
155
|
+
declare function extractAllTagText(xml: string, localName: string): string[];
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Pure string utilities for resolving digital signature reference URIs
|
|
159
|
+
* to ZIP part paths. Platform-agnostic (no Node dependencies).
|
|
160
|
+
*/
|
|
161
|
+
/** Normalize a ZIP part path: convert backslashes to forward slashes and strip leading slashes. */
|
|
162
|
+
declare function normalizePartPath(partPath: string): string;
|
|
163
|
+
/**
|
|
164
|
+
* Resolve a signature reference URI to a ZIP part path.
|
|
165
|
+
* Returns `undefined` for empty URIs, fragment-only URIs (#...), or invalid input.
|
|
166
|
+
*/
|
|
167
|
+
declare function resolveReferenceUriToPart(uri: string): string | undefined;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Platform-agnostic digest computation using the Web Crypto API.
|
|
171
|
+
*
|
|
172
|
+
* Works in both browser and Node.js (18+) environments via `crypto.subtle`.
|
|
173
|
+
*/
|
|
174
|
+
/**
|
|
175
|
+
* Compute a Base64-encoded digest of the given content using Web Crypto.
|
|
176
|
+
*
|
|
177
|
+
* @param content - The binary data to hash.
|
|
178
|
+
* @param digestAlgorithmUri - An XML Digital Signature digest algorithm URI
|
|
179
|
+
* (e.g. `http://www.w3.org/2001/04/xmlenc#sha256`).
|
|
180
|
+
* @returns The Base64-encoded digest, or `undefined` if the algorithm is unsupported
|
|
181
|
+
* or `crypto.subtle` is unavailable.
|
|
182
|
+
*/
|
|
183
|
+
declare function computeDigestBase64(content: Uint8Array, digestAlgorithmUri: string): Promise<string | undefined>;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Pure status-computation logic for digital signature inspection.
|
|
187
|
+
*
|
|
188
|
+
* These functions are platform-agnostic — they accept data and policy
|
|
189
|
+
* as parameters instead of reading from the environment.
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Compute the overall status for an individual signature detail
|
|
194
|
+
* based on its reference checks, trust, revocation, and timestamp statuses.
|
|
195
|
+
*
|
|
196
|
+
* @param detail - A partial `SignatureDetail` with the fields needed for status computation.
|
|
197
|
+
* @param policy - The validation policy controlling revocation/timestamp strictness.
|
|
198
|
+
* @returns The computed status for this signature detail.
|
|
199
|
+
*/
|
|
200
|
+
declare function computeDetailStatus(detail: Pick<SignatureDetail, 'signatureValueStatus' | 'missingPartReferences' | 'referenceChecks' | 'certificateTrustStatus' | 'certificateRevocationStatus' | 'timestampAuthorityStatus'>, policy: SignatureValidationPolicy): SignatureDetailStatus;
|
|
201
|
+
/**
|
|
202
|
+
* Compute the overall verification status from all signature details.
|
|
203
|
+
*
|
|
204
|
+
* @param details - Array of signature details from all signatures in the package.
|
|
205
|
+
* @returns The overall verification status for the report.
|
|
206
|
+
*/
|
|
207
|
+
declare function computeVerificationStatus(details: SignatureDetail[]): DigitalSignatureReport['verificationStatus'];
|
|
208
|
+
|
|
209
|
+
export { normalizePartPath as A, resolveReferenceUriToPart as B, type CertificateRevocationStatus as C, DIGEST_ALGORITHM_TO_HASH as D, ENTERPRISE_FAIL_ON_REVOCATION_UNKNOWN_ENV as E, type LoadedSigningMaterial as L, OPC_RELATIONSHIP_TRANSFORM as O, PPTX_VIEWER_MANIFEST_NS as P, type ReferenceTransformResult as R, SUPPORTED_XML_CANON_TRANSFORMS as S, type TimestampAuthorityStatus as T, XMLDSIG_NS as X, DIGEST_ALGORITHM_TO_WEB_CRYPTO as a, DIGITAL_SIGNATURE_ORIGIN_REL_TYPE as b, DIGITAL_SIGNATURE_REL_TYPE as c, type DigitalSignatureReport as d, type DigitalSignatureVerificationStatus as e, ENTERPRISE_REQUIRE_REVOCATION_ENV as f, ENTERPRISE_REQUIRE_TIMESTAMP_ENV as g, ENTERPRISE_TRUST_ROOTS_FILE_ENV as h, ENTERPRISE_TRUST_ROOTS_PEM_ENV as i, type OfficeSignatureReference as j, type ParsedReferenceTransform as k, type SignOptions as l, type SignResult as m, type SignatureDetail as n, type SignatureDetailStatus as o, type SignatureCertificateInfo as p, type SignatureReferenceCheck as q, type SignatureValidationPolicy as r, XML_TRANSFORM_ENVELOPED_SIGNATURE as s, computeDetailStatus as t, computeDigestBase64 as u, computeVerificationStatus as v, escapeXmlAttr as w, extractAllTagText as x, extractFirstTagText as y, extractTagAttribute as z };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for OOXML digital signature processing.
|
|
3
|
+
*
|
|
4
|
+
* OPC URIs, algorithm URIs, digest mappings, and enterprise
|
|
5
|
+
* environment variable names used across both platform-agnostic
|
|
6
|
+
* and Node-only signature modules.
|
|
7
|
+
*/
|
|
8
|
+
/** The OOXML relationship type for the digital signature origin part. */
|
|
9
|
+
declare const DIGITAL_SIGNATURE_ORIGIN_REL_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin";
|
|
10
|
+
/** The OOXML relationship type for individual signature parts. */
|
|
11
|
+
declare const DIGITAL_SIGNATURE_REL_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature";
|
|
12
|
+
/** Custom pptx-viewer manifest namespace for extended signature references. */
|
|
13
|
+
declare const PPTX_VIEWER_MANIFEST_NS = "urn:pptx-viewer:ooxml-signature:v1";
|
|
14
|
+
/** W3C XML Digital Signature namespace. */
|
|
15
|
+
declare const XMLDSIG_NS = "http://www.w3.org/2000/09/xmldsig#";
|
|
16
|
+
/** OPC relationship transform algorithm URI. */
|
|
17
|
+
declare const OPC_RELATIONSHIP_TRANSFORM = "http://schemas.openxmlformats.org/package/2006/RelationshipTransform";
|
|
18
|
+
/** Enveloped signature transform algorithm URI. */
|
|
19
|
+
declare const XML_TRANSFORM_ENVELOPED_SIGNATURE = "http://www.w3.org/2000/09/xmldsig#enveloped-signature";
|
|
20
|
+
/** Set of supported XML canonicalization transform algorithm URIs. */
|
|
21
|
+
declare const SUPPORTED_XML_CANON_TRANSFORMS: Set<string>;
|
|
22
|
+
/** Environment variable: path to file containing enterprise trust root PEM certificates. */
|
|
23
|
+
declare const ENTERPRISE_TRUST_ROOTS_FILE_ENV = "PPTX_VIEWER_TRUST_ROOTS_FILE";
|
|
24
|
+
/** Environment variable: inline PEM trust roots. */
|
|
25
|
+
declare const ENTERPRISE_TRUST_ROOTS_PEM_ENV = "PPTX_VIEWER_TRUST_ROOTS_PEM";
|
|
26
|
+
/** Environment variable: require revocation check. */
|
|
27
|
+
declare const ENTERPRISE_REQUIRE_REVOCATION_ENV = "PPTX_VIEWER_REQUIRE_REVOCATION_CHECK";
|
|
28
|
+
/** Environment variable: fail on unknown revocation status. */
|
|
29
|
+
declare const ENTERPRISE_FAIL_ON_REVOCATION_UNKNOWN_ENV = "PPTX_VIEWER_FAIL_ON_REVOCATION_UNKNOWN";
|
|
30
|
+
/** Environment variable: require timestamp authority. */
|
|
31
|
+
declare const ENTERPRISE_REQUIRE_TIMESTAMP_ENV = "PPTX_VIEWER_REQUIRE_TIMESTAMP";
|
|
32
|
+
/**
|
|
33
|
+
* Mapping from XML Digital Signature digest algorithm URIs to hash function names.
|
|
34
|
+
* Used by Node-only code with `node:crypto` (lowercase names).
|
|
35
|
+
*/
|
|
36
|
+
declare const DIGEST_ALGORITHM_TO_HASH: Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* Mapping from XML Digital Signature digest algorithm URIs to Web Crypto algorithm names.
|
|
39
|
+
* Used by platform-agnostic code with `crypto.subtle.digest`.
|
|
40
|
+
*/
|
|
41
|
+
declare const DIGEST_ALGORITHM_TO_WEB_CRYPTO: Record<string, string>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Rich types for digital signature inspection, signing, and PKI validation.
|
|
45
|
+
*
|
|
46
|
+
* These are platform-agnostic — used by both browser-level detection
|
|
47
|
+
* and Node-only full verification modules.
|
|
48
|
+
*/
|
|
49
|
+
type CertificateRevocationStatus = 'good' | 'revoked' | 'unknown' | 'not-checked' | 'error';
|
|
50
|
+
type TimestampAuthorityStatus = 'valid' | 'invalid' | 'not-present' | 'not-checked' | 'error' | 'untrusted';
|
|
51
|
+
interface SignatureReferenceCheck {
|
|
52
|
+
uri: string;
|
|
53
|
+
resolvedPartPath?: string;
|
|
54
|
+
existsInPackage: boolean;
|
|
55
|
+
digestAlgorithm?: string;
|
|
56
|
+
digestExpectedBase64?: string;
|
|
57
|
+
digestActualBase64?: string;
|
|
58
|
+
digestStatus: 'verified' | 'mismatch' | 'missing-part' | 'unsupported-transform' | 'unsupported-algorithm' | 'insufficient-data';
|
|
59
|
+
transformAlgorithms: string[];
|
|
60
|
+
}
|
|
61
|
+
interface SignatureCertificateInfo {
|
|
62
|
+
subject?: string;
|
|
63
|
+
issuer?: string;
|
|
64
|
+
serialNumber?: string;
|
|
65
|
+
validFrom?: string;
|
|
66
|
+
validTo?: string;
|
|
67
|
+
}
|
|
68
|
+
type SignatureDetailStatus = 'verified' | 'digest-mismatch' | 'reference-missing' | 'signature-invalid' | 'certificate-untrusted' | 'certificate-revoked' | 'timestamp-invalid' | 'timestamp-untrusted' | 'structural-only';
|
|
69
|
+
interface SignatureDetail {
|
|
70
|
+
path: string;
|
|
71
|
+
signatureMethod?: string;
|
|
72
|
+
canonicalizationMethod?: string;
|
|
73
|
+
signingTime?: string;
|
|
74
|
+
referenceCount: number;
|
|
75
|
+
missingPartReferences: string[];
|
|
76
|
+
unsupportedTransforms: string[];
|
|
77
|
+
referenceChecks: SignatureReferenceCheck[];
|
|
78
|
+
certificate?: SignatureCertificateInfo;
|
|
79
|
+
signatureValueStatus: 'verified' | 'invalid' | 'not-checked';
|
|
80
|
+
certificateTrustStatus: 'trusted' | 'untrusted' | 'not-checked';
|
|
81
|
+
certificateTrustError?: string;
|
|
82
|
+
certificateRevocationStatus: CertificateRevocationStatus;
|
|
83
|
+
certificateRevocationError?: string;
|
|
84
|
+
timestampAuthorityStatus: TimestampAuthorityStatus;
|
|
85
|
+
timestampAuthorityError?: string;
|
|
86
|
+
certificateFingerprintSha256?: string;
|
|
87
|
+
status: SignatureDetailStatus;
|
|
88
|
+
}
|
|
89
|
+
type DigitalSignatureVerificationStatus = 'unsigned' | 'verified-trusted' | 'verified-untrusted' | 'certificate-revoked' | 'digest-mismatch' | 'reference-missing' | 'signature-invalid' | 'timestamp-invalid' | 'timestamp-untrusted' | 'present-not-verified' | 'invalid-package' | 'error';
|
|
90
|
+
interface DigitalSignatureReport {
|
|
91
|
+
supported: boolean;
|
|
92
|
+
hasSignature: boolean;
|
|
93
|
+
signatureCount: number;
|
|
94
|
+
signaturePaths: string[];
|
|
95
|
+
verificationStatus: DigitalSignatureVerificationStatus;
|
|
96
|
+
error?: string;
|
|
97
|
+
details?: SignatureDetail[];
|
|
98
|
+
hasOriginRelationship?: boolean;
|
|
99
|
+
}
|
|
100
|
+
interface SignOptions {
|
|
101
|
+
certificatePath: string;
|
|
102
|
+
certificatePassword?: string;
|
|
103
|
+
}
|
|
104
|
+
interface SignResult {
|
|
105
|
+
success: boolean;
|
|
106
|
+
signedData?: Uint8Array;
|
|
107
|
+
report: DigitalSignatureReport;
|
|
108
|
+
error?: string;
|
|
109
|
+
}
|
|
110
|
+
interface LoadedSigningMaterial {
|
|
111
|
+
privateKeyPem: string;
|
|
112
|
+
certificatePem: string;
|
|
113
|
+
}
|
|
114
|
+
interface ParsedReferenceTransform {
|
|
115
|
+
algorithm: string;
|
|
116
|
+
relationshipReferenceIds: string[];
|
|
117
|
+
}
|
|
118
|
+
interface ReferenceTransformResult {
|
|
119
|
+
data: Uint8Array;
|
|
120
|
+
unsupportedAlgorithms: string[];
|
|
121
|
+
}
|
|
122
|
+
interface SignatureValidationPolicy {
|
|
123
|
+
requireRevocationCheck: boolean;
|
|
124
|
+
failOnRevocationUnknown: boolean;
|
|
125
|
+
requireTimestamp: boolean;
|
|
126
|
+
}
|
|
127
|
+
interface OfficeSignatureReference {
|
|
128
|
+
uri: string;
|
|
129
|
+
digestMethod: string;
|
|
130
|
+
digestValue: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Pure regex-based XML extraction utilities for digital signature processing.
|
|
135
|
+
*
|
|
136
|
+
* These functions operate on raw XML strings without requiring a DOM parser,
|
|
137
|
+
* making them platform-agnostic (browser + Node).
|
|
138
|
+
*/
|
|
139
|
+
/** Escape special characters in an XML attribute value. */
|
|
140
|
+
declare function escapeXmlAttr(value: string): string;
|
|
141
|
+
/**
|
|
142
|
+
* Extract an attribute value from the first matching XML tag via regex.
|
|
143
|
+
* Namespace prefixes on the tag name are supported via the pattern.
|
|
144
|
+
*/
|
|
145
|
+
declare function extractTagAttribute(xml: string, tagName: string, attributeName: string): string | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Extract the text content of the first matching tag, ignoring namespace prefixes.
|
|
148
|
+
* Whitespace within the content is collapsed.
|
|
149
|
+
*/
|
|
150
|
+
declare function extractFirstTagText(xml: string, localName: string): string | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* Extract the text content of all matching tags, ignoring namespace prefixes.
|
|
153
|
+
* Whitespace within each match is collapsed.
|
|
154
|
+
*/
|
|
155
|
+
declare function extractAllTagText(xml: string, localName: string): string[];
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Pure string utilities for resolving digital signature reference URIs
|
|
159
|
+
* to ZIP part paths. Platform-agnostic (no Node dependencies).
|
|
160
|
+
*/
|
|
161
|
+
/** Normalize a ZIP part path: convert backslashes to forward slashes and strip leading slashes. */
|
|
162
|
+
declare function normalizePartPath(partPath: string): string;
|
|
163
|
+
/**
|
|
164
|
+
* Resolve a signature reference URI to a ZIP part path.
|
|
165
|
+
* Returns `undefined` for empty URIs, fragment-only URIs (#...), or invalid input.
|
|
166
|
+
*/
|
|
167
|
+
declare function resolveReferenceUriToPart(uri: string): string | undefined;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Platform-agnostic digest computation using the Web Crypto API.
|
|
171
|
+
*
|
|
172
|
+
* Works in both browser and Node.js (18+) environments via `crypto.subtle`.
|
|
173
|
+
*/
|
|
174
|
+
/**
|
|
175
|
+
* Compute a Base64-encoded digest of the given content using Web Crypto.
|
|
176
|
+
*
|
|
177
|
+
* @param content - The binary data to hash.
|
|
178
|
+
* @param digestAlgorithmUri - An XML Digital Signature digest algorithm URI
|
|
179
|
+
* (e.g. `http://www.w3.org/2001/04/xmlenc#sha256`).
|
|
180
|
+
* @returns The Base64-encoded digest, or `undefined` if the algorithm is unsupported
|
|
181
|
+
* or `crypto.subtle` is unavailable.
|
|
182
|
+
*/
|
|
183
|
+
declare function computeDigestBase64(content: Uint8Array, digestAlgorithmUri: string): Promise<string | undefined>;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Pure status-computation logic for digital signature inspection.
|
|
187
|
+
*
|
|
188
|
+
* These functions are platform-agnostic — they accept data and policy
|
|
189
|
+
* as parameters instead of reading from the environment.
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Compute the overall status for an individual signature detail
|
|
194
|
+
* based on its reference checks, trust, revocation, and timestamp statuses.
|
|
195
|
+
*
|
|
196
|
+
* @param detail - A partial `SignatureDetail` with the fields needed for status computation.
|
|
197
|
+
* @param policy - The validation policy controlling revocation/timestamp strictness.
|
|
198
|
+
* @returns The computed status for this signature detail.
|
|
199
|
+
*/
|
|
200
|
+
declare function computeDetailStatus(detail: Pick<SignatureDetail, 'signatureValueStatus' | 'missingPartReferences' | 'referenceChecks' | 'certificateTrustStatus' | 'certificateRevocationStatus' | 'timestampAuthorityStatus'>, policy: SignatureValidationPolicy): SignatureDetailStatus;
|
|
201
|
+
/**
|
|
202
|
+
* Compute the overall verification status from all signature details.
|
|
203
|
+
*
|
|
204
|
+
* @param details - Array of signature details from all signatures in the package.
|
|
205
|
+
* @returns The overall verification status for the report.
|
|
206
|
+
*/
|
|
207
|
+
declare function computeVerificationStatus(details: SignatureDetail[]): DigitalSignatureReport['verificationStatus'];
|
|
208
|
+
|
|
209
|
+
export { normalizePartPath as A, resolveReferenceUriToPart as B, type CertificateRevocationStatus as C, DIGEST_ALGORITHM_TO_HASH as D, ENTERPRISE_FAIL_ON_REVOCATION_UNKNOWN_ENV as E, type LoadedSigningMaterial as L, OPC_RELATIONSHIP_TRANSFORM as O, PPTX_VIEWER_MANIFEST_NS as P, type ReferenceTransformResult as R, SUPPORTED_XML_CANON_TRANSFORMS as S, type TimestampAuthorityStatus as T, XMLDSIG_NS as X, DIGEST_ALGORITHM_TO_WEB_CRYPTO as a, DIGITAL_SIGNATURE_ORIGIN_REL_TYPE as b, DIGITAL_SIGNATURE_REL_TYPE as c, type DigitalSignatureReport as d, type DigitalSignatureVerificationStatus as e, ENTERPRISE_REQUIRE_REVOCATION_ENV as f, ENTERPRISE_REQUIRE_TIMESTAMP_ENV as g, ENTERPRISE_TRUST_ROOTS_FILE_ENV as h, ENTERPRISE_TRUST_ROOTS_PEM_ENV as i, type OfficeSignatureReference as j, type ParsedReferenceTransform as k, type SignOptions as l, type SignResult as m, type SignatureDetail as n, type SignatureDetailStatus as o, type SignatureCertificateInfo as p, type SignatureReferenceCheck as q, type SignatureValidationPolicy as r, XML_TRANSFORM_ENVELOPED_SIGNATURE as s, computeDetailStatus as t, computeDigestBase64 as u, computeVerificationStatus as v, escapeXmlAttr as w, extractAllTagText as x, extractFirstTagText as y, extractTagAttribute as z };
|