@enbox/dwn-sdk-js 0.0.7 → 0.0.8
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.
- package/dist/browser.mjs +8 -8
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/generated/precompiled-validators.js +761 -909
- package/dist/esm/generated/precompiled-validators.js.map +1 -1
- package/dist/esm/src/core/constants.js +11 -0
- package/dist/esm/src/core/constants.js.map +1 -0
- package/dist/esm/src/core/core-protocol.js +44 -0
- package/dist/esm/src/core/core-protocol.js.map +1 -0
- package/dist/esm/src/core/dwn-error.js +9 -12
- package/dist/esm/src/core/dwn-error.js.map +1 -1
- package/dist/esm/src/core/grant-authorization.js +16 -3
- package/dist/esm/src/core/grant-authorization.js.map +1 -1
- package/dist/esm/src/core/protocol-authorization-validation.js +67 -0
- package/dist/esm/src/core/protocol-authorization-validation.js.map +1 -1
- package/dist/esm/src/core/protocol-authorization.js +51 -30
- package/dist/esm/src/core/protocol-authorization.js.map +1 -1
- package/dist/esm/src/core/records-grant-authorization.js +6 -8
- package/dist/esm/src/core/records-grant-authorization.js.map +1 -1
- package/dist/esm/src/dwn.js +42 -18
- package/dist/esm/src/dwn.js.map +1 -1
- package/dist/esm/src/event-stream/event-emitter-event-log.js +204 -0
- package/dist/esm/src/event-stream/event-emitter-event-log.js.map +1 -0
- package/dist/esm/src/handlers/messages-read.js +7 -11
- package/dist/esm/src/handlers/messages-read.js.map +1 -1
- package/dist/esm/src/handlers/messages-subscribe.js +22 -24
- package/dist/esm/src/handlers/messages-subscribe.js.map +1 -1
- package/dist/esm/src/handlers/messages-sync.js +11 -15
- package/dist/esm/src/handlers/messages-sync.js.map +1 -1
- package/dist/esm/src/handlers/protocols-configure.js +37 -27
- package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
- package/dist/esm/src/handlers/protocols-query.js +7 -11
- package/dist/esm/src/handlers/protocols-query.js.map +1 -1
- package/dist/esm/src/handlers/records-count.js +10 -12
- package/dist/esm/src/handlers/records-count.js.map +1 -1
- package/dist/esm/src/handlers/records-delete.js +10 -18
- package/dist/esm/src/handlers/records-delete.js.map +1 -1
- package/dist/esm/src/handlers/records-query.js +11 -15
- package/dist/esm/src/handlers/records-query.js.map +1 -1
- package/dist/esm/src/handlers/records-read.js +31 -26
- package/dist/esm/src/handlers/records-read.js.map +1 -1
- package/dist/esm/src/handlers/records-subscribe.js +39 -26
- package/dist/esm/src/handlers/records-subscribe.js.map +1 -1
- package/dist/esm/src/handlers/records-write.js +47 -105
- package/dist/esm/src/handlers/records-write.js.map +1 -1
- package/dist/esm/src/index.js +5 -2
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/interfaces/messages-subscribe.js +1 -0
- package/dist/esm/src/interfaces/messages-subscribe.js.map +1 -1
- package/dist/esm/src/interfaces/protocols-configure.js +25 -3
- package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
- package/dist/esm/src/interfaces/records-count.js +1 -1
- package/dist/esm/src/interfaces/records-count.js.map +1 -1
- package/dist/esm/src/interfaces/records-delete.js +1 -1
- package/dist/esm/src/interfaces/records-delete.js.map +1 -1
- package/dist/esm/src/interfaces/records-query.js +1 -1
- package/dist/esm/src/interfaces/records-query.js.map +1 -1
- package/dist/esm/src/interfaces/records-read.js +1 -1
- package/dist/esm/src/interfaces/records-read.js.map +1 -1
- package/dist/esm/src/interfaces/records-subscribe.js +2 -1
- package/dist/esm/src/interfaces/records-subscribe.js.map +1 -1
- package/dist/esm/src/interfaces/records-write-signing.js +1 -12
- package/dist/esm/src/interfaces/records-write-signing.js.map +1 -1
- package/dist/esm/src/interfaces/records-write.js +22 -41
- package/dist/esm/src/interfaces/records-write.js.map +1 -1
- package/dist/esm/src/protocols/permission-grant.js +1 -1
- package/dist/esm/src/protocols/permission-grant.js.map +1 -1
- package/dist/esm/src/protocols/permission-request.js +1 -1
- package/dist/esm/src/protocols/permission-request.js.map +1 -1
- package/dist/esm/src/protocols/permissions.js +113 -5
- package/dist/esm/src/protocols/permissions.js.map +1 -1
- package/dist/esm/src/state-index/state-index-level.js +5 -7
- package/dist/esm/src/state-index/state-index-level.js.map +1 -1
- package/dist/esm/src/store/data-store-level.js +110 -33
- package/dist/esm/src/store/data-store-level.js.map +1 -1
- package/dist/esm/src/store/index-level.js +42 -32
- package/dist/esm/src/store/index-level.js.map +1 -1
- package/dist/esm/src/store/storage-controller.js +6 -6
- package/dist/esm/src/store/storage-controller.js.map +1 -1
- package/dist/esm/src/types/permission-types.js.map +1 -1
- package/dist/esm/src/types/protocols-types.js +10 -0
- package/dist/esm/src/types/protocols-types.js.map +1 -1
- package/dist/esm/src/types/records-types.js.map +1 -1
- package/dist/esm/src/utils/hd-key.js +0 -8
- package/dist/esm/src/utils/hd-key.js.map +1 -1
- package/dist/esm/src/utils/messages.js +16 -34
- package/dist/esm/src/utils/messages.js.map +1 -1
- package/dist/esm/src/utils/records.js +5 -43
- package/dist/esm/src/utils/records.js.map +1 -1
- package/dist/esm/tests/core/protocol-authorization.spec.js +2 -1
- package/dist/esm/tests/core/protocol-authorization.spec.js.map +1 -1
- package/dist/esm/tests/dwn.spec.js +32 -43
- package/dist/esm/tests/dwn.spec.js.map +1 -1
- package/dist/esm/tests/event-emitter-event-log.spec.js +305 -0
- package/dist/esm/tests/event-emitter-event-log.spec.js.map +1 -0
- package/dist/esm/tests/features/author-delegated-grant.spec.js +14 -7
- package/dist/esm/tests/features/author-delegated-grant.spec.js.map +1 -1
- package/dist/esm/tests/features/owner-delegated-grant.spec.js +9 -5
- package/dist/esm/tests/features/owner-delegated-grant.spec.js.map +1 -1
- package/dist/esm/tests/features/owner-signature.spec.js +14 -7
- package/dist/esm/tests/features/owner-signature.spec.js.map +1 -1
- package/dist/esm/tests/features/permissions.spec.js +12 -12
- package/dist/esm/tests/features/permissions.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-composition.spec.js +636 -5
- package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-create-action.spec.js +4 -4
- package/dist/esm/tests/features/protocol-create-action.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-delete-action.spec.js +7 -7
- package/dist/esm/tests/features/protocol-delete-action.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-update-action.spec.js +4 -4
- package/dist/esm/tests/features/protocol-update-action.spec.js.map +1 -1
- package/dist/esm/tests/features/records-immutable.spec.js +315 -0
- package/dist/esm/tests/features/records-immutable.spec.js.map +1 -0
- package/dist/esm/tests/features/records-prune.spec.js +4 -4
- package/dist/esm/tests/features/records-prune.spec.js.map +1 -1
- package/dist/esm/tests/features/records-record-limit.spec.js +542 -0
- package/dist/esm/tests/features/records-record-limit.spec.js.map +1 -0
- package/dist/esm/tests/features/records-tags.spec.js +16 -4
- package/dist/esm/tests/features/records-tags.spec.js.map +1 -1
- package/dist/esm/tests/features/resumable-tasks.spec.js +7 -8
- package/dist/esm/tests/features/resumable-tasks.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-read.spec.js +11 -5
- package/dist/esm/tests/handlers/messages-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-subscribe.spec.js +169 -22
- package/dist/esm/tests/handlers/messages-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-sync.spec.js +103 -21
- package/dist/esm/tests/handlers/messages-sync.spec.js.map +1 -1
- package/dist/esm/tests/handlers/protocols-configure.spec.js +5 -5
- package/dist/esm/tests/handlers/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/handlers/protocols-query.spec.js +5 -5
- package/dist/esm/tests/handlers/protocols-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-count.spec.js +9 -4
- package/dist/esm/tests/handlers/records-count.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-delete.spec.js +24 -25
- package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-query.spec.js +68 -9
- package/dist/esm/tests/handlers/records-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-read.spec.js +24 -138
- package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-subscribe.spec.js +175 -35
- package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-write.spec.js +173 -72
- package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-write.spec.js +52 -68
- package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -1
- package/dist/esm/tests/protocols/permission-grant.spec.js +6 -6
- package/dist/esm/tests/protocols/permission-grant.spec.js.map +1 -1
- package/dist/esm/tests/protocols/permission-request.spec.js +4 -4
- package/dist/esm/tests/protocols/permission-request.spec.js.map +1 -1
- package/dist/esm/tests/protocols/permissions.spec.js +4 -4
- package/dist/esm/tests/protocols/permissions.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/aggregator.spec.js +4 -4
- package/dist/esm/tests/scenarios/aggregator.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/deleted-record.spec.js +350 -5
- package/dist/esm/tests/scenarios/deleted-record.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +4 -4
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/nested-roles.spec.js +4 -4
- package/dist/esm/tests/scenarios/nested-roles.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/subscriptions.spec.js +93 -40
- package/dist/esm/tests/scenarios/subscriptions.spec.js.map +1 -1
- package/dist/esm/tests/store/data-store-level.spec.js +102 -41
- package/dist/esm/tests/store/data-store-level.spec.js.map +1 -1
- package/dist/esm/tests/test-event-stream.js +12 -13
- package/dist/esm/tests/test-event-stream.js.map +1 -1
- package/dist/esm/tests/test-suite.js +6 -4
- package/dist/esm/tests/test-suite.js.map +1 -1
- package/dist/esm/tests/utils/messages.spec.js +12 -5
- package/dist/esm/tests/utils/messages.spec.js.map +1 -1
- package/dist/esm/tests/utils/records.spec.js +8 -12
- package/dist/esm/tests/utils/records.spec.js.map +1 -1
- package/dist/esm/tests/utils/test-data-generator.js +35 -2
- package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js +37 -8
- package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js.map +1 -1
- package/dist/types/generated/precompiled-validators.d.ts +49 -40
- package/dist/types/generated/precompiled-validators.d.ts.map +1 -1
- package/dist/types/src/core/constants.d.ts +11 -0
- package/dist/types/src/core/constants.d.ts.map +1 -0
- package/dist/types/src/core/core-protocol.d.ts +89 -0
- package/dist/types/src/core/core-protocol.d.ts.map +1 -0
- package/dist/types/src/core/dwn-error.d.ts +9 -12
- package/dist/types/src/core/dwn-error.d.ts.map +1 -1
- package/dist/types/src/core/grant-authorization.d.ts +6 -2
- package/dist/types/src/core/grant-authorization.d.ts.map +1 -1
- package/dist/types/src/core/protocol-authorization-validation.d.ts +21 -0
- package/dist/types/src/core/protocol-authorization-validation.d.ts.map +1 -1
- package/dist/types/src/core/protocol-authorization.d.ts +19 -11
- package/dist/types/src/core/protocol-authorization.d.ts.map +1 -1
- package/dist/types/src/core/records-grant-authorization.d.ts.map +1 -1
- package/dist/types/src/dwn.d.ts +19 -7
- package/dist/types/src/dwn.d.ts.map +1 -1
- package/dist/types/src/event-stream/event-emitter-event-log.d.ts +50 -0
- package/dist/types/src/event-stream/event-emitter-event-log.d.ts.map +1 -0
- package/dist/types/src/handlers/messages-read.d.ts +3 -8
- package/dist/types/src/handlers/messages-read.d.ts.map +1 -1
- package/dist/types/src/handlers/messages-subscribe.d.ts +6 -10
- package/dist/types/src/handlers/messages-subscribe.d.ts.map +1 -1
- package/dist/types/src/handlers/messages-sync.d.ts +3 -8
- package/dist/types/src/handlers/messages-sync.d.ts.map +1 -1
- package/dist/types/src/handlers/protocols-configure.d.ts +3 -10
- package/dist/types/src/handlers/protocols-configure.d.ts.map +1 -1
- package/dist/types/src/handlers/protocols-query.d.ts +3 -8
- package/dist/types/src/handlers/protocols-query.d.ts.map +1 -1
- package/dist/types/src/handlers/records-count.d.ts +3 -6
- package/dist/types/src/handlers/records-count.d.ts.map +1 -1
- package/dist/types/src/handlers/records-delete.d.ts +3 -8
- package/dist/types/src/handlers/records-delete.d.ts.map +1 -1
- package/dist/types/src/handlers/records-query.d.ts +3 -8
- package/dist/types/src/handlers/records-query.d.ts.map +1 -1
- package/dist/types/src/handlers/records-read.d.ts +3 -8
- package/dist/types/src/handlers/records-read.d.ts.map +1 -1
- package/dist/types/src/handlers/records-subscribe.d.ts +8 -10
- package/dist/types/src/handlers/records-subscribe.d.ts.map +1 -1
- package/dist/types/src/handlers/records-write.d.ts +4 -25
- package/dist/types/src/handlers/records-write.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +8 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/interfaces/messages-subscribe.d.ts +5 -0
- package/dist/types/src/interfaces/messages-subscribe.d.ts.map +1 -1
- package/dist/types/src/interfaces/protocols-configure.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-subscribe.d.ts +5 -0
- package/dist/types/src/interfaces/records-subscribe.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-write-signing.d.ts +3 -4
- package/dist/types/src/interfaces/records-write-signing.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-write.d.ts +5 -11
- package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
- package/dist/types/src/protocols/permission-grant.d.ts +1 -1
- package/dist/types/src/protocols/permission-grant.d.ts.map +1 -1
- package/dist/types/src/protocols/permission-request.d.ts +1 -1
- package/dist/types/src/protocols/permission-request.d.ts.map +1 -1
- package/dist/types/src/protocols/permissions.d.ts +40 -3
- package/dist/types/src/protocols/permissions.d.ts.map +1 -1
- package/dist/types/src/state-index/state-index-level.d.ts.map +1 -1
- package/dist/types/src/store/data-store-level.d.ts +20 -4
- package/dist/types/src/store/data-store-level.d.ts.map +1 -1
- package/dist/types/src/store/index-level.d.ts +4 -0
- package/dist/types/src/store/index-level.d.ts.map +1 -1
- package/dist/types/src/store/storage-controller.d.ts +4 -4
- package/dist/types/src/store/storage-controller.d.ts.map +1 -1
- package/dist/types/src/types/message-types.d.ts +3 -3
- package/dist/types/src/types/message-types.d.ts.map +1 -1
- package/dist/types/src/types/messages-types.d.ts +12 -3
- package/dist/types/src/types/messages-types.d.ts.map +1 -1
- package/dist/types/src/types/method-handler.d.ts +24 -3
- package/dist/types/src/types/method-handler.d.ts.map +1 -1
- package/dist/types/src/types/permission-types.d.ts +7 -0
- package/dist/types/src/types/permission-types.d.ts.map +1 -1
- package/dist/types/src/types/protocols-types.d.ts +41 -1
- package/dist/types/src/types/protocols-types.d.ts.map +1 -1
- package/dist/types/src/types/records-types.d.ts +16 -6
- package/dist/types/src/types/records-types.d.ts.map +1 -1
- package/dist/types/src/types/subscriptions.d.ts +151 -13
- package/dist/types/src/types/subscriptions.d.ts.map +1 -1
- package/dist/types/src/utils/hd-key.d.ts +1 -9
- package/dist/types/src/utils/hd-key.d.ts.map +1 -1
- package/dist/types/src/utils/messages.d.ts +7 -5
- package/dist/types/src/utils/messages.d.ts.map +1 -1
- package/dist/types/src/utils/records.d.ts +1 -11
- package/dist/types/src/utils/records.d.ts.map +1 -1
- package/dist/types/tests/dwn.spec.d.ts.map +1 -1
- package/dist/types/tests/event-emitter-event-log.spec.d.ts +2 -0
- package/dist/types/tests/event-emitter-event-log.spec.d.ts.map +1 -0
- package/dist/types/tests/features/author-delegated-grant.spec.d.ts.map +1 -1
- package/dist/types/tests/features/owner-delegated-grant.spec.d.ts.map +1 -1
- package/dist/types/tests/features/owner-signature.spec.d.ts.map +1 -1
- package/dist/types/tests/features/protocol-composition.spec.d.ts.map +1 -1
- package/dist/types/tests/features/records-immutable.spec.d.ts +2 -0
- package/dist/types/tests/features/records-immutable.spec.d.ts.map +1 -0
- package/dist/types/tests/features/records-record-limit.spec.d.ts +2 -0
- package/dist/types/tests/features/records-record-limit.spec.d.ts.map +1 -0
- package/dist/types/tests/features/records-tags.spec.d.ts.map +1 -1
- package/dist/types/tests/features/resumable-tasks.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/messages-read.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/messages-subscribe.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/messages-sync.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-count.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-delete.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-query.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-read.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-subscribe.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-write.spec.d.ts.map +1 -1
- package/dist/types/tests/scenarios/deleted-record.spec.d.ts.map +1 -1
- package/dist/types/tests/scenarios/subscriptions.spec.d.ts.map +1 -1
- package/dist/types/tests/test-event-stream.d.ts +11 -12
- package/dist/types/tests/test-event-stream.d.ts.map +1 -1
- package/dist/types/tests/test-suite.d.ts +2 -2
- package/dist/types/tests/test-suite.d.ts.map +1 -1
- package/dist/types/tests/utils/test-data-generator.d.ts +18 -0
- package/dist/types/tests/utils/test-data-generator.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/core/constants.ts +11 -0
- package/src/core/core-protocol.ts +129 -0
- package/src/core/dwn-error.ts +15 -12
- package/src/core/grant-authorization.ts +20 -3
- package/src/core/protocol-authorization-validation.ts +96 -0
- package/src/core/protocol-authorization.ts +67 -23
- package/src/core/records-grant-authorization.ts +6 -8
- package/src/dwn.ts +58 -73
- package/src/event-stream/event-emitter-event-log.ts +283 -0
- package/src/handlers/messages-read.ts +8 -9
- package/src/handlers/messages-subscribe.ts +24 -28
- package/src/handlers/messages-sync.ts +10 -16
- package/src/handlers/protocols-configure.ts +47 -32
- package/src/handlers/protocols-query.ts +6 -9
- package/src/handlers/records-count.ts +11 -10
- package/src/handlers/records-delete.ts +12 -21
- package/src/handlers/records-query.ts +12 -12
- package/src/handlers/records-read.ts +34 -22
- package/src/handlers/records-subscribe.ts +47 -26
- package/src/handlers/records-write.ts +47 -120
- package/src/index.ts +9 -5
- package/src/interfaces/messages-subscribe.ts +7 -1
- package/src/interfaces/protocols-configure.ts +40 -3
- package/src/interfaces/records-count.ts +1 -1
- package/src/interfaces/records-delete.ts +1 -1
- package/src/interfaces/records-query.ts +1 -1
- package/src/interfaces/records-read.ts +1 -1
- package/src/interfaces/records-subscribe.ts +8 -1
- package/src/interfaces/records-write-signing.ts +2 -22
- package/src/interfaces/records-write.ts +25 -48
- package/src/protocols/permission-grant.ts +1 -1
- package/src/protocols/permission-request.ts +1 -1
- package/src/protocols/permissions.ts +148 -6
- package/src/state-index/state-index-level.ts +5 -7
- package/src/store/data-store-level.ts +124 -34
- package/src/store/index-level.ts +44 -35
- package/src/store/storage-controller.ts +11 -11
- package/src/types/message-types.ts +3 -3
- package/src/types/messages-types.ts +12 -3
- package/src/types/method-handler.ts +26 -4
- package/src/types/mitt.d.ts +28 -0
- package/src/types/permission-types.ts +7 -0
- package/src/types/protocols-types.ts +46 -0
- package/src/types/records-types.ts +16 -6
- package/src/types/subscriptions.ts +178 -14
- package/src/utils/hd-key.ts +0 -9
- package/src/utils/messages.ts +17 -37
- package/src/utils/records.ts +7 -58
- package/dist/esm/src/event-stream/event-emitter-stream.js +0 -46
- package/dist/esm/src/event-stream/event-emitter-stream.js.map +0 -1
- package/dist/esm/tests/event-stream/event-emitter-stream.spec.js +0 -68
- package/dist/esm/tests/event-stream/event-emitter-stream.spec.js.map +0 -1
- package/dist/esm/tests/event-stream/event-stream.spec.js +0 -114
- package/dist/esm/tests/event-stream/event-stream.spec.js.map +0 -1
- package/dist/types/src/event-stream/event-emitter-stream.d.ts +0 -23
- package/dist/types/src/event-stream/event-emitter-stream.d.ts.map +0 -1
- package/dist/types/tests/event-stream/event-emitter-stream.spec.d.ts +0 -2
- package/dist/types/tests/event-stream/event-emitter-stream.spec.d.ts.map +0 -1
- package/dist/types/tests/event-stream/event-stream.spec.d.ts +0 -2
- package/dist/types/tests/event-stream/event-stream.spec.d.ts.map +0 -1
- package/src/event-stream/event-emitter-stream.ts +0 -69
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-cutting constants that are shared between modules which cannot directly
|
|
3
|
+
* import each other without creating circular dependencies.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Well-known protocol path for permission grant revocation records.
|
|
7
|
+
* Defined here (rather than on `PermissionsProtocol`) to avoid circular
|
|
8
|
+
* dependencies between `grant-authorization.ts` and `protocols/permissions.ts`.
|
|
9
|
+
*/
|
|
10
|
+
export const PERMISSIONS_REVOCATION_PATH = 'grant/revocation';
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/core/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry of core protocols. Owned by a `Dwn` instance (not a static singleton)
|
|
3
|
+
* so that each DWN — including those in tests — gets an isolated registry.
|
|
4
|
+
*/
|
|
5
|
+
export class CoreProtocolRegistry {
|
|
6
|
+
_protocols = new Map();
|
|
7
|
+
/** Register a core protocol. */
|
|
8
|
+
register(protocol) {
|
|
9
|
+
this._protocols.set(protocol.uri, protocol);
|
|
10
|
+
}
|
|
11
|
+
/** Get a core protocol by URI, or `undefined` if not registered. */
|
|
12
|
+
get(uri) {
|
|
13
|
+
return this._protocols.get(uri);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get the protocol definition for a core protocol, or `undefined`.
|
|
17
|
+
* Used by `fetchProtocolDefinition()` to bypass the message store for core protocols.
|
|
18
|
+
*/
|
|
19
|
+
getDefinition(uri) {
|
|
20
|
+
return this._protocols.get(uri)?.definition;
|
|
21
|
+
}
|
|
22
|
+
/** Check whether a URI is a registered core protocol. */
|
|
23
|
+
has(uri) {
|
|
24
|
+
return this._protocols.has(uri);
|
|
25
|
+
}
|
|
26
|
+
/** Get all registered core protocols. */
|
|
27
|
+
all() {
|
|
28
|
+
return [...this._protocols.values()];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Delegate error code mapping to all registered core protocols.
|
|
32
|
+
* Returns the first non-`undefined` status code, or `undefined` if no protocol claims the error.
|
|
33
|
+
*/
|
|
34
|
+
mapErrorToStatusCode(errorCode) {
|
|
35
|
+
for (const protocol of this._protocols.values()) {
|
|
36
|
+
const status = protocol.mapErrorToStatusCode?.(errorCode);
|
|
37
|
+
if (status !== undefined) {
|
|
38
|
+
return status;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=core-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-protocol.js","sourceRoot":"","sources":["../../../../src/core/core-protocol.ts"],"names":[],"mappings":"AAgFA;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IACd,UAAU,GAA8B,IAAI,GAAG,EAAE,CAAC;IAEnE,gCAAgC;IACzB,QAAQ,CAAC,QAAsB;QACpC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED,oEAAoE;IAC7D,GAAG,CAAC,GAAW;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED;;;OAGG;IACI,aAAa,CAAC,GAAW;QAC9B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC;IAC9C,CAAC;IAED,yDAAyD;IAClD,GAAG,CAAC,GAAW;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,yCAAyC;IAClC,GAAG;QACR,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,oBAAoB,CAAC,SAAiB;QAC3C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;YAChD,MAAM,MAAM,GAAG,QAAQ,CAAC,oBAAoB,EAAE,CAAC,SAAS,CAAC,CAAC;YAC1D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -21,10 +21,10 @@ export var DwnErrorCode;
|
|
|
21
21
|
DwnErrorCode["ComputeCidCodecNotSupported"] = "ComputeCidCodecNotSupported";
|
|
22
22
|
DwnErrorCode["ComputeCidMultihashNotSupported"] = "ComputeCidMultihashNotSupported";
|
|
23
23
|
DwnErrorCode["Ed25519InvalidJwk"] = "Ed25519InvalidJwk";
|
|
24
|
-
DwnErrorCode["
|
|
24
|
+
DwnErrorCode["EventLogNotOpenError"] = "EventLogNotOpenError";
|
|
25
25
|
DwnErrorCode["MessagesGrantAuthorizationMismatchedProtocol"] = "EventsGrantAuthorizationMismatchedProtocol";
|
|
26
26
|
DwnErrorCode["MessagesSubscribeAuthorizationFailed"] = "MessagesSubscribeAuthorizationFailed";
|
|
27
|
-
DwnErrorCode["
|
|
27
|
+
DwnErrorCode["MessagesSubscribeEventLogUnimplemented"] = "MessagesSubscribeEventLogUnimplemented";
|
|
28
28
|
DwnErrorCode["GeneralJwsVerifierGetPublicKeyNotFound"] = "GeneralJwsVerifierGetPublicKeyNotFound";
|
|
29
29
|
DwnErrorCode["GeneralJwsVerifierInvalidSignature"] = "GeneralJwsVerifierInvalidSignature";
|
|
30
30
|
DwnErrorCode["GeneralJwsVerifierMissingAlg"] = "GeneralJwsVerifierMissingAlg";
|
|
@@ -79,11 +79,14 @@ export var DwnErrorCode;
|
|
|
79
79
|
DwnErrorCode["ProtocolAuthorizationIncorrectProtocolPath"] = "ProtocolAuthorizationIncorrectProtocolPath";
|
|
80
80
|
DwnErrorCode["ProtocolAuthorizationDuplicateRoleRecipient"] = "ProtocolAuthorizationDuplicateRoleRecipient";
|
|
81
81
|
DwnErrorCode["ProtocolAuthorizationEncryptionRequired"] = "ProtocolAuthorizationEncryptionRequired";
|
|
82
|
+
DwnErrorCode["ProtocolAuthorizationImmutableRecord"] = "ProtocolAuthorizationImmutableRecord";
|
|
82
83
|
DwnErrorCode["ProtocolAuthorizationInvalidSchema"] = "ProtocolAuthorizationInvalidSchema";
|
|
83
84
|
DwnErrorCode["ProtocolAuthorizationInvalidType"] = "ProtocolAuthorizationInvalidType";
|
|
84
85
|
DwnErrorCode["ProtocolAuthorizationMatchingRoleRecordNotFound"] = "ProtocolAuthorizationMatchingRoleRecordNotFound";
|
|
85
86
|
DwnErrorCode["ProtocolAuthorizationMaxSizeInvalid"] = "ProtocolAuthorizationMaxSizeInvalid";
|
|
86
87
|
DwnErrorCode["ProtocolAuthorizationMinSizeInvalid"] = "ProtocolAuthorizationMinSizeInvalid";
|
|
88
|
+
DwnErrorCode["ProtocolAuthorizationRecordLimitExceeded"] = "ProtocolAuthorizationRecordLimitExceeded";
|
|
89
|
+
DwnErrorCode["ProtocolAuthorizationRecordLimitStrategyNotImplemented"] = "ProtocolAuthorizationRecordLimitStrategyNotImplemented";
|
|
87
90
|
DwnErrorCode["ProtocolAuthorizationMissingContextId"] = "ProtocolAuthorizationMissingContextId";
|
|
88
91
|
DwnErrorCode["ProtocolAuthorizationMissingRuleSet"] = "ProtocolAuthorizationMissingRuleSet";
|
|
89
92
|
DwnErrorCode["ProtocolAuthorizationParentlessIncorrectProtocolPath"] = "ProtocolAuthorizationParentlessIncorrectProtocolPath";
|
|
@@ -100,6 +103,8 @@ export var DwnErrorCode;
|
|
|
100
103
|
DwnErrorCode["ProtocolsConfigureInvalidRefNodeHasDirectives"] = "ProtocolsConfigureInvalidRefNodeHasDirectives";
|
|
101
104
|
DwnErrorCode["ProtocolsConfigureInvalidRefNotAtRoot"] = "ProtocolsConfigureInvalidRefNotAtRoot";
|
|
102
105
|
DwnErrorCode["ProtocolsConfigureInvalidRefProtocolPath"] = "ProtocolsConfigureInvalidRefProtocolPath";
|
|
106
|
+
DwnErrorCode["ProtocolsConfigureInvalidRefTargetThroughRef"] = "ProtocolsConfigureInvalidRefTargetThroughRef";
|
|
107
|
+
DwnErrorCode["ProtocolsConfigureInvalidRecordLimit"] = "ProtocolsConfigureInvalidRecordLimit";
|
|
103
108
|
DwnErrorCode["ProtocolsConfigureInvalidSize"] = "ProtocolsConfigureInvalidSize";
|
|
104
109
|
DwnErrorCode["ProtocolsConfigureInvalidActionMissingOf"] = "ProtocolsConfigureInvalidActionMissingOf";
|
|
105
110
|
DwnErrorCode["ProtocolsConfigureInvalidActionOfNotAnAncestor"] = "ProtocolsConfigureInvalidActionOfNotAnAncestor";
|
|
@@ -126,7 +131,6 @@ export var DwnErrorCode;
|
|
|
126
131
|
DwnErrorCode["RecordsAuthorDelegatedGrantNotADelegatedGrant"] = "RecordsAuthorDelegatedGrantNotADelegatedGrant";
|
|
127
132
|
DwnErrorCode["RecordsDecryptNoMatchingKeyEncryptedFound"] = "RecordsDecryptNoMatchingKeyEncryptedFound";
|
|
128
133
|
DwnErrorCode["RecordsCountFilterMissingRequiredProperties"] = "RecordsCountFilterMissingRequiredProperties";
|
|
129
|
-
DwnErrorCode["RecordsDeleteAuthorizationFailed"] = "RecordsDeleteAuthorizationFailed";
|
|
130
134
|
DwnErrorCode["RecordsQueryCreateFilterPublishedSortInvalid"] = "RecordsQueryCreateFilterPublishedSortInvalid";
|
|
131
135
|
DwnErrorCode["RecordsQueryParseFilterPublishedSortInvalid"] = "RecordsQueryParseFilterPublishedSortInvalid";
|
|
132
136
|
DwnErrorCode["RecordsGrantAuthorizationConditionPublicationProhibited"] = "RecordsGrantAuthorizationConditionPublicationProhibited";
|
|
@@ -142,23 +146,18 @@ export var DwnErrorCode;
|
|
|
142
146
|
DwnErrorCode["RecordsOwnerDelegatedGrantCidMismatch"] = "RecordsOwnerDelegatedGrantCidMismatch";
|
|
143
147
|
DwnErrorCode["RecordsOwnerDelegatedGrantGrantedToAndOwnerSignatureMismatch"] = "RecordsOwnerDelegatedGrantGrantedToAndOwnerSignatureMismatch";
|
|
144
148
|
DwnErrorCode["RecordsOwnerDelegatedGrantNotADelegatedGrant"] = "RecordsOwnerDelegatedGrantNotADelegatedGrant";
|
|
145
|
-
DwnErrorCode["RecordsProtocolContextDerivationSchemeMissingContextId"] = "RecordsProtocolContextDerivationSchemeMissingContextId";
|
|
146
|
-
DwnErrorCode["RecordsProtocolPathDerivationSchemeMissingProtocol"] = "RecordsProtocolPathDerivationSchemeMissingProtocol";
|
|
147
149
|
DwnErrorCode["RecordsQueryFilterMissingRequiredProperties"] = "RecordsQueryFilterMissingRequiredProperties";
|
|
148
|
-
DwnErrorCode["RecordsReadAuthorizationFailed"] = "RecordsReadAuthorizationFailed";
|
|
149
150
|
DwnErrorCode["RecordsReadCreateFilterPublishedSortInvalid"] = "RecordsReadCreateFilterPublishedSortInvalid";
|
|
150
151
|
DwnErrorCode["RecordsReadParseFilterPublishedSortInvalid"] = "RecordsReadParseFilterPublishedSortInvalid";
|
|
151
|
-
DwnErrorCode["
|
|
152
|
+
DwnErrorCode["RecordsSubscribeEventLogUnimplemented"] = "RecordsSubscribeEventLogUnimplemented";
|
|
152
153
|
DwnErrorCode["RecordsSubscribeFilterMissingRequiredProperties"] = "RecordsSubscribeFilterMissingRequiredProperties";
|
|
153
|
-
DwnErrorCode["RecordsSchemasDerivationSchemeMissingSchema"] = "RecordsSchemasDerivationSchemeMissingSchema";
|
|
154
154
|
DwnErrorCode["RecordsWriteAttestationIntegrityMoreThanOneSignature"] = "RecordsWriteAttestationIntegrityMoreThanOneSignature";
|
|
155
155
|
DwnErrorCode["RecordsWriteAttestationIntegrityDescriptorCidMismatch"] = "RecordsWriteAttestationIntegrityDescriptorCidMismatch";
|
|
156
156
|
DwnErrorCode["RecordsWriteAttestationIntegrityInvalidPayloadProperty"] = "RecordsWriteAttestationIntegrityInvalidPayloadProperty";
|
|
157
|
-
DwnErrorCode["RecordsWriteAuthorizationFailed"] = "RecordsWriteAuthorizationFailed";
|
|
158
157
|
DwnErrorCode["RecordsWriteCreateMissingSigner"] = "RecordsWriteCreateMissingSigner";
|
|
159
158
|
DwnErrorCode["RecordsWriteCreateDataAndDataCidMutuallyExclusive"] = "RecordsWriteCreateDataAndDataCidMutuallyExclusive";
|
|
160
159
|
DwnErrorCode["RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive"] = "RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive";
|
|
161
|
-
DwnErrorCode["
|
|
160
|
+
DwnErrorCode["RecordsWriteCreateMissingProtocol"] = "RecordsWriteCreateMissingProtocol";
|
|
162
161
|
DwnErrorCode["RecordsWriteDataCidMismatch"] = "RecordsWriteDataCidMismatch";
|
|
163
162
|
DwnErrorCode["RecordsWriteDataSizeMismatch"] = "RecordsWriteDataSizeMismatch";
|
|
164
163
|
DwnErrorCode["RecordsWriteGetEntryIdUndefinedAuthor"] = "RecordsWriteGetEntryIdUndefinedAuthor";
|
|
@@ -169,8 +168,6 @@ export var DwnErrorCode;
|
|
|
169
168
|
DwnErrorCode["RecordsWriteMissingDataInPrevious"] = "RecordsWriteMissingDataInPrevious";
|
|
170
169
|
DwnErrorCode["RecordsWriteMissingEncodedDataInPrevious"] = "RecordsWriteMissingEncodedDataInPrevious";
|
|
171
170
|
DwnErrorCode["RecordsWriteMissingEncryption"] = "RecordsWriteMissingEncryption";
|
|
172
|
-
DwnErrorCode["RecordsWriteMissingProtocol"] = "RecordsWriteMissingProtocol";
|
|
173
|
-
DwnErrorCode["RecordsWriteMissingSchema"] = "RecordsWriteMissingSchema";
|
|
174
171
|
DwnErrorCode["RecordsWriteNotAllowedAfterDelete"] = "RecordsWriteNotAllowedAfterDelete";
|
|
175
172
|
DwnErrorCode["RecordsWriteOwnerAndTenantMismatch"] = "RecordsWriteOwnerAndTenantMismatch";
|
|
176
173
|
DwnErrorCode["RecordsWriteSignAsOwnerDelegateUnknownAuthor"] = "RecordsWriteSignAsOwnerDelegateUnknownAuthor";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dwn-error.js","sourceRoot":"","sources":["../../../../src/core/dwn-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACb;IAApB,YAAoB,IAAY,EAAE,OAAe;QAC/C,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QADX,SAAI,GAAJ,IAAI,CAAQ;QAG9B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"dwn-error.js","sourceRoot":"","sources":["../../../../src/core/dwn-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACb;IAApB,YAAoB,IAAY,EAAE,OAAe;QAC/C,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QADX,SAAI,GAAJ,IAAI,CAAQ;QAG9B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,YAsLX;AAtLD,WAAY,YAAY;IACtB,iEAAiD,CAAA;IACjD,uFAAuE,CAAA;IACvE,iHAAiG,CAAA;IACjG,mFAAmE,CAAA;IACnE,2EAA2D,CAAA;IAC3D,mFAAmE,CAAA;IACnE,uDAAuC,CAAA;IACvC,6DAA6C,CAAA;IAC7C,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G,mGAAmF,CAAA;IACnF,yGAAyF,CAAA;IACzF,qHAAqG,CAAA;IACrG,+FAA+E,CAAA;IAC/E,6IAA6H,CAAA;IAC7H,6GAA6F,CAAA;IAE7F,2GAA2F,CAAA;IAE3F,2GAA2F,CAAA;IAC3F,yGAAyF,CAAA;IACzF,+FAA+E,CAAA;IAC/E,mHAAmG,CAAA;IAEnG,6HAA6G,CAAA;IAC7G,+HAA+G,CAAA;IAC/G,iIAAiH,CAAA;IAEjH,mFAAmE,CAAA;IACnE,uHAAuG,CAAA;IACvG,+HAA+G,CAAA;IAC/G,uFAAuE,CAAA;IACvE,2EAA2D,CAAA;IAC3D,6EAA6D,CAAA;IAC7D,+FAA+E,CAAA;IAC/E,qGAAqF,CAAA;IACrF,2FAA2E,CAAA;IAC3E,6FAA6E,CAAA;IAC7E,uEAAuD,CAAA;IACvD,uFAAuE,CAAA;IACvE,qGAAqF,CAAA;IACrF,+EAA+D,CAAA;IAE/D,uFAAuE,CAAA;IACvE,yFAAyE,CAAA;IACzE,6GAA6F,CAAA;IAC7F,6FAA6E,CAAA;IAC7E,qHAAqG,CAAA;IACrG,iHAAiG,CAAA;IACjG,uJAAuI,CAAA;IACvI,qHAAqG,CAAA;IACrG,yHAAyG,CAAA;IACzG,uHAAuG,CAAA;IACvG,2GAA2F,CAAA;IAC3F,iEAAiD,CAAA;IACjD,+EAA+D,CAAA;IAC/D,6GAA6F,CAAA;IAC7F,6DAA6C,CAAA;IAC7C,6DAA6C,CAAA;IAC7C,qDAAqC,CAAA;IACrC,qEAAqD,CAAA;IACrD,yEAAyD,CAAA;IACzD,iEAAiD,CAAA;IACjD,mFAAmE,CAAA;AACrE,CAAC,EAtLW,YAAY,KAAZ,YAAY,QAsLvB;AAAA,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Message } from './message.js';
|
|
2
|
+
import { PERMISSIONS_REVOCATION_PATH } from './constants.js';
|
|
2
3
|
import { DwnError, DwnErrorCode } from './dwn-error.js';
|
|
4
|
+
import { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
3
5
|
export class GrantAuthorization {
|
|
4
6
|
/**
|
|
5
7
|
* Performs base permissions-grant-based authorization against the given message:
|
|
@@ -56,7 +58,7 @@ export class GrantAuthorization {
|
|
|
56
58
|
// Check if grant has been revoked
|
|
57
59
|
const query = {
|
|
58
60
|
parentId: permissionGrant.id,
|
|
59
|
-
protocolPath:
|
|
61
|
+
protocolPath: PERMISSIONS_REVOCATION_PATH,
|
|
60
62
|
isLatestBaseState: true
|
|
61
63
|
};
|
|
62
64
|
const { messages: revokes } = await messageStore.query(grantedFor, [query]);
|
|
@@ -66,14 +68,25 @@ export class GrantAuthorization {
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
69
|
-
* Verify that the `interface` and `method` grant scopes match the incoming message
|
|
70
|
-
*
|
|
71
|
+
* Verify that the `interface` and `method` grant scopes match the incoming message.
|
|
72
|
+
*
|
|
73
|
+
* For the Messages interface, a `Read` scope is treated as a unified scope that also authorizes
|
|
74
|
+
* `Subscribe` and `Sync` operations. This mirrors how protocol `$actions` treats `read` as a
|
|
75
|
+
* unified action covering read, query, subscribe, and count.
|
|
76
|
+
*
|
|
71
77
|
* @throws {DwnError} if the `interface` and `method` of the incoming message do not match the scope of the permission grant.
|
|
72
78
|
*/
|
|
73
79
|
static async verifyGrantScopeInterfaceAndMethod(dwnInterface, dwnMethod, permissionGrant) {
|
|
74
80
|
if (dwnInterface !== permissionGrant.scope.interface) {
|
|
75
81
|
throw new DwnError(DwnErrorCode.GrantAuthorizationInterfaceMismatch, `DWN Interface of incoming message is outside the scope of permission grant with ID ${permissionGrant.id}`);
|
|
76
82
|
}
|
|
83
|
+
// For the Messages interface, a `Read` scope is a unified scope that also covers `Subscribe` and `Sync`.
|
|
84
|
+
if (dwnInterface === DwnInterfaceName.Messages && permissionGrant.scope.method === DwnMethodName.Read) {
|
|
85
|
+
const allowedMethods = [DwnMethodName.Read, DwnMethodName.Subscribe, DwnMethodName.Sync];
|
|
86
|
+
if (!allowedMethods.includes(dwnMethod)) {
|
|
87
|
+
throw new DwnError(DwnErrorCode.GrantAuthorizationMethodMismatch, `DWN Method of incoming message is outside the scope of permission grant with ID ${permissionGrant.id}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
77
90
|
else if (dwnMethod !== permissionGrant.scope.method) {
|
|
78
91
|
throw new DwnError(DwnErrorCode.GrantAuthorizationMethodMismatch, `DWN Method of incoming message is outside the scope of permission grant with ID ${permissionGrant.id}`);
|
|
79
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant-authorization.js","sourceRoot":"","sources":["../../../../src/core/grant-authorization.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"grant-authorization.js","sourceRoot":"","sources":["../../../../src/core/grant-authorization.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEnF,MAAM,OAAO,kBAAkB;IAE7B;;;;;;;;;;OAUG;IACI,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,KAMvC;QACD,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;QAEnG,MAAM,yBAAyB,GAAG,eAAe,CAAC,UAAU,CAAC;QAE7D,kBAAkB,CAAC,+BAA+B,CAAC,eAAe,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;QAE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CAAC,gCAAgC,EAC7C,mFAAmF,eAAe,CAAC,EAAE,EAAE,CACxG,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,IAAI,SAAS,KAAK,eAAe,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACtD,MAAM,IAAI,QAAQ,CAChB,YAAY,CAAC,gCAAgC,EAC7C,mFAAmF,eAAe,CAAC,EAAE,EAAE,CACxG,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProtocolRecordLimitStrategy } from '../types/protocols-types.js';
|
|
1
2
|
import Ajv from 'ajv/dist/2020.js';
|
|
2
3
|
import { FilterUtility } from '../utils/filter.js';
|
|
3
4
|
import { Records } from '../utils/records.js';
|
|
@@ -251,4 +252,70 @@ export async function verifyAsRoleRecordIfNeeded(tenant, incomingMessage, ruleSe
|
|
|
251
252
|
throw new DwnError(DwnErrorCode.ProtocolAuthorizationDuplicateRoleRecipient, `DID '${recipient}' is already recipient of a role record at protocol path '${protocolPath} under the parent context ${parentContextId}.`);
|
|
252
253
|
}
|
|
253
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Verifies that a new record creation does not exceed the `$recordLimit` defined in the rule set.
|
|
257
|
+
*
|
|
258
|
+
* This check only applies to initial writes (new records). Updates to existing records are not counted.
|
|
259
|
+
* The count is scoped to the same `protocol + protocolPath` within the parent context:
|
|
260
|
+
* - For root-level records: counted across the entire protocol for the tenant.
|
|
261
|
+
* - For nested records: counted within the parent record's context.
|
|
262
|
+
*
|
|
263
|
+
* @throws {DwnError} with `ProtocolAuthorizationRecordLimitExceeded` if the limit is reached and strategy is `reject`.
|
|
264
|
+
* @throws {DwnError} with `ProtocolAuthorizationRecordLimitStrategyNotImplemented` if strategy is not yet implemented.
|
|
265
|
+
*/
|
|
266
|
+
export async function verifyRecordLimit(tenant, incomingMessage, ruleSet, messageStore) {
|
|
267
|
+
if (ruleSet.$recordLimit === undefined) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
// Only enforce on initial writes — updates to existing records do not count as new records.
|
|
271
|
+
const isInitialWrite = await incomingMessage.isInitialWrite();
|
|
272
|
+
if (!isInitialWrite) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const { max, strategy } = ruleSet.$recordLimit;
|
|
276
|
+
// Build a filter to count existing records at the same protocol path and parent context.
|
|
277
|
+
const protocolPath = incomingMessage.message.descriptor.protocolPath;
|
|
278
|
+
const filter = {
|
|
279
|
+
interface: DwnInterfaceName.Records,
|
|
280
|
+
method: DwnMethodName.Write,
|
|
281
|
+
isLatestBaseState: true,
|
|
282
|
+
protocol: incomingMessage.message.descriptor.protocol,
|
|
283
|
+
protocolPath,
|
|
284
|
+
};
|
|
285
|
+
// Scope by parent context for nested records.
|
|
286
|
+
const parentContextId = Records.getParentContextFromOfContextId(incomingMessage.message.contextId);
|
|
287
|
+
if (parentContextId !== '') {
|
|
288
|
+
const prefixFilter = FilterUtility.constructPrefixFilterAsRangeFilter(parentContextId);
|
|
289
|
+
filter.contextId = prefixFilter;
|
|
290
|
+
}
|
|
291
|
+
const existingCount = await messageStore.count(tenant, [filter]);
|
|
292
|
+
if (existingCount >= max) {
|
|
293
|
+
if (strategy === ProtocolRecordLimitStrategy.Reject) {
|
|
294
|
+
throw new DwnError(DwnErrorCode.ProtocolAuthorizationRecordLimitExceeded, `record limit of ${max} reached at protocol path '${protocolPath}'` +
|
|
295
|
+
`${parentContextId !== '' ? ` under parent context '${parentContextId}'` : ''}` +
|
|
296
|
+
`: new records are rejected until existing records are deleted.`);
|
|
297
|
+
}
|
|
298
|
+
// Future strategies (e.g. purgeOldest) will be implemented here.
|
|
299
|
+
// For now, any non-reject strategy that somehow passes schema validation is rejected.
|
|
300
|
+
throw new DwnError(DwnErrorCode.ProtocolAuthorizationRecordLimitStrategyNotImplemented, `record limit strategy '${strategy}' is not yet implemented.`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Verifies that an update is not attempted on a record whose protocol path has `$immutable: true`.
|
|
305
|
+
*
|
|
306
|
+
* Only non-initial writes (updates) are rejected — initial writes are always allowed.
|
|
307
|
+
* `RecordsDelete` is not affected by this check; immutability prevents data mutation, not removal.
|
|
308
|
+
*
|
|
309
|
+
* @throws {DwnError} with `ProtocolAuthorizationImmutableRecord` if an update is attempted on an immutable record.
|
|
310
|
+
*/
|
|
311
|
+
export async function verifyImmutability(incomingMessage, ruleSet) {
|
|
312
|
+
if (ruleSet.$immutable !== true) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const isInitialWrite = await incomingMessage.isInitialWrite();
|
|
316
|
+
if (isInitialWrite) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
throw new DwnError(DwnErrorCode.ProtocolAuthorizationImmutableRecord, `record at protocol path '${incomingMessage.message.descriptor.protocolPath}' is immutable: updates are not allowed.`);
|
|
320
|
+
}
|
|
254
321
|
//# sourceMappingURL=protocol-authorization-validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-authorization-validation.js","sourceRoot":"","sources":["../../../../src/core/protocol-authorization-validation.ts"],"names":[],"mappings":"AAOA,OAAO,GAAG,MAAM,kBAAkB,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAI3E;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,MAAc,EACd,cAA4B,EAC5B,YAA0B,EAC1B,uBAAkD,EAClD,kBAA2B;IAE3B,MAAM,oBAAoB,GA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mEAAmE;IACnE,IAAI,eAAe,KAAK,EAAE,EAAE,CAAC;QAC3B,MAAM,YAAY,GAAG,aAAa,CAAC,kCAAkC,CAAC,eAAe,CAAC,CAAC;QACvF,MAAM,CAAC,SAAS,GAAG,YAAY,CAAC;IAClC,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAClF,MAAM,eAAe,GAAG,gBAAyC,CAAC;IAClE,MAAM,qCAAqC,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,mBAAwC,EAAW,EAAE,CACzH,mBAAmB,CAAC,QAAQ,KAAK,oBAAoB,CAAC,OAAO,CAAC,QAAQ,CACvE,CAAC;IACF,IAAI,qCAAqC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,QAAQ,CAChB,YAAY,CAAC,2CAA2C,EACxD,QAAQ,SAAS,6DAA6D,YAAY,6BAA6B,eAAe,GAAG,CAC1I,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"protocol-authorization-validation.js","sourceRoot":"","sources":["../../../../src/core/protocol-authorization-validation.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAI1E,OAAO,GAAG,MAAM,kBAAkB,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAI3E;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,C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ChC,OAAO;IACT,CAAC;IAED,MAAM,cAAc,GAAG,MAAM,eAAe,CAAC,cAAc,EAAE,CAAC;IAC9D,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO;IACT,CAAC;IAED,MAAM,IAAI,QAAQ,CAChB,YAAY,CAAC,oCAAoC,EACjD,4BAA4B,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,0CAA0C,CACtH,CAAC;AACJ,CAAC"}
|
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import { getRuleSetAtPath } from '../utils/protocols.js';
|
|
2
|
-
import { PermissionsProtocol } from '../protocols/permissions.js';
|
|
3
2
|
import { SortDirection } from '../types/query-types.js';
|
|
4
3
|
import { DwnError, DwnErrorCode } from './dwn-error.js';
|
|
5
4
|
import { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
6
|
-
import { authorizeAgainstAllowedActions,
|
|
5
|
+
import { authorizeAgainstAllowedActions, verifyInvokedRole } from './protocol-authorization-action.js';
|
|
7
6
|
import { constructRecordChain, fetchInitialWrite, getGoverningTimestamp } from './record-chain.js';
|
|
8
|
-
import { verifyAsRoleRecordIfNeeded, verifyProtocolPathAndContextId, verifySizeLimit, verifyTagsIfNeeded, verifyTypeWithComposition, } from './protocol-authorization-validation.js';
|
|
7
|
+
import { verifyAsRoleRecordIfNeeded, verifyImmutability, verifyProtocolPathAndContextId, verifyRecordLimit, verifySizeLimit, verifyTagsIfNeeded, verifyTypeWithComposition, } from './protocol-authorization-validation.js';
|
|
9
8
|
export class ProtocolAuthorization {
|
|
10
9
|
/**
|
|
11
10
|
* Performs validation on the structure of RecordsWrite messages that use a protocol.
|
|
12
11
|
* @throws {Error} if validation fails.
|
|
13
12
|
*/
|
|
14
|
-
static async validateReferentialIntegrity(tenant, incomingMessage, messageStore) {
|
|
13
|
+
static async validateReferentialIntegrity(tenant, incomingMessage, messageStore, coreProtocols) {
|
|
15
14
|
// Determine the governing timestamp for protocol definition lookup.
|
|
16
15
|
// For an initial write, this is the message's own timestamp.
|
|
17
16
|
// For an update, this is the initial write's timestamp (the protocol version is locked at creation time).
|
|
18
17
|
const governingTimestamp = await getGoverningTimestamp(tenant, incomingMessage, messageStore);
|
|
19
18
|
// fetch the protocol definition that was active at the governing timestamp
|
|
20
|
-
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(tenant, incomingMessage.message.descriptor.protocol, messageStore, governingTimestamp);
|
|
19
|
+
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(tenant, incomingMessage.message.descriptor.protocol, messageStore, governingTimestamp, coreProtocols);
|
|
20
|
+
// Create a bound fetch function that captures the registry for downstream callbacks.
|
|
21
|
+
const boundFetchDefinition = ProtocolAuthorization.createBoundFetchDefinition(coreProtocols);
|
|
21
22
|
// verify declared protocol type exists in protocol and that it conforms to type specification.
|
|
22
23
|
// For cross-protocol composition, the type may be defined in a referenced protocol.
|
|
23
|
-
await verifyTypeWithComposition(tenant, incomingMessage.message, protocolDefinition, messageStore,
|
|
24
|
+
await verifyTypeWithComposition(tenant, incomingMessage.message, protocolDefinition, messageStore, boundFetchDefinition, governingTimestamp);
|
|
24
25
|
// validate `protocolPath`
|
|
25
|
-
await verifyProtocolPathAndContextId(tenant, incomingMessage, messageStore,
|
|
26
|
+
await verifyProtocolPathAndContextId(tenant, incomingMessage, messageStore, boundFetchDefinition, governingTimestamp);
|
|
26
27
|
// get the rule set for the inbound message
|
|
27
28
|
const ruleSet = ProtocolAuthorization.getRuleSet(incomingMessage.message.descriptor.protocolPath, protocolDefinition);
|
|
28
29
|
// Validate as a role record if the incoming message is writing a role record
|
|
@@ -31,12 +32,16 @@ export class ProtocolAuthorization {
|
|
|
31
32
|
verifySizeLimit(incomingMessage, ruleSet);
|
|
32
33
|
// Verify protocol tags
|
|
33
34
|
verifyTagsIfNeeded(incomingMessage, ruleSet);
|
|
35
|
+
// Verify immutability — reject updates to write-once records
|
|
36
|
+
await verifyImmutability(incomingMessage, ruleSet);
|
|
37
|
+
// Verify record count limit
|
|
38
|
+
await verifyRecordLimit(tenant, incomingMessage, ruleSet, messageStore);
|
|
34
39
|
}
|
|
35
40
|
/**
|
|
36
41
|
* Performs protocol-based authorization against the incoming RecordsWrite message.
|
|
37
42
|
* @throws {Error} if authorization fails.
|
|
38
43
|
*/
|
|
39
|
-
static async authorizeWrite(tenant, incomingMessage, messageStore) {
|
|
44
|
+
static async authorizeWrite(tenant, incomingMessage, messageStore, coreProtocols) {
|
|
40
45
|
const existingInitialWrite = await fetchInitialWrite(tenant, incomingMessage.message.recordId, messageStore);
|
|
41
46
|
let recordChain;
|
|
42
47
|
if (existingInitialWrite === undefined) {
|
|
@@ -51,11 +56,12 @@ export class ProtocolAuthorization {
|
|
|
51
56
|
// Determine the governing timestamp for protocol definition lookup.
|
|
52
57
|
const governingTimestamp = await getGoverningTimestamp(tenant, incomingMessage, messageStore);
|
|
53
58
|
// fetch the protocol definition that was active at the governing timestamp
|
|
54
|
-
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(tenant, incomingMessage.message.descriptor.protocol, messageStore, governingTimestamp);
|
|
59
|
+
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(tenant, incomingMessage.message.descriptor.protocol, messageStore, governingTimestamp, coreProtocols);
|
|
55
60
|
// get the rule set for the inbound message
|
|
56
61
|
const ruleSet = ProtocolAuthorization.getRuleSet(incomingMessage.message.descriptor.protocolPath, protocolDefinition);
|
|
62
|
+
const boundFetchDefinition = ProtocolAuthorization.createBoundFetchDefinition(coreProtocols);
|
|
57
63
|
// If the incoming message has `protocolRole` in the descriptor, validate the invoked role
|
|
58
|
-
await verifyInvokedRole(tenant, incomingMessage, incomingMessage.message.descriptor.protocol, incomingMessage.message.contextId, protocolDefinition, messageStore,
|
|
64
|
+
await verifyInvokedRole(tenant, incomingMessage, incomingMessage.message.descriptor.protocol, incomingMessage.message.contextId, protocolDefinition, messageStore, boundFetchDefinition, governingTimestamp);
|
|
59
65
|
// verify method invoked against the allowed actions in the rule set
|
|
60
66
|
await authorizeAgainstAllowedActions(tenant, incomingMessage, ruleSet, recordChain, messageStore, protocolDefinition);
|
|
61
67
|
}
|
|
@@ -64,7 +70,7 @@ export class ProtocolAuthorization {
|
|
|
64
70
|
* @param newestRecordsWrite The latest RecordsWrite associated with the recordId being read.
|
|
65
71
|
* @throws {Error} if authorization fails.
|
|
66
72
|
*/
|
|
67
|
-
static async authorizeRead(tenant, incomingMessage, newestRecordsWrite, messageStore) {
|
|
73
|
+
static async authorizeRead(tenant, incomingMessage, newestRecordsWrite, messageStore, coreProtocols) {
|
|
68
74
|
// fetch record chain
|
|
69
75
|
const recordChain = await constructRecordChain(tenant, newestRecordsWrite.message.recordId, messageStore);
|
|
70
76
|
// Use the initial write's timestamp to determine the governing protocol definition.
|
|
@@ -74,24 +80,26 @@ export class ProtocolAuthorization {
|
|
|
74
80
|
? initialWrite.descriptor.messageTimestamp
|
|
75
81
|
: newestRecordsWrite.message.descriptor.messageTimestamp;
|
|
76
82
|
// fetch the protocol definition that was active when the record was created
|
|
77
|
-
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(tenant, newestRecordsWrite.message.descriptor.protocol, messageStore, governingTimestamp);
|
|
83
|
+
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(tenant, newestRecordsWrite.message.descriptor.protocol, messageStore, governingTimestamp, coreProtocols);
|
|
78
84
|
// get the rule set for the inbound message
|
|
79
85
|
const ruleSet = ProtocolAuthorization.getRuleSet(newestRecordsWrite.message.descriptor.protocolPath, protocolDefinition);
|
|
86
|
+
const boundFetchDefinition = ProtocolAuthorization.createBoundFetchDefinition(coreProtocols);
|
|
80
87
|
// If the incoming message has `protocolRole` in the descriptor, validate the invoked role
|
|
81
|
-
await verifyInvokedRole(tenant, incomingMessage, newestRecordsWrite.message.descriptor.protocol, newestRecordsWrite.message.contextId, protocolDefinition, messageStore,
|
|
88
|
+
await verifyInvokedRole(tenant, incomingMessage, newestRecordsWrite.message.descriptor.protocol, newestRecordsWrite.message.contextId, protocolDefinition, messageStore, boundFetchDefinition, governingTimestamp);
|
|
82
89
|
// verify method invoked against the allowed actions in the rule set
|
|
83
90
|
await authorizeAgainstAllowedActions(tenant, incomingMessage, ruleSet, recordChain, messageStore, protocolDefinition);
|
|
84
91
|
}
|
|
85
|
-
static async authorizeQueryOrSubscribe(tenant, incomingMessage, messageStore) {
|
|
92
|
+
static async authorizeQueryOrSubscribe(tenant, incomingMessage, messageStore, coreProtocols) {
|
|
86
93
|
const { protocol, protocolPath, contextId } = incomingMessage.message.descriptor.filter;
|
|
87
94
|
// fetch the protocol definition
|
|
88
95
|
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(tenant, protocol, // `authorizeQueryOrSubscribe` is only called if `protocol` is present
|
|
89
|
-
messageStore);
|
|
96
|
+
messageStore, undefined, coreProtocols);
|
|
90
97
|
// get the rule set for the inbound message
|
|
91
98
|
const ruleSet = ProtocolAuthorization.getRuleSet(protocolPath, // presence of `protocolPath` is verified in `parse()`
|
|
92
99
|
protocolDefinition);
|
|
100
|
+
const boundFetchDefinition = ProtocolAuthorization.createBoundFetchDefinition(coreProtocols);
|
|
93
101
|
// If the incoming message has `protocolRole` in the descriptor, validate the invoked role
|
|
94
|
-
await verifyInvokedRole(tenant, incomingMessage, protocol, contextId, protocolDefinition, messageStore,
|
|
102
|
+
await verifyInvokedRole(tenant, incomingMessage, protocol, contextId, protocolDefinition, messageStore, boundFetchDefinition);
|
|
95
103
|
// verify method invoked against the allowed actions in the rule set
|
|
96
104
|
await authorizeAgainstAllowedActions(tenant, incomingMessage, ruleSet, [], // record chain is not relevant to queries or subscriptions
|
|
97
105
|
messageStore, protocolDefinition);
|
|
@@ -100,7 +108,7 @@ export class ProtocolAuthorization {
|
|
|
100
108
|
* Performs protocol-based authorization against the incoming `RecordsDelete` message.
|
|
101
109
|
* @param recordsWrite A `RecordsWrite` of the record being deleted.
|
|
102
110
|
*/
|
|
103
|
-
static async authorizeDelete(tenant, incomingMessage, recordsWrite, messageStore) {
|
|
111
|
+
static async authorizeDelete(tenant, incomingMessage, recordsWrite, messageStore, coreProtocols) {
|
|
104
112
|
// fetch record chain
|
|
105
113
|
const recordChain = await constructRecordChain(tenant, incomingMessage.message.descriptor.recordId, messageStore);
|
|
106
114
|
// Use the initial write's timestamp to determine the governing protocol definition.
|
|
@@ -109,11 +117,12 @@ export class ProtocolAuthorization {
|
|
|
109
117
|
? initialWrite.descriptor.messageTimestamp
|
|
110
118
|
: recordsWrite.message.descriptor.messageTimestamp;
|
|
111
119
|
// fetch the protocol definition that was active when the record was created
|
|
112
|
-
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(tenant, recordsWrite.message.descriptor.protocol, messageStore, governingTimestamp);
|
|
120
|
+
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(tenant, recordsWrite.message.descriptor.protocol, messageStore, governingTimestamp, coreProtocols);
|
|
113
121
|
// get the rule set for the inbound message
|
|
114
122
|
const ruleSet = ProtocolAuthorization.getRuleSet(recordsWrite.message.descriptor.protocolPath, protocolDefinition);
|
|
123
|
+
const boundFetchDefinition = ProtocolAuthorization.createBoundFetchDefinition(coreProtocols);
|
|
115
124
|
// If the incoming message has `protocolRole` in the descriptor, validate the invoked role
|
|
116
|
-
await verifyInvokedRole(tenant, incomingMessage, recordsWrite.message.descriptor.protocol, recordsWrite.message.contextId, protocolDefinition, messageStore,
|
|
125
|
+
await verifyInvokedRole(tenant, incomingMessage, recordsWrite.message.descriptor.protocol, recordsWrite.message.contextId, protocolDefinition, messageStore, boundFetchDefinition, governingTimestamp);
|
|
117
126
|
// verify method invoked against the allowed actions in the rule set
|
|
118
127
|
await authorizeAgainstAllowedActions(tenant, incomingMessage, ruleSet, recordChain, messageStore, protocolDefinition);
|
|
119
128
|
}
|
|
@@ -122,11 +131,19 @@ export class ProtocolAuthorization {
|
|
|
122
131
|
* When `messageTimestamp` is provided, returns the protocol definition that was active at that
|
|
123
132
|
* point in time — i.e. the ProtocolsConfigure with the greatest `messageTimestamp` that is <= the
|
|
124
133
|
* given timestamp. When not provided, returns the latest (current) protocol definition.
|
|
134
|
+
*
|
|
135
|
+
* When `coreProtocols` is provided, core protocol definitions are returned directly from the
|
|
136
|
+
* registry without a message store query. The extra parameter does not affect the
|
|
137
|
+
* `FetchProtocolDefinitionFn` callback type — callers that pass this function as a callback
|
|
138
|
+
* should bind the registry via a closure (see `createBoundFetchDefinition`).
|
|
125
139
|
*/
|
|
126
|
-
static async fetchProtocolDefinition(tenant, protocolUri, messageStore, messageTimestamp) {
|
|
127
|
-
// if
|
|
128
|
-
if (
|
|
129
|
-
|
|
140
|
+
static async fetchProtocolDefinition(tenant, protocolUri, messageStore, messageTimestamp, coreProtocols) {
|
|
141
|
+
// if the protocol is a registered core protocol, return the definition directly without a store query
|
|
142
|
+
if (coreProtocols !== undefined) {
|
|
143
|
+
const coreDefinition = coreProtocols.getDefinition(protocolUri);
|
|
144
|
+
if (coreDefinition !== undefined) {
|
|
145
|
+
return coreDefinition;
|
|
146
|
+
}
|
|
130
147
|
}
|
|
131
148
|
// fetch the corresponding protocol definition
|
|
132
149
|
const query = {
|
|
@@ -149,6 +166,17 @@ export class ProtocolAuthorization {
|
|
|
149
166
|
const protocolMessage = protocols[0];
|
|
150
167
|
return protocolMessage.descriptor.definition;
|
|
151
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Creates a `FetchProtocolDefinitionFn` closure that binds the given `CoreProtocolRegistry`.
|
|
171
|
+
* This allows core protocol definitions to be resolved from the registry without changing
|
|
172
|
+
* the `FetchProtocolDefinitionFn` type signature — zero ripple to downstream consumers
|
|
173
|
+
* like `protocol-authorization-action.ts` and `protocol-authorization-validation.ts`.
|
|
174
|
+
*/
|
|
175
|
+
static createBoundFetchDefinition(coreProtocols) {
|
|
176
|
+
return (tenant, protocolUri, messageStore, messageTimestamp) => {
|
|
177
|
+
return ProtocolAuthorization.fetchProtocolDefinition(tenant, protocolUri, messageStore, messageTimestamp, coreProtocols);
|
|
178
|
+
};
|
|
179
|
+
}
|
|
152
180
|
/**
|
|
153
181
|
* Gets the rule set corresponding to the given protocolPath.
|
|
154
182
|
*/
|
|
@@ -159,12 +187,5 @@ export class ProtocolAuthorization {
|
|
|
159
187
|
}
|
|
160
188
|
return ruleSet;
|
|
161
189
|
}
|
|
162
|
-
/**
|
|
163
|
-
* Returns all the ProtocolActions that would authorize the incoming message.
|
|
164
|
-
* Delegates to the standalone function in `protocol-authorization-action.ts`.
|
|
165
|
-
*/
|
|
166
|
-
static async getActionsSeekingARuleMatch(tenant, incomingMessage, messageStore) {
|
|
167
|
-
return getActionsSeekingARuleMatch(tenant, incomingMessage, messageStore);
|
|
168
|
-
}
|
|
169
190
|
}
|
|
170
191
|
//# sourceMappingURL=protocol-authorization.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-authorization.js","sourceRoot":"","sources":["../../../../src/core/protocol-authorization.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"protocol-authorization.js","sourceRoot":"","sources":["../../../../src/core/protocol-authorization.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEnF,OAAO,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvG,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACnG,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,8BAA8B,EAC9B,iBAAiB,EACjB,eAAe,EACf,k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