@opengeni/artifact-tool 0.2.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/LICENSE +190 -0
- package/README.md +104 -0
- package/dist/bounded-zip.d.ts +28 -0
- package/dist/chunk-4BSENMAE.js +39 -0
- package/dist/chunk-4BSENMAE.js.map +1 -0
- package/dist/chunk-4FRFNNBM.js +276 -0
- package/dist/chunk-4FRFNNBM.js.map +1 -0
- package/dist/chunk-5XIA6KHZ.js +49 -0
- package/dist/chunk-5XIA6KHZ.js.map +1 -0
- package/dist/chunk-66CT2ZRP.js +2229 -0
- package/dist/chunk-66CT2ZRP.js.map +1 -0
- package/dist/chunk-72SYDU4O.js +319 -0
- package/dist/chunk-72SYDU4O.js.map +1 -0
- package/dist/chunk-B2ZJRZDA.js +279 -0
- package/dist/chunk-B2ZJRZDA.js.map +1 -0
- package/dist/chunk-DCTLTNPW.js +2458 -0
- package/dist/chunk-DCTLTNPW.js.map +1 -0
- package/dist/chunk-FGZM4FQ6.js +473 -0
- package/dist/chunk-FGZM4FQ6.js.map +1 -0
- package/dist/chunk-HTJBLBDE.js +591 -0
- package/dist/chunk-HTJBLBDE.js.map +1 -0
- package/dist/chunk-IYFXZQ34.js +5306 -0
- package/dist/chunk-IYFXZQ34.js.map +1 -0
- package/dist/chunk-J6N7IR44.js +172 -0
- package/dist/chunk-J6N7IR44.js.map +1 -0
- package/dist/chunk-N2IHNWBS.js +1002 -0
- package/dist/chunk-N2IHNWBS.js.map +1 -0
- package/dist/chunk-NAG44K67.js +549 -0
- package/dist/chunk-NAG44K67.js.map +1 -0
- package/dist/chunk-O24KTEGP.js +33 -0
- package/dist/chunk-O24KTEGP.js.map +1 -0
- package/dist/chunk-PI2AZVGK.js +2074 -0
- package/dist/chunk-PI2AZVGK.js.map +1 -0
- package/dist/chunk-Q2FFHEY7.js +40 -0
- package/dist/chunk-Q2FFHEY7.js.map +1 -0
- package/dist/chunk-RBGQADXA.js +57 -0
- package/dist/chunk-RBGQADXA.js.map +1 -0
- package/dist/chunk-U5G2BKM2.js +613 -0
- package/dist/chunk-U5G2BKM2.js.map +1 -0
- package/dist/chunk-VOJHMSM3.js +39 -0
- package/dist/chunk-VOJHMSM3.js.map +1 -0
- package/dist/chunk-VUNV25KB.js +16 -0
- package/dist/chunk-VUNV25KB.js.map +1 -0
- package/dist/chunk-XIFUNVBO.js +101 -0
- package/dist/chunk-XIFUNVBO.js.map +1 -0
- package/dist/chunk-ZCJYRJGB.js +489 -0
- package/dist/chunk-ZCJYRJGB.js.map +1 -0
- package/dist/chunk-ZZXPEE4S.js +2260 -0
- package/dist/chunk-ZZXPEE4S.js.map +1 -0
- package/dist/document-docx-api.d.ts +49 -0
- package/dist/document-docx-codec.d.ts +9 -0
- package/dist/document-docx-codec.js +4765 -0
- package/dist/document-docx-codec.js.map +1 -0
- package/dist/document-docx-import.d.ts +261 -0
- package/dist/document-docx-packer.d.ts +18 -0
- package/dist/document-docx-state.d.ts +12 -0
- package/dist/document-render.d.ts +3 -0
- package/dist/document-render.js +492 -0
- package/dist/document-render.js.map +1 -0
- package/dist/document.d.ts +432 -0
- package/dist/document.js +37 -0
- package/dist/document.js.map +1 -0
- package/dist/errors.d.ts +23 -0
- package/dist/file-blob.d.ts +11 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +186 -0
- package/dist/index.js.map +1 -0
- package/dist/inspection.d.ts +12 -0
- package/dist/kernel.d.ts +101 -0
- package/dist/lib-GQLPACFK.js +9746 -0
- package/dist/lib-GQLPACFK.js.map +1 -0
- package/dist/materializer-cli-entry.d.ts +2 -0
- package/dist/materializer-cli-entry.js +29 -0
- package/dist/materializer-cli-entry.js.map +1 -0
- package/dist/materializer-cli.d.ts +24 -0
- package/dist/materializer-cli.js +24 -0
- package/dist/materializer-cli.js.map +1 -0
- package/dist/native-raster.d.ts +10 -0
- package/dist/native.d.ts +129 -0
- package/dist/native.js +31 -0
- package/dist/native.js.map +1 -0
- package/dist/office-import.d.ts +48 -0
- package/dist/office-import.js +154 -0
- package/dist/office-import.js.map +1 -0
- package/dist/presentation-pptx-api.d.ts +60 -0
- package/dist/presentation-pptx-import.d.ts +5 -0
- package/dist/presentation-pptx-state-digest-765CZZED.js +10 -0
- package/dist/presentation-pptx-state-digest-765CZZED.js.map +1 -0
- package/dist/presentation-pptx-state-digest.d.ts +3 -0
- package/dist/presentation-pptx-state.d.ts +4 -0
- package/dist/presentation-pptx-xml.d.ts +29 -0
- package/dist/presentation-pptx.d.ts +5 -0
- package/dist/presentation-pptx.js +2365 -0
- package/dist/presentation-pptx.js.map +1 -0
- package/dist/presentation-render.d.ts +29 -0
- package/dist/presentation-render.js +375 -0
- package/dist/presentation-render.js.map +1 -0
- package/dist/presentation.d.ts +565 -0
- package/dist/presentation.js +71 -0
- package/dist/presentation.js.map +1 -0
- package/dist/production-composite.d.ts +68 -0
- package/dist/production-document.d.ts +2 -0
- package/dist/production-document.js +176 -0
- package/dist/production-document.js.map +1 -0
- package/dist/production-native-codecs.d.ts +94 -0
- package/dist/production-presentation.d.ts +2 -0
- package/dist/production-presentation.js +176 -0
- package/dist/production-presentation.js.map +1 -0
- package/dist/production-sha256.d.ts +2 -0
- package/dist/production-spreadsheet-native.d.ts +12 -0
- package/dist/production-spreadsheet.d.ts +2 -0
- package/dist/production-spreadsheet.js +176 -0
- package/dist/production-spreadsheet.js.map +1 -0
- package/dist/production.d.ts +96 -0
- package/dist/raster-image.d.ts +34 -0
- package/dist/reference.d.ts +17 -0
- package/dist/reference.js +574 -0
- package/dist/reference.js.map +1 -0
- package/dist/runtime-cli-entry.d.ts +2 -0
- package/dist/runtime-cli-entry.js +21 -0
- package/dist/runtime-cli-entry.js.map +1 -0
- package/dist/runtime-cli.d.ts +76 -0
- package/dist/runtime-cli.js +26 -0
- package/dist/runtime-cli.js.map +1 -0
- package/dist/runtime-development.d.ts +73 -0
- package/dist/runtime-development.js +30 -0
- package/dist/runtime-development.js.map +1 -0
- package/dist/runtime-receipt.d.ts +19 -0
- package/dist/runtime.d.ts +355 -0
- package/dist/runtime.js +42 -0
- package/dist/runtime.js.map +1 -0
- package/dist/snapshot.d.ts +26 -0
- package/dist/snapshot.js +61 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/spreadsheet-address.d.ts +18 -0
- package/dist/spreadsheet-file.d.ts +17 -0
- package/dist/spreadsheet-formula.d.ts +67 -0
- package/dist/spreadsheet-image.d.ts +17 -0
- package/dist/spreadsheet-render.d.ts +5 -0
- package/dist/spreadsheet-render.js +752 -0
- package/dist/spreadsheet-render.js.map +1 -0
- package/dist/spreadsheet-types.d.ts +155 -0
- package/dist/spreadsheet-xlsx-api.d.ts +88 -0
- package/dist/spreadsheet-xlsx-codec.d.ts +16 -0
- package/dist/spreadsheet-xlsx-codec.js +16 -0
- package/dist/spreadsheet-xlsx-codec.js.map +1 -0
- package/dist/spreadsheet-xlsx-state.d.ts +16 -0
- package/dist/spreadsheet.d.ts +724 -0
- package/dist/spreadsheet.js +67 -0
- package/dist/spreadsheet.js.map +1 -0
- package/package.json +129 -0
- package/src/bounded-zip.ts +450 -0
- package/src/document-docx-api.ts +64 -0
- package/src/document-docx-codec.ts +2253 -0
- package/src/document-docx-import.ts +3814 -0
- package/src/document-docx-packer.ts +72 -0
- package/src/document-docx-state.ts +59 -0
- package/src/document-render.ts +615 -0
- package/src/document.ts +2800 -0
- package/src/errors.ts +45 -0
- package/src/file-blob.ts +43 -0
- package/src/index.ts +4 -0
- package/src/inspection.ts +50 -0
- package/src/kernel.ts +525 -0
- package/src/materializer-cli-entry.ts +11 -0
- package/src/materializer-cli.ts +743 -0
- package/src/native-raster.ts +141 -0
- package/src/native.ts +390 -0
- package/src/office-import.ts +243 -0
- package/src/presentation-pptx-api.ts +107 -0
- package/src/presentation-pptx-import.ts +2065 -0
- package/src/presentation-pptx-state-digest.ts +46 -0
- package/src/presentation-pptx-state.ts +18 -0
- package/src/presentation-pptx-xml.ts +473 -0
- package/src/presentation-pptx.ts +447 -0
- package/src/presentation-render.ts +532 -0
- package/src/presentation.ts +2599 -0
- package/src/production-composite.ts +805 -0
- package/src/production-document.ts +2 -0
- package/src/production-native-codecs.ts +1141 -0
- package/src/production-presentation.ts +2 -0
- package/src/production-sha256.ts +150 -0
- package/src/production-spreadsheet-native.ts +686 -0
- package/src/production-spreadsheet.ts +2 -0
- package/src/production.ts +1022 -0
- package/src/raster-image.ts +586 -0
- package/src/reference.ts +17 -0
- package/src/runtime-cli-entry.ts +13 -0
- package/src/runtime-cli.ts +670 -0
- package/src/runtime-development.ts +689 -0
- package/src/runtime-receipt.ts +169 -0
- package/src/runtime.ts +1463 -0
- package/src/snapshot.ts +88 -0
- package/src/spreadsheet-address.ts +90 -0
- package/src/spreadsheet-file.ts +71 -0
- package/src/spreadsheet-formula.ts +1212 -0
- package/src/spreadsheet-image.ts +242 -0
- package/src/spreadsheet-render.ts +985 -0
- package/src/spreadsheet-types.ts +171 -0
- package/src/spreadsheet-xlsx-api.ts +123 -0
- package/src/spreadsheet-xlsx-codec.ts +3063 -0
- package/src/spreadsheet-xlsx-state.ts +191 -0
- package/src/spreadsheet.ts +5195 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ARTIFACT_RUNTIME_TARGETS,
|
|
3
|
+
ArtifactRuntimeError,
|
|
4
|
+
artifactRuntimeTarget,
|
|
5
|
+
type ArtifactRuntimeTarget,
|
|
6
|
+
} from "./runtime";
|
|
7
|
+
|
|
8
|
+
const NATIVE_ASSET = "opengeni_artifact_kernel.node";
|
|
9
|
+
const WASM_RUNTIME_FILES = [
|
|
10
|
+
"artifact_kernel.js",
|
|
11
|
+
"artifact_kernel_bg.wasm",
|
|
12
|
+
"artifact_kernel_document.js",
|
|
13
|
+
"artifact_kernel_document_bg.wasm",
|
|
14
|
+
"artifact_kernel_presentation.js",
|
|
15
|
+
"artifact_kernel_presentation_bg.wasm",
|
|
16
|
+
"artifact_kernel_spreadsheet.js",
|
|
17
|
+
"artifact_kernel_spreadsheet_bg.wasm",
|
|
18
|
+
] as const;
|
|
19
|
+
const MAX_CAPABILITIES_BYTES = 1024 * 1024;
|
|
20
|
+
|
|
21
|
+
export type ArtifactKernelBuildReceipt = Readonly<{
|
|
22
|
+
schemaVersion: 1;
|
|
23
|
+
producer: "opengeni-artifact-kernel-smoke-v1";
|
|
24
|
+
target: ArtifactRuntimeTarget;
|
|
25
|
+
kind: "native" | "wasm";
|
|
26
|
+
buildIdentity: string;
|
|
27
|
+
capabilities: Readonly<{
|
|
28
|
+
bytes: number;
|
|
29
|
+
sha256: `sha256:${string}`;
|
|
30
|
+
}>;
|
|
31
|
+
runtimeFiles: readonly Readonly<{
|
|
32
|
+
path: string;
|
|
33
|
+
bytes: number;
|
|
34
|
+
sha256: `sha256:${string}`;
|
|
35
|
+
}>[];
|
|
36
|
+
}>;
|
|
37
|
+
|
|
38
|
+
export function validateArtifactKernelBuildReceipt(
|
|
39
|
+
value: unknown,
|
|
40
|
+
expectedTarget?: ArtifactRuntimeTarget,
|
|
41
|
+
): ArtifactKernelBuildReceipt {
|
|
42
|
+
const record = exactRecord(
|
|
43
|
+
value,
|
|
44
|
+
[
|
|
45
|
+
"schemaVersion",
|
|
46
|
+
"producer",
|
|
47
|
+
"target",
|
|
48
|
+
"kind",
|
|
49
|
+
"buildIdentity",
|
|
50
|
+
"capabilities",
|
|
51
|
+
"runtimeFiles",
|
|
52
|
+
],
|
|
53
|
+
"target build receipt",
|
|
54
|
+
);
|
|
55
|
+
if (record.schemaVersion !== 1 || record.producer !== "opengeni-artifact-kernel-smoke-v1") {
|
|
56
|
+
invalid("target build receipt schema/producer is invalid");
|
|
57
|
+
}
|
|
58
|
+
if (
|
|
59
|
+
typeof record.target !== "string" ||
|
|
60
|
+
!ARTIFACT_RUNTIME_TARGETS.includes(record.target as ArtifactRuntimeTarget)
|
|
61
|
+
) {
|
|
62
|
+
invalid("target build receipt target is invalid");
|
|
63
|
+
}
|
|
64
|
+
const descriptor = artifactRuntimeTarget(record.target as ArtifactRuntimeTarget);
|
|
65
|
+
if (expectedTarget !== undefined && descriptor.target !== expectedTarget) {
|
|
66
|
+
invalid(`target build receipt ${descriptor.target} does not match ${expectedTarget}`);
|
|
67
|
+
}
|
|
68
|
+
if (record.kind !== descriptor.kind) invalid("target build receipt kind is invalid");
|
|
69
|
+
if (
|
|
70
|
+
typeof record.buildIdentity !== "string" ||
|
|
71
|
+
record.buildIdentity.length === 0 ||
|
|
72
|
+
record.buildIdentity.length > 512
|
|
73
|
+
) {
|
|
74
|
+
invalid("target build receipt identity is invalid");
|
|
75
|
+
}
|
|
76
|
+
const capabilities = fileProof(record.capabilities, "target build capabilities", false);
|
|
77
|
+
if (capabilities.bytes > MAX_CAPABILITIES_BYTES) {
|
|
78
|
+
invalid("target build capabilities exceed their maximum size");
|
|
79
|
+
}
|
|
80
|
+
if (
|
|
81
|
+
!Array.isArray(record.runtimeFiles) ||
|
|
82
|
+
record.runtimeFiles.length === 0 ||
|
|
83
|
+
record.runtimeFiles.length > 8
|
|
84
|
+
) {
|
|
85
|
+
invalid("target build receipt runtimeFiles is invalid");
|
|
86
|
+
}
|
|
87
|
+
const runtimeFiles = record.runtimeFiles.map((entry, index) =>
|
|
88
|
+
fileProof(entry, `target build runtime file ${index}`, true),
|
|
89
|
+
);
|
|
90
|
+
if (
|
|
91
|
+
!runtimeFiles.every((entry, index) => index === 0 || runtimeFiles[index - 1]!.path < entry.path)
|
|
92
|
+
) {
|
|
93
|
+
invalid("target build receipt runtimeFiles must be strictly sorted");
|
|
94
|
+
}
|
|
95
|
+
const expectedPaths = descriptor.kind === "native" ? [NATIVE_ASSET] : WASM_RUNTIME_FILES;
|
|
96
|
+
if (JSON.stringify(runtimeFiles.map(({ path }) => path)) !== JSON.stringify(expectedPaths)) {
|
|
97
|
+
invalid("target build receipt runtimeFiles do not match the target package");
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
schemaVersion: 1,
|
|
101
|
+
producer: "opengeni-artifact-kernel-smoke-v1",
|
|
102
|
+
target: descriptor.target,
|
|
103
|
+
kind: descriptor.kind,
|
|
104
|
+
buildIdentity: record.buildIdentity,
|
|
105
|
+
capabilities: { bytes: capabilities.bytes, sha256: capabilities.sha256 },
|
|
106
|
+
runtimeFiles,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function canonicalArtifactKernelBuildReceiptBytes(value: unknown): Uint8Array {
|
|
111
|
+
const receipt = validateArtifactKernelBuildReceipt(value);
|
|
112
|
+
return new TextEncoder().encode(`${JSON.stringify(receipt, null, 2)}\n`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function fileProof(
|
|
116
|
+
value: unknown,
|
|
117
|
+
name: string,
|
|
118
|
+
includePath: true,
|
|
119
|
+
): { path: string; bytes: number; sha256: `sha256:${string}` };
|
|
120
|
+
function fileProof(
|
|
121
|
+
value: unknown,
|
|
122
|
+
name: string,
|
|
123
|
+
includePath: false,
|
|
124
|
+
): { bytes: number; sha256: `sha256:${string}` };
|
|
125
|
+
function fileProof(value: unknown, name: string, includePath: boolean) {
|
|
126
|
+
const record = exactRecord(
|
|
127
|
+
value,
|
|
128
|
+
includePath ? ["path", "bytes", "sha256"] : ["bytes", "sha256"],
|
|
129
|
+
name,
|
|
130
|
+
);
|
|
131
|
+
const bytes = record.bytes;
|
|
132
|
+
const digest = record.sha256;
|
|
133
|
+
if (!Number.isSafeInteger(bytes) || (bytes as number) <= 0) invalid(`${name} bytes is invalid`);
|
|
134
|
+
if (typeof digest !== "string" || !/^sha256:[0-9a-f]{64}$/u.test(digest)) {
|
|
135
|
+
invalid(`${name} digest is invalid`);
|
|
136
|
+
}
|
|
137
|
+
if (!includePath) return { bytes: bytes as number, sha256: digest as `sha256:${string}` };
|
|
138
|
+
const path = record.path;
|
|
139
|
+
if (
|
|
140
|
+
typeof path !== "string" ||
|
|
141
|
+
path.length === 0 ||
|
|
142
|
+
path.includes("/") ||
|
|
143
|
+
path.includes("\\") ||
|
|
144
|
+
path === "." ||
|
|
145
|
+
path === ".."
|
|
146
|
+
) {
|
|
147
|
+
invalid(`${name} path is invalid`);
|
|
148
|
+
}
|
|
149
|
+
return { path, bytes: bytes as number, sha256: digest as `sha256:${string}` };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function exactRecord(
|
|
153
|
+
value: unknown,
|
|
154
|
+
keys: readonly string[],
|
|
155
|
+
name: string,
|
|
156
|
+
): Record<string, unknown> {
|
|
157
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
158
|
+
invalid(`${name} is invalid`);
|
|
159
|
+
}
|
|
160
|
+
const record = value as Record<string, unknown>;
|
|
161
|
+
if (JSON.stringify(Object.keys(record).sort()) !== JSON.stringify([...keys].sort())) {
|
|
162
|
+
invalid(`${name} has unexpected fields`);
|
|
163
|
+
}
|
|
164
|
+
return record;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function invalid(message: string): never {
|
|
168
|
+
throw new ArtifactRuntimeError("ARTIFACT_RUNTIME_MANIFEST_INVALID", message);
|
|
169
|
+
}
|