@enbox/dwn-sdk-js 0.4.11 → 0.4.13

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 (142) hide show
  1. package/dist/browser.mjs +4 -1
  2. package/dist/browser.mjs.map +4 -4
  3. package/dist/esm/src/core/dwn-error.js +8 -1
  4. package/dist/esm/src/core/dwn-error.js.map +1 -1
  5. package/dist/esm/src/core/encryption-control.js +38 -2
  6. package/dist/esm/src/core/encryption-control.js.map +1 -1
  7. package/dist/esm/src/core/message-reply.js +14 -1
  8. package/dist/esm/src/core/message-reply.js.map +1 -1
  9. package/dist/esm/src/core/protocol-authorization-action.js +130 -107
  10. package/dist/esm/src/core/protocol-authorization-action.js.map +1 -1
  11. package/dist/esm/src/core/protocol-authorization.js +10 -0
  12. package/dist/esm/src/core/protocol-authorization.js.map +1 -1
  13. package/dist/esm/src/event-stream/broadcast-channel-wake-publisher.js +63 -0
  14. package/dist/esm/src/event-stream/broadcast-channel-wake-publisher.js.map +1 -0
  15. package/dist/esm/src/handlers/protocols-configure.js +2 -0
  16. package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
  17. package/dist/esm/src/handlers/records-subscribe.js +73 -46
  18. package/dist/esm/src/handlers/records-subscribe.js.map +1 -1
  19. package/dist/esm/src/handlers/records-write.js +132 -73
  20. package/dist/esm/src/handlers/records-write.js.map +1 -1
  21. package/dist/esm/src/index.js +1 -0
  22. package/dist/esm/src/index.js.map +1 -1
  23. package/dist/esm/src/interfaces/protocols-configure.js +3 -5
  24. package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
  25. package/dist/esm/src/interfaces/records-write-query.js +2 -3
  26. package/dist/esm/src/interfaces/records-write-query.js.map +1 -1
  27. package/dist/esm/src/interfaces/records-write.js +50 -35
  28. package/dist/esm/src/interfaces/records-write.js.map +1 -1
  29. package/dist/esm/src/jose/jws/general/verifier.js +1 -1
  30. package/dist/esm/src/store/blockstore-mock.js +3 -0
  31. package/dist/esm/src/store/blockstore-mock.js.map +1 -1
  32. package/dist/esm/src/store/index-level-compound.js +34 -18
  33. package/dist/esm/src/store/index-level-compound.js.map +1 -1
  34. package/dist/esm/src/store/index-level.js +5 -5
  35. package/dist/esm/src/store/index-level.js.map +1 -1
  36. package/dist/esm/src/store/message-store-level.js +2 -2
  37. package/dist/esm/src/store/message-store-level.js.map +1 -1
  38. package/dist/esm/src/store/storage-controller.js +26 -17
  39. package/dist/esm/src/store/storage-controller.js.map +1 -1
  40. package/dist/esm/src/types/message-types.js.map +1 -1
  41. package/dist/esm/src/utils/filter.js +4 -8
  42. package/dist/esm/src/utils/filter.js.map +1 -1
  43. package/dist/esm/src/utils/messages.js +46 -28
  44. package/dist/esm/src/utils/messages.js.map +1 -1
  45. package/dist/esm/src/utils/protocols.js +2 -2
  46. package/dist/esm/src/utils/protocols.js.map +1 -1
  47. package/dist/esm/src/utils/records.js +49 -33
  48. package/dist/esm/src/utils/records.js.map +1 -1
  49. package/dist/esm/src/utils/secp256r1.js +1 -1
  50. package/dist/esm/src/utils/secp256r1.js.map +1 -1
  51. package/dist/esm/src/utils/url.js +1 -1
  52. package/dist/esm/src/utils/url.js.map +1 -1
  53. package/dist/esm/tests/broadcast-channel-wake-publisher.spec.js +74 -0
  54. package/dist/esm/tests/broadcast-channel-wake-publisher.spec.js.map +1 -0
  55. package/dist/esm/tests/core/message-reply.spec.js +27 -0
  56. package/dist/esm/tests/core/message-reply.spec.js.map +1 -1
  57. package/dist/esm/tests/core/process-message-parity.spec.js +3 -0
  58. package/dist/esm/tests/core/process-message-parity.spec.js.map +1 -1
  59. package/dist/esm/tests/durable-event-log.spec.js +37 -0
  60. package/dist/esm/tests/durable-event-log.spec.js.map +1 -1
  61. package/dist/esm/tests/features/records-squash.spec.js +5 -0
  62. package/dist/esm/tests/features/records-squash.spec.js.map +1 -1
  63. package/dist/esm/tests/handlers/messages-query.spec.js +14 -28
  64. package/dist/esm/tests/handlers/messages-query.spec.js.map +1 -1
  65. package/dist/esm/tests/handlers/protocols-configure.spec.js +441 -1
  66. package/dist/esm/tests/handlers/protocols-configure.spec.js.map +1 -1
  67. package/dist/esm/tests/handlers/records-write.spec.js +1 -0
  68. package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
  69. package/dist/esm/tests/test-suite.js +8 -0
  70. package/dist/esm/tests/test-suite.js.map +1 -1
  71. package/dist/types/src/core/dwn-error.d.ts +14 -1
  72. package/dist/types/src/core/dwn-error.d.ts.map +1 -1
  73. package/dist/types/src/core/encryption-control.d.ts +16 -0
  74. package/dist/types/src/core/encryption-control.d.ts.map +1 -1
  75. package/dist/types/src/core/message-reply.d.ts +5 -0
  76. package/dist/types/src/core/message-reply.d.ts.map +1 -1
  77. package/dist/types/src/core/protocol-authorization-action.d.ts +6 -1
  78. package/dist/types/src/core/protocol-authorization-action.d.ts.map +1 -1
  79. package/dist/types/src/core/protocol-authorization.d.ts.map +1 -1
  80. package/dist/types/src/event-stream/broadcast-channel-wake-publisher.d.ts +35 -0
  81. package/dist/types/src/event-stream/broadcast-channel-wake-publisher.d.ts.map +1 -0
  82. package/dist/types/src/handlers/protocols-configure.d.ts.map +1 -1
  83. package/dist/types/src/handlers/records-subscribe.d.ts +18 -0
  84. package/dist/types/src/handlers/records-subscribe.d.ts.map +1 -1
  85. package/dist/types/src/handlers/records-write.d.ts +28 -0
  86. package/dist/types/src/handlers/records-write.d.ts.map +1 -1
  87. package/dist/types/src/index.d.ts +2 -0
  88. package/dist/types/src/index.d.ts.map +1 -1
  89. package/dist/types/src/interfaces/protocols-configure.d.ts.map +1 -1
  90. package/dist/types/src/interfaces/records-write-query.d.ts.map +1 -1
  91. package/dist/types/src/interfaces/records-write.d.ts +12 -0
  92. package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
  93. package/dist/types/src/store/blockstore-mock.d.ts.map +1 -1
  94. package/dist/types/src/store/index-level-compound.d.ts +4 -1
  95. package/dist/types/src/store/index-level-compound.d.ts.map +1 -1
  96. package/dist/types/src/store/index-level.d.ts.map +1 -1
  97. package/dist/types/src/store/storage-controller.d.ts +6 -0
  98. package/dist/types/src/store/storage-controller.d.ts.map +1 -1
  99. package/dist/types/src/types/jose-types.d.ts +3 -2
  100. package/dist/types/src/types/jose-types.d.ts.map +1 -1
  101. package/dist/types/src/types/message-types.d.ts +13 -0
  102. package/dist/types/src/types/message-types.d.ts.map +1 -1
  103. package/dist/types/src/utils/filter.d.ts.map +1 -1
  104. package/dist/types/src/utils/messages.d.ts +14 -0
  105. package/dist/types/src/utils/messages.d.ts.map +1 -1
  106. package/dist/types/src/utils/records.d.ts +10 -0
  107. package/dist/types/src/utils/records.d.ts.map +1 -1
  108. package/dist/types/tests/broadcast-channel-wake-publisher.spec.d.ts +2 -0
  109. package/dist/types/tests/broadcast-channel-wake-publisher.spec.d.ts.map +1 -0
  110. package/dist/types/tests/features/records-squash.spec.d.ts.map +1 -1
  111. package/dist/types/tests/handlers/messages-query.spec.d.ts.map +1 -1
  112. package/dist/types/tests/handlers/protocols-configure.spec.d.ts.map +1 -1
  113. package/dist/types/tests/handlers/records-write.spec.d.ts.map +1 -1
  114. package/dist/types/tests/test-suite.d.ts.map +1 -1
  115. package/package.json +4 -4
  116. package/src/core/dwn-error.ts +15 -1
  117. package/src/core/encryption-control.ts +66 -2
  118. package/src/core/message-reply.ts +18 -2
  119. package/src/core/protocol-authorization-action.ts +167 -117
  120. package/src/core/protocol-authorization.ts +13 -0
  121. package/src/event-stream/broadcast-channel-wake-publisher.ts +71 -0
  122. package/src/handlers/protocols-configure.ts +2 -0
  123. package/src/handlers/records-subscribe.ts +98 -47
  124. package/src/handlers/records-write.ts +177 -91
  125. package/src/index.ts +2 -0
  126. package/src/interfaces/protocols-configure.ts +6 -8
  127. package/src/interfaces/records-write-query.ts +2 -3
  128. package/src/interfaces/records-write.ts +62 -44
  129. package/src/jose/jws/general/verifier.ts +1 -1
  130. package/src/store/blockstore-mock.ts +3 -0
  131. package/src/store/index-level-compound.ts +55 -24
  132. package/src/store/index-level.ts +6 -4
  133. package/src/store/message-store-level.ts +2 -2
  134. package/src/store/storage-controller.ts +27 -16
  135. package/src/types/jose-types.ts +3 -2
  136. package/src/types/message-types.ts +16 -0
  137. package/src/utils/filter.ts +4 -8
  138. package/src/utils/messages.ts +53 -30
  139. package/src/utils/protocols.ts +2 -2
  140. package/src/utils/records.ts +76 -51
  141. package/src/utils/secp256r1.ts +1 -1
  142. package/src/utils/url.ts +1 -1
