@mhome/artifact-protocol 0.3.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 mHome.ai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # mhome-artifact-api
2
+
3
+ Storage-independent artifact references shared by mHome runtimes.
4
+
5
+ The crate is the source of truth for the `meow-artifact://v1/` URI format and its
6
+ immutable image, audio, and file metadata. The published schema and conformance
7
+ fixtures are intended for non-Rust runtimes.
8
+
9
+ The crate also defines the transport-neutral `/artifact/resolve` request and response.
10
+ Delivery is an explicit `DATA_URL` or `SIGNED_URL` union; a signed URL may point to a
11
+ cloud object store or an authenticated local streaming endpoint.
12
+
13
+ TTL, storage placement, filesystem paths, signed URLs, and cloud object keys are
14
+ runtime concerns and are deliberately not encoded into an artifact reference.
@@ -0,0 +1,71 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "valid": [
4
+ {
5
+ "name": "image",
6
+ "uri": "meow-artifact://v1/tenant/scope/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/eyJrIjoiaSIsIm0iOiJpbWFnZS9wbmciLCJzIjoxMiwidyI6MiwiaCI6M30",
7
+ "kind": "image",
8
+ "mimeType": "image/png",
9
+ "sizeBytes": 12,
10
+ "width": 2,
11
+ "height": 3
12
+ },
13
+ {
14
+ "name": "audio",
15
+ "uri": "meow-artifact://v1/tenant/scope/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/eyJrIjoiYSIsIm0iOiJhdWRpby9vZ2ciLCJzIjoyMCwiZCI6MTUwMH0",
16
+ "kind": "audio",
17
+ "mimeType": "audio/ogg",
18
+ "sizeBytes": 20,
19
+ "durationMillis": 1500
20
+ },
21
+ {
22
+ "name": "file",
23
+ "uri": "meow-artifact://v1/tenant/scope/cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc/eyJrIjoiZiIsIm0iOiJhcHBsaWNhdGlvbi9wZGYiLCJzIjozMH0",
24
+ "kind": "file",
25
+ "mimeType": "application/pdf",
26
+ "sizeBytes": 30
27
+ }
28
+ ],
29
+ "invalid": [
30
+ {
31
+ "name": "video-kind",
32
+ "uri": "meow-artifact://v1/tenant/scope/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/eyJrIjoidiIsIm0iOiJ2aWRlby9tcDQiLCJzIjoxMH0"
33
+ },
34
+ {
35
+ "name": "file-with-video-mime",
36
+ "uri": "meow-artifact://v1/tenant/scope/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/eyJrIjoiZiIsIm0iOiJ2aWRlby9tcDQiLCJzIjoxMH0"
37
+ },
38
+ {
39
+ "name": "image-with-duration",
40
+ "uri": "meow-artifact://v1/tenant/scope/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/eyJrIjoiaSIsIm0iOiJpbWFnZS9wbmciLCJzIjoxMCwidyI6MSwiaCI6MSwiZCI6MX0"
41
+ },
42
+ {
43
+ "name": "uppercase-digest",
44
+ "uri": "meow-artifact://v1/tenant/scope/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/eyJrIjoiZiIsIm0iOiJ0ZXh0L3BsYWluIiwicyI6MX0"
45
+ },
46
+ {
47
+ "name": "javascript-unsafe-size",
48
+ "uri": "meow-artifact://v1/tenant/scope/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/eyJrIjoiZiIsIm0iOiJ0ZXh0L3BsYWluIiwicyI6OTAwNzE5OTI1NDc0MDk5Mn0"
49
+ },
50
+ {
51
+ "name": "oversized-image-dimension",
52
+ "uri": "meow-artifact://v1/tenant/scope/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/eyJrIjoiaSIsIm0iOiJpbWFnZS9wbmciLCJzIjoxMCwidyI6MjE0NzQ4MzY0OCwiaCI6MX0"
53
+ },
54
+ {
55
+ "name": "padded-base64url",
56
+ "uri": "meow-artifact://v1/tenant/scope/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/eyJrIjoiZiIsIm0iOiJ0ZXh0L3BsYWluIiwicyI6MX0="
57
+ },
58
+ {
59
+ "name": "leading-whitespace",
60
+ "uri": " meow-artifact://v1/tenant/scope/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/eyJrIjoiZiIsIm0iOiJ0ZXh0L3BsYWluIiwicyI6MX0"
61
+ },
62
+ {
63
+ "name": "reordered-metadata",
64
+ "uri": "meow-artifact://v1/tenant/scope/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/eyJtIjoidGV4dC9wbGFpbiIsImsiOiJmIiwicyI6MX0"
65
+ },
66
+ {
67
+ "name": "duplicate-metadata-field",
68
+ "uri": "meow-artifact://v1/tenant/scope/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/eyJrIjoiZiIsIm0iOiJ0ZXh0L3BsYWluIiwicyI6MSwicyI6MX0"
69
+ }
70
+ ]
71
+ }
@@ -0,0 +1,75 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "valid": [
4
+ {
5
+ "name": "request",
6
+ "value": {
7
+ "uri": "meow-artifact://v1/tenant/scope/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/eyJrIjoiaSIsIm0iOiJpbWFnZS9wbmciLCJzIjoxMiwidyI6MiwiaCI6M30"
8
+ }
9
+ },
10
+ {
11
+ "name": "data-url-response",
12
+ "value": {
13
+ "uri": "meow-artifact://v1/tenant/scope/cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc/eyJrIjoiZiIsIm0iOiJhcHBsaWNhdGlvbi9wZGYiLCJzIjozMH0",
14
+ "kind": "FILE",
15
+ "mimeType": "application/pdf",
16
+ "sizeBytes": 30,
17
+ "delivery": {
18
+ "type": "DATA_URL",
19
+ "dataUrl": "data:application/pdf;base64,eA=="
20
+ }
21
+ }
22
+ },
23
+ {
24
+ "name": "signed-url-response",
25
+ "value": {
26
+ "uri": "meow-artifact://v1/tenant/scope/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/eyJrIjoiYSIsIm0iOiJhdWRpby9vZ2ciLCJzIjoyMCwiZCI6MTUwMH0",
27
+ "kind": "AUDIO",
28
+ "mimeType": "audio/ogg",
29
+ "sizeBytes": 20,
30
+ "durationMillis": 1500,
31
+ "delivery": {
32
+ "type": "SIGNED_URL",
33
+ "url": "https://example.test/artifact",
34
+ "expiresAtUnixMs": 1900000000000
35
+ }
36
+ }
37
+ }
38
+ ],
39
+ "invalid": [
40
+ {
41
+ "name": "unknown-request-field",
42
+ "value": {
43
+ "uri": "meow-artifact://v1/tenant/scope/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/eyJrIjoiaSIsIm0iOiJpbWFnZS9wbmciLCJzIjoxMiwidyI6MiwiaCI6M30",
44
+ "scopeId": "scope"
45
+ }
46
+ },
47
+ {
48
+ "name": "ambiguous-delivery",
49
+ "value": {
50
+ "uri": "meow-artifact://v1/tenant/scope/cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc/eyJrIjoiZiIsIm0iOiJhcHBsaWNhdGlvbi9wZGYiLCJzIjozMH0",
51
+ "kind": "FILE",
52
+ "mimeType": "application/pdf",
53
+ "sizeBytes": 30,
54
+ "delivery": {
55
+ "type": "DATA_URL",
56
+ "dataUrl": "data:application/pdf;base64,eA==",
57
+ "url": "https://example.test/artifact"
58
+ }
59
+ }
60
+ },
61
+ {
62
+ "name": "signed-url-without-expiry",
63
+ "value": {
64
+ "uri": "meow-artifact://v1/tenant/scope/cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc/eyJrIjoiZiIsIm0iOiJhcHBsaWNhdGlvbi9wZGYiLCJzIjozMH0",
65
+ "kind": "FILE",
66
+ "mimeType": "application/pdf",
67
+ "sizeBytes": 30,
68
+ "delivery": {
69
+ "type": "SIGNED_URL",
70
+ "url": "https://example.test/artifact"
71
+ }
72
+ }
73
+ }
74
+ ]
75
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "manifest": "mhome.artifact.v1",
3
+ "contractVersion": "0.3.0",
4
+ "uriPrefix": "meow-artifact://v1/",
5
+ "kinds": ["image", "audio", "file"],
6
+ "resolve": {
7
+ "target": "/artifact/resolve",
8
+ "schema": "schema/artifact-resolve.v1.schema.json",
9
+ "schemaVersion": 1
10
+ }
11
+ }
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@mhome/artifact-protocol",
3
+ "version": "0.3.0",
4
+ "description": "Build-time protocol artifacts for mhome.artifact",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/mhome-ai/foundation.git",
9
+ "directory": "crates/artifact"
10
+ },
11
+ "homepage": "https://github.com/mhome-ai/foundation#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/mhome-ai/foundation/issues"
14
+ },
15
+ "keywords": [
16
+ "mhome",
17
+ "protocol",
18
+ "json-schema",
19
+ "fixtures"
20
+ ],
21
+ "private": false,
22
+ "files": [
23
+ "protocol.json",
24
+ "manifest",
25
+ "contract",
26
+ "schema",
27
+ "fixtures",
28
+ "README.md",
29
+ "LICENSE"
30
+ ],
31
+ "exports": {
32
+ "./package.json": "./package.json",
33
+ "./protocol.json": "./protocol.json",
34
+ "./manifest/*": "./manifest/*",
35
+ "./contract/*": "./contract/*",
36
+ "./schema/*": "./schema/*",
37
+ "./fixtures/*": "./fixtures/*"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "provenance": true
42
+ }
43
+ }
package/protocol.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "protocol": "mhome.artifact",
3
+ "contractVersion": "0.3.0",
4
+ "manifest": "manifest/artifact.v1.json",
5
+ "schemas": {
6
+ "artifactMetadata": "schema/artifact-metadata.v1.schema.json",
7
+ "artifactResolve": "schema/artifact-resolve.v1.schema.json"
8
+ },
9
+ "fixtures": {
10
+ "artifactReference": "fixtures/artifact-reference.conformance.json",
11
+ "artifactResolve": "fixtures/artifact-resolve.conformance.json"
12
+ }
13
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://mhome.ai/schema/artifact-metadata.v1.schema.json",
4
+ "title": "mHome Artifact Metadata v1",
5
+ "oneOf": [
6
+ {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "required": ["k", "m", "s", "w", "h"],
10
+ "properties": {
11
+ "k": { "const": "i" },
12
+ "m": { "type": "string", "pattern": "^image/[a-z0-9!#$&^_.+-]+$", "maxLength": 255 },
13
+ "s": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 },
14
+ "w": { "type": "integer", "minimum": 1, "maximum": 2147483647 },
15
+ "h": { "type": "integer", "minimum": 1, "maximum": 2147483647 }
16
+ }
17
+ },
18
+ {
19
+ "type": "object",
20
+ "additionalProperties": false,
21
+ "required": ["k", "m", "s"],
22
+ "properties": {
23
+ "k": { "const": "a" },
24
+ "m": { "type": "string", "pattern": "^audio/[a-z0-9!#$&^_.+-]+$", "maxLength": 255 },
25
+ "s": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 },
26
+ "d": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 }
27
+ }
28
+ },
29
+ {
30
+ "type": "object",
31
+ "additionalProperties": false,
32
+ "required": ["k", "m", "s"],
33
+ "properties": {
34
+ "k": { "const": "f" },
35
+ "m": {
36
+ "type": "string",
37
+ "pattern": "^(?!video/)[a-z0-9!#$&^_.+-]+/[a-z0-9!#$&^_.+-]+$",
38
+ "maxLength": 255
39
+ },
40
+ "s": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 }
41
+ }
42
+ }
43
+ ]
44
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://mhome.ai/schema/artifact-resolve.v1.schema.json",
4
+ "title": "mHome Artifact Resolve v1",
5
+ "oneOf": [
6
+ { "$ref": "#/$defs/request" },
7
+ { "$ref": "#/$defs/response" }
8
+ ],
9
+ "$defs": {
10
+ "request": {
11
+ "type": "object",
12
+ "additionalProperties": false,
13
+ "required": ["uri"],
14
+ "properties": {
15
+ "uri": { "type": "string", "pattern": "^meow-artifact://v1/", "maxLength": 2048 }
16
+ }
17
+ },
18
+ "response": {
19
+ "type": "object",
20
+ "additionalProperties": false,
21
+ "required": ["uri", "kind", "mimeType", "sizeBytes", "delivery"],
22
+ "properties": {
23
+ "uri": { "type": "string", "pattern": "^meow-artifact://v1/", "maxLength": 2048 },
24
+ "kind": { "enum": ["IMAGE", "AUDIO", "FILE"] },
25
+ "mimeType": { "type": "string", "minLength": 3, "maxLength": 255 },
26
+ "sizeBytes": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 },
27
+ "width": { "type": "integer", "minimum": 1, "maximum": 2147483647 },
28
+ "height": { "type": "integer", "minimum": 1, "maximum": 2147483647 },
29
+ "durationMillis": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 },
30
+ "delivery": {
31
+ "oneOf": [
32
+ {
33
+ "type": "object",
34
+ "additionalProperties": false,
35
+ "required": ["type", "dataUrl"],
36
+ "properties": {
37
+ "type": { "const": "DATA_URL" },
38
+ "dataUrl": { "type": "string", "pattern": "^data:[^;,]+;base64,.+$" }
39
+ }
40
+ },
41
+ {
42
+ "type": "object",
43
+ "additionalProperties": false,
44
+ "required": ["type", "url", "expiresAtUnixMs"],
45
+ "properties": {
46
+ "type": { "const": "SIGNED_URL" },
47
+ "url": { "type": "string", "pattern": "^https?://" },
48
+ "expiresAtUnixMs": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 }
49
+ }
50
+ }
51
+ ]
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }