-
Notifications
You must be signed in to change notification settings - Fork 79
update records write #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andorsk
wants to merge
15
commits into
decentralized-identity:main
Choose a base branch
from
andorsk:ask/records-write
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
update records write #257
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ecff360
records write. needs some work
andorsk a31adff
updated records write to include additional properties
andorsk 961f670
Update spec/spec.md
andorsk 042b073
Update spec/spec.md
andorsk 7eb654c
Update spec/spec.md
andorsk b2320ba
Update spec/spec.md
andorsk e8d9dc9
Update spec/spec.md
andorsk ecf4658
Update spec/spec.md
andorsk e7a5d9b
Update spec/spec.md
andorsk 2b03331
Update spec/spec.md
andorsk c28d0cb
Update spec/spec.md
andorsk fe18cd3
Update spec/spec.md
andorsk d66358d
Update spec/spec.md
andorsk 3f1f963
Update spec/spec.md
andorsk 3295cb4
Update spec/spec.md
andorsk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -835,22 +835,41 @@ Get all objects of a given schema type: | |
|
|
||
| #### `RecordsWrite` | ||
|
|
||
| `RecordsWrite` messages are JSON objects that include general [Message Descriptor](#message-descriptors) properties and the following additional properties, which ****must**** be composed as follows: | ||
| `RecordsWrite` messages are JSON objects that include general [Message Descriptor](#message-descriptors) properties and the following additional properties, which ****MUST**** be composed as follows: | ||
|
|
||
| - The message object ****MUST**** contain a `recordId` property, and its value ****MUST**** be the `recordId` of the logical record the entry corresponds with. If the message is the initial entry for a new record, the value ****MUST**** be set to the resulting string from the [_Record ID Generation Process_](#recordid-generation). | ||
| - If the message object is attached to a Protocol, and its value ****MUST**** be a [_Computed Context ID_](#computed-context-ids). If the message is not attached to a Protocol, it ****MUST NOT**** contain a `contextId` property. | ||
| - The message object ****MUST**** contain a `recordId` property, and its value ****MUST**** be the `recordId` of the logical record with which the entry corresponds. If the message is the initial entry for a new record, the value ****MUST**** be set to the string resulting from the [_Record ID Generation Process_](#recordid-generation). | ||
| - The object ****MAY**** contain a `contextId` property. If present, its value ****MUST**** be the deterministic ID for a contextually linked set of objects. | ||
| - The object ****MAY**** contain an `attestation` property. If present, its value ****MUST**** be a `string` representing the signing conditions detailed below. If the property is not present, evaluators ****MUST**** treat it as if its value was set to `optional`. | ||
| - If the message object is attached to a Protocol, the value of its `contextId` property ****MUST**** be a [_Computed Context ID_](#computed-context-ids). If the message is not attached to a Protocol, it ****MUST NOT**** contain a `contextId` property. | ||
| - The message object ****MUST**** contain an `authorization` property, which ****MUST**** be a JSON object as defined by the [Message Authorization](#message-authorization) | ||
| section of this specification, with the requirement that the `kid` and `signature` ****MUST**** match the DID of the requesting party. | ||
| - The object ****MAY**** contain an `encryption` property. If present, its value ****MUST**** be a string that matches one of the [Supported Encryption Formats](#supported-encryption-format), indicating the encryption format with which the data is encrypted. The absence of this property indicates the data is not encrypted. | ||
| - The message object ****MUST**** contain a `descriptor` property, and its value ****MUST**** be a JSON object composed as follows: | ||
| - The object ****MUST**** contain an `interface` property, and its value ****MUST**** be the string `Records`. | ||
| - The object ****MUST**** contain a `method` property, and its value ****MUST**** be the string `Write`. | ||
| - The object ****MUST**** include a `parentId` property if the currently active entry for the record is a `RecordsDelete` or a `CollectionWrite` that has a declared a Commit Strategy. The object ****MUST NOT**** contain a `parentId` under any other circumstance. If present, the value of the `parentId` property ****MUST**** be the stringified [Version 1 CID](https://docs.ipfs.io/concepts/content-addressing/#identifier-formats) of the [DAG CBOR](https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-cbor.md) encoded `descriptor` object of the previous `RecordsWrite` or `RecordsDelete` entry the message is intending to overwrite. | ||
| - The object ****MAY**** contain a `protocol` property, and its value ****Must**** be a URI that denotes the Protocol an object is a part of. | ||
| - If the object contains a `protocol` property the object ****MUST**** also contain a `protocolVersion` property, and its value ****Must**** be a [SemVer](https://semver.org/) string that denotes the version of the Protocol the object is a part of. | ||
| - The object ****MAY**** contain a `schema` property, and if present its value ****Must**** be a URI string that indicates the schema of the associated data and ****MUST**** be treated as an immutable value for the lifetime of the logical record. | ||
| - The object ****MAY**** contain a `commitStrategy` property, and if present its value ****Must**** be a string from the table of registered [Commit Strategies](#commit-strategies). | ||
| - The object ****MAY**** contain a `published` property, and if present its value ****Must**** be a boolean indicating the record's publication state. A value of `true` indicates the record has been published for public queries and consumption without requiring authorization. A value of `false` or the absence of the property indicates the record ****MUST NOT**** be served in response to public queries that lack proper authorization. | ||
| - The object ****MAY**** contain an `encryption` property, and if present its value ****Must**** be a string that matches one of the [Supported Encryption Formats](#supported-encryption-format), indicating the encryption format with which the data is encrypted. The absence of this property indicates the data is not encrypted. | ||
| - The object ****MAY**** include a `parentId` property if the currently active entry for the record is a `RecordsDelete` or a `CollectionWrite` that has a declared Commit Strategy. The object ****MUST NOT**** contain a `parentId` under any other circumstance. If present, the value of the `parentId` property ****MUST**** be the stringified [Version 1 CID](https://docs.ipfs.io/concepts/content-addressing/#identifier-formats) of the [DAG CBOR](https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-cbor.md) encoded `descriptor` object of the previous `RecordsWrite` or `RecordsDelete` entry the message is intended to overwrite. | ||
| - The object ****MAY**** contain a `protocol` property. If present, its value ****MUST**** be a URI that denotes the Protocol of which the object is a part. | ||
| - If the object contains a `protocol` property, the object ****MUST**** also contain a `protocolVersion` property. If present, its value ****MUST**** be a [SemVer](https://semver.org/) string that denotes the version of the Protocol of which the object is a part. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we currently do not use a However there is a |
||
| - The object ****MAY**** contain a `schema` property. If present, its value ****MUST**** be a URI string that indicates the schema of the associated data, and ****MUST**** be treated as an immutable value for the lifetime of the logical record. | ||
| - The object ****MAY**** contain a `commitStrategy` property. If present, its value ****MUST**** be a string from the table of registered [Commit Strategies](#commit-strategies). | ||
| - The object ****MAY**** contain a `published` property. If present, its value ****MUST**** be a boolean indicating the record's publication state. A value of `true` indicates the record has been published for public queries and consumption without requiring authorization. A value of `false` or the absence of the property indicates the record ****MUST NOT**** be served in response to public queries that lack proper authorization. | ||
| - The object ****MUST**** contain a `dateCreated` property, and its value ****MUST**** be an [[spec:rfc3339]] ISO 8601 timestamp that ****MUST**** be set and interpreted as the time the `RecordsWrite` was created by the DID owner or another permitted party. | ||
| - The object ****MAY**** contain a `datePublished` property, and its value ****MUST**** be an [[spec:rfc3339]] ISO 8601 timestamp that ****MUST**** be set and interpreted as the time the `RecordsWrite` was published by the DID owner or another permitted party. | ||
| - The object ****MUST**** contain a `dataFormats` property, and its value ****MUST**** be an array of strings that indicate the format of the data in accordance with its media type designation. The most common format is JSON, which is indicated by setting the value of the `dataFormats` property to `['application/json']`. | ||
| - The object ****MUST**** contain a `messageTimestamp` property, which ****MUST**** be of type `string`, with a value that ****MUST**** be an [[spec:rfc3339]] ISO 8601 timestamp that ****MUST**** be set and interpreted as the time the `RecordsWrite` record itself was created by the requester. | ||
| - The object ****MUST**** contain a `dataCid` property, and its value ****MUST**** be the stringified [Version 1 CID](https://docs.ipfs.io/concepts/content-addressing/#identifier-formats) of the [DAG PB](https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-pb.md) encoded data. | ||
| - The object ****MUST**** contain a `dataSize` property, and its value must be equal to the number of bytes in the record. | ||
|
|
||
| ``` | ||
| <tab-panels selected-index="0"> | ||
| <nav> | ||
| <button type="button">Simple Records Write Example</button> | ||
| <button type="button">Sample JSON Schema For Records Write</button> | ||
| </nav> | ||
|
|
||
| <section> | ||
|
|
||
| ::: Sample Records Write | ||
|
|
||
| ```json | ||
| { // Message | ||
|
|
@@ -869,6 +888,287 @@ Get all objects of a given schema type: | |
| } | ||
| } | ||
| ``` | ||
| </section> | ||
|
|
||
| <section> | ||
|
|
||
| ::: example Records Write - JSON Schema | ||
|
|
||
| ```json | ||
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "$id": "https://identity.foundation/dwn/json-schemas/records-write-unidentified.json", | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "descriptor" | ||
| ], | ||
| "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", | ||
| "protocolContext", | ||
| "protocolPath", | ||
| "schemas" | ||
| ] | ||
| }, | ||
| "derivedPublicKey": { | ||
| "$ref": "https://identity.foundation/dwn/json-schemas/public-jwk.json" | ||
| }, | ||
| "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": [ | ||
| { | ||
| "properties": { | ||
| "descriptor": { | ||
| "type": "object", | ||
| "required": [ | ||
| "protocol", | ||
| "protocolPath", | ||
| "schema" | ||
| ] | ||
| } | ||
| }, | ||
| "required": [ | ||
| "contextId" | ||
| ] | ||
| }, | ||
| { | ||
| "allOf": [ | ||
| { | ||
| "not": { | ||
| "required": [ | ||
| "contextId" | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "properties": { | ||
| "descriptor": { | ||
| "type": "object", | ||
| "not": { | ||
| "required": [ | ||
| "protocol" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "properties": { | ||
| "descriptor": { | ||
| "type": "object", | ||
| "not": { | ||
| "required": [ | ||
| "protocolPath" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| </section> | ||
| </tab-panels> | ||
|
|
||
| #### `RecordsCommit` | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be folded into the rules described on line 841 or into bullet points under a single
contextIdline.