@@ -1,3 +1,4 @@
1
+ import type { DwnErrorInfo } from '../core/dwn-error.js';
1
2
  import type { GeneralJws } from './jws-types.js';
2
3
  import type { ProgressToken } from './subscriptions.js';
3
4
  import type { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
@@ -110,8 +111,20 @@ export type Pagination = {
110
111
  limit?: number;
111
112
  };
112
113
  export type Status = {
114
+ /** Numeric status code representing the outcome of the operation, aligned with HTTP status codes. */
113
115
  code: number;
116
+ /** Human-readable detail about the status or error. Prose only — load-bearing values belong in `info`. */
114
117
  detail: string;
118
+ /**
119
+ * The `DwnErrorCode` of the `DwnError` that produced this status.
120
+ * Only present when the failure originated from a `DwnError`; synthesized statuses (e.g. tenant gate rejections) omit it.
121
+ */
122
+ errorCode?: string;
123
+ /**
124
+ * Structured, machine-readable error data (e.g. the squash floor timestamp for a squash backstop rejection).
125
+ * Only present when the originating `DwnError` carries an info bag; values mirror `DwnErrorInfo`.
126
+ */
127
+ info?: DwnErrorInfo;
115
128
  };
116
129
  export type GenericMessageReply = {
117
130
  status: Status;
@@ -1 +1 @@
1
- {"version":3,"file":"message-types.d.ts","sourceRoot":"","sources":["../../../../src/types/message-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACxF,OAAO,KAAK,EA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AM,GAAG,MAAM;CAkD5C"}
@@ -22,6 +22,20 @@ export declare class Messages {
22
22
  * @returns {Filter[]} an array of generic Filter able to be used when querying.
23
23
  */
24
24
  static convertFilters(filters: MessagesFilter[], coreProtocols?: CoreProtocolRegistry): Filter[];
25
+ /**
26
+ * Asks each core protocol whether it needs an additional shadow filter for the given query filter.
27
+ * For example, the Permissions protocol injects a filter for grants/requests/revocations
28
+ * tagged with the target protocol so they appear alongside that protocol's own records.
29
+ */
30
+ private static constructCoreProtocolFilters;
31
+ /**
32
+ * When protocolPathPrefix or contextIdPrefix is used with a protocol, constructs a shadow filter
33
+ * for ProtocolsConfigure events. Without this, protocol metadata updates would be excluded
34
+ * (ProtocolsConfigure indexes have no protocolPath). This mirrors the core-protocol additional-filter
35
+ * pattern above. The messageTimestamp constraint is carried over so time-bounded queries
36
+ * (including cursor-based subscriptions) also apply to the shadow filter.
37
+ */
38
+ private static constructProtocolConfigureShadowFilter;
25
39
  /**
26
40
  * Returns a copy of a RecordsWrite message without inline encodedData, and the
27
41
  * detached encodedData value for wire surfaces that carry data beside the message.
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../src/utils/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAUjE;;GAEG;AACH,qBAAa,QAAQ;IACnB;;OAEG;WACW,gBAAgB,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE;IAwB3E;;;;;;;;;;OAUG;WACW,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,aAAa,CAAC,EAAE,oBAAoB,GAAG,MAAM,EAAE;IA8CvG;;;OAGG;WACW,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAY3G;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAmC5B,OAAO,CAAC,MAAM,CAAC,cAAc;CAG9B"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../src/utils/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAUjE;;GAEG;AACH,qBAAa,QAAQ;IACnB;;OAEG;WACW,gBAAgB,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE;IAwB3E;;;;;;;;;;OAUG;WACW,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,aAAa,CAAC,EAAE,oBAAoB,GAAG,MAAM,EAAE;IAoBvG;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAgB3C;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,sCAAsC;IAqBrD;;;OAGG;WACW,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAY3G;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAmC5B,OAAO,CAAC,MAAM,CAAC,cAAc;CAG9B"}
@@ -97,6 +97,16 @@ export declare class Records {
97
97
  * Passed purely as a performance optimization so we don't have to decode the owner signature payload again.
98
98
  */
99
99
  static validateDelegatedGrantReferentialIntegrity(message: RecordsCountMessage | RecordsReadMessage | RecordsQueryMessage | RecordsWriteMessage | RecordsDeleteMessage | RecordsSubscribeMessage, authorSignaturePayload: GenericSignaturePayload | undefined, ownerSignaturePayload?: GenericSignaturePayload | undefined): Promise<void>;
100
+ /**
101
+ * Validates the referential integrity of the author-delegated grant, if any.
102
+ * Extracted from `validateDelegatedGrantReferentialIntegrity()` to keep its cognitive complexity low.
103
+ */
104
+ private static validateAuthorDelegatedGrantReferentialIntegrity;
105
+ /**
106
+ * Validates the referential integrity of the owner-delegated grant, if any.
107
+ * Extracted from `validateDelegatedGrantReferentialIntegrity()` to keep its cognitive complexity low.
108
+ */
109
+ private static validateOwnerDelegatedGrantReferentialIntegrity;
100
110
  /**
101
111
  * Convert a `DateSort` value to a `MessageSort` object accepted by the `MessageStore`.
102
112
  * Defaults to `messageTimestamp` descending (most recently updated first) when no sort is given.
@@ -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;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,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;AAInQ,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AASrD,OAAO,EAAY,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAc,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAE9E,OAAO,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1 @@
1
+ {"version":3,"file":"broadcast-channel-wake-publisher.spec.d.ts","sourceRoot":"","sources":["../../../tests/broadcast-channel-wake-publisher.spec.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"records-squash.spec.d.ts","sourceRoot":"","sources":["../../../../tests/features/records-squash.spec.ts"],"names":[],"mappings":"AAqBA,wBAAgB,iBAAiB,IAAI,IAAI,CA8oCxC"}
1
+ {"version":3,"file":"records-squash.spec.d.ts","sourceRoot":"","sources":["../../../../tests/features/records-squash.spec.ts"],"names":[],"mappings":"AAqBA,wBAAgB,iBAAiB,IAAI,IAAI,CAopCxC"}
@@ -1 +1 @@
1
- {"version":3,"file":"messages-query.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/messages-query.spec.ts"],"names":[],"mappings":"AAoCA,wBAAgB,wBAAwB,IAAI,IAAI,CA0c/C"}
1
+ {"version":3,"file":"messages-query.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/messages-query.spec.ts"],"names":[],"mappings":"AAoCA,wBAAgB,wBAAwB,IAAI,IAAI,CAsb/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"protocols-configure.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/protocols-configure.spec.ts"],"names":[],"mappings":"AA6BA,wBAAgB,6BAA6B,IAAI,IAAI,CA6lDpD"}
1
+ {"version":3,"file":"protocols-configure.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/protocols-configure.spec.ts"],"names":[],"mappings":"AAgCA,wBAAgB,6BAA6B,IAAI,IAAI,CAkkEpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"records-write.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-write.spec.ts"],"names":[],"mappings":"AA+DA,wBAAgB,uBAAuB,IAAI,IAAI,CA4yM9C"}
1
+ {"version":3,"file":"records-write.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-write.spec.ts"],"names":[],"mappings":"AA+DA,wBAAgB,uBAAuB,IAAI,IAAI,CA6yM9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"test-suite.d.ts","sourceRoot":"","sources":["../../../tests/test-suite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAyC7F;;GAEG;AACH,qBAAa,SAAS;IAEpB;;;OAGG;WACW,2BAA2B,CAAC,SAAS,CAAC,EAAE;QACpD,YAAY,CAAC,EAAE,YAAY,CAAC;QAC5B,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACpB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;KACzC,GAAG,IAAI;CAgDT"}
1
+ {"version":3,"file":"test-suite.d.ts","sourceRoot":"","sources":["../../../tests/test-suite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAyC7F;;GAEG;AACH,qBAAa,SAAS;IAEpB;;;OAGG;WACW,2BAA2B,CAAC,SAAS,CAAC,EAAE;QACpD,YAAY,CAAC,EAAE,YAAY,CAAC;QAC5B,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACpB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;KACzC,GAAG,IAAI;CAyDT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enbox/dwn-sdk-js",
3
- "version": "0.4.11",
3
+ "version": "0.4.13",
4
4
  "description": "A reference implementation of https://identity.foundation/decentralized-web-node/spec/",
5
5
  "repository": {
6
6
  "type": "git",
@@ -72,9 +72,9 @@
72
72
  },
73
73
  "react-native": "./dist/esm/src/index.js",
74
74
  "dependencies": {
75
- "@enbox/common": "0.1.3",
76
- "@enbox/crypto": "0.1.5",
77
- "@enbox/dids": "0.1.5",
75
+ "@enbox/common": "0.1.4",
76
+ "@enbox/crypto": "0.1.7",
77
+ "@enbox/dids": "0.1.7",
78
78
  "@ipld/dag-cbor": "10.0.1",
79
79
  "@noble/curves": "2.2.0",
80
80
  "ajv": "8.18.0",
@@ -1,11 +1,25 @@
1
+ /**
2
+ * Structured, machine-readable data attached to a `DwnError`.
3
+ * Values are restricted to JSON primitives so the bag can be surfaced verbatim in a message reply `status.info`.
4
+ */
5
+ export type DwnErrorInfo = Record<string, string | number | boolean>;
6
+
1
7
  /**
2
8
  * A class that represents a DWN error.
3
9
  */
4
10
  export class DwnError extends Error {
5
- constructor (public code: string, message: string) {
11
+ /**
12
+ * Structured, machine-readable data describing this error.
13
+ * Surfaced verbatim as `status.info` when the error becomes a message reply,
14
+ * so consumers can read error-specific values (e.g. the squash floor timestamp) without parsing prose.
15
+ */
16
+ public readonly info?: DwnErrorInfo;
17
+
18
+ constructor (public code: string, message: string, options?: { info?: DwnErrorInfo }) {
6
19
  super(`${code}: ${message}`);
7
20
 
8
21
  this.name = 'DwnError';
22
+ this.info = options?.info;
9
23
  }
10
24
  }
11
25
 
@@ -35,6 +35,11 @@ type RoleAudienceDefinition = {
35
35
  ruleSet: ProtocolRuleSet;
36
36
  };
37
37
 
38
+ type ValidatedAudiencePayload = {
39
+ payload: EncryptionControlAudiencePayload;
40
+ tags: RoleAudienceKeyId;
41
+ };
42
+
38
43
  type EffectiveControlActor = {
39
44
  did: string | undefined;
40
45
  grant?: PermissionGrant;
@@ -357,6 +362,50 @@ export class EncryptionControl {
357
362
  }
358
363
  }
359
364
 
365
+ /**
366
+ * Validates the config-owned invariants of a stored encryption control record.
367
+ *
368
+ * The definition governing the record timestamp is replayed first so a newly learned historical
369
+ * config cannot leave a record that would have failed admission under the complete history. The
370
+ * newest definition then decides whether the role still exists. Live dependency checks (audience
371
+ * lookups, role records, parent chains) are deliberately excluded, and the newest definition does
372
+ * not need `$keyAgreement`: a current definition missing it is recoverable and must not destroy
373
+ * historically valid sealed key material.
374
+ *
375
+ * @returns The role rule set that governed the stored record's timestamp.
376
+ */
377
+ public static async validateStoredControlRecord(
378
+ tenant: string,
379
+ recordsWrite: RecordsWrite,
380
+ validationStateReader: ValidationStateReader,
381
+ ): Promise<ProtocolRuleSet> {
382
+ const message = recordsWrite.message;
383
+ const recordType = EncryptionControl.getRecordType(message);
384
+ const tags = EncryptionControl.getRoleAudienceKeyId(message, recordType);
385
+
386
+ const { ruleSet: governingRuleSet } = await EncryptionControl.verifyRoleAudienceDefinition(
387
+ tenant, tags, message, validationStateReader, recordType
388
+ );
389
+ const encodedData = (message as RecordsWriteMessage & { encodedData?: string }).encodedData;
390
+ if (recordType === 'audience' && encodedData !== undefined) {
391
+ const { payload } = await EncryptionControl.validateAudiencePayload(
392
+ message, Encoder.base64UrlToBytes(encodedData)
393
+ );
394
+ await EncryptionControl.verifyAudienceSealKey(payload, governingRuleSet);
395
+ }
396
+
397
+ const newestDefinition = await validationStateReader.fetchProtocolDefinition(tenant, tags.protocol);
398
+ const newestRuleSet = getRuleSetAtPath(tags.rolePath, newestDefinition.structure);
399
+ if (newestRuleSet?.$role !== true) {
400
+ throw new DwnError(
401
+ DwnErrorCode.EncryptionControlValidateAudienceRolePathInvalid,
402
+ `role audience path '${tags.rolePath}' no longer exists as a role in protocol '${tags.protocol}'.`
403
+ );
404
+ }
405
+
406
+ return governingRuleSet;
407
+ }
408
+
360
409
  public static async preProcessWrite(
361
410
  tenant: string,
362
411
  message: RecordsWriteMessage,
@@ -470,6 +519,15 @@ export class EncryptionControl {
470
519
  dataBytes: Uint8Array,
471
520
  validationStateReader: ValidationStateReader,
472
521
  ): Promise<void> {
522
+ const { payload, tags } = await EncryptionControl.validateAudiencePayload(message, dataBytes);
523
+ const { ruleSet } = await EncryptionControl.verifyRoleAudienceDefinition(tenant, tags, message, validationStateReader, 'audience');
524
+ await EncryptionControl.verifyAudienceSealKey(payload, ruleSet);
525
+ }
526
+
527
+ private static async validateAudiencePayload(
528
+ message: RecordsWriteMessage,
529
+ dataBytes: Uint8Array,
530
+ ): Promise<ValidatedAudiencePayload> {
473
531
  if (message.encryption !== undefined) {
474
532
  throw new DwnError(
475
533
  DwnErrorCode.EncryptionControlValidateUnexpectedRecord,
@@ -491,9 +549,15 @@ export class EncryptionControl {
491
549
  );
492
550
  }
493
551
 
494
- const { ruleSet } = await EncryptionControl.verifyRoleAudienceDefinition(tenant, tags, message, validationStateReader, 'audience');
552
+ return { payload: dataObject, tags };
553
+ }
554
+
555
+ private static async verifyAudienceSealKey(
556
+ payload: EncryptionControlAudiencePayload,
557
+ ruleSet: ProtocolRuleSet,
558
+ ): Promise<void> {
495
559
  const sealingKeyId = await Encryption.getKeyId(ruleSet.$keyAgreement!.publicKeyJwk);
496
- if (Object.is(sealingKeyId, dataObject.sealedPrivateKey.keyId)) {
560
+ if (Object.is(sealingKeyId, payload.sealedPrivateKey.keyId)) {
497
561
  return;
498
562
  }
499
563
 
@@ -2,14 +2,30 @@ import type { PaginationCursor } from '../types/query-types.js';
2
2
  import type { ProgressToken } from '../types/subscriptions.js';
3
3
  import type { ProtocolsConfigureMessage } from '../types/protocols-types.js';
4
4
  import type { RecordsReadReplyEntry } from '../types/records-types.js';
5
- import type { GenericMessageReply, MessageSubscription, QueryResultEntry } from '../types/message-types.js';
5
+ import type { GenericMessageReply, MessageSubscription, QueryResultEntry, Status } from '../types/message-types.js';
6
6
  import type { MessagesQueryReplyEntry, MessagesReadReplyEntry } from '../types/messages-types.js';
7
7
 
8
+ import { DwnError } from './dwn-error.js';
9
+
10
+ /**
11
+ * Constructs a message reply from the given error.
12
+ * When the error is a `DwnError`, the reply status carries the machine-readable `errorCode`
13
+ * (and `info` when present) in addition to the human-readable `detail` prose.
14
+ */
8
15
  export function messageReplyFromError(e: unknown, code: number): GenericMessageReply {
9
16
 
10
17
  const detail = e instanceof Error ? e.message : 'Error';
18
+ const status: Status = { code, detail };
19
+
20
+ if (e instanceof DwnError) {
21
+ status.errorCode = e.code;
22
+
23
+ if (e.info !== undefined) {
24
+ status.info = e.info;
25
+ }
26
+ }
11
27
 
12
- return { status: { code, detail } };
28
+ return { status };
13
29
  }
14
30
 
15
31
  /**