@enbox/dwn-sdk-js 0.4.4 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/dist/browser.mjs +15 -15
  2. package/dist/browser.mjs.map +4 -4
  3. package/dist/esm/generated/precompiled-validators.js +5406 -2391
  4. package/dist/esm/generated/precompiled-validators.js.map +1 -1
  5. package/dist/esm/json-schemas/definitions.json +18 -0
  6. package/dist/esm/src/core/constants.js +3 -3
  7. package/dist/esm/src/core/constants.js.map +1 -1
  8. package/dist/esm/src/core/dwn-error.js +29 -1
  9. package/dist/esm/src/core/dwn-error.js.map +1 -1
  10. package/dist/esm/src/core/messages-grant-authorization.js +20 -0
  11. package/dist/esm/src/core/messages-grant-authorization.js.map +1 -1
  12. package/dist/esm/src/core/protocol-authorization-validation.js +80 -3
  13. package/dist/esm/src/core/protocol-authorization-validation.js.map +1 -1
  14. package/dist/esm/src/core/recording-validation-state-reader.js +5 -0
  15. package/dist/esm/src/core/recording-validation-state-reader.js.map +1 -1
  16. package/dist/esm/src/core/replication-apply.js +163 -7
  17. package/dist/esm/src/core/replication-apply.js.map +1 -1
  18. package/dist/esm/src/core/validation-state-reader.js +20 -0
  19. package/dist/esm/src/core/validation-state-reader.js.map +1 -1
  20. package/dist/esm/src/dwn.js +19 -2
  21. package/dist/esm/src/dwn.js.map +1 -1
  22. package/dist/esm/src/handlers/messages-query.js +3 -5
  23. package/dist/esm/src/handlers/messages-query.js.map +1 -1
  24. package/dist/esm/src/handlers/protocols-configure.js +10 -4
  25. package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
  26. package/dist/esm/src/handlers/records-write.js +1 -1
  27. package/dist/esm/src/handlers/records-write.js.map +1 -1
  28. package/dist/esm/src/index.js +2 -1
  29. package/dist/esm/src/index.js.map +1 -1
  30. package/dist/esm/src/interfaces/protocols-configure.js +23 -10
  31. package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
  32. package/dist/esm/src/interfaces/records-write-signing.js +2 -8
  33. package/dist/esm/src/interfaces/records-write-signing.js.map +1 -1
  34. package/dist/esm/src/interfaces/records-write.js +43 -65
  35. package/dist/esm/src/interfaces/records-write.js.map +1 -1
  36. package/dist/esm/src/protocols/encryption.js +411 -0
  37. package/dist/esm/src/protocols/encryption.js.map +1 -0
  38. package/dist/esm/src/protocols/permission-grant.js +0 -5
  39. package/dist/esm/src/protocols/permission-grant.js.map +1 -1
  40. package/dist/esm/src/types/message-types.js.map +1 -1
  41. package/dist/esm/src/types/permission-types.js.map +1 -1
  42. package/dist/esm/src/types/protocols-types.js.map +1 -1
  43. package/dist/esm/src/utils/encryption.js +156 -188
  44. package/dist/esm/src/utils/encryption.js.map +1 -1
  45. package/dist/esm/src/utils/hd-key.js +0 -1
  46. package/dist/esm/src/utils/hd-key.js.map +1 -1
  47. package/dist/esm/src/utils/permission-scope.js +9 -6
  48. package/dist/esm/src/utils/permission-scope.js.map +1 -1
  49. package/dist/esm/src/utils/protocols.js +12 -9
  50. package/dist/esm/src/utils/protocols.js.map +1 -1
  51. package/dist/esm/src/utils/records.js +54 -56
  52. package/dist/esm/src/utils/records.js.map +1 -1
  53. package/dist/esm/src/utils/replication.js +27 -4
  54. package/dist/esm/src/utils/replication.js.map +1 -1
  55. package/dist/esm/tests/core/replication-apply.spec.js +141 -1
  56. package/dist/esm/tests/core/replication-apply.spec.js.map +1 -1
  57. package/dist/esm/tests/core/replication-replay-property.spec.js +1 -0
  58. package/dist/esm/tests/core/replication-replay-property.spec.js.map +1 -1
  59. package/dist/esm/tests/core/validation-read-closure.spec.js +111 -0
  60. package/dist/esm/tests/core/validation-read-closure.spec.js.map +1 -1
  61. package/dist/esm/tests/core/validation-state-reader.spec.js +89 -0
  62. package/dist/esm/tests/core/validation-state-reader.spec.js.map +1 -1
  63. package/dist/esm/tests/features/protocol-composition.spec.js +30 -31
  64. package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -1
  65. package/dist/esm/tests/fuzz/encryption.fuzz.spec.js +29 -121
  66. package/dist/esm/tests/fuzz/encryption.fuzz.spec.js.map +1 -1
  67. package/dist/esm/tests/handlers/messages-query.spec.js +71 -3
  68. package/dist/esm/tests/handlers/messages-query.spec.js.map +1 -1
  69. package/dist/esm/tests/handlers/messages-read.spec.js +2 -2
  70. package/dist/esm/tests/handlers/messages-read.spec.js.map +1 -1
  71. package/dist/esm/tests/handlers/records-read.spec.js +9 -135
  72. package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
  73. package/dist/esm/tests/handlers/records-write.spec.js +279 -19
  74. package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
  75. package/dist/esm/tests/interfaces/protocols-configure.spec.js +17 -22
  76. package/dist/esm/tests/interfaces/protocols-configure.spec.js.map +1 -1
  77. package/dist/esm/tests/interfaces/records-write.spec.js +170 -150
  78. package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -1
  79. package/dist/esm/tests/protocols/encryption.spec.js +914 -0
  80. package/dist/esm/tests/protocols/encryption.spec.js.map +1 -0
  81. package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +100 -100
  82. package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
  83. package/dist/esm/tests/store/message-store-level.spec.js +20 -2
  84. package/dist/esm/tests/store/message-store-level.spec.js.map +1 -1
  85. package/dist/esm/tests/utils/encryption-callbacks.spec.js +88 -125
  86. package/dist/esm/tests/utils/encryption-callbacks.spec.js.map +1 -1
  87. package/dist/esm/tests/utils/encryption.spec.js +121 -271
  88. package/dist/esm/tests/utils/encryption.spec.js.map +1 -1
  89. package/dist/esm/tests/utils/permission-scope.spec.js +5 -1
  90. package/dist/esm/tests/utils/permission-scope.spec.js.map +1 -1
  91. package/dist/esm/tests/utils/records.spec.js +15 -5
  92. package/dist/esm/tests/utils/records.spec.js.map +1 -1
  93. package/dist/esm/tests/utils/test-data-generator.js +7 -44
  94. package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
  95. package/dist/esm/tests/validation/json-schemas/encryption/audience-key.spec.js +40 -0
  96. package/dist/esm/tests/validation/json-schemas/encryption/audience-key.spec.js.map +1 -0
  97. package/dist/esm/tests/validation/json-schemas/encryption/grant-key.spec.js +72 -0
  98. package/dist/esm/tests/validation/json-schemas/encryption/grant-key.spec.js.map +1 -0
  99. package/dist/types/generated/precompiled-validators.d.ts +140 -92
  100. package/dist/types/generated/precompiled-validators.d.ts.map +1 -1
  101. package/dist/types/src/core/constants.d.ts +2 -2
  102. package/dist/types/src/core/constants.d.ts.map +1 -1
  103. package/dist/types/src/core/core-protocol.d.ts +1 -1
  104. package/dist/types/src/core/core-protocol.d.ts.map +1 -1
  105. package/dist/types/src/core/dwn-error.d.ts +29 -1
  106. package/dist/types/src/core/dwn-error.d.ts.map +1 -1
  107. package/dist/types/src/core/messages-grant-authorization.d.ts +2 -0
  108. package/dist/types/src/core/messages-grant-authorization.d.ts.map +1 -1
  109. package/dist/types/src/core/protocol-authorization-validation.d.ts +2 -2
  110. package/dist/types/src/core/protocol-authorization-validation.d.ts.map +1 -1
  111. package/dist/types/src/core/recording-validation-state-reader.d.ts +9 -0
  112. package/dist/types/src/core/recording-validation-state-reader.d.ts.map +1 -1
  113. package/dist/types/src/core/replication-apply.d.ts +4 -3
  114. package/dist/types/src/core/replication-apply.d.ts.map +1 -1
  115. package/dist/types/src/core/validation-state-reader.d.ts +9 -0
  116. package/dist/types/src/core/validation-state-reader.d.ts.map +1 -1
  117. package/dist/types/src/dwn.d.ts +1 -0
  118. package/dist/types/src/dwn.d.ts.map +1 -1
  119. package/dist/types/src/handlers/messages-query.d.ts.map +1 -1
  120. package/dist/types/src/handlers/protocols-configure.d.ts.map +1 -1
  121. package/dist/types/src/index.d.ts +6 -5
  122. package/dist/types/src/index.d.ts.map +1 -1
  123. package/dist/types/src/interfaces/protocols-configure.d.ts +1 -1
  124. package/dist/types/src/interfaces/protocols-configure.d.ts.map +1 -1
  125. package/dist/types/src/interfaces/records-write-signing.d.ts +4 -8
  126. package/dist/types/src/interfaces/records-write-signing.d.ts.map +1 -1
  127. package/dist/types/src/interfaces/records-write.d.ts +10 -26
  128. package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
  129. package/dist/types/src/protocols/encryption.d.ts +43 -0
  130. package/dist/types/src/protocols/encryption.d.ts.map +1 -0
  131. package/dist/types/src/protocols/permission-grant.d.ts +0 -7
  132. package/dist/types/src/protocols/permission-grant.d.ts.map +1 -1
  133. package/dist/types/src/types/encryption-types.d.ts +5 -38
  134. package/dist/types/src/types/encryption-types.d.ts.map +1 -1
  135. package/dist/types/src/types/message-types.d.ts +0 -13
  136. package/dist/types/src/types/message-types.d.ts.map +1 -1
  137. package/dist/types/src/types/permission-types.d.ts +0 -9
  138. package/dist/types/src/types/permission-types.d.ts.map +1 -1
  139. package/dist/types/src/types/protocols-types.d.ts +9 -14
  140. package/dist/types/src/types/protocols-types.d.ts.map +1 -1
  141. package/dist/types/src/types/records-types.d.ts +3 -3
  142. package/dist/types/src/types/records-types.d.ts.map +1 -1
  143. package/dist/types/src/types/validation-state-reader.d.ts +12 -0
  144. package/dist/types/src/types/validation-state-reader.d.ts.map +1 -1
  145. package/dist/types/src/utils/encryption.d.ts +61 -145
  146. package/dist/types/src/utils/encryption.d.ts.map +1 -1
  147. package/dist/types/src/utils/hd-key.d.ts +1 -1
  148. package/dist/types/src/utils/hd-key.d.ts.map +1 -1
  149. package/dist/types/src/utils/permission-scope.d.ts +4 -3
  150. package/dist/types/src/utils/permission-scope.d.ts.map +1 -1
  151. package/dist/types/src/utils/protocols.d.ts +3 -5
  152. package/dist/types/src/utils/protocols.d.ts.map +1 -1
  153. package/dist/types/src/utils/records.d.ts +5 -13
  154. package/dist/types/src/utils/records.d.ts.map +1 -1
  155. package/dist/types/src/utils/replication.d.ts +3 -0
  156. package/dist/types/src/utils/replication.d.ts.map +1 -1
  157. package/dist/types/tests/features/protocol-composition.spec.d.ts.map +1 -1
  158. package/dist/types/tests/handlers/messages-query.spec.d.ts.map +1 -1
  159. package/dist/types/tests/handlers/records-read.spec.d.ts.map +1 -1
  160. package/dist/types/tests/handlers/records-write.spec.d.ts.map +1 -1
  161. package/dist/types/tests/protocols/encryption.spec.d.ts +2 -0
  162. package/dist/types/tests/protocols/encryption.spec.d.ts.map +1 -0
  163. package/dist/types/tests/scenarios/end-to-end-tests.spec.d.ts.map +1 -1
  164. package/dist/types/tests/utils/test-data-generator.d.ts +0 -5
  165. package/dist/types/tests/utils/test-data-generator.d.ts.map +1 -1
  166. package/dist/types/tests/validation/json-schemas/encryption/audience-key.spec.d.ts +2 -0
  167. package/dist/types/tests/validation/json-schemas/encryption/audience-key.spec.d.ts.map +1 -0
  168. package/dist/types/tests/validation/json-schemas/encryption/grant-key.spec.d.ts +2 -0
  169. package/dist/types/tests/validation/json-schemas/encryption/grant-key.spec.d.ts.map +1 -0
  170. package/package.json +3 -3
  171. package/src/core/constants.ts +3 -3
  172. package/src/core/core-protocol.ts +1 -1
  173. package/src/core/dwn-error.ts +29 -1
  174. package/src/core/messages-grant-authorization.ts +27 -0
  175. package/src/core/protocol-authorization-validation.ts +145 -6
  176. package/src/core/recording-validation-state-reader.ts +13 -0
  177. package/src/core/replication-apply.ts +222 -8
  178. package/src/core/validation-state-reader.ts +30 -0
  179. package/src/dwn.ts +24 -2
  180. package/src/handlers/messages-query.ts +6 -5
  181. package/src/handlers/protocols-configure.ts +19 -3
  182. package/src/handlers/records-write.ts +1 -1
  183. package/src/index.ts +15 -5
  184. package/src/interfaces/protocols-configure.ts +39 -12
  185. package/src/interfaces/records-write-signing.ts +5 -12
  186. package/src/interfaces/records-write.ts +75 -92
  187. package/src/protocols/encryption.ts +649 -0
  188. package/src/protocols/permission-grant.ts +0 -6
  189. package/src/types/encryption-types.ts +9 -38
  190. package/src/types/message-types.ts +0 -13
  191. package/src/types/permission-types.ts +0 -10
  192. package/src/types/protocols-types.ts +9 -16
  193. package/src/types/records-types.ts +3 -3
  194. package/src/types/validation-state-reader.ts +13 -0
  195. package/src/utils/encryption.ts +258 -280
  196. package/src/utils/hd-key.ts +1 -1
  197. package/src/utils/permission-scope.ts +10 -6
  198. package/src/utils/protocols.ts +16 -15
  199. package/src/utils/records.ts +86 -71
  200. package/src/utils/replication.ts +30 -4
  201. package/dist/esm/tests/vectors/protocol-definitions/chat.json +0 -70
