From a7aeaf37fa2e963deb34b145887e234ee3f4ac49 Mon Sep 17 00:00:00 2001 From: Andor Kesselman Date: Wed, 6 Mar 2024 08:58:30 -0800 Subject: [PATCH 1/2] updated schemas and working on protocolsconfigure --- .../authorization-delegated-grant.json | 14 + schemas/json-schemas/authorization-owner.json | 23 ++ ...zation-payload.json => authorization.json} | 12 +- .../interface-methods/events-filter.json | 112 ++++++++ .../events-get.json | 6 +- .../events-query.json} | 30 +- .../interface-methods/events-subscribe.json | 48 ++++ .../interface-methods/messages-get.json | 4 +- .../number-range-filter.json | 43 +++ .../interface-methods/pagination-cursor.json | 19 ++ .../permissions-definitions.json | 41 --- .../interface-methods/permissions-grant.json | 5 +- .../permissions-request.json | 4 +- .../interface-methods/permissions-revoke.json | 4 +- .../interface-methods/protocol-rule-set.json | 61 +++- .../protocols-configure.json | 2 +- .../interface-methods/protocols-query.json | 4 +- .../interface-methods/records-delete.json | 4 +- .../interface-methods/records-filter.json | 106 +++++++ .../interface-methods/records-query.json | 46 +-- .../interface-methods/records-read.json | 10 +- ...ots-create.json => records-subscribe.json} | 15 +- .../records-write-unidentified.json} | 33 ++- .../interface-methods/records-write.json | 269 +----------------- .../json-schemas/jwk-verification-method.json | 5 +- .../json-schemas/messages/messages-get.json | 44 --- .../json-schemas/permissions/definitions.json | 57 ---- .../permissions/permissions-definitions.json | 51 ++++ .../permissions/permissions-grant.json | 69 ----- .../permissions/permissions-request.json | 59 ---- schemas/json-schemas/permissions/scopes.json | 129 +++++++++ .../scopes/records-read-scope.json | 0 schemas/json-schemas/protocol-definition.json | 44 --- schemas/json-schemas/protocol-rule-set.json | 71 ----- .../protocols/protocols-configure.json | 45 --- .../protocols/protocols-query.json | 54 ---- .../json-schemas/records/records-delete.json | 45 --- .../json-schemas/records/records-query.json | 95 ------- .../json-schemas/records/records-read.json | 44 --- .../generic-signature-payload.json | 24 ++ .../records-write-signature-payload.json} | 11 +- spec/spec.md | 269 ++++++++++++++---- 42 files changed, 932 insertions(+), 1099 deletions(-) create mode 100644 schemas/json-schemas/authorization-delegated-grant.json create mode 100644 schemas/json-schemas/authorization-owner.json rename schemas/json-schemas/{authorization-payloads/base-authorization-payload.json => authorization.json} (51%) create mode 100644 schemas/json-schemas/interface-methods/events-filter.json rename schemas/json-schemas/{events => interface-methods}/events-get.json (81%) rename schemas/json-schemas/{hooks/hooks-write.json => interface-methods/events-query.json} (61%) create mode 100644 schemas/json-schemas/interface-methods/events-subscribe.json create mode 100644 schemas/json-schemas/interface-methods/number-range-filter.json create mode 100644 schemas/json-schemas/interface-methods/pagination-cursor.json delete mode 100644 schemas/json-schemas/interface-methods/permissions-definitions.json create mode 100644 schemas/json-schemas/interface-methods/records-filter.json rename schemas/json-schemas/interface-methods/{snapshots-create.json => records-subscribe.json} (68%) rename schemas/json-schemas/{records/records-write.json => interface-methods/records-write-unidentified.json} (89%) delete mode 100644 schemas/json-schemas/messages/messages-get.json delete mode 100644 schemas/json-schemas/permissions/definitions.json create mode 100644 schemas/json-schemas/permissions/permissions-definitions.json delete mode 100644 schemas/json-schemas/permissions/permissions-grant.json delete mode 100644 schemas/json-schemas/permissions/permissions-request.json create mode 100644 schemas/json-schemas/permissions/scopes.json create mode 100644 schemas/json-schemas/permissions/scopes/records-read-scope.json delete mode 100644 schemas/json-schemas/protocol-definition.json delete mode 100644 schemas/json-schemas/protocol-rule-set.json delete mode 100644 schemas/json-schemas/protocols/protocols-configure.json delete mode 100644 schemas/json-schemas/protocols/protocols-query.json delete mode 100644 schemas/json-schemas/records/records-delete.json delete mode 100644 schemas/json-schemas/records/records-query.json delete mode 100644 schemas/json-schemas/records/records-read.json create mode 100644 schemas/json-schemas/signature-payloads/generic-signature-payload.json rename schemas/json-schemas/{authorization-payloads/records-write-authorization-payload.json => signature-payloads/records-write-signature-payload.json} (61%) diff --git a/schemas/json-schemas/authorization-delegated-grant.json b/schemas/json-schemas/authorization-delegated-grant.json new file mode 100644 index 0000000..a1a4487 --- /dev/null +++ b/schemas/json-schemas/authorization-delegated-grant.json @@ -0,0 +1,14 @@ +{ + "$id": "https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "properties": { + "signature": { + "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + }, + "authorDelegatedGrant": { + "$ref": "https://identity.foundation/dwn/json-schemas/permissions-grant.json" + } + } +} \ No newline at end of file diff --git a/schemas/json-schemas/authorization-owner.json b/schemas/json-schemas/authorization-owner.json new file mode 100644 index 0000000..28dc82b --- /dev/null +++ b/schemas/json-schemas/authorization-owner.json @@ -0,0 +1,23 @@ +{ + "$id": "https://identity.foundation/dwn/json-schemas/authorization-owner.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "properties": { + "signature": { + "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + }, + "authorDelegatedGrant": { + "$ref": "https://identity.foundation/dwn/json-schemas/permissions-grant.json" + }, + "ownerSignature": { + "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + } + }, + "description": "`signature` can exist by itself. But if `ownerSignature` is present, then `signature` must also exist", + "dependencies": { + "ownerSignature": [ + "signature" + ] + } +} \ No newline at end of file diff --git a/schemas/json-schemas/authorization-payloads/base-authorization-payload.json b/schemas/json-schemas/authorization.json similarity index 51% rename from schemas/json-schemas/authorization-payloads/base-authorization-payload.json rename to schemas/json-schemas/authorization.json index 3676458..69e9975 100644 --- a/schemas/json-schemas/authorization-payloads/base-authorization-payload.json +++ b/schemas/json-schemas/authorization.json @@ -1,17 +1,11 @@ { + "$id": "https://identity.foundation/dwn/json-schemas/authorization.json", "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/authorization-payloads/base-authorization-payload.json", "type": "object", "additionalProperties": false, - "required": [ - "descriptorCid" - ], "properties": { - "descriptorCid": { - "type": "string" - }, - "permissionsGrantId": { - "type": "string" + "signature": { + "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" } } } \ No newline at end of file diff --git a/schemas/json-schemas/interface-methods/events-filter.json b/schemas/json-schemas/interface-methods/events-filter.json new file mode 100644 index 0000000..7843477 --- /dev/null +++ b/schemas/json-schemas/interface-methods/events-filter.json @@ -0,0 +1,112 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://identity.foundation/dwn/json-schemas/events-filter.json", + "type": "object", + "additionalProperties": false, + "minProperties": 1, + "properties": { + "interface": { + "enum": [ + "Permissions", + "Protocols", + "Records" + ], + "type": "string" + }, + "method":{ + "enum": [ + "Configure", + "Delete", + "Grant", + "Revoke", + "Write" + ], + "type": "string" + }, + "protocol": { + "type": "string" + }, + "protocolPath": { + "type": "string" + }, + "recipient": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" + }, + "contextId": { + "type": "string" + }, + "schema": { + "type": "string" + }, + "recordId": { + "type": "string" + }, + "parentId": { + "type": "string" + }, + "dataFormat": { + "type": "string" + }, + "dataSize": { + "$ref": "https://identity.foundation/dwn/json-schemas/number-range-filter.json" + }, + "dateCreated": { + "type": "object", + "minProperties": 1, + "additionalProperties": false, + "properties": { + "from": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + }, + "to": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + } + } + }, + "datePublished": { + "type": "object", + "minProperties": 1, + "additionalProperties": false, + "properties": { + "from": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + }, + "to": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + } + } + }, + "dateUpdated": { + "type": "object", + "minProperties": 1, + "additionalProperties": false, + "properties": { + "from": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + }, + "to": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + } + } + } + }, + "dependencies": { + "datePublished": { + "oneOf": [ + { + "properties": { + "published": { + "enum": [true] + } + }, + "required": ["published"] + }, + { + "not": { + "required": ["published"] + } + } + ] + } + } +} \ No newline at end of file diff --git a/schemas/json-schemas/events/events-get.json b/schemas/json-schemas/interface-methods/events-get.json similarity index 81% rename from schemas/json-schemas/events/events-get.json rename to schemas/json-schemas/interface-methods/events-get.json index 93429ef..63e013c 100644 --- a/schemas/json-schemas/events/events-get.json +++ b/schemas/json-schemas/interface-methods/events-get.json @@ -9,7 +9,7 @@ ], "properties": { "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization.json" }, "descriptor": { "type": "object", @@ -35,8 +35,8 @@ "messageTimestamp": { "type": "string" }, - "watermark": { - "type": "string" + "cursor": { + "$ref": "https://identity.foundation/dwn/json-schemas/pagination-cursor.json" } } } diff --git a/schemas/json-schemas/hooks/hooks-write.json b/schemas/json-schemas/interface-methods/events-query.json similarity index 61% rename from schemas/json-schemas/hooks/hooks-write.json rename to schemas/json-schemas/interface-methods/events-query.json index ac8e215..bc569c8 100644 --- a/schemas/json-schemas/hooks/hooks-write.json +++ b/schemas/json-schemas/interface-methods/events-query.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/hooks-write.json", + "$id": "https://identity.foundation/dwn/json-schemas/events-query.json", "type": "object", "additionalProperties": false, "required": [ @@ -9,7 +9,7 @@ ], "properties": { "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization.json" }, "descriptor": { "type": "object", @@ -18,37 +18,33 @@ "interface", "method", "messageTimestamp", - "uri", - "filter" + "filters" ], "properties": { "interface": { "enum": [ - "Hooks" + "Events" ], "type": "string" }, "method": { "enum": [ - "Write" + "Query" ], "type": "string" }, "messageTimestamp": { "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" }, - "schema": { - "type": "string" - }, - "filter": { - "type": "object", - "minProperties": 1, - "additionalProperties": false, - "properties": { - "method": { - "type": "string" - } + "filters": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "https://identity.foundation/dwn/json-schemas/events-filter.json" } + }, + "cursor": { + "$ref": "https://identity.foundation/dwn/json-schemas/pagination-cursor.json" } } } diff --git a/schemas/json-schemas/interface-methods/events-subscribe.json b/schemas/json-schemas/interface-methods/events-subscribe.json new file mode 100644 index 0000000..99bbc25 --- /dev/null +++ b/schemas/json-schemas/interface-methods/events-subscribe.json @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://identity.foundation/dwn/json-schemas/events-subscribe.json", + "type": "object", + "additionalProperties": false, + "required": [ + "descriptor", + "authorization" + ], + "properties": { + "authorization": { + "$ref": "https://identity.foundation/dwn/json-schemas/authorization.json" + }, + "descriptor": { + "type": "object", + "additionalProperties": false, + "required": [ + "interface", + "method", + "messageTimestamp", + "filters" + ], + "properties": { + "interface": { + "enum": [ + "Events" + ], + "type": "string" + }, + "method": { + "enum": [ + "Subscribe" + ], + "type": "string" + }, + "messageTimestamp": { + "type": "string" + }, + "filters": { + "type": "array", + "items": { + "$ref": "https://identity.foundation/dwn/json-schemas/events-filter.json" + } + } + } + } + } + } diff --git a/schemas/json-schemas/interface-methods/messages-get.json b/schemas/json-schemas/interface-methods/messages-get.json index 3126ff5..3f0bf98 100644 --- a/schemas/json-schemas/interface-methods/messages-get.json +++ b/schemas/json-schemas/interface-methods/messages-get.json @@ -9,7 +9,7 @@ ], "properties": { "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization.json" }, "descriptor": { "type": "object", @@ -33,7 +33,7 @@ "type": "string" }, "messageTimestamp": { - "type": "string" + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" }, "messageCids": { "type": "array", diff --git a/schemas/json-schemas/interface-methods/number-range-filter.json b/schemas/json-schemas/interface-methods/number-range-filter.json new file mode 100644 index 0000000..3b7d2f5 --- /dev/null +++ b/schemas/json-schemas/interface-methods/number-range-filter.json @@ -0,0 +1,43 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://identity.foundation/dwn/json-schemas/number-range-filter.json", + "type": "object", + "minProperties": 1, + "additionalProperties": false, + "properties": { + "gt": { + "type": "number" + }, + "gte": { + "type": "number" + }, + "lt": { + "type": "number" + }, + "lte": { + "type": "number" + } + }, + "dependencies": { + "gt": { + "not": { + "required": ["gte"] + } + }, + "gte": { + "not": { + "required": ["gt"] + } + }, + "lt": { + "not": { + "required": ["lte"] + } + }, + "lte": { + "not": { + "required": ["lt"] + } + } + } +} \ No newline at end of file diff --git a/schemas/json-schemas/interface-methods/pagination-cursor.json b/schemas/json-schemas/interface-methods/pagination-cursor.json new file mode 100644 index 0000000..0b3ee6c --- /dev/null +++ b/schemas/json-schemas/interface-methods/pagination-cursor.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://identity.foundation/dwn/json-schemas/pagination-cursor.json", + "type": "object", + "minProperties": 1, + "additionalProperties": false, + "required": [ + "messageCid", + "value" + ], + "properties": { + "messageCid": { + "type": "string" + }, + "value": { + "type": [ "string", "number" ] + } + } +} \ No newline at end of file diff --git a/schemas/json-schemas/interface-methods/permissions-definitions.json b/schemas/json-schemas/interface-methods/permissions-definitions.json deleted file mode 100644 index 66f07fc..0000000 --- a/schemas/json-schemas/interface-methods/permissions-definitions.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/permissions/defs.json", - "type": "object", - "definitions": { - "grantedTo": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" - }, - "grantedBy": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" - }, - "grantedFor": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" - }, - "scope": { - "type": "object", - "additionalProperties": false, - "required": [ - "interface", - "method" - ], - "properties": { - "interface": { - "type": "string" - }, - "method": { - "type": "string" - } - } - }, - "conditions": { - "type": "object", - "additionalProperties": false, - "properties": { - "publication": { - "type": "boolean" - } - } - } - } -} \ No newline at end of file diff --git a/schemas/json-schemas/interface-methods/permissions-grant.json b/schemas/json-schemas/interface-methods/permissions-grant.json index 8b75f8d..3b44d0d 100644 --- a/schemas/json-schemas/interface-methods/permissions-grant.json +++ b/schemas/json-schemas/interface-methods/permissions-grant.json @@ -9,7 +9,7 @@ "additionalProperties": false, "properties": { "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization.json" }, "delegationChain": { "description": "the parent grant", @@ -34,6 +34,9 @@ "description": { "type": "string" }, + "delegated": { + "type": "boolean" + }, "grantedTo": { "description": "DID of the grantee", "$ref": "https://identity.foundation/dwn/json-schemas/permissions/defs.json#/definitions/grantedTo" diff --git a/schemas/json-schemas/interface-methods/permissions-request.json b/schemas/json-schemas/interface-methods/permissions-request.json index f1442fa..6b6ec68 100644 --- a/schemas/json-schemas/interface-methods/permissions-request.json +++ b/schemas/json-schemas/interface-methods/permissions-request.json @@ -9,7 +9,7 @@ ], "properties": { "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization.json" }, "descriptor": { "type": "object", @@ -37,7 +37,7 @@ "type": "string" }, "messageTimestamp": { - "type": "string" + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" }, "description": { "type": "string" diff --git a/schemas/json-schemas/interface-methods/permissions-revoke.json b/schemas/json-schemas/interface-methods/permissions-revoke.json index d86ac2f..2b62e5e 100644 --- a/schemas/json-schemas/interface-methods/permissions-revoke.json +++ b/schemas/json-schemas/interface-methods/permissions-revoke.json @@ -9,7 +9,7 @@ "additionalProperties": false, "properties": { "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization.json" }, "descriptor": { "type": "object", @@ -22,7 +22,7 @@ ], "properties": { "messageTimestamp": { - "type": "string" + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" }, "permissionsGrantId": { "type": "string" diff --git a/schemas/json-schemas/interface-methods/protocol-rule-set.json b/schemas/json-schemas/interface-methods/protocol-rule-set.json index f0bb701..9f9c01e 100644 --- a/schemas/json-schemas/interface-methods/protocol-rule-set.json +++ b/schemas/json-schemas/interface-methods/protocol-rule-set.json @@ -4,12 +4,24 @@ "type": "object", "additionalProperties": false, "properties": { + "$encryption": { + "type": "object", + "additionalProperties": false, + "properties": { + "rootKeyId": { + "type": "string" + }, + "publicKeyJwk": { + "$ref": "https://identity.foundation/dwn/json-schemas/public-jwk.json" + } + } + }, "$actions": { "type": "array", "minItems": 1, "items": { "type": "object", - "anyOf": [ + "oneOf": [ { "required": [ "who", @@ -20,12 +32,20 @@ "who": { "type": "string", "enum": [ - "anyone" + "anyone", + "author", + "recipient" ] }, + "of": { + "type": "string" + }, "can": { "type": "string", "enum": [ + "co-delete", + "co-update", + "create", "read", "write" ] @@ -34,25 +54,22 @@ }, { "required": [ - "who", - "of", + "role", "can" ], - "additionalProperties": false, "properties": { - "who": { - "type": "string", - "enum": [ - "author", - "recipient" - ] - }, - "of": { + "role": { + "$comment": "Must be the protocol path of a role record type", "type": "string" }, "can": { "type": "string", "enum": [ + "co-delete", + "co-update", + "create", + "query", + "subscribe", "read", "write" ] @@ -61,6 +78,24 @@ } ] } + }, + "$role": { + "$comment": "When `true`, this turns a record into `role` that may be used within a context/sub-context", + "type": "boolean" + }, + "$size": { + "type": "object", + "additionalProperties": false, + "properties": { + "min": { + "type": "number", + "minimum": 0 + }, + "max": { + "type": "number", + "minimum": 0 + } + } } }, "patternProperties": { diff --git a/schemas/json-schemas/interface-methods/protocols-configure.json b/schemas/json-schemas/interface-methods/protocols-configure.json index 5c99cfc..b852621 100644 --- a/schemas/json-schemas/interface-methods/protocols-configure.json +++ b/schemas/json-schemas/interface-methods/protocols-configure.json @@ -9,7 +9,7 @@ ], "properties": { "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization.json" }, "descriptor": { "type": "object", diff --git a/schemas/json-schemas/interface-methods/protocols-query.json b/schemas/json-schemas/interface-methods/protocols-query.json index f37818c..88bfa11 100644 --- a/schemas/json-schemas/interface-methods/protocols-query.json +++ b/schemas/json-schemas/interface-methods/protocols-query.json @@ -8,7 +8,7 @@ ], "properties": { "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization.json" }, "descriptor": { "type": "object", @@ -32,7 +32,7 @@ "type": "string" }, "messageTimestamp": { - "type": "string" + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" }, "filter": { "type": "object", diff --git a/schemas/json-schemas/interface-methods/records-delete.json b/schemas/json-schemas/interface-methods/records-delete.json index 7f3b48d..6013600 100644 --- a/schemas/json-schemas/interface-methods/records-delete.json +++ b/schemas/json-schemas/interface-methods/records-delete.json @@ -9,7 +9,7 @@ ], "properties": { "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json" }, "descriptor": { "type": "object", @@ -34,7 +34,7 @@ "type": "string" }, "messageTimestamp": { - "type": "string" + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" }, "recordId": { "type": "string" diff --git a/schemas/json-schemas/interface-methods/records-filter.json b/schemas/json-schemas/interface-methods/records-filter.json new file mode 100644 index 0000000..2ab6c0f --- /dev/null +++ b/schemas/json-schemas/interface-methods/records-filter.json @@ -0,0 +1,106 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://identity.foundation/dwn/json-schemas/records-filter.json", + "type": "object", + "minProperties": 1, + "additionalProperties": false, + "properties": { + "protocol": { + "type": "string" + }, + "protocolPath": { + "type": "string" + }, + "author": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" + }, + "attester": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" + }, + "recipient": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" + }, + "contextId": { + "type": "string" + }, + "schema": { + "type": "string" + }, + "recordId": { + "type": "string" + }, + "parentId": { + "type": "string" + }, + "published": { + "type": "boolean" + }, + "dataFormat": { + "type": "string" + }, + "dataSize": { + "$ref": "https://identity.foundation/dwn/json-schemas/number-range-filter.json" + }, + "dataCid": { + "type": "string" + }, + "dateCreated": { + "type": "object", + "minProperties": 1, + "additionalProperties": false, + "properties": { + "from": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + }, + "to": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + } + } + }, + "datePublished": { + "type": "object", + "minProperties": 1, + "additionalProperties": false, + "properties": { + "from": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + }, + "to": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + } + } + }, + "dateUpdated": { + "type": "object", + "minProperties": 1, + "additionalProperties": false, + "properties": { + "from": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + }, + "to": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + } + } + } + }, + "dependencies": { + "datePublished": { + "oneOf": [ + { + "properties": { + "published": { + "enum": [true] + } + }, + "required": ["published"] + }, + { + "not": { + "required": ["published"] + } + } + ] + } + } +} \ No newline at end of file diff --git a/schemas/json-schemas/interface-methods/records-query.json b/schemas/json-schemas/interface-methods/records-query.json index 19cfe68..38b66e4 100644 --- a/schemas/json-schemas/interface-methods/records-query.json +++ b/schemas/json-schemas/interface-methods/records-query.json @@ -8,7 +8,7 @@ ], "properties": { "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json" }, "descriptor": { "type": "object", @@ -36,46 +36,18 @@ "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" }, "filter": { + "$ref": "https://identity.foundation/dwn/json-schemas/records-filter.json" + }, + "pagination": { "type": "object", - "minProperties": 1, "additionalProperties": false, "properties": { - "protocol": { - "type": "string" - }, - "attester": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" - }, - "recipient": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" - }, - "contextId": { - "type": "string" - }, - "schema": { - "type": "string" - }, - "recordId": { - "type": "string" - }, - "parentId": { - "type": "string" - }, - "dataFormat": { - "type": "string" + "limit": { + "type": "number", + "minimum": 1 }, - "dateCreated": { - "type": "object", - "minProperties": 1, - "additionalProperties": false, - "properties": { - "from": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" - }, - "to": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" - } - } + "cursor": { + "$ref": "https://identity.foundation/dwn/json-schemas/pagination-cursor.json" } } }, diff --git a/schemas/json-schemas/interface-methods/records-read.json b/schemas/json-schemas/interface-methods/records-read.json index e31b120..ec8700c 100644 --- a/schemas/json-schemas/interface-methods/records-read.json +++ b/schemas/json-schemas/interface-methods/records-read.json @@ -8,7 +8,7 @@ ], "properties": { "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json" }, "descriptor": { "type": "object", @@ -17,7 +17,7 @@ "interface", "method", "messageTimestamp", - "recordId" + "filter" ], "properties": { "interface": { @@ -33,10 +33,10 @@ "type": "string" }, "messageTimestamp": { - "type": "string" + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" }, - "recordId": { - "type": "string" + "filter": { + "$ref": "https://identity.foundation/dwn/json-schemas/records-filter.json" } } } diff --git a/schemas/json-schemas/interface-methods/snapshots-create.json b/schemas/json-schemas/interface-methods/records-subscribe.json similarity index 68% rename from schemas/json-schemas/interface-methods/snapshots-create.json rename to schemas/json-schemas/interface-methods/records-subscribe.json index 7ebaed7..92c7939 100644 --- a/schemas/json-schemas/interface-methods/snapshots-create.json +++ b/schemas/json-schemas/interface-methods/records-subscribe.json @@ -1,15 +1,14 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/snapshots-create.json", + "$id": "https://identity.foundation/dwn/json-schemas/records-subscribe.json", "type": "object", "additionalProperties": false, "required": [ - "authorization", "descriptor" ], "properties": { "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json" }, "descriptor": { "type": "object", @@ -18,26 +17,26 @@ "interface", "method", "messageTimestamp", - "definitionCid" + "filter" ], "properties": { "interface": { "enum": [ - "Snapshots" + "Records" ], "type": "string" }, "method": { "enum": [ - "Create" + "Subscribe" ], "type": "string" }, "messageTimestamp": { "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" }, - "definitionCid": { - "type": "string" + "filter": { + "$ref": "https://identity.foundation/dwn/json-schemas/records-filter.json" } } } diff --git a/schemas/json-schemas/records/records-write.json b/schemas/json-schemas/interface-methods/records-write-unidentified.json similarity index 89% rename from schemas/json-schemas/records/records-write.json rename to schemas/json-schemas/interface-methods/records-write-unidentified.json index 09eccf2..4bc7333 100644 --- a/schemas/json-schemas/records/records-write.json +++ b/schemas/json-schemas/interface-methods/records-write-unidentified.json @@ -1,25 +1,24 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/records-write.json", + "$id": "https://identity.foundation/dwn/json-schemas/records-write-unidentified.json", "type": "object", "additionalProperties": false, "required": [ - "authorization", - "descriptor", - "recordId" + "descriptor" ], "properties": { "recordId": { "type": "string" }, "contextId": { - "type": "string" + "type": "string", + "pattern": "^[a-zA-Z0-9]+(\/[a-zA-Z0-9]+)*$" }, "attestation": { "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" }, "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" + "$ref": "https://identity.foundation/dwn/json-schemas/authorization-owner.json" }, "encryption": { "type": "object", @@ -39,14 +38,21 @@ "items": { "type": "object", "properties": { + "rootKeyId": { + "type": "string" + }, "derivationScheme": { "type": "string", "enum": [ "dataFormats", - "protocols", + "protocolContext", + "protocolPath", "schemas" ] }, + "derivedPublicKey": { + "$ref": "https://identity.foundation/dwn/json-schemas/public-jwk.json" + }, "algorithm": { "type": "string", "enum": [ @@ -68,6 +74,7 @@ }, "additionalProperties": false, "required": [ + "rootKeyId", "derivationScheme", "algorithm", "encryptedKey", @@ -125,7 +132,7 @@ "dateCreated": { "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" }, - "dateModified": { + "messageTimestamp": { "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" }, "published": { @@ -145,9 +152,14 @@ "dataCid", "dataSize", "dateCreated", - "dateModified", + "messageTimestamp", "dataFormat" ], + "dependencies": { + "parentId": [ + "protocol" + ] + }, "allOf": [ { "$comment": "rule defining `published` and `datePublished` relationship", @@ -212,8 +224,7 @@ "type": "object", "required": [ "protocol", - "protocolPath", - "schema" + "protocolPath" ] } }, diff --git a/schemas/json-schemas/interface-methods/records-write.json b/schemas/json-schemas/interface-methods/records-write.json index adef376..b1cf44b 100644 --- a/schemas/json-schemas/interface-methods/records-write.json +++ b/schemas/json-schemas/interface-methods/records-write.json @@ -1,269 +1,12 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/records-write.json", - "type": "object", - "additionalProperties": false, - "required": [ - "authorization", - "descriptor", - "recordId" - ], - "properties": { - "recordId": { - "type": "string" - }, - "contextId": { - "type": "string" - }, - "attestation": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" - }, - "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" - }, - "encryption": { - "type": "object", - "properties": { - "algorithm": { - "type": "string", - "enum": [ - "A256CTR" - ] - }, - "initializationVector": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/base64url" - }, - "keyEncryption": { - "type": "array", - "minItems": 1, - "items": { - "type": "object", - "properties": { - "rootKeyId": { - "type": "string" - }, - "derivationScheme": { - "type": "string", - "enum": [ - "dataFormats", - "protocols", - "schemas" - ] - }, - "algorithm": { - "type": "string", - "enum": [ - "ECIES-ES256K" - ] - }, - "encryptedKey": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/base64url" - }, - "initializationVector": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/base64url" - }, - "ephemeralPublicKey": { - "$ref": "https://identity.foundation/dwn/json-schemas/public-jwk.json" - }, - "messageAuthenticationCode": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/base64url" - } - }, - "additionalProperties": false, - "required": [ - "rootKeyId", - "derivationScheme", - "algorithm", - "encryptedKey", - "initializationVector", - "ephemeralPublicKey", - "messageAuthenticationCode" - ] - } - } - }, - "additionalProperties": false, - "required": [ - "algorithm", - "initializationVector", - "keyEncryption" - ] - }, - "descriptor": { - "type": "object", - "properties": { - "interface": { - "enum": [ - "Records" - ], - "type": "string" - }, - "method": { - "enum": [ - "Write" - ], - "type": "string" - }, - "recipient": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" - }, - "protocol": { - "type": "string" - }, - "protocolPath": { - "type": "string", - "pattern": "^[a-zA-Z]+(\/[a-zA-Z]+)*$" - }, - "schema": { - "type": "string" - }, - "parentId": { - "type": "string" - }, - "dataCid": { - "type": "string" - }, - "dataSize": { - "type": "number" - }, - "dateCreated": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" - }, - "messageTimestamp": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" - }, - "published": { - "type": "boolean" - }, - "datePublished": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" - }, - "dataFormat": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "interface", - "method", - "dataCid", - "dataSize", - "dateCreated", - "messageTimestamp", - "dataFormat" - ], - "dependencies": { - "parentId": [ - "protocol" - ] - }, - "allOf": [ - { - "$comment": "rule defining `published` and `datePublished` relationship", - "anyOf": [ - { - "properties": { - "published": { - "type": "boolean", - "enum": [ - true - ] - } - }, - "required": [ - "published", - "datePublished" - ] - }, - { - "properties": { - "published": { - "type": "boolean", - "enum": [ - false - ] - } - }, - "not": { - "required": [ - "datePublished" - ] - } - }, - { - "allOf": [ - { - "not": { - "required": [ - "published" - ] - } - }, - { - "not": { - "required": [ - "datePublished" - ] - } - } - ] - } - ] - } - ] - } - }, - "$comment": "rule defining `protocol` and `contextId` relationship", - "anyOf": [ + "$ref": "https://identity.foundation/dwn/json-schemas/records-write-unidentified.json", + "allOf": [ { - "properties": { - "descriptor": { - "type": "object", - "required": [ - "protocol", - "protocolPath", - "schema" - ] - } - }, + "type": "object", "required": [ - "contextId" - ] - }, - { - "allOf": [ - { - "not": { - "required": [ - "contextId" - ] - } - }, - { - "properties": { - "descriptor": { - "type": "object", - "not": { - "required": [ - "protocol" - ] - } - } - } - }, - { - "properties": { - "descriptor": { - "type": "object", - "not": { - "required": [ - "protocolPath" - ] - } - } - } - } + "recordId", + "authorization" ] } ] -} \ No newline at end of file +} diff --git a/schemas/json-schemas/jwk-verification-method.json b/schemas/json-schemas/jwk-verification-method.json index d18353b..25d41c9 100644 --- a/schemas/json-schemas/jwk-verification-method.json +++ b/schemas/json-schemas/jwk-verification-method.json @@ -14,7 +14,10 @@ "type": "string" }, "type": { - "const": "JsonWebKey2020" + "enum": [ + "JsonWebKey", + "JsonWebKey2020" + ] }, "controller": { "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" diff --git a/schemas/json-schemas/messages/messages-get.json b/schemas/json-schemas/messages/messages-get.json deleted file mode 100644 index 017b913..0000000 --- a/schemas/json-schemas/messages/messages-get.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/messages-get.json", - "type": "object", - "additionalProperties": false, - "required": [ - "authorization", - "descriptor" - ], - "properties": { - "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" - }, - "descriptor": { - "type": "object", - "additionalProperties": false, - "required": [ - "interface", - "method" - ], - "properties": { - "interface": { - "enum": [ - "Messages" - ], - "type": "string" - }, - "method": { - "enum": [ - "Get" - ], - "type": "string" - }, - "messageCids": { - "type": "array", - "items": { - "type": "string" - }, - "minItems": 1 - } - } - } - } -} \ No newline at end of file diff --git a/schemas/json-schemas/permissions/definitions.json b/schemas/json-schemas/permissions/definitions.json deleted file mode 100644 index 0c52aaf..0000000 --- a/schemas/json-schemas/permissions/definitions.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/permissions/defs.json", - "type": "object", - "definitions": { - "conditions": { - "type": "object", - "additionalProperties": false, - "properties": { - "attestation": { - "enum": [ - "optional", - "required" - ], - "type": "string" - }, - "delegation": { - "type": "boolean" - }, - "encryption": { - "enum": [ - "optional", - "required" - ], - "type": "string" - }, - "publication": { - "type": "boolean" - }, - "sharedAccess": { - "type": "boolean" - } - } - }, - "grantedTo": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" - }, - "grantedBy": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" - }, - "scope": { - "properties": { - "method": { - "type": "string" - }, - "objectId": { - "type": "string" - }, - "schema": { - "type": "string" - } - }, - "type": "object", - "additionalProperties": false - } - } -} \ No newline at end of file diff --git a/schemas/json-schemas/permissions/permissions-definitions.json b/schemas/json-schemas/permissions/permissions-definitions.json new file mode 100644 index 0000000..4e19ef0 --- /dev/null +++ b/schemas/json-schemas/permissions/permissions-definitions.json @@ -0,0 +1,51 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://identity.foundation/dwn/json-schemas/permissions/defs.json", + "type": "object", + "definitions": { + "grantedTo": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" + }, + "grantedBy": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" + }, + "grantedFor": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" + }, + "scope": { + "oneOf": [ + { + "$ref": "https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/definitions/protocols-query-scope" + }, + { + "$ref": "https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/definitions/records-read-scope" + }, + { + "$ref": "https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/definitions/records-delete-scope" + }, + { + "$ref": "https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/definitions/records-write-scope" + }, + { + "$ref": "https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/definitions/records-query-scope" + }, + { + "$ref": "https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/definitions/records-subscribe-scope" + } + ] + }, + "conditions": { + "type": "object", + "additionalProperties": false, + "properties": { + "publication": { + "enum": [ + "Required", + "Prohibited" + ], + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/schemas/json-schemas/permissions/permissions-grant.json b/schemas/json-schemas/permissions/permissions-grant.json deleted file mode 100644 index a29cb64..0000000 --- a/schemas/json-schemas/permissions/permissions-grant.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/permissions-grant.json", - "type": "object", - "required": [ - "authorization", - "descriptor" - ], - "additionalProperties": false, - "properties": { - "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" - }, - "delegationChain": { - "description": "the parent grant", - "$ref": "#" - }, - "descriptor": { - "type": "object", - "additionalProperties": false, - "required": [ - "interface", - "method", - "dateCreated" - ], - "properties": { - "dateCreated": { - "type": "string" - }, - "conditions": { - "$ref": "https://identity.foundation/dwn/json-schemas/permissions/defs.json#/definitions/conditions" - }, - "delegatedFrom": { - "description": "CID of the parent grant", - "type": "string" - }, - "description": { - "type": "string" - }, - "grantedTo": { - "description": "DID of the grantee", - "$ref": "https://identity.foundation/dwn/json-schemas/permissions/defs.json#/definitions/grantedTo" - }, - "grantedBy": { - "description": "DID of the grantor", - "$ref": "https://identity.foundation/dwn/json-schemas/permissions/defs.json#/definitions/grantedBy" - }, - "interface": { - "enum": [ - "Permissions" - ], - "type": "string" - }, - "method": { - "enum": [ - "Grant" - ], - "type": "string" - }, - "scope": { - "$ref": "https://identity.foundation/dwn/json-schemas/permissions/defs.json#/definitions/scope" - }, - "objectId": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/uuid" - } - } - } - } -} \ No newline at end of file diff --git a/schemas/json-schemas/permissions/permissions-request.json b/schemas/json-schemas/permissions/permissions-request.json deleted file mode 100644 index 1afb45b..0000000 --- a/schemas/json-schemas/permissions/permissions-request.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/permissions-request.json", - "additionalProperties": false, - "type": "object", - "required": [ - "authorization", - "descriptor" - ], - "properties": { - "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" - }, - "descriptor": { - "type": "object", - "additionalProperties": false, - "required": [ - "interface", - "method", - "dateCreated" - ], - "properties": { - "dateCreated": { - "type": "string" - }, - "conditions": { - "$ref": "https://identity.foundation/dwn/json-schemas/permissions/defs.json#/definitions/conditions" - }, - "description": { - "type": "string" - }, - "grantedTo": { - "$ref": "https://identity.foundation/dwn/json-schemas/permissions/defs.json#/definitions/grantedTo" - }, - "grantedBy": { - "$ref": "https://identity.foundation/dwn/json-schemas/permissions/defs.json#/definitions/grantedBy" - }, - "interface": { - "enum": [ - "Permissions" - ], - "type": "string" - }, - "method": { - "enum": [ - "Request" - ], - "type": "string" - }, - "scope": { - "$ref": "https://identity.foundation/dwn/json-schemas/permissions/defs.json#/definitions/scope" - }, - "objectId": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/uuid" - } - } - } - } -} \ No newline at end of file diff --git a/schemas/json-schemas/permissions/scopes.json b/schemas/json-schemas/permissions/scopes.json new file mode 100644 index 0000000..af83b84 --- /dev/null +++ b/schemas/json-schemas/permissions/scopes.json @@ -0,0 +1,129 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://identity.foundation/dwn/json-schemas/permissions/scopes.json", + "type": "object", + "definitions": { + "protocols-query-scope": { + "type": "object", + "properties": { + "interface": { + "const": "Protocols" + }, + "method": { + "const": "Query" + } + } + }, + "records-delete-scope": { + "type": "object", + "required": [ + "interface", + "method" + ], + "properties": { + "interface": { + "const": "Records" + }, + "method": { + "const": "Delete" + }, + "protocol": { + "type": "string" + }, + "schema": { + "type": "string" + } + } + }, + "records-read-scope": { + "type": "object", + "required": [ + "interface", + "method" + ], + "properties": { + "interface": { + "const": "Records" + }, + "method": { + "const": "Read" + }, + "schema": { + "type": "string" + }, + "protocol": { + "type": "string" + }, + "contextId": { + "type": "string" + }, + "protocolPath": { + "type": "string" + } + } + }, + "records-write-scope": { + "type": "object", + "required": [ + "interface", + "method" + ], + "properties": { + "interface": { + "const": "Records" + }, + "method": { + "const": "Write" + }, + "schema": { + "type": "string" + }, + "protocol": { + "type": "string" + }, + "contextId": { + "type": "string" + }, + "protocolPath": { + "type": "string" + } + } + }, + "records-query-scope": { + "type": "object", + "required": [ + "interface", + "method" + ], + "properties": { + "interface": { + "const": "Records" + }, + "method": { + "const": "Query" + }, + "protocol": { + "type": "string" + } + } + }, + "records-subscribe-scope": { + "type": "object", + "required": [ + "interface", + "method" + ], + "properties": { + "interface": { + "const": "Records" + }, + "method": { + "const": "Subscribe" + }, + "protocol": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/schemas/json-schemas/permissions/scopes/records-read-scope.json b/schemas/json-schemas/permissions/scopes/records-read-scope.json new file mode 100644 index 0000000..e69de29 diff --git a/schemas/json-schemas/protocol-definition.json b/schemas/json-schemas/protocol-definition.json deleted file mode 100644 index 4909b83..0000000 --- a/schemas/json-schemas/protocol-definition.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "$id": "https://identity.foundation/dwn/json-schemas/protocol-definition.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "required": [ - "types", - "structure" - ], - "properties": { - "protocol": { - "type": "string" - }, - "types": { - "type": "object", - "patternProperties": { - ".*": { - "type": "object", - "additionalProperties": false, - "properties": { - "schema": { - "type": "string" - }, - "dataFormats": { - "type": "array", - "minItems": 1, - "items": { - "type": "string" - } - } - } - } - } - }, - "structure": { - "type": "object", - "patternProperties": { - ".*": { - "$ref": "https://identity.foundation/dwn/json-schemas/protocol-rule-set.json" - } - } - } - } -} diff --git a/schemas/json-schemas/protocol-rule-set.json b/schemas/json-schemas/protocol-rule-set.json deleted file mode 100644 index f0bb701..0000000 --- a/schemas/json-schemas/protocol-rule-set.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "$id": "https://identity.foundation/dwn/json-schemas/protocol-rule-set.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "properties": { - "$actions": { - "type": "array", - "minItems": 1, - "items": { - "type": "object", - "anyOf": [ - { - "required": [ - "who", - "can" - ], - "additionalProperties": false, - "properties": { - "who": { - "type": "string", - "enum": [ - "anyone" - ] - }, - "can": { - "type": "string", - "enum": [ - "read", - "write" - ] - } - } - }, - { - "required": [ - "who", - "of", - "can" - ], - "additionalProperties": false, - "properties": { - "who": { - "type": "string", - "enum": [ - "author", - "recipient" - ] - }, - "of": { - "type": "string" - }, - "can": { - "type": "string", - "enum": [ - "read", - "write" - ] - } - } - } - ] - } - } - }, - "patternProperties": { - "^[^$].*": { - "$ref": "https://identity.foundation/dwn/json-schemas/protocol-rule-set.json" - } - } -} \ No newline at end of file diff --git a/schemas/json-schemas/protocols/protocols-configure.json b/schemas/json-schemas/protocols/protocols-configure.json deleted file mode 100644 index a063602..0000000 --- a/schemas/json-schemas/protocols/protocols-configure.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/protocols-configure.json", - "type": "object", - "additionalProperties": false, - "required": [ - "authorization", - "descriptor" - ], - "properties": { - "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" - }, - "descriptor": { - "type": "object", - "additionalProperties": false, - "required": [ - "interface", - "method", - "dateCreated", - "definition" - ], - "properties": { - "interface": { - "enum": [ - "Protocols" - ], - "type": "string" - }, - "method": { - "enum": [ - "Configure" - ], - "type": "string" - }, - "dateCreated": { - "type": "string" - }, - "definition": { - "$ref": "https://identity.foundation/dwn/json-schemas/protocol-definition.json" - } - } - } - } -} \ No newline at end of file diff --git a/schemas/json-schemas/protocols/protocols-query.json b/schemas/json-schemas/protocols/protocols-query.json deleted file mode 100644 index d16880f..0000000 --- a/schemas/json-schemas/protocols/protocols-query.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/protocols-query.json", - "type": "object", - "additionalProperties": false, - "required": [ - "authorization", - "descriptor" - ], - "properties": { - "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" - }, - "descriptor": { - "type": "object", - "additionalProperties": false, - "required": [ - "interface", - "method", - "dateCreated" - ], - "properties": { - "interface": { - "enum": [ - "Protocols" - ], - "type": "string" - }, - "method": { - "enum": [ - "Query" - ], - "type": "string" - }, - "dateCreated": { - "type": "string" - }, - "filter": { - "type": "object", - "minProperties": 1, - "additionalProperties": false, - "properties": { - "protocol": { - "type": "string" - }, - "recipient": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" - } - } - } - } - } - } -} \ No newline at end of file diff --git a/schemas/json-schemas/records/records-delete.json b/schemas/json-schemas/records/records-delete.json deleted file mode 100644 index 5618410..0000000 --- a/schemas/json-schemas/records/records-delete.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/records-delete.json", - "type": "object", - "additionalProperties": false, - "required": [ - "authorization", - "descriptor" - ], - "properties": { - "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" - }, - "descriptor": { - "type": "object", - "additionalProperties": false, - "required": [ - "interface", - "method", - "dateModified", - "recordId" - ], - "properties": { - "interface": { - "enum": [ - "Records" - ], - "type": "string" - }, - "method": { - "enum": [ - "Delete" - ], - "type": "string" - }, - "dateModified": { - "type": "string" - }, - "recordId": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/schemas/json-schemas/records/records-query.json b/schemas/json-schemas/records/records-query.json deleted file mode 100644 index 09c5b58..0000000 --- a/schemas/json-schemas/records/records-query.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/records-query.json", - "type": "object", - "additionalProperties": false, - "required": [ - "authorization", - "descriptor" - ], - "properties": { - "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" - }, - "descriptor": { - "type": "object", - "additionalProperties": false, - "required": [ - "interface", - "method", - "dateCreated", - "filter" - ], - "properties": { - "interface": { - "enum": [ - "Records" - ], - "type": "string" - }, - "method": { - "enum": [ - "Query" - ], - "type": "string" - }, - "dateCreated": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" - }, - "filter": { - "type": "object", - "minProperties": 1, - "additionalProperties": false, - "properties": { - "protocol": { - "type": "string" - }, - "attester": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" - }, - "recipient": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did" - }, - "contextId": { - "type": "string" - }, - "schema": { - "type": "string" - }, - "recordId": { - "type": "string" - }, - "parentId": { - "type": "string" - }, - "dataFormat": { - "type": "string" - }, - "dateCreated": { - "type": "object", - "minProperties": 1, - "additionalProperties": false, - "properties": { - "from": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" - }, - "to": { - "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" - } - } - } - } - }, - "dateSort": { - "enum": [ - "createdAscending", - "createdDescending", - "publishedAscending", - "publishedDescending" - ], - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/schemas/json-schemas/records/records-read.json b/schemas/json-schemas/records/records-read.json deleted file mode 100644 index fee1c51..0000000 --- a/schemas/json-schemas/records/records-read.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/records-read.json", - "type": "object", - "additionalProperties": false, - "required": [ - "descriptor" - ], - "properties": { - "authorization": { - "$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json" - }, - "descriptor": { - "type": "object", - "additionalProperties": false, - "required": [ - "interface", - "method", - "date", - "recordId" - ], - "properties": { - "interface": { - "enum": [ - "Records" - ], - "type": "string" - }, - "method": { - "enum": [ - "Read" - ], - "type": "string" - }, - "date": { - "type": "string" - }, - "recordId": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/schemas/json-schemas/signature-payloads/generic-signature-payload.json b/schemas/json-schemas/signature-payloads/generic-signature-payload.json new file mode 100644 index 0000000..0e6d5d1 --- /dev/null +++ b/schemas/json-schemas/signature-payloads/generic-signature-payload.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://identity.foundation/dwn/json-schemas/signature-payloads/generic-signature-payload.json", + "type": "object", + "additionalProperties": false, + "required": [ + "descriptorCid" + ], + "properties": { + "descriptorCid": { + "type": "string" + }, + "delegatedGrantId": { + "type": "string" + }, + "permissionsGrantId": { + "type": "string" + }, + "protocolRole": { + "$comment": "Used in the Records interface to authorize role-authorized actions for protocol records", + "type": "string" + } + } +} \ No newline at end of file diff --git a/schemas/json-schemas/authorization-payloads/records-write-authorization-payload.json b/schemas/json-schemas/signature-payloads/records-write-signature-payload.json similarity index 61% rename from schemas/json-schemas/authorization-payloads/records-write-authorization-payload.json rename to schemas/json-schemas/signature-payloads/records-write-signature-payload.json index 670d806..1cb3387 100644 --- a/schemas/json-schemas/authorization-payloads/records-write-authorization-payload.json +++ b/schemas/json-schemas/signature-payloads/records-write-signature-payload.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://identity.foundation/dwn/json-schemas/authorization-payloads/records-write-authorization-payload.json", + "$id": "https://identity.foundation/dwn/json-schemas/signature-payloads/records-write-signature-payload.json", "type": "object", "additionalProperties": false, "required": [ @@ -22,6 +22,15 @@ }, "encryptionCid": { "type": "string" + }, + "delegatedGrantId": { + "type": "string" + }, + "permissionsGrantId": { + "type": "string" + }, + "protocolRole": { + "type": "string" } } } \ No newline at end of file diff --git a/spec/spec.md b/spec/spec.md index 7920cab..2aaf1b3 100644 --- a/spec/spec.md +++ b/spec/spec.md @@ -1072,61 +1072,82 @@ Protocol Definition objects are declarative rules within `ProtocolConfigure` mes ```json { - "interface": "Protocols", - "method": "Configure", - "definition": { - "protocol": "https://decentralized-social-example.org/protocol/", - "published": true, - "types": { - "post": { - "schema": "https://decentralized-social-example.org/schemas/post", - "dataFormat": ["application/json"], - }, - "reply": { - "schema": "https://decentralized-social-example.org/schemas/reply", - "dataFormat": ["application/json"], - }, - "image": { - "dataFormat": ["image/jpeg", "image/png", "image/gif"], - } - }, - "structure": { - "post": { - "$actions": [{ - "who": "anyone", - "can": "read", - }], - "reply": { - "$actions":[{ - "who": "anyone", - "can": "write", - }], - "image": { - "$actions": [{ - "who": "anyone", - "can": "read", - },{ - "who": "author", - "of": "reply", - "can": "write", - }] - } - }, - "image": { - "$actions":[{ - "who": "anyone", - "can": "read", - }, { - "who": "author", - "of": "post", - "can": "write", - }] + "descriptor": { + "interface": "Protocols", + "method": "Configure", + "definition": { + "protocol": "https://decentralized-social-example.org/protocol/", + "published": true, + "types": { + "post": { + "schema": "https://decentralized-social-example.org/schemas/post", + "dataFormat": [ + "application/json" + ] + }, + "reply": { + "schema": "https://decentralized-social-example.org/schemas/reply", + "dataFormat": [ + "application/json" + ] + }, + "image": { + "dataFormat": [ + "image/jpeg", + "image/png", + "image/gif" + ] + } + }, + "structure": { + "post": { + "$actions": [ + { + "who": "anyone", + "can": "read" + } + ], + "reply": { + "$actions": [ + { + "who": "anyone", + "can": "write" + } + ], + "image": { + "$actions": [ + { + "who": "anyone", + "can": "read" + }, + { + "who": "author", + "of": "reply", + "can": "write" + } + ] + } + }, + "image": { + "$actions": [ + { + "who": "anyone", + "can": "read" + }, + { + "who": "author", + "of": "post", + "can": "write" + } + ] + } + } + } } - } } - } } ``` + - The _Protocols Definition_ object ****MUST**** contain a `protocol` property, and its value ****Must**** be a URI that denotes the Protocol the configuration pertains to. - The _Protocols Definition_ ****MUST**** contain a `published` property, and its value ****Must**** be a boolean indicating the `ProtocolConfiguration`'s publication state. - The _Protocols Definition_ object ****MUST**** contain a `types` property, and its value ****MUST**** be an object composed as follows: @@ -1150,6 +1171,152 @@ Protocol Definition objects are declarative rules within `ProtocolConfigure` mes ADD PROTOCOL DEFINITION SPEC TEXT ::: + + + +
+ +::: Get a single object by its ID reference: + +```json + +{ + "authorization": , + "descriptor": { + "interface": "Protocols", + "method": "Configure", + "definition": { + "protocol": "https://decentralized-social-example.org/protocol/", + "published": true, + "types": { + "post": { + "schema": "https://decentralized-social-example.org/schemas/post", + "dataFormat": [ + "application/json" + ] + }, + "reply": { + "schema": "https://decentralized-social-example.org/schemas/reply", + "dataFormat": [ + "application/json" + ] + }, + "image": { + "dataFormat": [ + "image/jpeg", + "image/png", + "image/gif" + ] + } + }, + "structure": { + "post": { + "$actions": [ + { + "who": "anyone", + "can": "read" + } + ], + "reply": { + "$actions": [ + { + "who": "anyone", + "can": "write" + } + ], + "image": { + "$actions": [ + { + "who": "anyone", + "can": "read" + }, + { + "who": "author", + "of": "reply", + "can": "write" + } + ] + } + }, + "image": { + "$actions": [ + { + "who": "anyone", + "can": "read" + }, + { + "who": "author", + "of": "post", + "can": "write" + } + ] + } + } + } + } + } +} +``` +
+ +
+ +::: Protocols Configure JSON Schema + +```json +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://identity.foundation/dwn/json-schemas/protocols-configure.json", + "type": "object", + "additionalProperties": false, + "required": [ + "authorization", + "descriptor" + ], + "properties": { + "authorization": { + "$ref": "https://identity.foundation/dwn/json-schemas/authorization.json" + }, + "descriptor": { + "type": "object", + "additionalProperties": false, + "required": [ + "interface", + "method", + "messageTimestamp", + "definition" + ], + "properties": { + "interface": { + "enum": [ + "Protocols" + ], + "type": "string" + }, + "method": { + "enum": [ + "Configure" + ], + "type": "string" + }, + "messageTimestamp": { + "$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time" + }, + "definition": { + "$ref": "https://identity.foundation/dwn/json-schemas/protocol-definition.json" + } + } + } + } +} +``` +
+
+ + ##### Processing Instructions When processing a `ProtocolsConfigure` message, a conforming implementation ****MUST**** perform the following steps: From 12b57544312dcecc34e8ed0af93def4dfe06ee81 Mon Sep 17 00:00:00 2001 From: Andor Kesselman Date: Wed, 6 Mar 2024 09:08:04 -0800 Subject: [PATCH 2/2] added protocols language section --- spec/spec.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spec/spec.md b/spec/spec.md index 2aaf1b3..f48af1f 100644 --- a/spec/spec.md +++ b/spec/spec.md @@ -1166,10 +1166,7 @@ Protocol Definition objects are declarative rules within `ProtocolConfigure` mes - The object ****MUST**** contain a `can` property and it ****MUST**** have a value of either `read` or `write` - The object ****MAY**** contain a `of` property and it ****MUST**** have a string value that references one of the `types` - -::: todo -ADD PROTOCOL DEFINITION SPEC TEXT -::: +For details on the DWN Protocol language see [here](#dweb-protocol-language)