Skip to content

Commit 7752d05

Browse files
committed
records write. needs some work
1 parent 494af0b commit 7752d05

File tree

1 file changed

+307
-0
lines changed

1 file changed

+307
-0
lines changed

spec/spec.md

Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,313 @@ Get all objects of a given schema type:
870870
}
871871
```
872872

873+
<tab-panels selected-index="0">
874+
<nav>
875+
<button type="button">Simple Records Write Example</button>
876+
<button type="button">Sample JSON Schema For Records Write</button>
877+
</nav>
878+
879+
<section>
880+
881+
::: Sample Records Write
882+
883+
```json
884+
{ // Message
885+
"recordId": "b65b7r8n7bewv5w6eb7r8n7t78yj7hbevsv567n8r77bv65b7e6vwvd67b6",
886+
"descriptor": { // Message Descriptor
887+
"parentId": CID(PREVIOUS_DESCRIPTOR),
888+
"dataCid": CID(data),
889+
"dateCreated": 123456789,
890+
"published": true,
891+
"encryption": "jwe",
892+
"interface": "Records",
893+
"method": "Write",
894+
"schema": "https://schema.org/SocialMediaPosting",
895+
"commitStrategy": "json-merge",
896+
"dataFormat": DATA_FORMAT
897+
}
898+
}
899+
```
900+
</section>
901+
902+
<section>
903+
904+
::: example Records Write - JSON Schema
905+
906+
```json
907+
{
908+
"$schema": "http://json-schema.org/draft-07/schema#",
909+
"$id": "https://identity.foundation/dwn/json-schemas/records-write.json",
910+
"type": "object",
911+
"additionalProperties": false,
912+
"required": [
913+
"authorization",
914+
"descriptor",
915+
"recordId"
916+
],
917+
"properties": {
918+
"recordId": {
919+
"type": "string"
920+
},
921+
"contextId": {
922+
"type": "string"
923+
},
924+
"attestation": {
925+
"$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json"
926+
},
927+
"authorization": {
928+
"$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json"
929+
},
930+
"encryption": {
931+
"type": "object",
932+
"properties": {
933+
"algorithm": {
934+
"type": "string",
935+
"enum": [
936+
"A256CTR"
937+
]
938+
},
939+
"initializationVector": {
940+
"$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/base64url"
941+
},
942+
"keyEncryption": {
943+
"type": "array",
944+
"minItems": 1,
945+
"items": {
946+
"type": "object",
947+
"properties": {
948+
"rootKeyId": {
949+
"type": "string"
950+
},
951+
"derivationScheme": {
952+
"type": "string",
953+
"enum": [
954+
"dataFormats",
955+
"protocols",
956+
"schemas"
957+
]
958+
},
959+
"algorithm": {
960+
"type": "string",
961+
"enum": [
962+
"ECIES-ES256K"
963+
]
964+
},
965+
"encryptedKey": {
966+
"$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/base64url"
967+
},
968+
"initializationVector": {
969+
"$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/base64url"
970+
},
971+
"ephemeralPublicKey": {
972+
"$ref": "https://identity.foundation/dwn/json-schemas/public-jwk.json"
973+
},
974+
"messageAuthenticationCode": {
975+
"$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/base64url"
976+
}
977+
},
978+
"additionalProperties": false,
979+
"required": [
980+
"rootKeyId",
981+
"derivationScheme",
982+
"algorithm",
983+
"encryptedKey",
984+
"initializationVector",
985+
"ephemeralPublicKey",
986+
"messageAuthenticationCode"
987+
]
988+
}
989+
}
990+
},
991+
"additionalProperties": false,
992+
"required": [
993+
"algorithm",
994+
"initializationVector",
995+
"keyEncryption"
996+
]
997+
},
998+
"descriptor": {
999+
"type": "object",
1000+
"properties": {
1001+
"interface": {
1002+
"enum": [
1003+
"Records"
1004+
],
1005+
"type": "string"
1006+
},
1007+
"method": {
1008+
"enum": [
1009+
"Write"
1010+
],
1011+
"type": "string"
1012+
},
1013+
"recipient": {
1014+
"$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/did"
1015+
},
1016+
"protocol": {
1017+
"type": "string"
1018+
},
1019+
"protocolPath": {
1020+
"type": "string",
1021+
"pattern": "^[a-zA-Z]+(\/[a-zA-Z]+)*$"
1022+
},
1023+
"schema": {
1024+
"type": "string"
1025+
},
1026+
"parentId": {
1027+
"type": "string"
1028+
},
1029+
"dataCid": {
1030+
"type": "string"
1031+
},
1032+
"dataSize": {
1033+
"type": "number"
1034+
},
1035+
"dateCreated": {
1036+
"$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time"
1037+
},
1038+
"messageTimestamp": {
1039+
"$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time"
1040+
},
1041+
"published": {
1042+
"type": "boolean"
1043+
},
1044+
"datePublished": {
1045+
"$ref": "https://identity.foundation/dwn/json-schemas/defs.json#/definitions/date-time"
1046+
},
1047+
"dataFormat": {
1048+
"type": "string"
1049+
}
1050+
},
1051+
"additionalProperties": false,
1052+
"required": [
1053+
"interface",
1054+
"method",
1055+
"dataCid",
1056+
"dataSize",
1057+
"dateCreated",
1058+
"messageTimestamp",
1059+
"dataFormat"
1060+
],
1061+
"dependencies": {
1062+
"parentId": [
1063+
"protocol"
1064+
]
1065+
},
1066+
"allOf": [
1067+
{
1068+
"$comment": "rule defining `published` and `datePublished` relationship",
1069+
"anyOf": [
1070+
{
1071+
"properties": {
1072+
"published": {
1073+
"type": "boolean",
1074+
"enum": [
1075+
true
1076+
]
1077+
}
1078+
},
1079+
"required": [
1080+
"published",
1081+
"datePublished"
1082+
]
1083+
},
1084+
{
1085+
"properties": {
1086+
"published": {
1087+
"type": "boolean",
1088+
"enum": [
1089+
false
1090+
]
1091+
}
1092+
},
1093+
"not": {
1094+
"required": [
1095+
"datePublished"
1096+
]
1097+
}
1098+
},
1099+
{
1100+
"allOf": [
1101+
{
1102+
"not": {
1103+
"required": [
1104+
"published"
1105+
]
1106+
}
1107+
},
1108+
{
1109+
"not": {
1110+
"required": [
1111+
"datePublished"
1112+
]
1113+
}
1114+
}
1115+
]
1116+
}
1117+
]
1118+
}
1119+
]
1120+
}
1121+
},
1122+
"$comment": "rule defining `protocol` and `contextId` relationship",
1123+
"anyOf": [
1124+
{
1125+
"properties": {
1126+
"descriptor": {
1127+
"type": "object",
1128+
"required": [
1129+
"protocol",
1130+
"protocolPath",
1131+
"schema"
1132+
]
1133+
}
1134+
},
1135+
"required": [
1136+
"contextId"
1137+
]
1138+
},
1139+
{
1140+
"allOf": [
1141+
{
1142+
"not": {
1143+
"required": [
1144+
"contextId"
1145+
]
1146+
}
1147+
},
1148+
{
1149+
"properties": {
1150+
"descriptor": {
1151+
"type": "object",
1152+
"not": {
1153+
"required": [
1154+
"protocol"
1155+
]
1156+
}
1157+
}
1158+
}
1159+
},
1160+
{
1161+
"properties": {
1162+
"descriptor": {
1163+
"type": "object",
1164+
"not": {
1165+
"required": [
1166+
"protocolPath"
1167+
]
1168+
}
1169+
}
1170+
}
1171+
}
1172+
]
1173+
}
1174+
]
1175+
}
1176+
```
1177+
</section>
1178+
</tab-panels>
1179+
8731180
#### `RecordsCommit`
8741181

8751182
`RecordsCommit` messages are JSON objects that include general [Message Descriptor](#message-descriptors) properties and the following additional properties, which ****must**** be composed as follows:

0 commit comments

Comments
 (0)