@@ -15,9 +15,9 @@ export type ProtocolScope = {
15
15
  *
16
16
  * Matching fails closed for invalid combinations: `protocolPath` and
17
17
  * `contextId` are mutually exclusive, and either field requires `protocol`.
18
- * `protocol` and `protocolPath` match by exact equality. `contextId` scopes
19
- * match a context subtree: the target context must equal the scoped context or
20
- * begin with the scoped context followed by `/`.
18
+ * `protocol` matches by exact equality. `protocolPath` and `contextId` scopes
19
+ * match subtrees: the target value must equal the scoped value or begin with the
20
+ * scoped value followed by `/`.
21
21
  */
22
22
  export declare class PermissionScopeMatcher {
23
23
  /**
@@ -25,5 +25,6 @@ export declare class PermissionScopeMatcher {
25
25
  */
26
26
  static matches(scope: ProtocolScope, target: ProtocolScope): boolean;
27
27
  private static matchesContextId;
28
+ private static matchesSubtree;
28
29
  }
29
30
  //# sourceMappingURL=permission-scope.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"permission-scope.d.ts","sourceRoot":"","sources":["../../../../src/utils/permission-scope.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,qBAAa,sBAAsB;IACjC;;OAEG;WACW,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO;IAwB3E,OAAO,CAAC,MAAM,CAAC,gBAAgB;CAIhC"}
1
+ {"version":3,"file":"permission-scope.d.ts","sourceRoot":"","sources":["../../../../src/utils/permission-scope.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,qBAAa,sBAAsB;IACjC;;OAEG;WACW,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO;IAwB3E,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAI/B,OAAO,CAAC,MAAM,CAAC,cAAc;CAI9B"}
@@ -41,11 +41,10 @@ export declare function getRuleSetAtPath(protocolPath: string, structure: {
41
41
  */
42
42
  export declare class Protocols {
43
43
  /**
44
- * Derives public encryptions keys and inject it in the `$encryption` property for each protocol path segment of the given Protocol definition,
45
- * then returns the final encryption-enabled protocol definition.
44
+ * Derives public encryption keys and injects them in `$keyAgreement`.
46
45
  * NOTE: The original definition passed in is unmodified.
47
46
  *
48
- * `$ref` nodes (cross-protocol attachment points) are skipped during `$encryption` injection
47
+ * `$ref` nodes (cross-protocol attachment points) are skipped during `$keyAgreement` injection
49
48
  * because their records belong to the referenced protocol, whose own encryption keys govern them.
50
49
  * Children of `$ref` nodes are still processed because they belong to the composing protocol.
51
50
  *
@@ -54,8 +53,7 @@ export declare class Protocols {
54
53
  */
55
54
  static deriveAndInjectPublicEncryptionKeys(protocolDefinition: ProtocolDefinition, keyDeriver: EncryptionKeyDeriver): Promise<ProtocolDefinition>;
56
55
  /**
57
- * Overload 2 (raw-key, existing): Takes rootKeyId and raw PrivateKeyJwk directly.
58
- * Preserved for backward compatibility with tests and non-KMS callers.
56
+ * Overload 2 (raw-key): Takes rootKeyId and raw PrivateKeyJwk directly.
59
57
  */
60
58
  static deriveAndInjectPublicEncryptionKeys(protocolDefinition: ProtocolDefinition, rootKeyId: string, privateJwk: PrivateKeyJwk): Promise<ProtocolDefinition>;
61
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"protocols.d.ts","sourceRoot":"","sources":["../../../../src/utils/protocols.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAKvF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAU/E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,GAAG,eAAe,GAAG,SAAS,CAcjI;AAED;;GAEG;AACH,qBAAa,SAAS;IACpB;;;;;;;;;;;OAWG;WACiB,mCAAmC,CACrD,kBAAkB,EAAE,kBAAkB,EACtC,UAAU,EAAE,oBAAoB,GAC/B,OAAO,CAAC,kBAAkB,CAAC;IAE9B;;;OAGG;WACiB,mCAAmC,CACrD,kBAAkB,EAAE,kBAAkB,EACtC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,aAAa,GACxB,OAAO,CAAC,kBAAkB,CAAC;CAkF/B"}
1
+ {"version":3,"file":"protocols.d.ts","sourceRoot":"","sources":["../../../../src/utils/protocols.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAKvF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAU/E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,GAAG,eAAe,GAAG,SAAS,CAcjI;AAED;;GAEG;AACH,qBAAa,SAAS;IACpB;;;;;;;;;;OAUG;WACiB,mCAAmC,CACrD,kBAAkB,EAAE,kBAAkB,EACtC,UAAU,EAAE,oBAAoB,GAC/B,OAAO,CAAC,kBAAkB,CAAC;IAE9B;;OAEG;WACiB,mCAAmC,CACrD,kBAAkB,EAAE,kBAAkB,EACtC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,aAAa,GACxB,OAAO,CAAC,kBAAkB,CAAC;CAqF/B"}
@@ -5,6 +5,7 @@ import type { GenericMessage, GenericSignaturePayload, MessageSort } from '../ty
5
5
  import type { RecordsCountMessage, RecordsDeleteMessage, RecordsFilter, RecordsQueryMessage, RecordsReadMessage, RecordsSubscribeMessage, RecordsWriteDescriptor, RecordsWriteMessage, RecordsWriteTags, RecordsWriteTagsFilter } from '../types/records-types.js';
6
6
  import { DateSort } from '../types/records-types.js';
7
7
  import { DwnErrorCode } from '../core/dwn-error.js';
8
+ import { ROLE_AUDIENCE_DERIVATION_SCHEME } from './encryption.js';
8
9
  import { KeyDerivationScheme } from './hd-key.js';
9
10
  /**
10
11
  * Class containing useful utilities related to the Records interface.
@@ -26,7 +27,7 @@ export declare class Records {
26
27
  * Decrypts the encrypted data in a message reply.
27
28
  *
28
29
  * Overload 1 (callback-based): Accepts a KeyDecrypter that performs
29
- * HKDF derivation + ECDH-ES key agreement + AES Key Unwrap internally.
30
+ * X25519-HKDF key agreement + AES Key Unwrap internally.
30
31
  */
31
32
  static decrypt(recordsWrite: RecordsWriteMessage, keyDecrypter: KeyDecrypter, cipherStream: ReadableStream<Uint8Array>): Promise<ReadableStream<Uint8Array>>;
32
33
  /**
@@ -34,10 +35,12 @@ export declare class Records {
34
35
  * @param ancestorPrivateKey Any ancestor private key in the key derivation path.
35
36
  */
36
37
  static decrypt(recordsWrite: RecordsWriteMessage, ancestorPrivateKey: DerivedPrivateJwk, cipherStream: ReadableStream<Uint8Array>): Promise<ReadableStream<Uint8Array>>;
38
+ private static findMatchingKeyEncryption;
39
+ private static validateEncryptedDataIntegrity;
37
40
  /**
38
41
  * Constructs full key derivation path using the specified scheme.
39
42
  */
40
- static constructKeyDerivationPath(keyDerivationScheme: KeyDerivationScheme, recordsWriteMessage: RecordsWriteMessage): string[];
43
+ static constructKeyDerivationPath(keyDerivationScheme: KeyDerivationScheme | typeof ROLE_AUDIENCE_DERIVATION_SCHEME, recordsWriteMessage: RecordsWriteMessage): string[];
41
44
  /**
42
45
  * Constructs the full key derivation path using `protocolPath` scheme.
43
46
  *
@@ -47,17 +50,6 @@ export declare class Records {
47
50
  * its children (composing protocol) use different protocol URIs and thus different key trees.
48
51
  */
49
52
  static constructKeyDerivationPathUsingProtocolPathScheme(descriptor: RecordsWriteDescriptor): string[];
50
- /**
51
- * Constructs the full key derivation path using `protocolContext` scheme.
52
- *
53
- * NOTE on protocol composition: When a context tree spans two protocols via `$ref` composition,
54
- * the root `contextId` segment (the `$ref` parent record's ID) is shared across both protocols.
55
- * This means ProtocolContext-encrypted records from the composing protocol and the referenced
56
- * protocol derive the same context key. This is by design — it enables multi-party access within
57
- * a shared context (e.g., thread participants can decrypt messages from both the threads protocol
58
- * and composing protocols that attach to those threads).
59
- */
60
- static constructKeyDerivationPathUsingProtocolContextScheme(contextId: string): string[];
61
53
  /**
62
54
  * Derives a descendant private key given an ancestor private key and the full absolute derivation path.
63
55
  * Uses X25519 keys for encryption key derivation.
@@ -1 +1 @@
1
- {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../../src/utils/records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACtG,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,aAAa,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnQ,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAUrD,OAAO,EAAY,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAS,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGzD;;GAEG;AACH,qBAAa,OAAO;IAElB;;OAEG;WACW,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,IAAI,mBAAmB;IAQrF;;OAEG;WACiB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,EA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AAE,aAAa,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM;IA0D/E;;;;;;OAMG;WACiB,0CAA0C,CAC5D,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,GAAG,mBAAmB,GAAG,mBAAmB,GAAG,oBAAoB,GAAG,uBAAuB,EAC9I,sBAAsB,EAAE,uBAAuB,GAAG,SAAS,EAC3D,qBAAqB,CAAC,EAAE,uBAAuB,GAAG,SAAS,GAC1D,OAAO,CAAC,IAAI,CAAC;IAwFhB;;;;;;OAMG;WACW,eAAe,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,WAAW;IAmB/D;;OAEG;WACW,uBAAuB,CAAC,gBAAgB,EAAE,uBAAuB,GAAG,OAAO;IAIzF;;OAEG;WACW,8BAA8B,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO;IAK5E;;OAEG;WACW,gCAAgC,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO;IAQ9E;;;;;;;;;;OAUG;WACiB,iCAAiC,CACnD,mBAAmB,EAAE,oBAAoB,EACzC,qBAAqB,EAAE,cAAc,GACpC,OAAO,CAAC,OAAO,CAAC;IAenB;;;;;;OAMG;IACH,MAAM,CAAC,qCAAqC,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAQ/F;;;;;;OAMG;IACH,MAAM,CAAC,kCAAkC,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;CAO1F"}
@@ -7,11 +7,14 @@ export declare class Replication {
7
7
  static readonly globalDomain = "";
8
8
  static protocolDomain(protocolUri: string): string;
9
9
  static permissionDomain(protocolUri: string): string;
10
+ static encryptionDomain(protocolUri: string): string;
11
+ static taggedCoreProtocolDomains(protocolUri: string, protocolsInScope?: ReadonlySet<string>): string[];
10
12
  static deriveStreamId(tenant: string): Promise<string>;
11
13
  static computeFingerprintScopes(message: GenericMessage, indexes: KeyValues): string[];
12
14
  static assertFingerprintScopesUntouched(persistedScopes: string[], message: GenericMessage, messageCid: string, newIndexes: KeyValues): void;
13
15
  private static scopeSetsMatch;
14
16
  private static throwFingerprintScopeMutation;
17
+ private static isCoreProtocolUri;
15
18
  static hashMessageCid(messageCid: string): Promise<Uint8Array>;
16
19
  static emptyFingerprint(): Uint8Array;
17
20
  static xorFingerprint(fingerprint: Uint8Array, contribution: Uint8Array): Uint8Array;
@@ -1 +1 @@
1
- {"version":3,"file":"replication.d.ts","sourceRoot":"","sources":["../../../../src/utils/replication.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAWzD;;GAEG;AACH,qBAAa,WAAW;IACtB,gBAAuB,YAAY,MAAM;WAE3B,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;WAI3C,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;WAIvC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAOrD,wBAAwB,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,GAAG,MAAM,EAAE;WAoB/E,gCAAgC,CAC5C,eAAe,EAAE,MAAM,EAAE,EACzB,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,SAAS,GACpB,IAAI;IAOP,OAAO,CAAC,MAAM,CAAC,cAAc;IAQ7B,OAAO,CAAC,MAAM,CAAC,6BAA6B;WAOxB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;WAM7D,gBAAgB,IAAI,UAAU;WAI9B,cAAc,CAAC,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,GAAG,UAAU;WAQ7E,gBAAgB,CAAC,WAAW,EAAE,UAAU,GAAG,MAAM;WAIjD,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAA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AAG,UAAU;WAQzC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAW1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"protocol-composition.spec.d.ts","sourceRoot":"","sources":["../../../../tests/features/protocol-composition.spec.ts"],"names":[],"mappings":"AAyBA;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CA6hF9C"}
1
+ {"version":3,"file":"protocol-composition.spec.d.ts","sourceRoot":"","sources":["../../../../tests/features/protocol-composition.spec.ts"],"names":[],"mappings":"AAyBA;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CA4hF9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"messages-query.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/messages-query.spec.ts"],"names":[],"mappings":"AAyBA,wBAAgB,wBAAwB,IAAI,IAAI,CA6Q/C"}
1
+ {"version":3,"file":"messages-query.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/messages-query.spec.ts"],"names":[],"mappings":"AAyBA,wBAAgB,wBAAwB,IAAI,IAAI,CAuV/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"records-read.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-read.spec.ts"],"names":[],"mappings":"AAkCA,wBAAgB,sBAAsB,IAAI,IAAI,CA2nE7C"}
1
+ {"version":3,"file":"records-read.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-read.spec.ts"],"names":[],"mappings":"AAiCA,wBAAgB,sBAAsB,IAAI,IAAI,CA09D7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"records-write.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-write.spec.ts"],"names":[],"mappings":"AAqDA,wBAAgB,uBAAuB,IAAI,IAAI,CA0mJ9C"}
1
+ {"version":3,"file":"records-write.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-write.spec.ts"],"names":[],"mappings":"AAmDA,wBAAgB,uBAAuB,IAAI,IAAI,CA26J9C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=encryption.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption.spec.d.ts","sourceRoot":"","sources":["../../../../tests/protocols/encryption.spec.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"end-to-end-tests.spec.d.ts","sourceRoot":"","sources":["../../../../tests/scenarios/end-to-end-tests.spec.ts"],"names":[],"mappings":"AAqBA,wBAAgB,qBAAqB,IAAI,IAAI,CAsP5C"}
1
+ {"version":3,"file":"end-to-end-tests.spec.d.ts","sourceRoot":"","sources":["../../../../tests/scenarios/end-to-end-tests.spec.ts"],"names":[],"mappings":"AA8BA,wBAAgB,qBAAqB,IAAI,IAAI,CAsO5C"}
@@ -285,8 +285,6 @@ export declare class TestDataGenerator {
285
285
  * @param input.encryptSymmetricKeyWithProtocolPathDerivedKey
286
286
  * Set to `true` to attach the symmetric key encrypted by the protocol path derived public key
287
287
  *
288
- * @param input.encryptSymmetricKeyWithProtocolContextDerivedKey
289
- * Set to `true` to attach the symmetric key encrypted by the protocol context derived public key
290
288
  */
291
289
  static generateProtocolEncryptedRecordsWrite(input: {
292
290
  plaintextBytes: Uint8Array;
@@ -295,10 +293,7 @@ export declare class TestDataGenerator {
295
293
  protocolDefinition: ProtocolDefinition;
296
294
  protocolPath: string;
297
295
  protocolParentContextId?: string;
298
- protocolContextDerivingRootKeyId?: string;
299
- protocolContextDerivedPublicKeyJwk?: PublicKeyJwk;
300
296
  encryptSymmetricKeyWithProtocolPathDerivedKey: boolean;
301
- encryptSymmetricKeyWithProtocolContextDerivedKey: boolean;
302
297
  }): Promise<{
303
298
  message: RecordsWriteMessage;
304
299
  dataStream: ReadableStream<Uint8Array>;
@@ -1 +1 @@
1
- {"version":3,"file":"test-data-generator.d.ts","sourceRoot":"","sources":["../../../../tests/utils/test-data-generator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAA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@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=audience-key.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audience-key.spec.d.ts","sourceRoot":"","sources":["../../../../../../tests/validation/json-schemas/encryption/audience-key.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=grant-key.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grant-key.spec.d.ts","sourceRoot":"","sources":["../../../../../../tests/validation/json-schemas/encryption/grant-key.spec.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enbox/dwn-sdk-js",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "A reference implementation of https://identity.foundation/decentralized-web-node/spec/",
5
5
  "repository": {
6
6
  "type": "git",
@@ -65,8 +65,8 @@
65
65
  "react-native": "./dist/esm/src/index.js",
66
66
  "dependencies": {
67
67
  "@enbox/common": "0.1.1",
68
- "@enbox/crypto": "0.1.1",
69
- "@enbox/dids": "0.1.1",
68
+ "@enbox/crypto": "0.1.2",
69
+ "@enbox/dids": "0.1.2",
70
70
  "@ipld/dag-cbor": "9.0.5",
71
71
  "@js-temporal/polyfill": "0.4.4",
72
72
  "@noble/ciphers": "0.5.3",
@@ -16,12 +16,12 @@ export const PERMISSIONS_REVOCATION_PATH = 'grant/revocation';
16
16
  export const PERMISSIONS_PROTOCOL_URI = 'https://identity.foundation/dwn/permissions';
17
17
 
18
18
  /**
19
- * Well-known key-delivery protocol URI used for encrypted context-key records.
19
+ * The DWN Encryption protocol URI.
20
20
  */
21
- export const KEY_DELIVERY_PROTOCOL_URI = 'https://identity.foundation/protocols/key-delivery';
21
+ export const ENCRYPTION_PROTOCOL_URI = 'https://identity.foundation/dwn/protocols/encryption';
22
22
 
23
23
  const RECORDS_PRIMARY_PROJECTION_EXCLUDED_PROTOCOLS = new Set<string>([
24
- KEY_DELIVERY_PROTOCOL_URI,
24
+ ENCRYPTION_PROTOCOL_URI,
25
25
  PERMISSIONS_PROTOCOL_URI,
26
26
  ]);
27
27
 
@@ -35,7 +35,7 @@ export interface CoreProtocol {
35
35
  * Called after protocol authorization but before storage.
36
36
  * @throws DwnError to reject the write with the appropriate status code.
37
37
  */
38
- validateRecord?(message: RecordsWriteMessage, dataBytes: Uint8Array): void;
38
+ validateRecord?(message: RecordsWriteMessage, dataBytes: Uint8Array): Promise<void> | void;
39
39
 
40
40
  /**
41
41
  * Pre-processing hook: runs before storing a record under this protocol.
@@ -20,6 +20,22 @@ export enum DwnErrorCode {
20
20
  ComputeCidCodecNotSupported = 'ComputeCidCodecNotSupported',
21
21
  ComputeCidMultihashNotSupported = 'ComputeCidMultihashNotSupported',
22
22
  Ed25519InvalidJwk = 'Ed25519InvalidJwk',
23
+ EncryptionProtocolValidateAudienceEpochEncrypted = 'EncryptionProtocolValidateAudienceEpochEncrypted',
24
+ EncryptionProtocolValidateAudienceEpochKeyIdMismatch = 'EncryptionProtocolValidateAudienceEpochKeyIdMismatch',
25
+ EncryptionProtocolValidateAudienceEpochMissing = 'EncryptionProtocolValidateAudienceEpochMissing',
26
+ EncryptionProtocolValidateAudienceKeyRecipientMissing = 'EncryptionProtocolValidateAudienceKeyRecipientMissing',
27
+ EncryptionProtocolValidateAudienceKeyRoleRecordMissing = 'EncryptionProtocolValidateAudienceKeyRoleRecordMissing',
28
+ EncryptionProtocolValidateAudienceMissingRequiredTag = 'EncryptionProtocolValidateAudienceMissingRequiredTag',
29
+ EncryptionProtocolValidateAudienceTagsMismatch = 'EncryptionProtocolValidateAudienceTagsMismatch',
30
+ EncryptionProtocolValidateAudienceWriterUnauthorized = 'EncryptionProtocolValidateAudienceWriterUnauthorized',
31
+ EncryptionProtocolValidateEncryptedDeliveryMissingEncryption = 'EncryptionProtocolValidateEncryptedDeliveryMissingEncryption',
32
+ EncryptionProtocolValidateGrantKeyAuthorMismatch = 'EncryptionProtocolValidateGrantKeyAuthorMismatch',
33
+ EncryptionProtocolValidateGrantKeyGrantScopeMismatch = 'EncryptionProtocolValidateGrantKeyGrantScopeMismatch',
34
+ EncryptionProtocolValidateGrantKeyMissingRequiredTag = 'EncryptionProtocolValidateGrantKeyMissingRequiredTag',
35
+ EncryptionProtocolValidateGrantKeyRecipientMismatch = 'EncryptionProtocolValidateGrantKeyRecipientMismatch',
36
+ EncryptionProtocolValidateRoleAudienceContextInvalid = 'EncryptionProtocolValidateRoleAudienceContextInvalid',
37
+ EncryptionProtocolValidateRoleAudienceInvalid = 'EncryptionProtocolValidateRoleAudienceInvalid',
38
+ EncryptionProtocolValidateSchemaUnexpectedRecord = 'EncryptionProtocolValidateSchemaUnexpectedRecord',
23
39
  EventLogNotOpenError = 'EventLogNotOpenError',
24
40
  EventLogProgressGap = 'EventLogProgressGap',
25
41
  MessagesGrantAuthorizationMismatchedProtocol = 'MessagesGrantAuthorizationMismatchedProtocol',
@@ -101,6 +117,10 @@ export enum DwnErrorCode {
101
117
  ProtocolAuthorizationInitialWriteRevalidationNotInitial = 'ProtocolAuthorizationInitialWriteRevalidationNotInitial',
102
118
  ProtocolAuthorizationDuplicateRoleRecipient = 'ProtocolAuthorizationDuplicateRoleRecipient',
103
119
  ProtocolAuthorizationEncryptionRequired = 'ProtocolAuthorizationEncryptionRequired',
120
+ ProtocolAuthorizationEncryptionKeyAgreementMissing = 'ProtocolAuthorizationEncryptionKeyAgreementMissing',
121
+ ProtocolAuthorizationEncryptionProtocolPathEntryMissing = 'ProtocolAuthorizationEncryptionProtocolPathEntryMissing',
122
+ ProtocolAuthorizationEncryptionRoleAudienceEntryMissing = 'ProtocolAuthorizationEncryptionRoleAudienceEntryMissing',
123
+ ProtocolAuthorizationEncryptionRoleAudienceEpochMissing = 'ProtocolAuthorizationEncryptionRoleAudienceEpochMissing',
104
124
  ProtocolAuthorizationImmutableRecord = 'ProtocolAuthorizationImmutableRecord',
105
125
  ProtocolAuthorizationInvalidSchema = 'ProtocolAuthorizationInvalidSchema',
106
126
  ProtocolAuthorizationInvalidType = 'ProtocolAuthorizationInvalidType',
@@ -142,6 +162,10 @@ export enum DwnErrorCode {
142
162
  ProtocolsConfigureInvalidActionUpdateWithoutCreate = 'ProtocolsConfigureInvalidActionUpdateWithoutCreate',
143
163
  ProtocolsConfigureInvalidCrossProtocolOf = 'ProtocolsConfigureInvalidCrossProtocolOf',
144
164
  ProtocolsConfigureInvalidCrossProtocolRole = 'ProtocolsConfigureInvalidCrossProtocolRole',
165
+ ProtocolsConfigureInvalidEncryptedAnyoneRead = 'ProtocolsConfigureInvalidEncryptedAnyoneRead',
166
+ ProtocolsConfigureInvalidEncryptedRoleMissingKeyAgreement = 'ProtocolsConfigureInvalidEncryptedRoleMissingKeyAgreement',
167
+ ProtocolsConfigureMissingEncryptedPathKeyAgreement = 'ProtocolsConfigureMissingEncryptedPathKeyAgreement',
168
+ ProtocolsConfigureMissingTopLevelKeyAgreement = 'ProtocolsConfigureMissingTopLevelKeyAgreement',
145
169
  ProtocolsConfigureInvalidRecipientOfAction = 'ProtocolsConfigureInvalidRecipientOfAction',
146
170
  ProtocolsConfigureInvalidRuleSetRecordType = 'ProtocolsConfigureInvalidRuleSetRecordType',
147
171
  ProtocolsConfigureInvalidTagSchema = 'ProtocolsConfigureInvalidTagSchema',
@@ -158,6 +182,7 @@ export enum DwnErrorCode {
158
182
  RecordsAuthorDelegatedGrantGrantedToAndOwnerSignatureMismatch = 'RecordsAuthorDelegatedGrantGrantedToAndOwnerSignatureMismatch',
159
183
  RecordsAuthorDelegatedGrantNotADelegatedGrant = 'RecordsAuthorDelegatedGrantNotADelegatedGrant',
160
184
  RecordsDecryptNoMatchingKeyEncryptedFound = 'RecordsDecryptNoMatchingKeyEncryptedFound',
185
+ RecordsDecryptUnsupportedKeyDerivationScheme = 'RecordsDecryptUnsupportedKeyDerivationScheme',
161
186
  RecordsCountFilterMissingRequiredProperties = 'RecordsCountFilterMissingRequiredProperties',
162
187
  RecordsCountNestedProtocolPathContextIdInvalid = 'RecordsCountNestedProtocolPathContextIdInvalid',
163
188
 
@@ -194,6 +219,7 @@ export enum DwnErrorCode {
194
219
  RecordsWriteCreateMissingSigner = 'RecordsWriteCreateMissingSigner',
195
220
  RecordsWriteCreateDataAndDataCidMutuallyExclusive = 'RecordsWriteCreateDataAndDataCidMutuallyExclusive',
196
221
  RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive = 'RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive',
222
+ RecordsWriteCreateEncryptionAndEncryptionInputMutuallyExclusive = 'RecordsWriteCreateEncryptionAndEncryptionInputMutuallyExclusive',
197
223
  RecordsWriteCreateMissingProtocol = 'RecordsWriteCreateMissingProtocol',
198
224
  RecordsWriteDataCidMismatch = 'RecordsWriteDataCidMismatch',
199
225
  RecordsWriteDataSizeMismatch = 'RecordsWriteDataSizeMismatch',
@@ -204,7 +230,6 @@ export enum DwnErrorCode {
204
230
  RecordsWriteMissingSigner = 'RecordsWriteMissingSigner',
205
231
  RecordsWriteMissingDataInPrevious = 'RecordsWriteMissingDataInPrevious',
206
232
  RecordsWriteMissingEncodedDataInPrevious = 'RecordsWriteMissingEncodedDataInPrevious',
207
- RecordsWriteMissingEncryption = 'RecordsWriteMissingEncryption',
208
233
 
209
234
  RecordsWriteNotAllowedAfterDelete = 'RecordsWriteNotAllowedAfterDelete',
210
235
  RecordsWriteOwnerAndTenantMismatch = 'RecordsWriteOwnerAndTenantMismatch',
@@ -214,7 +239,10 @@ export enum DwnErrorCode {
214
239
  RecordsWriteValidateIntegrityContextIdMismatch = 'RecordsWriteValidateIntegrityContextIdMismatch',
215
240
  RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload = 'RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload',
216
241
  RecordsWriteValidateIntegrityDateCreatedMismatch = 'RecordsWriteValidateIntegrityDateCreatedMismatch',
242
+ RecordsWriteValidateIntegrityEncryptionCidMissing = 'RecordsWriteValidateIntegrityEncryptionCidMissing',
217
243
  RecordsWriteValidateIntegrityEncryptionCidMismatch = 'RecordsWriteValidateIntegrityEncryptionCidMismatch',
244
+ RecordsWriteValidateIntegrityEncryptionEphemeralPublicKeyInvalid = 'RecordsWriteValidateIntegrityEncryptionEphemeralPublicKeyInvalid',
245
+ RecordsWriteValidateIntegrityEncryptionInitializationVectorInvalid = 'RecordsWriteValidateIntegrityEncryptionInitializationVectorInvalid',
218
246
  RecordsWriteValidateIntegrityRecordIdUnauthorized = 'RecordsWriteValidateIntegrityRecordIdUnauthorized',
219
247
  SchemaValidatorAdditionalPropertyNotAllowed = 'SchemaValidatorAdditionalPropertyNotAllowed',
220
248
  SchemaValidatorFailure = 'SchemaValidatorFailure',
@@ -8,6 +8,7 @@ import type { DataEncodedRecordsWriteMessage, RecordsDeleteMessage, RecordsWrite
8
8
  import type { MessagesQueryMessage, MessagesReadMessage, MessagesSubscribeMessage } from '../types/messages-types.js';
9
9
 
10
10
  import { DwnInterfaceName } from '../enums/dwn-interface-method.js';
11
+ import { EncryptionProtocol } from '../protocols/encryption.js';
11
12
  import { GrantAuthorization } from './grant-authorization.js';
12
13
  import { PermissionScopeMatcher } from '../utils/permission-scope.js';
13
14
  import { PermissionsProtocol } from '../protocols/permissions.js';
@@ -240,6 +241,10 @@ export class MessagesGrantAuthorization {
240
241
  );
241
242
  }
242
243
 
244
+ if (recordsWriteMessage.descriptor.protocol === EncryptionProtocol.uri) {
245
+ return MessagesGrantAuthorization.isEncryptionRecordScopeAuthorized(recordsWriteMessage, incomingScope);
246
+ }
247
+
243
248
  return PermissionScopeMatcher.matches(incomingScope, MessagesGrantAuthorization.getRecordsScopeTarget(recordsWriteMessage));
244
249
  }
245
250
 
@@ -263,6 +268,23 @@ export class MessagesGrantAuthorization {
263
268
  && PermissionScopeMatcher.matches(incomingScope, permissionScope);
264
269
  }
265
270
 
271
+ private static isEncryptionRecordScopeAuthorized(
272
+ recordsWriteMessage: RecordsWriteMessage,
273
+ incomingScope: MessagesPermissionScope,
274
+ ): boolean {
275
+ const tags = recordsWriteMessage.descriptor.tags;
276
+ const protocol = tags?.protocol;
277
+ if (typeof protocol !== 'string') {
278
+ return false;
279
+ }
280
+
281
+ return PermissionScopeMatcher.matches(incomingScope, {
282
+ protocol,
283
+ protocolPath : MessagesGrantAuthorization.getStringTag(recordsWriteMessage, 'protocolPath'),
284
+ contextId : MessagesGrantAuthorization.getStringTag(recordsWriteMessage, 'contextId'),
285
+ });
286
+ }
287
+
266
288
  private static isProtocolsConfigureScopeAuthorized(
267
289
  protocolsConfigureMessage: ProtocolsConfigureMessage,
268
290
  incomingScope: MessagesPermissionScope
@@ -291,6 +313,11 @@ export class MessagesGrantAuthorization {
291
313
  return { protocol, protocolPath, contextId };
292
314
  }
293
315
 
316
+ private static getStringTag(recordsWriteMessage: RecordsWriteMessage, tag: string): string | undefined {
317
+ const value = recordsWriteMessage.descriptor.tags?.[tag];
318
+ return typeof value === 'string' ? value : undefined;
319
+ }
320
+
294
321
  private static isSubtreeScope(scope: MessagesPermissionScope): boolean {
295
322
  return scope.protocolPath !== undefined || scope.contextId !== undefined;
296
323
  }
@@ -1,14 +1,16 @@
1
1
  import type { RecordsWrite } from '../interfaces/records-write.js';
2
2
  import type { RecordsWriteMessage } from '../types/records-types.js';
3
+ import type { RoleAudienceKeyEncryption } from '../utils/encryption.js';
3
4
  import type { ValidationStateReader } from '../types/validation-state-reader.js';
4
- import type { ProtocolDefinition, ProtocolRuleSet, ProtocolType, ProtocolTypes } from '../types/protocols-types.js';
5
-
6
- import { ProtocolRecordLimitStrategy } from '../types/protocols-types.js';
5
+ import type { ProtocolActionRule, ProtocolDefinition, ProtocolRuleSet, ProtocolType, ProtocolTypes } from '../types/protocols-types.js';
7
6
 
7
+ import { KeyDerivationScheme } from '../utils/hd-key.js';
8
8
  import { Records } from '../utils/records.js';
9
9
  import { validateProtocolTags } from '../utils/protocol-tags.js';
10
10
  import { DwnError, DwnErrorCode } from './dwn-error.js';
11
- import { getTypeName, parseCrossProtocolRef } from '../utils/protocols.js';
11
+ import { Encryption, ROLE_AUDIENCE_DERIVATION_SCHEME } from '../utils/encryption.js';
12
+ import { getRuleSetAtPath, getTypeName, parseCrossProtocolRef } from '../utils/protocols.js';
13
+ import { ProtocolAction, ProtocolRecordLimitStrategy } from '../types/protocols-types.js';
12
14
 
13
15
  /**
14
16
  * Verifies the `protocolPath` declared in the given message matches the path of actual record chain.
@@ -170,7 +172,14 @@ export async function verifyTypeWithComposition(
170
172
  tenant, declaredProtocolPath, protocolDefinition, validationStateReader, protocolDefinitionTimestamp
171
173
  );
172
174
 
173
- verifyType(inboundMessage, protocolTypes, declaredTypeName);
175
+ const protocolType = verifyType(inboundMessage, protocolTypes, declaredTypeName);
176
+ await verifyProtocolPathEncryptionIfNeeded(
177
+ tenant,
178
+ inboundMessage,
179
+ protocolDefinition,
180
+ protocolType,
181
+ validationStateReader,
182
+ );
174
183
  }
175
184
 
176
185
  /**
@@ -216,7 +225,7 @@ export function verifyType(
216
225
  inboundMessage: RecordsWriteMessage,
217
226
  protocolTypes: ProtocolTypes,
218
227
  typeName?: string,
219
- ): void {
228
+ ): ProtocolType {
220
229
  const declaredTypeName = typeName ?? getTypeName(inboundMessage.descriptor.protocolPath);
221
230
  const typeNames = Object.keys(protocolTypes);
222
231
 
@@ -254,6 +263,136 @@ export function verifyType(
254
263
  `type '${declaredTypeName}' requires encryption but message has no encryption metadata`
255
264
  );
256
265
  }
266
+
267
+ return protocolType;
268
+ }
269
+
270
+ async function verifyProtocolPathEncryptionIfNeeded(
271
+ tenant: string,
272
+ inboundMessage: RecordsWriteMessage,
273
+ protocolDefinition: ProtocolDefinition,
274
+ protocolType: ProtocolType,
275
+ validationStateReader: ValidationStateReader,
276
+ ): Promise<void> {
277
+ if (protocolType.encryptionRequired !== true) {
278
+ return;
279
+ }
280
+
281
+ const ruleSet = getRuleSetAtPath(inboundMessage.descriptor.protocolPath, protocolDefinition.structure);
282
+ if (ruleSet?.$keyAgreement?.publicKeyJwk === undefined) {
283
+ throw new DwnError(
284
+ DwnErrorCode.ProtocolAuthorizationEncryptionKeyAgreementMissing,
285
+ `encrypted protocol path '${inboundMessage.descriptor.protocolPath}' has no $keyAgreement`
286
+ );
287
+ }
288
+
289
+ const publicKeyJwk = ruleSet.$keyAgreement.publicKeyJwk;
290
+ const keyId = await Encryption.getKeyId(publicKeyJwk);
291
+ const hasProtocolPathEntry = inboundMessage.encryption!.keyEncryption.some((entry): boolean =>
292
+ entry.derivationScheme === KeyDerivationScheme.ProtocolPath && entry.keyId === keyId
293
+ );
294
+
295
+ if (!hasProtocolPathEntry) {
296
+ throw new DwnError(
297
+ DwnErrorCode.ProtocolAuthorizationEncryptionProtocolPathEntryMissing,
298
+ `encrypted record is missing a protocolPath keyEncryption entry for '${inboundMessage.descriptor.protocolPath}'`
299
+ );
300
+ }
301
+
302
+ await verifyRoleAudienceEncryptionIfNeeded(tenant, inboundMessage, protocolDefinition, ruleSet, validationStateReader);
303
+ }
304
+
305
+ async function verifyRoleAudienceEncryptionIfNeeded(
306
+ tenant: string,
307
+ inboundMessage: RecordsWriteMessage,
308
+ protocolDefinition: ProtocolDefinition,
309
+ ruleSet: ProtocolRuleSet,
310
+ validationStateReader: ValidationStateReader,
311
+ ): Promise<void> {
312
+ const readRoleRules = (ruleSet.$actions ?? []).filter((actionRule): boolean =>
313
+ actionRule.role !== undefined && actionRule.can.includes(ProtocolAction.Read)
314
+ );
315
+
316
+ for (const actionRule of readRoleRules) {
317
+ const roleAudience = resolveRoleAudience(actionRule, inboundMessage, protocolDefinition);
318
+ if (roleAudience === undefined) {
319
+ continue;
320
+ }
321
+
322
+ const matchingEntry = inboundMessage.encryption!.keyEncryption.find((entry): entry is RoleAudienceKeyEncryption =>
323
+ entry.derivationScheme === ROLE_AUDIENCE_DERIVATION_SCHEME &&
324
+ entry.protocol === roleAudience.protocol &&
325
+ entry.role === roleAudience.role
326
+ );
327
+
328
+ if (matchingEntry === undefined) {
329
+ throw new DwnError(
330
+ DwnErrorCode.ProtocolAuthorizationEncryptionRoleAudienceEntryMissing,
331
+ `encrypted record is missing a roleAudience keyEncryption entry for role '${roleAudience.role}'`
332
+ );
333
+ }
334
+
335
+ const matchingEpochs = await validationStateReader.queryAudienceEpochs({
336
+ tenant,
337
+ protocol : roleAudience.protocol,
338
+ contextId : roleAudience.contextId,
339
+ role : roleAudience.role,
340
+ epoch : matchingEntry.epoch,
341
+ keyId : matchingEntry.keyId,
342
+ });
343
+
344
+ if (matchingEpochs.length === 0) {
345
+ throw new DwnError(
346
+ DwnErrorCode.ProtocolAuthorizationEncryptionRoleAudienceEpochMissing,
347
+ `encrypted record references a missing audienceEpoch for role '${roleAudience.role}'`
348
+ );
349
+ }
350
+ }
351
+ }
352
+
353
+ function resolveRoleAudience(
354
+ actionRule: ProtocolActionRule,
355
+ inboundMessage: RecordsWriteMessage,
356
+ protocolDefinition: ProtocolDefinition,
357
+ ): { protocol: string; role: string; contextId: string } | undefined {
358
+ const roleRef = actionRule.role;
359
+ if (roleRef === undefined) {
360
+ return undefined;
361
+ }
362
+
363
+ const parsed = parseCrossProtocolRef(roleRef);
364
+ const protocol = parsed === undefined
365
+ ? inboundMessage.descriptor.protocol
366
+ : protocolDefinition.uses?.[parsed.alias];
367
+ const role = parsed === undefined ? roleRef : parsed.protocolPath;
368
+ if (protocol === undefined) {
369
+ return undefined;
370
+ }
371
+
372
+ const contextId = getRoleAudienceContextId(inboundMessage, role);
373
+ return contextId === undefined ? undefined : { protocol, role, contextId };
374
+ }
375
+
376
+ function getRoleAudienceContextId(
377
+ inboundMessage: RecordsWriteMessage,
378
+ rolePath: string,
379
+ ): string | undefined {
380
+ const parentDepth = rolePath.split('/').length - 1;
381
+ if (parentDepth === 0) {
382
+ return '';
383
+ }
384
+
385
+ const contextId = inboundMessage.contextId;
386
+ if (typeof contextId !== 'string') {
387
+ return undefined;
388
+ }
389
+
390
+ const contextSegments = contextId.split('/');
391
+ if (contextSegments.length < parentDepth) {
392
+ return undefined;
393
+ }
394
+
395
+ return contextSegments.slice(0, parentDepth).join('/');
257
396
  }
258
397
 
259
398
  /**