@enbox/dwn-sdk-js 0.0.6 → 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 +762 -911
- package/dist/esm/generated/precompiled-validators.js.map +1 -1
- package/dist/esm/src/core/abstract-message.js +4 -0
- package/dist/esm/src/core/abstract-message.js.map +1 -1
- package/dist/esm/src/core/auth.js +22 -33
- package/dist/esm/src/core/auth.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-constant.js +7 -7
- package/dist/esm/src/core/dwn-constant.js.map +1 -1
- package/dist/esm/src/core/dwn-error.js +10 -12
- package/dist/esm/src/core/dwn-error.js.map +1 -1
- package/dist/esm/src/core/grant-authorization.js +50 -52
- package/dist/esm/src/core/grant-authorization.js.map +1 -1
- package/dist/esm/src/core/message.js +85 -116
- package/dist/esm/src/core/message.js.map +1 -1
- package/dist/esm/src/core/messages-grant-authorization.js +63 -78
- package/dist/esm/src/core/messages-grant-authorization.js.map +1 -1
- package/dist/esm/src/core/protocol-authorization-action.js +266 -0
- package/dist/esm/src/core/protocol-authorization-action.js.map +1 -0
- package/dist/esm/src/core/protocol-authorization-validation.js +321 -0
- package/dist/esm/src/core/protocol-authorization-validation.js.map +1 -0
- package/dist/esm/src/core/protocol-authorization.js +144 -741
- package/dist/esm/src/core/protocol-authorization.js.map +1 -1
- package/dist/esm/src/core/protocols-grant-authorization.js +24 -38
- package/dist/esm/src/core/protocols-grant-authorization.js.map +1 -1
- package/dist/esm/src/core/record-chain.js +64 -0
- package/dist/esm/src/core/record-chain.js.map +1 -0
- package/dist/esm/src/core/records-grant-authorization.js +53 -72
- package/dist/esm/src/core/records-grant-authorization.js.map +1 -1
- package/dist/esm/src/core/resumable-task-manager.js +50 -65
- package/dist/esm/src/core/resumable-task-manager.js.map +1 -1
- package/dist/esm/src/core/tenant-gate.js +2 -13
- package/dist/esm/src/core/tenant-gate.js.map +1 -1
- package/dist/esm/src/dwn.js +108 -101
- 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 +67 -81
- package/dist/esm/src/handlers/messages-read.js.map +1 -1
- package/dist/esm/src/handlers/messages-subscribe.js +51 -63
- package/dist/esm/src/handlers/messages-subscribe.js.map +1 -1
- package/dist/esm/src/handlers/messages-sync.js +75 -89
- package/dist/esm/src/handlers/messages-sync.js.map +1 -1
- package/dist/esm/src/handlers/protocols-configure.js +153 -163
- package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
- package/dist/esm/src/handlers/protocols-query.js +52 -55
- package/dist/esm/src/handlers/protocols-query.js.map +1 -1
- package/dist/esm/src/handlers/records-count.js +97 -85
- package/dist/esm/src/handlers/records-count.js.map +1 -1
- package/dist/esm/src/handlers/records-delete.js +75 -93
- package/dist/esm/src/handlers/records-delete.js.map +1 -1
- package/dist/esm/src/handlers/records-query.js +116 -105
- package/dist/esm/src/handlers/records-query.js.map +1 -1
- package/dist/esm/src/handlers/records-read.js +130 -132
- package/dist/esm/src/handlers/records-read.js.map +1 -1
- package/dist/esm/src/handlers/records-subscribe.js +164 -104
- package/dist/esm/src/handlers/records-subscribe.js.map +1 -1
- package/dist/esm/src/handlers/records-write.js +213 -280
- 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-read.js +24 -32
- package/dist/esm/src/interfaces/messages-read.js.map +1 -1
- package/dist/esm/src/interfaces/messages-subscribe.js +28 -41
- package/dist/esm/src/interfaces/messages-subscribe.js.map +1 -1
- package/dist/esm/src/interfaces/messages-sync.js +26 -40
- package/dist/esm/src/interfaces/messages-sync.js.map +1 -1
- package/dist/esm/src/interfaces/protocols-configure.js +87 -65
- package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
- package/dist/esm/src/interfaces/protocols-query.js +55 -68
- package/dist/esm/src/interfaces/protocols-query.js.map +1 -1
- package/dist/esm/src/interfaces/records-count.js +50 -66
- package/dist/esm/src/interfaces/records-count.js.map +1 -1
- package/dist/esm/src/interfaces/records-delete.js +45 -55
- package/dist/esm/src/interfaces/records-delete.js.map +1 -1
- package/dist/esm/src/interfaces/records-query.js +60 -76
- package/dist/esm/src/interfaces/records-query.js.map +1 -1
- package/dist/esm/src/interfaces/records-read.js +51 -67
- package/dist/esm/src/interfaces/records-read.js.map +1 -1
- package/dist/esm/src/interfaces/records-subscribe.js +53 -68
- package/dist/esm/src/interfaces/records-subscribe.js.map +1 -1
- package/dist/esm/src/interfaces/records-write-query.js +102 -0
- package/dist/esm/src/interfaces/records-write-query.js.map +1 -0
- package/dist/esm/src/interfaces/records-write-signing.js +81 -0
- package/dist/esm/src/interfaces/records-write-signing.js.map +1 -0
- package/dist/esm/src/interfaces/records-write.js +396 -610
- package/dist/esm/src/interfaces/records-write.js.map +1 -1
- package/dist/esm/src/jose/algorithms/signing/ed25519.js +10 -19
- package/dist/esm/src/jose/algorithms/signing/ed25519.js.map +1 -1
- package/dist/esm/src/jose/jws/general/builder.js +23 -35
- package/dist/esm/src/jose/jws/general/builder.js.map +1 -1
- package/dist/esm/src/jose/jws/general/verifier.js +56 -69
- package/dist/esm/src/jose/jws/general/verifier.js.map +1 -1
- package/dist/esm/src/protocols/permission-grant.js +43 -14
- package/dist/esm/src/protocols/permission-grant.js.map +1 -1
- package/dist/esm/src/protocols/permission-request.js +28 -14
- package/dist/esm/src/protocols/permission-request.js.map +1 -1
- package/dist/esm/src/protocols/permissions.js +325 -227
- package/dist/esm/src/protocols/permissions.js.map +1 -1
- package/dist/esm/src/smt/smt-store-level.js +42 -64
- package/dist/esm/src/smt/smt-store-level.js.map +1 -1
- package/dist/esm/src/smt/smt-store-memory.js +19 -45
- package/dist/esm/src/smt/smt-store-memory.js.map +1 -1
- package/dist/esm/src/smt/smt-utils.js +28 -45
- package/dist/esm/src/smt/smt-utils.js.map +1 -1
- package/dist/esm/src/smt/sparse-merkle-tree.js +426 -471
- package/dist/esm/src/smt/sparse-merkle-tree.js.map +1 -1
- package/dist/esm/src/state-index/state-index-level.js +113 -150
- package/dist/esm/src/state-index/state-index-level.js.map +1 -1
- package/dist/esm/src/store/blockstore-level.js +54 -156
- package/dist/esm/src/store/blockstore-level.js.map +1 -1
- package/dist/esm/src/store/blockstore-mock.js +48 -153
- package/dist/esm/src/store/blockstore-mock.js.map +1 -1
- package/dist/esm/src/store/data-store-level.js +137 -100
- package/dist/esm/src/store/data-store-level.js.map +1 -1
- package/dist/esm/src/store/index-level-compound.js +246 -0
- package/dist/esm/src/store/index-level-compound.js.map +1 -0
- package/dist/esm/src/store/index-level.js +307 -715
- package/dist/esm/src/store/index-level.js.map +1 -1
- package/dist/esm/src/store/level-wrapper.js +143 -244
- package/dist/esm/src/store/level-wrapper.js.map +1 -1
- package/dist/esm/src/store/message-store-level.js +71 -94
- package/dist/esm/src/store/message-store-level.js.map +1 -1
- package/dist/esm/src/store/resumable-task-store-level.js +62 -101
- package/dist/esm/src/store/resumable-task-store-level.js.map +1 -1
- package/dist/esm/src/store/storage-controller.js +131 -146
- 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/abort.js +8 -19
- package/dist/esm/src/utils/abort.js.map +1 -1
- package/dist/esm/src/utils/array.js +15 -49
- package/dist/esm/src/utils/array.js.map +1 -1
- package/dist/esm/src/utils/cid.js +29 -77
- package/dist/esm/src/utils/cid.js.map +1 -1
- package/dist/esm/src/utils/data-stream.js +37 -65
- package/dist/esm/src/utils/data-stream.js.map +1 -1
- package/dist/esm/src/utils/encryption.js +136 -162
- package/dist/esm/src/utils/encryption.js.map +1 -1
- package/dist/esm/src/utils/filter.js +1 -12
- package/dist/esm/src/utils/filter.js.map +1 -1
- package/dist/esm/src/utils/hd-key.js +45 -71
- package/dist/esm/src/utils/hd-key.js.map +1 -1
- package/dist/esm/src/utils/jws.js +9 -20
- package/dist/esm/src/utils/jws.js.map +1 -1
- package/dist/esm/src/utils/memory-cache.js +12 -23
- package/dist/esm/src/utils/memory-cache.js.map +1 -1
- package/dist/esm/src/utils/messages.js +21 -33
- package/dist/esm/src/utils/messages.js.map +1 -1
- package/dist/esm/src/utils/private-key-signer.js +9 -17
- package/dist/esm/src/utils/private-key-signer.js.map +1 -1
- package/dist/esm/src/utils/protocols.js +62 -70
- package/dist/esm/src/utils/protocols.js.map +1 -1
- package/dist/esm/src/utils/records.js +103 -166
- package/dist/esm/src/utils/records.js.map +1 -1
- package/dist/esm/src/utils/secp256k1.js +60 -96
- package/dist/esm/src/utils/secp256k1.js.map +1 -1
- package/dist/esm/src/utils/secp256r1.js +54 -71
- package/dist/esm/src/utils/secp256r1.js.map +1 -1
- package/dist/esm/src/utils/time.js +5 -18
- package/dist/esm/src/utils/time.js.map +1 -1
- package/dist/esm/src/utils/url.js +3 -3
- package/dist/esm/src/utils/url.js.map +1 -1
- package/dist/esm/tests/core/auth.spec.js +3 -12
- package/dist/esm/tests/core/auth.spec.js.map +1 -1
- package/dist/esm/tests/core/message.spec.js +50 -59
- package/dist/esm/tests/core/message.spec.js.map +1 -1
- package/dist/esm/tests/core/protocol-authorization.spec.js +10 -18
- package/dist/esm/tests/core/protocol-authorization.spec.js.map +1 -1
- package/dist/esm/tests/dwn.spec.js +65 -89
- 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 +337 -347
- package/dist/esm/tests/features/author-delegated-grant.spec.js.map +1 -1
- package/dist/esm/tests/features/owner-delegated-grant.spec.js +160 -172
- package/dist/esm/tests/features/owner-delegated-grant.spec.js.map +1 -1
- package/dist/esm/tests/features/owner-signature.spec.js +78 -82
- package/dist/esm/tests/features/owner-signature.spec.js.map +1 -1
- package/dist/esm/tests/features/permissions.spec.js +449 -184
- package/dist/esm/tests/features/permissions.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-composition.spec.js +981 -360
- package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-create-action.spec.js +45 -54
- package/dist/esm/tests/features/protocol-create-action.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-delete-action.spec.js +99 -108
- package/dist/esm/tests/features/protocol-delete-action.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-update-action.spec.js +108 -117
- 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 +178 -194
- 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 +456 -463
- package/dist/esm/tests/features/records-tags.spec.js.map +1 -1
- package/dist/esm/tests/features/resumable-tasks.spec.js +88 -98
- package/dist/esm/tests/features/resumable-tasks.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-read.spec.js +215 -210
- package/dist/esm/tests/handlers/messages-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-subscribe.spec.js +309 -171
- package/dist/esm/tests/handlers/messages-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-sync.spec.js +272 -199
- package/dist/esm/tests/handlers/messages-sync.spec.js.map +1 -1
- package/dist/esm/tests/handlers/protocols-configure.spec.js +247 -241
- package/dist/esm/tests/handlers/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/handlers/protocols-query.spec.js +159 -172
- package/dist/esm/tests/handlers/protocols-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-count.spec.js +101 -105
- package/dist/esm/tests/handlers/records-count.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-delete.spec.js +266 -279
- package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-query.spec.js +984 -996
- package/dist/esm/tests/handlers/records-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-read.spec.js +542 -671
- package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-subscribe.spec.js +433 -302
- package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-write.spec.js +1216 -1140
- package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/messages-get.spec.js +39 -48
- package/dist/esm/tests/interfaces/messages-get.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/messages-subscribe.spec.js +4 -13
- package/dist/esm/tests/interfaces/messages-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/protocols-configure.spec.js +212 -88
- package/dist/esm/tests/interfaces/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/protocols-query.spec.js +8 -17
- package/dist/esm/tests/interfaces/protocols-query.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-delete.spec.js +8 -17
- package/dist/esm/tests/interfaces/records-delete.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-query.spec.js +20 -29
- package/dist/esm/tests/interfaces/records-query.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-read.spec.js +42 -51
- package/dist/esm/tests/interfaces/records-read.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-subscribe.spec.js +16 -25
- package/dist/esm/tests/interfaces/records-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-write.spec.js +190 -219
- package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -1
- package/dist/esm/tests/jose/jws/general.spec.js +36 -45
- package/dist/esm/tests/jose/jws/general.spec.js.map +1 -1
- package/dist/esm/tests/protocols/permission-grant.spec.js +44 -50
- package/dist/esm/tests/protocols/permission-grant.spec.js.map +1 -1
- package/dist/esm/tests/protocols/permission-request.spec.js +23 -32
- package/dist/esm/tests/protocols/permission-request.spec.js.map +1 -1
- package/dist/esm/tests/protocols/permissions.spec.js +49 -55
- package/dist/esm/tests/protocols/permissions.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/aggregator.spec.js +127 -138
- package/dist/esm/tests/scenarios/aggregator.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/deleted-record.spec.js +372 -36
- package/dist/esm/tests/scenarios/deleted-record.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +55 -64
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/nested-roles.spec.js +66 -76
- package/dist/esm/tests/scenarios/nested-roles.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/subscriptions.spec.js +451 -354
- package/dist/esm/tests/scenarios/subscriptions.spec.js.map +1 -1
- package/dist/esm/tests/smt/smt-store-level.spec.js +76 -87
- package/dist/esm/tests/smt/smt-store-level.spec.js.map +1 -1
- package/dist/esm/tests/smt/sparse-merkle-tree.spec.js +344 -353
- package/dist/esm/tests/smt/sparse-merkle-tree.spec.js.map +1 -1
- package/dist/esm/tests/state-index/state-index-level.spec.js +117 -126
- package/dist/esm/tests/state-index/state-index-level.spec.js.map +1 -1
- package/dist/esm/tests/store/blockstore-level.spec.js +44 -99
- package/dist/esm/tests/store/blockstore-level.spec.js.map +1 -1
- package/dist/esm/tests/store/blockstore-mock.spec.js +40 -120
- package/dist/esm/tests/store/blockstore-mock.spec.js.map +1 -1
- package/dist/esm/tests/store/data-store-level.spec.js +160 -108
- package/dist/esm/tests/store/data-store-level.spec.js.map +1 -1
- package/dist/esm/tests/store/index-level.spec.js +404 -414
- package/dist/esm/tests/store/index-level.spec.js.map +1 -1
- package/dist/esm/tests/store/message-store-level.spec.js +13 -22
- package/dist/esm/tests/store/message-store-level.spec.js.map +1 -1
- package/dist/esm/tests/store/message-store.spec.js +229 -238
- package/dist/esm/tests/store/message-store.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-stores.js +16 -13
- package/dist/esm/tests/test-stores.js.map +1 -1
- package/dist/esm/tests/test-suite.js +8 -15
- package/dist/esm/tests/test-suite.js.map +1 -1
- package/dist/esm/tests/utils/cid.spec.js +24 -33
- package/dist/esm/tests/utils/cid.spec.js.map +1 -1
- package/dist/esm/tests/utils/data-stream.spec.js +48 -57
- package/dist/esm/tests/utils/data-stream.spec.js.map +1 -1
- package/dist/esm/tests/utils/encryption-callbacks.spec.js +45 -54
- package/dist/esm/tests/utils/encryption-callbacks.spec.js.map +1 -1
- package/dist/esm/tests/utils/encryption.spec.js +229 -82
- package/dist/esm/tests/utils/encryption.spec.js.map +1 -1
- package/dist/esm/tests/utils/filters.spec.js +46 -55
- package/dist/esm/tests/utils/filters.spec.js.map +1 -1
- package/dist/esm/tests/utils/hd-key.spec.js +10 -19
- package/dist/esm/tests/utils/hd-key.spec.js.map +1 -1
- package/dist/esm/tests/utils/jws.spec.js +3 -12
- package/dist/esm/tests/utils/jws.spec.js.map +1 -1
- package/dist/esm/tests/utils/memory-cache.spec.js +9 -18
- package/dist/esm/tests/utils/memory-cache.spec.js.map +1 -1
- package/dist/esm/tests/utils/messages.spec.js +18 -20
- package/dist/esm/tests/utils/messages.spec.js.map +1 -1
- package/dist/esm/tests/utils/poller.js +22 -33
- package/dist/esm/tests/utils/poller.js.map +1 -1
- package/dist/esm/tests/utils/private-key-signer.spec.js +15 -24
- package/dist/esm/tests/utils/private-key-signer.spec.js.map +1 -1
- package/dist/esm/tests/utils/records.spec.js +14 -27
- package/dist/esm/tests/utils/records.spec.js.map +1 -1
- package/dist/esm/tests/utils/secp256k1.spec.js +16 -25
- package/dist/esm/tests/utils/secp256k1.spec.js.map +1 -1
- package/dist/esm/tests/utils/secp256r1.spec.js +18 -27
- package/dist/esm/tests/utils/secp256r1.spec.js.map +1 -1
- package/dist/esm/tests/utils/test-data-generator.js +446 -467
- package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/definitions.spec.js +2 -11
- package/dist/esm/tests/validation/json-schemas/definitions.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/jwk/general-jwk.spec.js +4 -13
- package/dist/esm/tests/validation/json-schemas/jwk/general-jwk.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/jwk/public-jwk.spec.js +8 -17
- package/dist/esm/tests/validation/json-schemas/jwk/public-jwk.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/jwk-verification-method.spec.js +3 -12
- package/dist/esm/tests/validation/json-schemas/jwk-verification-method.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js +4 -13
- package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/records/records-query.spec.js +2 -11
- package/dist/esm/tests/validation/json-schemas/records/records-query.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/records/records-read.spec.js +2 -11
- package/dist/esm/tests/validation/json-schemas/records/records-read.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js +44 -24
- 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-action.d.ts +42 -0
- package/dist/types/src/core/protocol-authorization-action.d.ts.map +1 -0
- package/dist/types/src/core/protocol-authorization-validation.d.ts +81 -0
- package/dist/types/src/core/protocol-authorization-validation.d.ts.map +1 -0
- package/dist/types/src/core/protocol-authorization.d.ts +24 -106
- package/dist/types/src/core/protocol-authorization.d.ts.map +1 -1
- package/dist/types/src/core/record-chain.d.ts +24 -0
- package/dist/types/src/core/record-chain.d.ts.map +1 -0
- 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 -24
- 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-query.d.ts +33 -0
- package/dist/types/src/interfaces/records-write-query.d.ts.map +1 -0
- package/dist/types/src/interfaces/records-write-signing.d.ts +34 -0
- package/dist/types/src/interfaces/records-write-signing.d.ts.map +1 -0
- package/dist/types/src/interfaces/records-write.d.ts +13 -53
- 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-compound.d.ts +70 -0
- package/dist/types/src/store/index-level-compound.d.ts.map +1 -0
- package/dist/types/src/store/index-level.d.ts +4 -58
- 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/protocols.d.ts +5 -0
- package/dist/types/src/utils/protocols.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/permissions.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-action.ts +377 -0
- package/src/core/protocol-authorization-validation.ts +487 -0
- package/src/core/protocol-authorization.ts +111 -856
- package/src/core/record-chain.ts +99 -0
- 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 -104
- package/src/index.ts +9 -5
- package/src/interfaces/messages-subscribe.ts +7 -1
- package/src/interfaces/protocols-configure.ts +73 -8
- 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-query.ts +139 -0
- package/src/interfaces/records-write-signing.ts +123 -0
- package/src/interfaces/records-write.ts +66 -261
- 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-compound.ts +324 -0
- package/src/store/index-level.ts +68 -341
- 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/protocols.ts +8 -0
- package/src/utils/records.ts +8 -59
- package/dist/esm/src/event-stream/event-emitter-stream.js +0 -60
- 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 -77
- 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 -123
- 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
|
@@ -16,10 +16,10 @@ export declare enum DwnErrorCode {
|
|
|
16
16
|
ComputeCidCodecNotSupported = "ComputeCidCodecNotSupported",
|
|
17
17
|
ComputeCidMultihashNotSupported = "ComputeCidMultihashNotSupported",
|
|
18
18
|
Ed25519InvalidJwk = "Ed25519InvalidJwk",
|
|
19
|
-
|
|
19
|
+
EventLogNotOpenError = "EventLogNotOpenError",
|
|
20
20
|
MessagesGrantAuthorizationMismatchedProtocol = "EventsGrantAuthorizationMismatchedProtocol",
|
|
21
21
|
MessagesSubscribeAuthorizationFailed = "MessagesSubscribeAuthorizationFailed",
|
|
22
|
-
|
|
22
|
+
MessagesSubscribeEventLogUnimplemented = "MessagesSubscribeEventLogUnimplemented",
|
|
23
23
|
GeneralJwsVerifierGetPublicKeyNotFound = "GeneralJwsVerifierGetPublicKeyNotFound",
|
|
24
24
|
GeneralJwsVerifierInvalidSignature = "GeneralJwsVerifierInvalidSignature",
|
|
25
25
|
GeneralJwsVerifierMissingAlg = "GeneralJwsVerifierMissingAlg",
|
|
@@ -74,11 +74,14 @@ export declare enum DwnErrorCode {
|
|
|
74
74
|
ProtocolAuthorizationIncorrectProtocolPath = "ProtocolAuthorizationIncorrectProtocolPath",
|
|
75
75
|
ProtocolAuthorizationDuplicateRoleRecipient = "ProtocolAuthorizationDuplicateRoleRecipient",
|
|
76
76
|
ProtocolAuthorizationEncryptionRequired = "ProtocolAuthorizationEncryptionRequired",
|
|
77
|
+
ProtocolAuthorizationImmutableRecord = "ProtocolAuthorizationImmutableRecord",
|
|
77
78
|
ProtocolAuthorizationInvalidSchema = "ProtocolAuthorizationInvalidSchema",
|
|
78
79
|
ProtocolAuthorizationInvalidType = "ProtocolAuthorizationInvalidType",
|
|
79
80
|
ProtocolAuthorizationMatchingRoleRecordNotFound = "ProtocolAuthorizationMatchingRoleRecordNotFound",
|
|
80
81
|
ProtocolAuthorizationMaxSizeInvalid = "ProtocolAuthorizationMaxSizeInvalid",
|
|
81
82
|
ProtocolAuthorizationMinSizeInvalid = "ProtocolAuthorizationMinSizeInvalid",
|
|
83
|
+
ProtocolAuthorizationRecordLimitExceeded = "ProtocolAuthorizationRecordLimitExceeded",
|
|
84
|
+
ProtocolAuthorizationRecordLimitStrategyNotImplemented = "ProtocolAuthorizationRecordLimitStrategyNotImplemented",
|
|
82
85
|
ProtocolAuthorizationMissingContextId = "ProtocolAuthorizationMissingContextId",
|
|
83
86
|
ProtocolAuthorizationMissingRuleSet = "ProtocolAuthorizationMissingRuleSet",
|
|
84
87
|
ProtocolAuthorizationParentlessIncorrectProtocolPath = "ProtocolAuthorizationParentlessIncorrectProtocolPath",
|
|
@@ -95,6 +98,8 @@ export declare enum DwnErrorCode {
|
|
|
95
98
|
ProtocolsConfigureInvalidRefNodeHasDirectives = "ProtocolsConfigureInvalidRefNodeHasDirectives",
|
|
96
99
|
ProtocolsConfigureInvalidRefNotAtRoot = "ProtocolsConfigureInvalidRefNotAtRoot",
|
|
97
100
|
ProtocolsConfigureInvalidRefProtocolPath = "ProtocolsConfigureInvalidRefProtocolPath",
|
|
101
|
+
ProtocolsConfigureInvalidRefTargetThroughRef = "ProtocolsConfigureInvalidRefTargetThroughRef",
|
|
102
|
+
ProtocolsConfigureInvalidRecordLimit = "ProtocolsConfigureInvalidRecordLimit",
|
|
98
103
|
ProtocolsConfigureInvalidSize = "ProtocolsConfigureInvalidSize",
|
|
99
104
|
ProtocolsConfigureInvalidActionMissingOf = "ProtocolsConfigureInvalidActionMissingOf",
|
|
100
105
|
ProtocolsConfigureInvalidActionOfNotAnAncestor = "ProtocolsConfigureInvalidActionOfNotAnAncestor",
|
|
@@ -121,7 +126,6 @@ export declare enum DwnErrorCode {
|
|
|
121
126
|
RecordsAuthorDelegatedGrantNotADelegatedGrant = "RecordsAuthorDelegatedGrantNotADelegatedGrant",
|
|
122
127
|
RecordsDecryptNoMatchingKeyEncryptedFound = "RecordsDecryptNoMatchingKeyEncryptedFound",
|
|
123
128
|
RecordsCountFilterMissingRequiredProperties = "RecordsCountFilterMissingRequiredProperties",
|
|
124
|
-
RecordsDeleteAuthorizationFailed = "RecordsDeleteAuthorizationFailed",
|
|
125
129
|
RecordsQueryCreateFilterPublishedSortInvalid = "RecordsQueryCreateFilterPublishedSortInvalid",
|
|
126
130
|
RecordsQueryParseFilterPublishedSortInvalid = "RecordsQueryParseFilterPublishedSortInvalid",
|
|
127
131
|
RecordsGrantAuthorizationConditionPublicationProhibited = "RecordsGrantAuthorizationConditionPublicationProhibited",
|
|
@@ -137,23 +141,18 @@ export declare enum DwnErrorCode {
|
|
|
137
141
|
RecordsOwnerDelegatedGrantCidMismatch = "RecordsOwnerDelegatedGrantCidMismatch",
|
|
138
142
|
RecordsOwnerDelegatedGrantGrantedToAndOwnerSignatureMismatch = "RecordsOwnerDelegatedGrantGrantedToAndOwnerSignatureMismatch",
|
|
139
143
|
RecordsOwnerDelegatedGrantNotADelegatedGrant = "RecordsOwnerDelegatedGrantNotADelegatedGrant",
|
|
140
|
-
RecordsProtocolContextDerivationSchemeMissingContextId = "RecordsProtocolContextDerivationSchemeMissingContextId",
|
|
141
|
-
RecordsProtocolPathDerivationSchemeMissingProtocol = "RecordsProtocolPathDerivationSchemeMissingProtocol",
|
|
142
144
|
RecordsQueryFilterMissingRequiredProperties = "RecordsQueryFilterMissingRequiredProperties",
|
|
143
|
-
RecordsReadAuthorizationFailed = "RecordsReadAuthorizationFailed",
|
|
144
145
|
RecordsReadCreateFilterPublishedSortInvalid = "RecordsReadCreateFilterPublishedSortInvalid",
|
|
145
146
|
RecordsReadParseFilterPublishedSortInvalid = "RecordsReadParseFilterPublishedSortInvalid",
|
|
146
|
-
|
|
147
|
+
RecordsSubscribeEventLogUnimplemented = "RecordsSubscribeEventLogUnimplemented",
|
|
147
148
|
RecordsSubscribeFilterMissingRequiredProperties = "RecordsSubscribeFilterMissingRequiredProperties",
|
|
148
|
-
RecordsSchemasDerivationSchemeMissingSchema = "RecordsSchemasDerivationSchemeMissingSchema",
|
|
149
149
|
RecordsWriteAttestationIntegrityMoreThanOneSignature = "RecordsWriteAttestationIntegrityMoreThanOneSignature",
|
|
150
150
|
RecordsWriteAttestationIntegrityDescriptorCidMismatch = "RecordsWriteAttestationIntegrityDescriptorCidMismatch",
|
|
151
151
|
RecordsWriteAttestationIntegrityInvalidPayloadProperty = "RecordsWriteAttestationIntegrityInvalidPayloadProperty",
|
|
152
|
-
RecordsWriteAuthorizationFailed = "RecordsWriteAuthorizationFailed",
|
|
153
152
|
RecordsWriteCreateMissingSigner = "RecordsWriteCreateMissingSigner",
|
|
154
153
|
RecordsWriteCreateDataAndDataCidMutuallyExclusive = "RecordsWriteCreateDataAndDataCidMutuallyExclusive",
|
|
155
154
|
RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive = "RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive",
|
|
156
|
-
|
|
155
|
+
RecordsWriteCreateMissingProtocol = "RecordsWriteCreateMissingProtocol",
|
|
157
156
|
RecordsWriteDataCidMismatch = "RecordsWriteDataCidMismatch",
|
|
158
157
|
RecordsWriteDataSizeMismatch = "RecordsWriteDataSizeMismatch",
|
|
159
158
|
RecordsWriteGetEntryIdUndefinedAuthor = "RecordsWriteGetEntryIdUndefinedAuthor",
|
|
@@ -164,8 +163,6 @@ export declare enum DwnErrorCode {
|
|
|
164
163
|
RecordsWriteMissingDataInPrevious = "RecordsWriteMissingDataInPrevious",
|
|
165
164
|
RecordsWriteMissingEncodedDataInPrevious = "RecordsWriteMissingEncodedDataInPrevious",
|
|
166
165
|
RecordsWriteMissingEncryption = "RecordsWriteMissingEncryption",
|
|
167
|
-
RecordsWriteMissingProtocol = "RecordsWriteMissingProtocol",
|
|
168
|
-
RecordsWriteMissingSchema = "RecordsWriteMissingSchema",
|
|
169
166
|
RecordsWriteNotAllowedAfterDelete = "RecordsWriteNotAllowedAfterDelete",
|
|
170
167
|
RecordsWriteOwnerAndTenantMismatch = "RecordsWriteOwnerAndTenantMismatch",
|
|
171
168
|
RecordsWriteSignAsOwnerDelegateUnknownAuthor = "RecordsWriteSignAsOwnerDelegateUnknownAuthor",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dwn-error.d.ts","sourceRoot":"","sources":["../../../../src/core/dwn-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACb,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAKlD;AAED;;GAEG;AACH,oBAAY,YAAY;IACtB,sBAAsB,2BAA2B;IACjD,iCAAiC,sCAAsC;IACvE,8CAA8C,mDAAmD;IACjG,+BAA+B,oCAAoC;IACnE,2BAA2B,gCAAgC;IAC3D,+BAA+B,oCAAoC;IACnE,iBAAiB,sBAAsB;IACvC,
|
|
1
|
+
{"version":3,"file":"dwn-error.d.ts","sourceRoot":"","sources":["../../../../src/core/dwn-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACb,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAKlD;AAED;;GAEG;AACH,oBAAY,YAAY;IACtB,sBAAsB,2BAA2B;IACjD,iCAAiC,sCAAsC;IACvE,8CAA8C,mDAAmD;IACjG,+BAA+B,oCAAoC;IACnE,2BAA2B,gCAAgC;IAC3D,+BAA+B,oCAAoC;IACnE,iBAA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AgD;IAC3F,sBAAsB,2BAA2B;IACjD,6BAA6B,kCAAkC;IAC/D,4CAA4C,iDAAiD;IAC7F,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;IAC7C,gBAAgB,qBAAqB;IACrC,wBAAwB,6BAA6B;IACrD,0BAA0B,+BAA+B;IACzD,sBAAsB,2BAA2B;IACjD,+BAA+B,oCAAoC;CACpE"}
|
|
@@ -34,8 +34,12 @@ export declare class GrantAuthorization {
|
|
|
34
34
|
*/
|
|
35
35
|
private static verifyGrantActive;
|
|
36
36
|
/**
|
|
37
|
-
* Verify that the `interface` and `method` grant scopes match the incoming message
|
|
38
|
-
*
|
|
37
|
+
* Verify that the `interface` and `method` grant scopes match the incoming message.
|
|
38
|
+
*
|
|
39
|
+
* For the Messages interface, a `Read` scope is treated as a unified scope that also authorizes
|
|
40
|
+
* `Subscribe` and `Sync` operations. This mirrors how protocol `$actions` treats `read` as a
|
|
41
|
+
* unified action covering read, query, subscribe, and count.
|
|
42
|
+
*
|
|
39
43
|
* @throws {DwnError} if the `interface` and `method` of the incoming message do not match the scope of the permission grant.
|
|
40
44
|
*/
|
|
41
45
|
private static verifyGrantScopeInterfaceAndMethod;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant-authorization.d.ts","sourceRoot":"","sources":["../../../../src/core/grant-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"grant-authorization.d.ts","sourceRoot":"","sources":["../../../../src/core/grant-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAOxE,qBAAa,kBAAkB;IAE7B;;;;;;;;;;OAUG;WACiB,qBAAqB,CAAC,KAAK,EAAE;QAC/C,eAAe,EAAE,cAAc,CAAC;QAChC,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,eAAe,CAAC;QACjC,YAAY,EAAE,YAAY,CAAC;KAC1B,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBnB;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,+BAA+B;IAuB9C;;;;;OAKG;mBACkB,iBAAiB;IAwCtC;;;;;;;;OAQG;mBACkB,kCAAkC;CA6BxD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { MessageStore } from '../types/message-store.js';
|
|
2
|
+
import type { RecordsCount } from '../interfaces/records-count.js';
|
|
3
|
+
import type { RecordsDelete } from '../interfaces/records-delete.js';
|
|
4
|
+
import type { RecordsQuery } from '../interfaces/records-query.js';
|
|
5
|
+
import type { RecordsRead } from '../interfaces/records-read.js';
|
|
6
|
+
import type { RecordsSubscribe } from '../interfaces/records-subscribe.js';
|
|
7
|
+
import type { RecordsWriteMessage } from '../types/records-types.js';
|
|
8
|
+
import type { ProtocolActionRule, ProtocolDefinition, ProtocolRuleSet } from '../types/protocols-types.js';
|
|
9
|
+
import { RecordsWrite } from '../interfaces/records-write.js';
|
|
10
|
+
import { ProtocolAction } from '../types/protocols-types.js';
|
|
11
|
+
import type { FetchProtocolDefinitionFn } from './protocol-authorization.js';
|
|
12
|
+
/**
|
|
13
|
+
* Check if the incoming message is invoking a role. If so, validate the invoked role.
|
|
14
|
+
* For cross-protocol role invocation, the role record may live in a different protocol
|
|
15
|
+
* (resolved via the composing protocol's `uses` map).
|
|
16
|
+
*/
|
|
17
|
+
export declare function verifyInvokedRole(tenant: string, incomingMessage: RecordsCount | RecordsDelete | RecordsQuery | RecordsRead | RecordsSubscribe | RecordsWrite, protocolUri: string, contextId: string | undefined, protocolDefinition: ProtocolDefinition, messageStore: MessageStore, fetchProtocolDefinition: FetchProtocolDefinitionFn, governingTimestamp?: string): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns all the ProtocolActions that would authorized the incoming message
|
|
20
|
+
* (but we still need to later verify if there is a rule defined that matches one of the actions).
|
|
21
|
+
* NOTE: the reason why there could be multiple actions is because:
|
|
22
|
+
* - In case of an initial RecordsWrite, the RecordsWrite can be authorized by an allow `create` or `write` rule.
|
|
23
|
+
* - In case of a non-initial RecordsWrite by the original record author, the RecordsWrite can be authorized by a `write` or `co-update` rule.
|
|
24
|
+
*
|
|
25
|
+
* It is important to recognize that the `write` access that allowed the original record author to create the record maybe revoked
|
|
26
|
+
* (e.g. by role revocation) by the time a "non-initial" write by the same author is attempted.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getActionsSeekingARuleMatch(tenant: string, incomingMessage: RecordsCount | RecordsDelete | RecordsQuery | RecordsRead | RecordsSubscribe | RecordsWrite, messageStore: MessageStore): Promise<ProtocolAction[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Verifies the given message is authorized by one of the action rules in the given protocol rule set.
|
|
31
|
+
* @param protocolDefinition Optional protocol definition for resolving cross-protocol `of` and `role` references.
|
|
32
|
+
* @throws {Error} if action not allowed.
|
|
33
|
+
*/
|
|
34
|
+
export declare function authorizeAgainstAllowedActions(tenant: string, incomingMessage: RecordsCount | RecordsDelete | RecordsQuery | RecordsRead | RecordsSubscribe | RecordsWrite, ruleSet: ProtocolRuleSet, recordChain: RecordsWriteMessage[], messageStore: MessageStore, protocolDefinition?: ProtocolDefinition): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Checks if the `who: 'author' | 'recipient'` action rule has a matching record in the record chain.
|
|
37
|
+
* For cross-protocol `of` references (e.g., `"threads:thread"`), matches against both the protocol URI
|
|
38
|
+
* and the protocol path of the ancestor record.
|
|
39
|
+
* @returns `true` if the action rule is satisfied; `false` otherwise.
|
|
40
|
+
*/
|
|
41
|
+
export declare function checkActor(author: string, actionRule: ProtocolActionRule, recordChain: RecordsWriteMessage[], composingDefinition?: ProtocolDefinition): Promise<boolean>;
|
|
42
|
+
//# sourceMappingURL=protocol-authorization-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-authorization-action.d.ts","sourceRoot":"","sources":["../../../../src/core/protocol-authorization-action.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG3G,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAI9D,OAAO,EAAE,cAAc,EAAiB,MAAM,6BAA6B,CAAC;AAE5E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAE7E;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,WAAW,GAAG,gBAAgB,GAAG,YAAY,EAC5G,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,kBAAkB,EAAE,kBAAkB,EACtC,YAAY,EAAE,YAAY,EAC1B,uBAAuB,EAAE,yBAAyB,EAClD,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC,IAAI,CAAC,CA6Ff;AAED;;;;;;;;;GASG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,WAAW,GAAG,gBAAgB,GAAG,YAAY,EAC5G,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,cAAc,EAAE,CAAC,CA4E3B;AAED;;;;GAIG;AACH,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,WAAW,GAAG,gBAAgB,GAAG,YAAY,EAC5G,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,mBAAmB,EAAE,EAClC,YAAY,EAAE,YAAY,EAC1B,kBAAkB,CAAC,EAAE,kBAAkB,GACtC,OAAO,CAAC,IAAI,CAAC,CAyFf;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,kBAAkB,EAC9B,WAAW,EAAE,mBAAmB,EAAE,EAClC,mBAAmB,CAAC,EAAE,kBAAkB,GACvC,OAAO,CAAC,OAAO,CAAC,CA0ClB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { MessageStore } from '../types/message-store.js';
|
|
2
|
+
import type { RecordsWriteMessage } from '../types/records-types.js';
|
|
3
|
+
import type { ProtocolDefinition, ProtocolRuleSet, ProtocolTypes } from '../types/protocols-types.js';
|
|
4
|
+
import type { RecordsWrite } from '../interfaces/records-write.js';
|
|
5
|
+
import type { FetchProtocolDefinitionFn } from './protocol-authorization.js';
|
|
6
|
+
/**
|
|
7
|
+
* Verifies the `protocolPath` declared in the given message matches the path of actual record chain.
|
|
8
|
+
* For cross-protocol composition, the parent record may belong to a different protocol (resolved via `$ref` in the composing protocol).
|
|
9
|
+
* @throws {DwnError} if fails verification.
|
|
10
|
+
*/
|
|
11
|
+
export declare function verifyProtocolPathAndContextId(tenant: string, inboundMessage: RecordsWrite, messageStore: MessageStore, fetchProtocolDefinition: FetchProtocolDefinitionFn, governingTimestamp?: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the protocol URI that should be used when querying for the parent record.
|
|
14
|
+
* For standard (non-composed) records, this is the same as the child's protocol.
|
|
15
|
+
* For cross-protocol composition, the parent may live in a different protocol
|
|
16
|
+
* (resolved via `$ref` in the composing protocol's definition).
|
|
17
|
+
*
|
|
18
|
+
* Logic: Given a child at protocolPath `a/b/c`, the parent is at `a/b`.
|
|
19
|
+
* Walk up the composing protocol's structure from root to `a/b`.
|
|
20
|
+
* If any segment along the way has a `$ref`, the parent (and its ancestors up to the `$ref` boundary)
|
|
21
|
+
* live in the referenced protocol. Specifically, the `$ref` at the topmost ancestor tells us
|
|
22
|
+
* the parent's protocol URI.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveParentProtocolUri(tenant: string, childProtocolUri: string, childProtocolPath: string, messageStore: MessageStore, fetchProtocolDefinition: FetchProtocolDefinitionFn, governingTimestamp?: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Verifies the `dataFormat` and `schema` declared in the given message matches the type in the protocol.
|
|
27
|
+
* For cross-protocol composition, if the type is at a `$ref` position in the structure,
|
|
28
|
+
* the type definition is looked up in the referenced protocol's `types` map instead.
|
|
29
|
+
*/
|
|
30
|
+
export declare function verifyTypeWithComposition(tenant: string, inboundMessage: RecordsWriteMessage, protocolDefinition: ProtocolDefinition, messageStore: MessageStore, fetchProtocolDefinition: FetchProtocolDefinitionFn, governingTimestamp?: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Resolves the `ProtocolTypes` map that contains the type definition for the given protocol path.
|
|
33
|
+
* For non-composed records, this is the protocol definition's own `types` map.
|
|
34
|
+
* For records at a `$ref` position, this is the referenced protocol's `types` map.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveProtocolTypesForPath(tenant: string, protocolPath: string, protocolDefinition: ProtocolDefinition, messageStore: MessageStore, fetchProtocolDefinition: FetchProtocolDefinitionFn, governingTimestamp?: string): Promise<ProtocolTypes>;
|
|
37
|
+
/**
|
|
38
|
+
* Verifies the `dataFormat` and `schema` declared in the given message (if it is a RecordsWrite) matches dataFormat
|
|
39
|
+
* and schema of the type in the given protocol.
|
|
40
|
+
* @throws {DwnError} if fails verification.
|
|
41
|
+
*/
|
|
42
|
+
export declare function verifyType(inboundMessage: RecordsWriteMessage, protocolTypes: ProtocolTypes, typeName?: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Verifies that writes adhere to the $size constraints if provided
|
|
45
|
+
* @throws {Error} if size is exceeded.
|
|
46
|
+
*/
|
|
47
|
+
export declare function verifySizeLimit(incomingMessage: RecordsWrite, ruleSet: ProtocolRuleSet): void;
|
|
48
|
+
/**
|
|
49
|
+
* Verifies record tags against the `$tags` schema in the rule set using JSON Schema (Ajv).
|
|
50
|
+
* Checks required tags, additional properties, and schema conformance.
|
|
51
|
+
*/
|
|
52
|
+
export declare function verifyTagsIfNeeded(incomingMessage: RecordsWrite, ruleSet: ProtocolRuleSet): void;
|
|
53
|
+
/**
|
|
54
|
+
* If the given RecordsWrite is not a role record, this method does nothing and succeeds immediately.
|
|
55
|
+
*
|
|
56
|
+
* Else it verifies the validity of the given `RecordsWrite` as a role record, including:
|
|
57
|
+
* 1. The same role has not been assigned to the same entity/recipient.
|
|
58
|
+
*/
|
|
59
|
+
export declare function verifyAsRoleRecordIfNeeded(tenant: string, incomingMessage: RecordsWrite, ruleSet: ProtocolRuleSet, messageStore: MessageStore): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Verifies that a new record creation does not exceed the `$recordLimit` defined in the rule set.
|
|
62
|
+
*
|
|
63
|
+
* This check only applies to initial writes (new records). Updates to existing records are not counted.
|
|
64
|
+
* The count is scoped to the same `protocol + protocolPath` within the parent context:
|
|
65
|
+
* - For root-level records: counted across the entire protocol for the tenant.
|
|
66
|
+
* - For nested records: counted within the parent record's context.
|
|
67
|
+
*
|
|
68
|
+
* @throws {DwnError} with `ProtocolAuthorizationRecordLimitExceeded` if the limit is reached and strategy is `reject`.
|
|
69
|
+
* @throws {DwnError} with `ProtocolAuthorizationRecordLimitStrategyNotImplemented` if strategy is not yet implemented.
|
|
70
|
+
*/
|
|
71
|
+
export declare function verifyRecordLimit(tenant: string, incomingMessage: RecordsWrite, ruleSet: ProtocolRuleSet, messageStore: MessageStore): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Verifies that an update is not attempted on a record whose protocol path has `$immutable: true`.
|
|
74
|
+
*
|
|
75
|
+
* Only non-initial writes (updates) are rejected — initial writes are always allowed.
|
|
76
|
+
* `RecordsDelete` is not affected by this check; immutability prevents data mutation, not removal.
|
|
77
|
+
*
|
|
78
|
+
* @throws {DwnError} with `ProtocolAuthorizationImmutableRecord` if an update is attempted on an immutable record.
|
|
79
|
+
*/
|
|
80
|
+
export declare function verifyImmutability(incomingMessage: RecordsWrite, ruleSet: ProtocolRuleSet): Promise<void>;
|
|
81
|
+
//# sourceMappingURL=protocol-authorization-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-authorization-validation.d.ts","sourceRoot":"","sources":["../../../../src/core/protocol-authorization-validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAgB,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAIpH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AASnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAE7E;;;;GAIG;AACH,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,MAAM,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;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CA6Cf;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CAiDf;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,IAAI,CAAC,CAcf"}
|
|
@@ -1,144 +1,62 @@
|
|
|
1
|
+
import type { CoreProtocolRegistry } from './core-protocol.js';
|
|
1
2
|
import type { MessageStore } from '../types/message-store.js';
|
|
2
3
|
import type { RecordsCount } from '../interfaces/records-count.js';
|
|
3
4
|
import type { RecordsDelete } from '../interfaces/records-delete.js';
|
|
4
5
|
import type { RecordsQuery } from '../interfaces/records-query.js';
|
|
5
6
|
import type { RecordsRead } from '../interfaces/records-read.js';
|
|
6
7
|
import type { RecordsSubscribe } from '../interfaces/records-subscribe.js';
|
|
7
|
-
import { RecordsWrite } from '../interfaces/records-write.js';
|
|
8
|
+
import type { RecordsWrite } from '../interfaces/records-write.js';
|
|
9
|
+
import type { ProtocolDefinition } from '../types/protocols-types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Function signature for fetching a protocol definition.
|
|
12
|
+
* Used by extracted modules to break the circular dependency on `ProtocolAuthorization`.
|
|
13
|
+
*/
|
|
14
|
+
export type FetchProtocolDefinitionFn = (tenant: string, protocolUri: string, messageStore: MessageStore, messageTimestamp?: string) => Promise<ProtocolDefinition>;
|
|
8
15
|
export declare class ProtocolAuthorization {
|
|
9
16
|
/**
|
|
10
17
|
* Performs validation on the structure of RecordsWrite messages that use a protocol.
|
|
11
18
|
* @throws {Error} if validation fails.
|
|
12
19
|
*/
|
|
13
|
-
static validateReferentialIntegrity(tenant: string, incomingMessage: RecordsWrite, messageStore: MessageStore): Promise<void>;
|
|
20
|
+
static validateReferentialIntegrity(tenant: string, incomingMessage: RecordsWrite, messageStore: MessageStore, coreProtocols?: CoreProtocolRegistry): Promise<void>;
|
|
14
21
|
/**
|
|
15
22
|
* Performs protocol-based authorization against the incoming RecordsWrite message.
|
|
16
23
|
* @throws {Error} if authorization fails.
|
|
17
24
|
*/
|
|
18
|
-
static authorizeWrite(tenant: string, incomingMessage: RecordsWrite, messageStore: MessageStore): Promise<void>;
|
|
25
|
+
static authorizeWrite(tenant: string, incomingMessage: RecordsWrite, messageStore: MessageStore, coreProtocols?: CoreProtocolRegistry): Promise<void>;
|
|
19
26
|
/**
|
|
20
27
|
* Performs protocol-based authorization against the incoming `RecordsRead` message.
|
|
21
28
|
* @param newestRecordsWrite The latest RecordsWrite associated with the recordId being read.
|
|
22
29
|
* @throws {Error} if authorization fails.
|
|
23
30
|
*/
|
|
24
|
-
static authorizeRead(tenant: string, incomingMessage: RecordsRead, newestRecordsWrite: RecordsWrite, messageStore: MessageStore): Promise<void>;
|
|
25
|
-
static authorizeQueryOrSubscribe(tenant: string, incomingMessage: RecordsCount | RecordsQuery | RecordsSubscribe, messageStore: MessageStore): Promise<void>;
|
|
31
|
+
static authorizeRead(tenant: string, incomingMessage: RecordsRead, newestRecordsWrite: RecordsWrite, messageStore: MessageStore, coreProtocols?: CoreProtocolRegistry): Promise<void>;
|
|
32
|
+
static authorizeQueryOrSubscribe(tenant: string, incomingMessage: RecordsCount | RecordsQuery | RecordsSubscribe, messageStore: MessageStore, coreProtocols?: CoreProtocolRegistry): Promise<void>;
|
|
26
33
|
/**
|
|
27
34
|
* Performs protocol-based authorization against the incoming `RecordsDelete` message.
|
|
28
35
|
* @param recordsWrite A `RecordsWrite` of the record being deleted.
|
|
29
36
|
*/
|
|
30
|
-
static authorizeDelete(tenant: string, incomingMessage: RecordsDelete, recordsWrite: RecordsWrite, messageStore: MessageStore): Promise<void>;
|
|
37
|
+
static authorizeDelete(tenant: string, incomingMessage: RecordsDelete, recordsWrite: RecordsWrite, messageStore: MessageStore, coreProtocols?: CoreProtocolRegistry): Promise<void>;
|
|
31
38
|
/**
|
|
32
39
|
* Fetches the protocol definition based on the protocol specified in the given message.
|
|
33
40
|
* When `messageTimestamp` is provided, returns the protocol definition that was active at that
|
|
34
41
|
* point in time — i.e. the ProtocolsConfigure with the greatest `messageTimestamp` that is <= the
|
|
35
42
|
* given timestamp. When not provided, returns the latest (current) protocol definition.
|
|
43
|
+
*
|
|
44
|
+
* When `coreProtocols` is provided, core protocol definitions are returned directly from the
|
|
45
|
+
* registry without a message store query. The extra parameter does not affect the
|
|
46
|
+
* `FetchProtocolDefinitionFn` callback type — callers that pass this function as a callback
|
|
47
|
+
* should bind the registry via a closure (see `createBoundFetchDefinition`).
|
|
36
48
|
*/
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Constructs the chain of EXISTING records in the datastore where the first record is the root initial `RecordsWrite` of the record chain
|
|
40
|
-
* and last record is the initial `RecordsWrite` of the descendant record specified.
|
|
41
|
-
* @param descendantRecordId The ID of the descendent record to start constructing the record chain from by repeatedly looking up the parent.
|
|
42
|
-
* @returns the record chain where each record is represented by its initial `RecordsWrite`;
|
|
43
|
-
* returns empty array if `descendantRecordId` is `undefined`.
|
|
44
|
-
* @throws {DwnError} if `descendantRecordId` is defined but any initial `RecordsWrite` is not found in the chain of records.
|
|
45
|
-
*/
|
|
46
|
-
private static constructRecordChain;
|
|
49
|
+
static fetchProtocolDefinition(tenant: string, protocolUri: string, messageStore: MessageStore, messageTimestamp?: string, coreProtocols?: CoreProtocolRegistry): Promise<ProtocolDefinition>;
|
|
47
50
|
/**
|
|
48
|
-
*
|
|
51
|
+
* Creates a `FetchProtocolDefinitionFn` closure that binds the given `CoreProtocolRegistry`.
|
|
52
|
+
* This allows core protocol definitions to be resolved from the registry without changing
|
|
53
|
+
* the `FetchProtocolDefinitionFn` type signature — zero ripple to downstream consumers
|
|
54
|
+
* like `protocol-authorization-action.ts` and `protocol-authorization-validation.ts`.
|
|
49
55
|
*/
|
|
50
|
-
private static
|
|
56
|
+
private static createBoundFetchDefinition;
|
|
51
57
|
/**
|
|
52
58
|
* Gets the rule set corresponding to the given protocolPath.
|
|
53
59
|
*/
|
|
54
60
|
private static getRuleSet;
|
|
55
|
-
/**
|
|
56
|
-
* Verifies the `protocolPath` declared in the given message (if it is a RecordsWrite) matches the path of actual record chain.
|
|
57
|
-
* For cross-protocol composition, the parent record may belong to a different protocol (resolved via `$ref` in the composing protocol).
|
|
58
|
-
* @throws {DwnError} if fails verification.
|
|
59
|
-
*/
|
|
60
|
-
private static verifyProtocolPathAndContextId;
|
|
61
|
-
/**
|
|
62
|
-
* Resolves the protocol URI that should be used when querying for the parent record.
|
|
63
|
-
* For standard (non-composed) records, this is the same as the child's protocol.
|
|
64
|
-
* For cross-protocol composition, the parent may live in a different protocol
|
|
65
|
-
* (resolved via `$ref` in the composing protocol's definition).
|
|
66
|
-
*
|
|
67
|
-
* Logic: Given a child at protocolPath `a/b/c`, the parent is at `a/b`.
|
|
68
|
-
* Walk up the composing protocol's structure from root to `a/b`.
|
|
69
|
-
* If any segment along the way has a `$ref`, the parent (and its ancestors up to the `$ref` boundary)
|
|
70
|
-
* live in the referenced protocol. Specifically, the `$ref` at the topmost ancestor tells us
|
|
71
|
-
* the parent's protocol URI.
|
|
72
|
-
*/
|
|
73
|
-
private static resolveParentProtocolUri;
|
|
74
|
-
/**
|
|
75
|
-
* Verifies the `dataFormat` and `schema` declared in the given message matches the type in the protocol.
|
|
76
|
-
* For cross-protocol composition, if the type is at a `$ref` position in the structure,
|
|
77
|
-
* the type definition is looked up in the referenced protocol's `types` map instead.
|
|
78
|
-
*/
|
|
79
|
-
private static verifyTypeWithComposition;
|
|
80
|
-
/**
|
|
81
|
-
* Resolves the `ProtocolTypes` map that contains the type definition for the given protocol path.
|
|
82
|
-
* For non-composed records, this is the protocol definition's own `types` map.
|
|
83
|
-
* For records at a `$ref` position, this is the referenced protocol's `types` map.
|
|
84
|
-
*/
|
|
85
|
-
private static resolveProtocolTypesForPath;
|
|
86
|
-
/**
|
|
87
|
-
* Verifies the `dataFormat` and `schema` declared in the given message (if it is a RecordsWrite) matches dataFormat
|
|
88
|
-
* and schema of the type in the given protocol.
|
|
89
|
-
* @throws {DwnError} if fails verification.
|
|
90
|
-
*/
|
|
91
|
-
private static verifyType;
|
|
92
|
-
/**
|
|
93
|
-
* Check if the incoming message is invoking a role. If so, validate the invoked role.
|
|
94
|
-
* For cross-protocol role invocation, the role record may live in a different protocol
|
|
95
|
-
* (resolved via the composing protocol's `uses` map).
|
|
96
|
-
*/
|
|
97
|
-
private static verifyInvokedRole;
|
|
98
|
-
/**
|
|
99
|
-
* Returns all the ProtocolActions that would authorized the incoming message
|
|
100
|
-
* (but we still need to later verify if there is a rule defined that matches one of the actions).
|
|
101
|
-
* NOTE: the reason why there could be multiple actions is because:
|
|
102
|
-
* - In case of an initial RecordsWrite, the RecordsWrite can be authorized by an allow `create` or `write` rule.
|
|
103
|
-
* - In case of a non-initial RecordsWrite by the original record author, the RecordsWrite can be authorized by a `write` or `co-update` rule.
|
|
104
|
-
*
|
|
105
|
-
* It is important to recognize that the `write` access that allowed the original record author to create the record maybe revoked
|
|
106
|
-
* (e.g. by role revocation) by the time a "non-initial" write by the same author is attempted.
|
|
107
|
-
*/
|
|
108
|
-
private static getActionsSeekingARuleMatch;
|
|
109
|
-
/**
|
|
110
|
-
* Verifies the given message is authorized by one of the action rules in the given protocol rule set.
|
|
111
|
-
* @param protocolDefinition Optional protocol definition for resolving cross-protocol `of` and `role` references.
|
|
112
|
-
* @throws {Error} if action not allowed.
|
|
113
|
-
*/
|
|
114
|
-
private static authorizeAgainstAllowedActions;
|
|
115
|
-
/**
|
|
116
|
-
* Verifies that writes adhere to the $size constraints if provided
|
|
117
|
-
* @throws {Error} if size is exceeded.
|
|
118
|
-
*/
|
|
119
|
-
private static verifySizeLimit;
|
|
120
|
-
private static verifyTagsIfNeeded;
|
|
121
|
-
/**
|
|
122
|
-
* If the given RecordsWrite is not a role record, this method does nothing and succeeds immediately.
|
|
123
|
-
*
|
|
124
|
-
* Else it verifies the validity of the given `RecordsWrite` as a role record, including:
|
|
125
|
-
* 1. The same role has not been assigned to the same entity/recipient.
|
|
126
|
-
*/
|
|
127
|
-
private static verifyAsRoleRecordIfNeeded;
|
|
128
|
-
/**
|
|
129
|
-
* Checks if the `who: 'author' | 'recipient'` action rule has a matching record in the record chain.
|
|
130
|
-
* For cross-protocol `of` references (e.g., `"threads:thread"`), matches against both the protocol URI
|
|
131
|
-
* and the protocol path of the ancestor record.
|
|
132
|
-
* @returns `true` if the action rule is satisfied; `false` otherwise.
|
|
133
|
-
*/
|
|
134
|
-
private static checkActor;
|
|
135
|
-
/**
|
|
136
|
-
* Determines the timestamp that governs which protocol definition version applies to the given RecordsWrite.
|
|
137
|
-
* For an update, this is the initial write's `messageTimestamp` (the protocol version is locked at creation time).
|
|
138
|
-
* For a new initial write, returns `undefined` — the latest protocol definition should be used because the
|
|
139
|
-
* record is being created now and must conform to the current protocol rules.
|
|
140
|
-
*/
|
|
141
|
-
private static getGoverningTimestamp;
|
|
142
|
-
private static getTypeName;
|
|
143
61
|
}
|
|
144
62
|
//# sourceMappingURL=protocol-authorization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-authorization.d.ts","sourceRoot":"","sources":["../../../../src/core/protocol-authorization.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"protocol-authorization.d.ts","sourceRoot":"","sources":["../../../../src/core/protocol-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAA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YAAY,EAC1B,aAAa,CAAC,EAAE,oBAAoB,GACnC,OAAO,CAAC,IAAI,CAAC;IA0ChB;;;OAGG;WACiB,eAAe,CACjC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,aAAa,EAC9B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,aAAa,CAAC,EAAE,oBAAoB,GACnC,OAAO,CAAC,IAAI,CAAC;IAsDhB;;;;;;;;;;OAUG;WACiB,uBAAuB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,YAAY,EAC1B,gBAAgB,CAAC,EAAE,MAAM,EACzB,aAAa,CAAC,EAAE,oBAAoB,GACnC,OAAO,CAAC,kBAAkB,CAAC;IAuC9B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAWzC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;CAY1B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { MessageStore } from '../types/message-store.js';
|
|
2
|
+
import type { RecordsWriteMessage } from '../types/records-types.js';
|
|
3
|
+
import { RecordsWrite } from '../interfaces/records-write.js';
|
|
4
|
+
/**
|
|
5
|
+
* Fetches the initial RecordsWrite message associated with the given (tenant + recordId).
|
|
6
|
+
*/
|
|
7
|
+
export declare function fetchInitialWrite(tenant: string, recordId: string, messageStore: MessageStore): Promise<RecordsWriteMessage | undefined>;
|
|
8
|
+
/**
|
|
9
|
+
* Constructs the chain of EXISTING records in the datastore where the first record is the root initial `RecordsWrite` of the record chain
|
|
10
|
+
* and last record is the initial `RecordsWrite` of the descendant record specified.
|
|
11
|
+
* @param descendantRecordId The ID of the descendent record to start constructing the record chain from by repeatedly looking up the parent.
|
|
12
|
+
* @returns the record chain where each record is represented by its initial `RecordsWrite`;
|
|
13
|
+
* returns empty array if `descendantRecordId` is `undefined`.
|
|
14
|
+
* @throws {DwnError} if `descendantRecordId` is defined but any initial `RecordsWrite` is not found in the chain of records.
|
|
15
|
+
*/
|
|
16
|
+
export declare function constructRecordChain(tenant: string, descendantRecordId: string | undefined, messageStore: MessageStore): Promise<RecordsWriteMessage[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Determines the timestamp that governs which protocol definition version applies to the given RecordsWrite.
|
|
19
|
+
* For an update, this is the initial write's `messageTimestamp` (the protocol version is locked at creation time).
|
|
20
|
+
* For a new initial write, returns `undefined` — the latest protocol definition should be used because the
|
|
21
|
+
* record is being created now and must conform to the current protocol rules.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getGoverningTimestamp(tenant: string, incomingMessage: RecordsWrite, messageStore: MessageStore): Promise<string | undefined>;
|
|
24
|
+
//# sourceMappingURL=record-chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-chain.d.ts","sourceRoot":"","sources":["../../../../src/core/record-chain.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAI9D;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAe1C;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,MAAM,GAAG,SAAS,EACtC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CA8BhC;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,EAC7B,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAY7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records-grant-authorization.d.ts","sourceRoot":"","sources":["../../../../src/core/records-grant-authorization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAMlL,qBAAa,yBAAyB;IACpC;;OAEG;WACiB,cAAc,CAAC,KAAK,EAAE;QACxC,mBAAmB,EAAE,mBAAmB,CAAC;QACzC,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,eAAe,CAAC;QACjC,YAAY,EAAE,YAAY,CAAC;KAC5B,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBjB;;;OAGG;WACiB,aAAa,CAAC,KAAK,EAAE;QACvC,kBAAkB,EAAE,kBAAkB,CAAC;QACvC,2BAA2B,EAAE,mBAAmB,CAAC;QACjD,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,eAAe,CAAC;QACjC,YAAY,EAAE,YAAY,CAAC;KAC5B,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBjB;;;OAGG;WACiB,yBAAyB,CAAC,KAAK,EAAE;QACnD,eAAe,EAAE,mBAAmB,GAAG,mBAAmB,GAAG,uBAAuB,CAAC;QACrF,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,eAAe,CAAC;QACjC,YAAY,EAAE,YAAY,CAAC;KAC5B,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"records-grant-authorization.d.ts","sourceRoot":"","sources":["../../../../src/core/records-grant-auth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AE,MAAM,CAAC;QACxB,eAAe,EAAE,eAAe,CAAC;QACjC,YAAY,EAAE,YAAY,CAAC;KAC5B,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBjB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAgC1B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;CAkBhC"}
|
package/dist/types/src/dwn.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { DataStore } from './types/data-store.js';
|
|
2
2
|
import type { DidResolver } from '@enbox/dids';
|
|
3
|
-
import type { EventStream } from './types/subscriptions.js';
|
|
4
3
|
import type { MessageStore } from './types/message-store.js';
|
|
5
4
|
import type { ResumableTaskStore } from './types/resumable-task-store.js';
|
|
6
5
|
import type { StateIndex } from './types/state-index.js';
|
|
7
6
|
import type { TenantGate } from './core/tenant-gate.js';
|
|
8
7
|
import type { UnionMessageReply } from './core/message-reply.js';
|
|
8
|
+
import type { EventLog, SubscriptionListener } from './types/subscriptions.js';
|
|
9
9
|
import type { GenericMessageReply } from './types/message-types.js';
|
|
10
|
-
import type { MessagesReadMessage, MessagesReadReply, MessagesSubscribeMessage, MessagesSubscribeMessageOptions, MessagesSubscribeReply, MessagesSyncMessage, MessagesSyncReply
|
|
10
|
+
import type { MessagesReadMessage, MessagesReadReply, MessagesSubscribeMessage, MessagesSubscribeMessageOptions, MessagesSubscribeReply, MessagesSyncMessage, MessagesSyncReply } from './types/messages-types.js';
|
|
11
11
|
import type { ProtocolsConfigureMessage, ProtocolsQueryMessage, ProtocolsQueryReply } from './types/protocols-types.js';
|
|
12
|
-
import type { RecordsCountMessage, RecordsCountReply, RecordsDeleteMessage, RecordsQueryMessage, RecordsQueryReply, RecordsReadMessage, RecordsReadReply, RecordsSubscribeMessage, RecordsSubscribeMessageOptions, RecordsSubscribeReply,
|
|
12
|
+
import type { RecordsCountMessage, RecordsCountReply, RecordsDeleteMessage, RecordsQueryMessage, RecordsQueryReply, RecordsReadMessage, RecordsReadReply, RecordsSubscribeMessage, RecordsSubscribeMessageOptions, RecordsSubscribeReply, RecordsWriteMessage, RecordsWriteMessageOptions } from './types/records-types.js';
|
|
13
|
+
import { CoreProtocolRegistry } from './core/core-protocol.js';
|
|
13
14
|
export declare class Dwn {
|
|
14
15
|
private methodHandlers;
|
|
15
16
|
private didResolver;
|
|
@@ -18,9 +19,10 @@ export declare class Dwn {
|
|
|
18
19
|
private resumableTaskStore;
|
|
19
20
|
private stateIndex;
|
|
20
21
|
private tenantGate;
|
|
21
|
-
private
|
|
22
|
+
private eventLog?;
|
|
22
23
|
private storageController;
|
|
23
24
|
private resumableTaskManager;
|
|
25
|
+
private _coreProtocols;
|
|
24
26
|
private constructor();
|
|
25
27
|
/**
|
|
26
28
|
* Creates an instance of the DWN.
|
|
@@ -31,6 +33,12 @@ export declare class Dwn {
|
|
|
31
33
|
*/
|
|
32
34
|
open(): Promise<void>;
|
|
33
35
|
close(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* The registry of core protocols (hardcoded, immutable, always-installed).
|
|
38
|
+
* Used by handlers and utilities that need to check whether a protocol URI
|
|
39
|
+
* belongs to a core protocol or to dispatch lifecycle hooks.
|
|
40
|
+
*/
|
|
41
|
+
get coreProtocols(): CoreProtocolRegistry;
|
|
34
42
|
/**
|
|
35
43
|
* Returns the internal storage components for advanced operations that
|
|
36
44
|
* cannot be expressed through the standard `processMessage()` pipeline
|
|
@@ -41,7 +49,7 @@ export declare class Dwn {
|
|
|
41
49
|
get storage(): {
|
|
42
50
|
messageStore: MessageStore;
|
|
43
51
|
stateIndex: StateIndex;
|
|
44
|
-
|
|
52
|
+
eventLog: EventLog | undefined;
|
|
45
53
|
};
|
|
46
54
|
/**
|
|
47
55
|
* Processes the given DWN message and returns with a reply.
|
|
@@ -80,7 +88,7 @@ export declare class Dwn {
|
|
|
80
88
|
*/
|
|
81
89
|
export interface MessageOptions {
|
|
82
90
|
dataStream?: ReadableStream<Uint8Array>;
|
|
83
|
-
subscriptionHandler?:
|
|
91
|
+
subscriptionHandler?: SubscriptionListener;
|
|
84
92
|
}
|
|
85
93
|
/**
|
|
86
94
|
* DWN configuration.
|
|
@@ -88,7 +96,11 @@ export interface MessageOptions {
|
|
|
88
96
|
export type DwnConfig = {
|
|
89
97
|
didResolver?: DidResolver;
|
|
90
98
|
tenantGate?: TenantGate;
|
|
91
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Persistent event log with cursor-based reads and in-process subscriptions.
|
|
101
|
+
* Optional — if not provided, subscriptions will not be supported.
|
|
102
|
+
*/
|
|
103
|
+
eventLog?: EventLog;
|
|
92
104
|
messageStore: MessageStore;
|
|
93
105
|
dataStore: DataStore;
|
|
94
106
|
stateIndex: StateIndex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dwn.d.ts","sourceRoot":"","sources":["../../../src/dwn.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dwn.d.ts","sourceRoot":"","sources":["../../../src/dwn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAkB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpF,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAA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