From a38b6d1261669dc8b5279e58de39f06627293f02 Mon Sep 17 00:00:00 2001 From: redsolver Date: Thu, 29 Jul 2021 11:20:33 +0200 Subject: [PATCH 1/2] Added schemas that will be used by the FileSystem DAC --- draft-01/directoryFile.schema.json | 59 +++++++++++++++++++++++++++++ draft-01/directoryIndex.schema.json | 43 +++++++++++++++++++++ draft-01/fileData.schema.json | 48 +++++++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 draft-01/directoryFile.schema.json create mode 100644 draft-01/directoryIndex.schema.json create mode 100644 draft-01/fileData.schema.json diff --git a/draft-01/directoryFile.schema.json b/draft-01/directoryFile.schema.json new file mode 100644 index 0000000..53951b3 --- /dev/null +++ b/draft-01/directoryFile.schema.json @@ -0,0 +1,59 @@ +{ + "$id": "https://skystandards.hns.siasky.net/draft-01/directoryFile.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Metadata of a file, can contain multiple versions", + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Name of this file" + }, + "created": { + "type": "integer", + "description": "Unix timestamp (in milliseconds) when this file was created", + "minimum": 0 + }, + "modified": { + "type": "integer", + "description": "Unix timestamp (in milliseconds) when this file was last modified", + "minimum": 0 + }, + "mimeType": { + "type": "string", + "description": "MIME Type of the file, optional" + }, + "version": { + "type": "integer", + "description": "Current version of the file. When this file was already modified 9 times, this value is 9", + "minimum": 0 + }, + "size": { + "type": "integer", + "description": "Unencrypted size of the file, in bytes", + "minimum": 0 + }, + "file": { + "$ref": "https://skystandards.hns.siasky.net/draft-01/fileData.schema.json", + "description": "The current version of a file" + }, + "history": { + "type": "object", + "patternProperties": { + "^[0-9]+$": { + "$ref": "https://skystandards.hns.siasky.net/draft-01/fileData.schema.json", + "description": "A file version" + } + }, + "description": "Historic versions of a file", + "additionalProperties": false + } + }, + "required": [ + "name", + "created", + "modified", + "version", + "size", + "file" + ] +} \ No newline at end of file diff --git a/draft-01/directoryIndex.schema.json b/draft-01/directoryIndex.schema.json new file mode 100644 index 0000000..c3b320f --- /dev/null +++ b/draft-01/directoryIndex.schema.json @@ -0,0 +1,43 @@ +{ + "$id": "https://skystandards.hns.siasky.net/draft-01/directoryIndex.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Index file of a directory, contains all directories and files in this specific directory", + "type": "object", + "properties": { + "directories": { + "type": "object", + "patternProperties": { + "^.+$": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Name of this directory" + }, + "created": { + "type": "integer", + "description": "Unix timestamp (in milliseconds) when this directory was created", + "minimum": 0 + } + } + } + }, + "additionalProperties": false, + "description": "A subdirectory in this directory" + }, + "files": { + "type": "object", + "patternProperties": { + "^.+$": { + "$ref": "https://skystandards.hns.siasky.net/draft-01/directoryFile.schema.json" + } + }, + "additionalProperties": false, + "description": "A file in this directory" + } + }, + "required": [ + "directories", + "files" + ] +} \ No newline at end of file diff --git a/draft-01/fileData.schema.json b/draft-01/fileData.schema.json new file mode 100644 index 0000000..c699fdf --- /dev/null +++ b/draft-01/fileData.schema.json @@ -0,0 +1,48 @@ +{ + "$id": "https://skystandards.hns.siasky.net/draft-01/fileData.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Specific version of a file. Immutable.", + "type": "object", + "properties": { + "url": { + "type": "string", + "description": "URL where the encrypted file blob can be downloaded, usually a skylink (sia://)" + }, + "key": { + "type": "string", + "description": "The secret key used to encrypt this file, base64Url-encoded" + }, + "encryptionType": { + "type": "string", + "description": "Which algorithm is used to encrypt and decrypt this file", + "examples": [ + "AEAD_XCHACHA20_POLY1305" + ] + }, + "chunkSize": { + "type": "integer", + "description": "maxiumum size of every unencrypted file chunk in bytes", + "exclusiveMinimum": 0, + "examples": [ + 16777216 + ] + }, + "hash": { + "$ref": "https://skystandards.hns.siasky.net/draft-01/hash.schema.json", + "description": "Multihash of the unencrypted file, starts with 1220 for sha256" + }, + "ts": { + "type": "integer", + "description": "Unix timestamp (in milliseconds) when this version was added to the FileSystem DAC", + "minimum": 0 + } + }, + "required": [ + "url", + "key", + "encryptionType", + "chunkSize", + "hash", + "ts" + ] +} \ No newline at end of file From 005e78ee4a3986560d9f77bf7926861b76f39f83 Mon Sep 17 00:00:00 2001 From: redsolver Date: Sun, 8 Aug 2021 11:51:04 +0200 Subject: [PATCH 2/2] Moved the file size from DirectoryFile to FileData, because it is version-specific --- draft-01/directoryFile.schema.json | 6 ------ draft-01/fileData.schema.json | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/draft-01/directoryFile.schema.json b/draft-01/directoryFile.schema.json index 53951b3..614633f 100644 --- a/draft-01/directoryFile.schema.json +++ b/draft-01/directoryFile.schema.json @@ -27,11 +27,6 @@ "description": "Current version of the file. When this file was already modified 9 times, this value is 9", "minimum": 0 }, - "size": { - "type": "integer", - "description": "Unencrypted size of the file, in bytes", - "minimum": 0 - }, "file": { "$ref": "https://skystandards.hns.siasky.net/draft-01/fileData.schema.json", "description": "The current version of a file" @@ -53,7 +48,6 @@ "created", "modified", "version", - "size", "file" ] } \ No newline at end of file diff --git a/draft-01/fileData.schema.json b/draft-01/fileData.schema.json index c699fdf..5bb6dce 100644 --- a/draft-01/fileData.schema.json +++ b/draft-01/fileData.schema.json @@ -19,6 +19,11 @@ "AEAD_XCHACHA20_POLY1305" ] }, + "size": { + "type": "integer", + "description": "Unencrypted size of the file, in bytes", + "minimum": 0 + }, "chunkSize": { "type": "integer", "description": "maxiumum size of every unencrypted file chunk in bytes", @@ -43,6 +48,7 @@ "encryptionType", "chunkSize", "hash", + "size", "ts" ] } \ No newline at end of file