@oim-media/spec 1.36.10 → 1.37.3

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/CANONICAL_SPEC.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > This document describes **1.x** (legacy, no longer painted by readers). The current format is OIM 2.0: see [CANONICAL_SPEC_2.md](CANONICAL_SPEC_2.md).
4
4
 
5
- **Contract version:** 1.36.10
5
+ **Contract version:** 1.37.3
6
6
  **Date:** 2026-11-02 (reviewed against `packages/core/src/schema.ts`; the source of truth is the schema, this document summarises it)
7
7
  **Status:** Normative / In force
8
8
  **License:** Apache-2.0
@@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0
6
6
  # OIM 2.0 Canonical Specification
7
7
 
8
8
  **Document version emitted by the reference writer:** `2.0.0` (`DOCUMENT_VERSION` in `@oim-media/core/v2`)
9
- **Contract release this text was checked against:** 1.36.10
9
+ **Contract release this text was checked against:** 1.37.3
10
10
  **Status:** Normative
11
11
  **License:** Apache-2.0
12
12
  **Authority:** Xue Studios LLC
@@ -77,6 +77,14 @@ pre-release string `2.0.0-draft.1` and are not re-signed: that string is still a
77
77
  A `.oim` is a conforming PNG (ISO/IEC 15948) that starts with the 8-byte PNG signature. Any viewer that
78
78
  does not know OIM shows it as an ordinary image. The pixels are the **base picture** (section 2.4).
79
79
 
80
+ - **Unknown ancillary chunks:** Readers MUST ignore unknown ancillary PNG chunks (chunks whose first type byte is
81
+ lowercase per ISO/IEC 15948, such as `iCCP`, `pHYs`, non-OIM `tEXt`, retired `OIM_Seal`, or unknown private chunks
82
+ like `uNkN`) placed before `IEND`. Because the signature seals `OIM_Data` and the concatenated `IDAT` payloads
83
+ (section 6.5), an extra unsigned ancillary chunk does not break verification (`verified`).
84
+ - **Scanning past `IEND`:** When collecting `IDAT` chunks for the image seal (section 6.5), readers MUST continue
85
+ scanning well-formed PNG chunks even after `IEND` so a smuggled trailing `IDAT` chunk changes `sha256-idat` and is
86
+ refused as `image_mismatch`.
87
+
80
88
  ### 2.2. The document chunk
81
89
 
82
90
  The document is stored in one ancillary text chunk:
@@ -235,7 +243,7 @@ A **paint** is one of the following objects. `opacity` is a number 0..1 on every
235
243
  | `kind` | Fields |
236
244
  |---|---|
237
245
  | `color` | `value`: a colour (3.5). |
238
- | `gradient` | `gradient` or `preset` (exactly one). `gradient`: `type` (`linear` \| `radial` \| `conic`), `angle` (number), `stops` (2..32 of `{ color, at }`, `at` 0..1). `preset`: a name ≤64. |
246
+ | `gradient` | `gradient` or `preset` (exactly one). `gradient`: `type` (`linear` \| `radial` \| `conic`), `angle` (number), `stops` (2..32 of `{ color, at }`, `at` 0..1). `preset`: a name ≤64, one of `sunset-gold`, `metallic-chrome` or `neon-glow` (their stops are in `gradient-presets.json`); a reader paints an unknown preset as nothing. |
239
247
  | `image` | `src` (string; a `data:image/` URI), `fit` (`contain` \| `cover` \| `fill` \| `none` \| `scale-down`), `crop` (`{ x: 0..100, y: 0..100, zoom: 1..10 }`), `flipX`, `flipY`, `filters` (3.8). |
240
248
  | `pattern` | `pattern`: `preset` (name ≤64), `colors` (≤16 colours), `bg` (colour), `scale`, `sizes`/`counts`/`dispersions` (numbers, ≤16), `svgs` (strings, ≤16), `fit` (≤32), `motion` (`direction`: `right` \| `left` \| `up` \| `down` \| `zoom-in` \| `zoom-out` \| `pulse`; `period` >0; `speed`), `tile`: `{ viewBox: number[4], paths: pathEntry[1..64] }` (a stored drawing; with it `preset` and `svgs` are ignored). |
241
249
  | `generative` | `generative`: `generatorId` (`^[a-z0-9-]+$`, ≤64), `seed` (number), `params` (map of ≤64-char keys to number, string ≤256 or boolean), `colors` (`mode`: `monochrome` \| `palette`; `stops`: ≤16 colours; `direction`: `forward` \| `reverse` \| `radial`; `background`: colour; `backgroundVisible`: boolean). |
@@ -283,8 +291,9 @@ Effects apply in array order to the whole layer.
283
291
  ### 3.7. Geometry and corners
284
292
 
285
293
  `geometry` (required on `shape`) is discriminated by `kind`. Every kind may carry `trim`
286
- (`{ start?: 0..1, end?: 0..1 }`, how much of the outline is drawn). The reference painter draws it on a figure
287
- it draws as an SVG outline (a preset, a line, an ellipse, a single path); a plain rectangle is not trimmed.
294
+ (`{ start?: 0..1, end?: 0..1 }`, how much of the outline's stroke is drawn, as a share of its total length).
295
+ A rectangle's outline is inset by half the stroke, rounded by its first corner, and starts after its top-left
296
+ corner; a drawing trims each of its paths. A dashed or dotted stroke keeps its dashes inside the trim.
288
297
 
289
298
  | `kind` | Fields |
290
299
  |---|---|
@@ -427,6 +436,12 @@ for that role, else its `fallback`, else it paints nothing. The active palette i
427
436
  matches the viewer's colour scheme; else `defaults.palette`. A host page may override a role with the CSS
428
437
  custom property `--oim-color-<role>`.
429
438
 
439
+ A length bound by `{ "var": name }` (a font size, a `maxWidth`, a stroke `width`) takes `values[name]` when it
440
+ is a number, or a string that reads as one. When `values[name]` is a map option → number, the length has a
441
+ value per mode: the option named in `defaults` is its value (else its `fallback`, else the first option), and
442
+ the reader selects the other options by language, as for an exception. A stroke width takes the value alone.
443
+ With no number for it and no `fallback`, the length is absent. The cases are in `length-binding-cases.json`.
444
+
430
445
  ### 3.15. Resources
431
446
 
432
447
  `resources` maps a name to a paint. A `{ "ref": name }` in `canvas.fills`, a layer's `fills`, a stroke's `paint`
@@ -655,9 +670,10 @@ is the profile of [BINARY_SPEC.md](BINARY_SPEC.md) section 5.1, **not** RFC 8785
655
670
  - Value: the 64 bytes `r ‖ s` (IEEE P1363, not ASN.1 DER), base64-encoded, in `signature`.
656
671
  - `key_version` names the signing key (`kid`), for example `v1` or `v2`. `signed_at` is an ISO 8601 timestamp with
657
672
  seconds and a time-zone designator, written by the signer and inside the signed bytes.
658
- - The public keys are published in [`keys.json`](keys.json) and by the signer at
659
- `https://api.oim.media/v1/media/keys`. A reader embeds the keys it knows and fetches the list only for a
660
- `key_version` it does not.
673
+ - The public keys are published in [`keys.json`](keys.json) and mirrored at
674
+ `https://api.oim.media/v1/media/keys` for tooling and build-time packaging. Sandboxed players MUST embed the
675
+ public keys from `keys.json` and verify strictly offline; a player MUST NOT make automatic outbound network requests
676
+ to look up unknown keys.
661
677
 
662
678
  ### 6.4. Verification
663
679
 
@@ -666,9 +682,11 @@ A reader verifies in this order:
666
682
  1. Extract the document (section 2). No document: the file is a plain image (`no_metadata`).
667
683
  2. Validate the limits of section 5.3. A violation: `corrupt`, refuse.
668
684
  3. If `signature` or `key_version` is absent: `unsigned`.
669
- 4. Otherwise rebuild the canonical form (6.2) and verify the signature with the key `key_version`. A number with
670
- no canonical form, an unknown key, or a failed verification: `invalid_signature`, refuse. When the
671
- embedded key fails, the reader MAY retry once with the key the server publishes for the same `kid`.
685
+ 4. Otherwise rebuild the canonical form (6.2) and verify the signature with the embedded key for `key_version`. A
686
+ number with no canonical form, an unknown key, or a failed verification: `invalid_signature`, refuse. Sandboxed
687
+ players MUST NOT issue outbound network calls during verification, even when `key_version` is unknown or
688
+ verification fails (the only network request permitted is fetching the user's `.oim` file itself when loaded
689
+ from a URL).
672
690
  (Informative: for older files the reference player also retries when the document has `creator_user_id`,
673
691
  keeping that field and using UTF-16 key order with no number normalisation. Writers and signers MUST NOT rely on it.)
674
692
  5. If the key was retired (`not_after` earlier than `signed_at`) the signature is invalid. A key the player no
@@ -704,9 +722,13 @@ Embedding the document changes no `IDAT` byte.
704
722
  The 2.0 conformance corpus is `vectors-2/`: 48 signed `.oim.png` files that exercise text and multilingual
705
723
  content, strokes, effects, masks, patterns, generative and image fills, animation presets, interactions, groups,
706
724
  loops, palettes, fonts and re-edit. Each has a golden image `vectors-2/golden/<name>.web.png` rendered by the web
707
- reference (one vector, `background-pattern-order`, has none yet). A vector has no `.expected.json`: the
725
+ reference. A vector has no `.expected.json`: the
708
726
  expectation is the golden. Known differences of a renderer go in an `exceptions.json` beside the goldens, with a
709
- reason; an excepted vector that passes fails the run (`vectors-2/golden` has none today).
727
+ reason; an excepted vector that passes fails the run.
728
+
729
+ Security boundary and negative fixtures live in `vectors-tampered/` together with `vectors-tampered/manifest.json`:
730
+ - `cases` (5 tampered 2.0 files): files altered after signing (modified `IDAT` bytes, appended `IDAT` chunk before `IEND`, smuggled `IDAT` chunk appended after `IEND`, mutated layer metadata, and invalid signatures) that every compliant reader MUST refuse with the declared verdict (`image_mismatch` or `invalid_signature`).
731
+ - `accepted`: a validly signed 2.0 file carrying an extra unknown ancillary PNG chunk (`uNkN`) before `IEND` that every compliant reader MUST ignore and verify as `verified`.
710
732
 
711
733
  Procedure (800 px wide, device pixel ratio 1, animations disabled, white background, `sans-serif` host font),
712
734
  metric (pixel channel difference above 40, 3 × 3 erosion, fail above 0.4 % area or a 576 px blob) and
@@ -776,25 +798,16 @@ A writer is checked by validating its documents against `schema/oim2.schema.json
776
798
 
777
799
  ## 11. Appendix D: what the schema allows and the reference painter does not draw
778
800
 
779
- Checked against the working tree that follows release 1.36.10. A reader that does not draw one of these is still
801
+ Checked against the working tree that follows release 1.37.3. A reader that does not draw one of these is still
780
802
  conforming to the schema; a writer SHOULD NOT rely on them being painted.
781
803
 
782
- - A gradient paint with `preset` and no `gradient`: the reference painter reads the preset only for an artistic
783
- text (`text.artistic`), where it names the gradient type. On any other fill it draws nothing; writers SHOULD
784
- give an explicit `gradient`. (Kept in the schema because a signed vector, `artistic-text`, uses it.)
785
- - Length bindings `{ var }` for `font.size`, `maxWidth` and a stroke's `width` are not resolved; literals and
786
- `{ value, modes }` are. Nothing in this repository writes them. Readers MAY ignore them; colour bindings are
787
- resolved.
788
804
  - A `{ ref }` chain through several resources beyond four steps: not drawn.
789
805
  - Text marks in 2.0 are not limited by the schema to the 1.x pattern `^[a-z][a-z0-9-]{0,23}$` and 8 per
790
806
  layer; writers SHOULD respect them because the shared parser of `{name}…{/name}` does.
791
- - A trim is not drawn on a rectangle (a box, no outline) or on a drawing of several paths.
792
- - A trimmed stroke drops a dashed or dotted style; the trim replaces it.
793
807
  - A figure's stroke width is in layer pixels and scales with the figure, like the rest of the layer (no
794
808
  `vector-effect: non-scaling-stroke`); at any display size it keeps the same share of the figure.
795
- - A feathered cutout edge is drawn hard.
796
- - The reference player does not check the per-layer schema limits (fills, strokes, effects, animations, interactions, actions, tracks, keyframes, gradient stops, paths and the like); only 150 per list, 1000 total, depth 32 and 10 MiB.
809
+ - The reference player checks the lists inside each layer (fills, strokes, effects, animations, interactions, tracks, keyframes, actions, gradient stops, paths, pattern tile paths) but not the canvas's own fills or a pattern's colour and size lists.
797
810
 
798
- Painted since the draft of this appendix: `geometry.trim` and the `trimStart` / `trimEnd` tracks, an animation
811
+ Painted since the draft of this appendix: a cutout's `feather` (its edge blurred by that standard deviation), length bindings `{ var }`, a gradient `preset` on any fill, `geometry.trim` and the `trimStart` / `trimEnd` tracks, an animation
799
812
  `on: "press"`, `animation.stagger`, a layer's own `languages`, `extensionsRequired` (refusal), and a cutout mask
800
813
  inside a group. The root `timestamp` is part of the schema (section 1.2).
package/README.md CHANGED
@@ -15,6 +15,7 @@ marks-cases.json Known-answer cases for text marks, shared with the backend's
15
15
  canonical-cases.json Known-answer case for the canonical form, checked by the TypeScript, Rust and Dart implementations.
16
16
  schema/oim2.schema.json The 2.0 document, generated from @oim-media/core/v2.
17
17
  vectors-2/ 48 signed 2.0 .oim files with web goldens (golden/).
18
+ vectors-tampered/ 5 tampered signed 2.0 files + unknown ancillary chunk fixture + manifest.json.
18
19
  vectors/ 39 signed .oim files, each with <name>.expected.json.
19
20
  tools/ Read-only checks: contract-summary.mjs, canonical-check.mjs, style-usage.mjs.
20
21
  ```
@@ -0,0 +1,64 @@
1
+ {
2
+ "sunset-gold": {
3
+ "type": "linear",
4
+ "angle": 180,
5
+ "stops": [
6
+ {
7
+ "color": "#FDE047",
8
+ "at": 0
9
+ },
10
+ {
11
+ "color": "#F97316",
12
+ "at": 0.5
13
+ },
14
+ {
15
+ "color": "#BE185D",
16
+ "at": 1
17
+ }
18
+ ]
19
+ },
20
+ "metallic-chrome": {
21
+ "type": "linear",
22
+ "angle": 180,
23
+ "stops": [
24
+ {
25
+ "color": "#FFFFFF",
26
+ "at": 0
27
+ },
28
+ {
29
+ "color": "#E2E8F0",
30
+ "at": 0.35
31
+ },
32
+ {
33
+ "color": "#64748B",
34
+ "at": 0.5
35
+ },
36
+ {
37
+ "color": "#0F172A",
38
+ "at": 0.51
39
+ },
40
+ {
41
+ "color": "#94A3B8",
42
+ "at": 0.75
43
+ },
44
+ {
45
+ "color": "#FFFFFF",
46
+ "at": 1
47
+ }
48
+ ]
49
+ },
50
+ "neon-glow": {
51
+ "type": "linear",
52
+ "angle": 90,
53
+ "stops": [
54
+ {
55
+ "color": "#67E8F9",
56
+ "at": 0
57
+ },
58
+ {
59
+ "color": "#A5F3FC",
60
+ "at": 1
61
+ }
62
+ ]
63
+ }
64
+ }
@@ -0,0 +1,26 @@
1
+ [
2
+ { "name": "a number value", "variables": { "values": { "h": 24 } }, "binding": { "var": "h" }, "expected": 24 },
3
+ { "name": "a numeric string value", "variables": { "values": { "h": "24.5" } }, "binding": { "var": "h" }, "expected": 24.5 },
4
+ { "name": "no value: the fallback", "variables": {}, "binding": { "var": "h", "fallback": 12 }, "expected": 12 },
5
+ { "name": "no value and no fallback: removed", "variables": {}, "binding": { "var": "h" }, "expected": null },
6
+ { "name": "a non-numeric value: the fallback", "variables": { "values": { "h": "big" } }, "binding": { "var": "h", "fallback": 9 }, "expected": 9 },
7
+ {
8
+ "name": "per mode, the default mode is the value",
9
+ "variables": { "modes": { "language": ["es", "en"] }, "defaults": { "language": "en" }, "values": { "h": { "es": 30, "en": 24 } } },
10
+ "binding": { "var": "h", "fallback": 10 },
11
+ "expected": { "value": 24, "modes": { "es": 30, "en": 24 } }
12
+ },
13
+ {
14
+ "name": "per mode, no default: the fallback is the value",
15
+ "variables": { "values": { "h": { "es": 30, "en": 24 } } },
16
+ "binding": { "var": "h", "fallback": 10 },
17
+ "expected": { "value": 10, "modes": { "es": 30, "en": 24 } }
18
+ },
19
+ {
20
+ "name": "per mode, no default and no fallback: the first mode",
21
+ "variables": { "values": { "h": { "es": 30, "en": 24 } } },
22
+ "binding": { "var": "h" },
23
+ "expected": { "value": 30, "modes": { "es": 30, "en": 24 } }
24
+ },
25
+ { "name": "an inherited name is not a variable", "variables": { "values": {} }, "binding": { "var": "constructor", "fallback": 7 }, "expected": 7 }
26
+ ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oim-media/spec",
3
- "version": "1.36.10",
3
+ "version": "1.37.3",
4
4
  "description": "OIM format contract: JSON Schema, normative specification and conformance vectors that every OIM player must pass.",
5
5
  "keywords": [
6
6
  "oim",
@@ -15,12 +15,15 @@
15
15
  "schema",
16
16
  "vectors",
17
17
  "vectors-2",
18
+ "vectors-tampered",
18
19
  "BINARY_SPEC.md",
19
20
  "CANONICAL_SPEC.md",
20
21
  "CANONICAL_SPEC_2.md",
21
22
  "SPEC_2.md",
22
23
  "README.md",
23
24
  "marks-cases.json",
25
+ "length-binding-cases.json",
26
+ "gradient-presets.json",
24
27
  "canonical-cases.json",
25
28
  "keyframe-cases.json",
26
29
  "action-cases.json",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://oim.media/spec/1.36.10/oim.schema.json",
3
+ "$id": "https://oim.media/spec/1.37.3/oim.schema.json",
4
4
  "title": "OIM document metadata",
5
- "specVersion": "1.36.10",
5
+ "specVersion": "1.37.3",
6
6
  "type": "object",
7
7
  "properties": {
8
8
  "description": {
Binary file
Binary file
@@ -0,0 +1,38 @@
1
+ {
2
+ "description": "Signed OIM 2.0 files modified after signing. Every compliant reader MUST refuse every file listed here.",
3
+ "source": "vectors-2/basic-text.oim.png",
4
+ "cases": [
5
+ {
6
+ "file": "tampered-idat.oim.png",
7
+ "expected": "image_mismatch",
8
+ "reason": "1 bit flipped in the first IDAT chunk payload with valid PNG CRC-32; signature verifies but sha256-idat seal breaks."
9
+ },
10
+ {
11
+ "file": "tampered-trailing-idat.oim.png",
12
+ "expected": "image_mismatch",
13
+ "reason": "Extra IDAT chunk appended before IEND with valid PNG CRC-32; signature verifies but concatenated IDAT hash breaks."
14
+ },
15
+ {
16
+ "file": "tampered-payload.oim.png",
17
+ "expected": "invalid_signature",
18
+ "reason": "Signed layer metadata modified in OIM_Data with valid PNG CRC-32; ECDSA P-256 signature verification fails."
19
+ },
20
+ {
21
+ "file": "tampered-signature.oim.png",
22
+ "expected": "invalid_signature",
23
+ "reason": "1 byte flipped inside the 64-byte IEEE P1363 ECDSA signature (metadata and IDAT intact) with valid PNG CRC-32."
24
+ },
25
+ {
26
+ "file": "tampered-idat-after-iend.oim.png",
27
+ "expected": "image_mismatch",
28
+ "reason": "Extra IDAT chunk appended after IEND with valid PNG CRC-32; readers scan past IEND so concatenated IDAT hash breaks."
29
+ }
30
+ ],
31
+ "accepted": [
32
+ {
33
+ "file": "valid-unknown-ancillary-chunk.oim.png",
34
+ "expected": "verified",
35
+ "reason": "Validly signed file with an extra unknown ancillary PNG chunk (uNkN, valid CRC-32) inserted before IEND; compliant readers MUST ignore unknown ancillary chunks and verify the document."
36
+ }
37
+ ]
38
+ }