@enbox/dwn-sdk-js 0.0.5 → 0.0.7
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 +1 -2
- 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/dwn-constant.js +7 -7
- package/dist/esm/src/core/dwn-constant.js.map +1 -1
- package/dist/esm/src/core/dwn-error.js +1 -0
- package/dist/esm/src/core/dwn-error.js.map +1 -1
- package/dist/esm/src/core/grant-authorization.js +37 -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 +254 -0
- package/dist/esm/src/core/protocol-authorization-validation.js.map +1 -0
- package/dist/esm/src/core/protocol-authorization.js +122 -740
- 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 +55 -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 +69 -86
- package/dist/esm/src/dwn.js.map +1 -1
- package/dist/esm/src/event-stream/event-emitter-stream.js +17 -31
- package/dist/esm/src/event-stream/event-emitter-stream.js.map +1 -1
- package/dist/esm/src/handlers/messages-read.js +67 -77
- package/dist/esm/src/handlers/messages-read.js.map +1 -1
- package/dist/esm/src/handlers/messages-subscribe.js +51 -61
- package/dist/esm/src/handlers/messages-subscribe.js.map +1 -1
- package/dist/esm/src/handlers/messages-sync.js +75 -85
- package/dist/esm/src/handlers/messages-sync.js.map +1 -1
- package/dist/esm/src/handlers/protocols-configure.js +135 -155
- package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
- package/dist/esm/src/handlers/protocols-query.js +52 -51
- package/dist/esm/src/handlers/protocols-query.js.map +1 -1
- package/dist/esm/src/handlers/records-count.js +96 -82
- package/dist/esm/src/handlers/records-count.js.map +1 -1
- package/dist/esm/src/handlers/records-delete.js +78 -88
- package/dist/esm/src/handlers/records-delete.js.map +1 -1
- package/dist/esm/src/handlers/records-query.js +116 -101
- package/dist/esm/src/handlers/records-query.js.map +1 -1
- package/dist/esm/src/handlers/records-read.js +124 -131
- package/dist/esm/src/handlers/records-read.js.map +1 -1
- package/dist/esm/src/handlers/records-subscribe.js +150 -103
- package/dist/esm/src/handlers/records-subscribe.js.map +1 -1
- package/dist/esm/src/handlers/records-write.js +250 -259
- package/dist/esm/src/handlers/records-write.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 +27 -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 +63 -63
- 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 +52 -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 +92 -0
- package/dist/esm/src/interfaces/records-write-signing.js.map +1 -0
- package/dist/esm/src/interfaces/records-write.js +407 -602
- 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 +44 -15
- package/dist/esm/src/protocols/permission-grant.js.map +1 -1
- package/dist/esm/src/protocols/permission-request.js +29 -15
- package/dist/esm/src/protocols/permission-request.js.map +1 -1
- package/dist/esm/src/protocols/permissions.js +216 -226
- 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 +115 -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 +59 -99
- 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 +295 -713
- 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 +129 -144
- package/dist/esm/src/store/storage-controller.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 -63
- 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 +9 -3
- 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 +108 -140
- 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 +9 -18
- package/dist/esm/tests/core/protocol-authorization.spec.js.map +1 -1
- package/dist/esm/tests/dwn.spec.js +45 -58
- package/dist/esm/tests/dwn.spec.js.map +1 -1
- package/dist/esm/tests/event-stream/event-emitter-stream.spec.js +24 -33
- package/dist/esm/tests/event-stream/event-emitter-stream.spec.js.map +1 -1
- package/dist/esm/tests/event-stream/event-stream.spec.js +46 -55
- package/dist/esm/tests/event-stream/event-stream.spec.js.map +1 -1
- package/dist/esm/tests/features/author-delegated-grant.spec.js +326 -343
- package/dist/esm/tests/features/author-delegated-grant.spec.js.map +1 -1
- package/dist/esm/tests/features/owner-delegated-grant.spec.js +153 -169
- package/dist/esm/tests/features/owner-delegated-grant.spec.js.map +1 -1
- package/dist/esm/tests/features/owner-signature.spec.js +67 -78
- package/dist/esm/tests/features/owner-signature.spec.js.map +1 -1
- package/dist/esm/tests/features/permissions.spec.js +446 -181
- package/dist/esm/tests/features/permissions.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-composition.spec.js +346 -356
- package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-create-action.spec.js +42 -51
- package/dist/esm/tests/features/protocol-create-action.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-delete-action.spec.js +94 -103
- package/dist/esm/tests/features/protocol-delete-action.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-update-action.spec.js +105 -114
- package/dist/esm/tests/features/protocol-update-action.spec.js.map +1 -1
- package/dist/esm/tests/features/records-prune.spec.js +175 -191
- package/dist/esm/tests/features/records-prune.spec.js.map +1 -1
- package/dist/esm/tests/features/records-tags.spec.js +441 -460
- package/dist/esm/tests/features/records-tags.spec.js.map +1 -1
- package/dist/esm/tests/features/resumable-tasks.spec.js +82 -91
- package/dist/esm/tests/features/resumable-tasks.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-read.spec.js +206 -207
- package/dist/esm/tests/handlers/messages-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-subscribe.spec.js +145 -154
- package/dist/esm/tests/handlers/messages-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-sync.spec.js +174 -183
- package/dist/esm/tests/handlers/messages-sync.spec.js.map +1 -1
- package/dist/esm/tests/handlers/protocols-configure.spec.js +244 -238
- package/dist/esm/tests/handlers/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/handlers/protocols-query.spec.js +156 -169
- package/dist/esm/tests/handlers/protocols-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-count.spec.js +93 -102
- package/dist/esm/tests/handlers/records-count.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-delete.spec.js +252 -264
- package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-query.spec.js +917 -988
- package/dist/esm/tests/handlers/records-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-read.spec.js +553 -568
- package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-subscribe.spec.js +269 -278
- package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-write.spec.js +1057 -1082
- 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 +152 -165
- 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 +124 -135
- package/dist/esm/tests/scenarios/aggregator.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/deleted-record.spec.js +23 -32
- package/dist/esm/tests/scenarios/deleted-record.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +52 -61
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/nested-roles.spec.js +63 -73
- package/dist/esm/tests/scenarios/nested-roles.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/subscriptions.spec.js +377 -333
- 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 +86 -95
- 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 +3 -3
- 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 +2 -11
- 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 +291 -44
- 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 +6 -15
- 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 +10 -19
- 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 +414 -468
- 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 +7 -16
- package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js.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 +60 -0
- package/dist/types/src/core/protocol-authorization-validation.d.ts.map +1 -0
- package/dist/types/src/core/protocol-authorization.d.ts +10 -100
- 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/handlers/records-write.d.ts +2 -1
- package/dist/types/src/handlers/records-write.d.ts.map +1 -1
- package/dist/types/src/interfaces/protocols-configure.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 +35 -0
- package/dist/types/src/interfaces/records-write-signing.d.ts.map +1 -0
- package/dist/types/src/interfaces/records-write.d.ts +10 -44
- package/dist/types/src/interfaces/records-write.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 +0 -58
- package/dist/types/src/store/index-level.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 +3 -1
- package/dist/types/src/utils/records.d.ts.map +1 -1
- package/dist/types/tests/features/permissions.spec.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/core/protocol-authorization-action.ts +377 -0
- package/src/core/protocol-authorization-validation.ts +391 -0
- package/src/core/protocol-authorization.ts +60 -849
- package/src/core/record-chain.ts +99 -0
- package/src/handlers/records-read.ts +1 -1
- package/src/handlers/records-write.ts +37 -21
- package/src/interfaces/protocols-configure.ts +33 -5
- package/src/interfaces/records-write-query.ts +139 -0
- package/src/interfaces/records-write-signing.ts +143 -0
- package/src/interfaces/records-write.ts +49 -221
- package/src/store/index-level-compound.ts +324 -0
- package/src/store/index-level.ts +24 -306
- package/src/utils/protocols.ts +8 -0
- package/src/utils/records.ts +9 -15
|
@@ -7,7 +7,6 @@ import type { PublicKeyJwk } from '../types/jose-types.js';
|
|
|
7
7
|
import type {
|
|
8
8
|
DataEncodedRecordsWriteMessage,
|
|
9
9
|
InternalRecordsWriteMessage,
|
|
10
|
-
RecordsWriteAttestationPayload,
|
|
11
10
|
RecordsWriteDescriptor,
|
|
12
11
|
RecordsWriteMessage,
|
|
13
12
|
RecordsWriteSignaturePayload,
|
|
@@ -17,19 +16,29 @@ import type { EncryptionInput, JweEncryption } from '../utils/encryption.js';
|
|
|
17
16
|
import type { GenericMessage, GenericSignaturePayload } from '../types/message-types.js';
|
|
18
17
|
|
|
19
18
|
import { Cid } from '../utils/cid.js';
|
|
20
|
-
import { Encoder } from '../utils/encoder.js';
|
|
21
|
-
import { Encryption } from '../utils/encryption.js';
|
|
22
|
-
import { GeneralJwsBuilder } from '../jose/jws/general/builder.js';
|
|
23
19
|
import { Jws } from '../utils/jws.js';
|
|
24
|
-
import { KeyDerivationScheme } from '../utils/hd-key.js';
|
|
25
20
|
import { Message } from '../core/message.js';
|
|
26
21
|
import { PermissionGrant } from '../protocols/permission-grant.js';
|
|
27
22
|
import { Records } from '../utils/records.js';
|
|
28
23
|
import { RecordsGrantAuthorization } from '../core/records-grant-authorization.js';
|
|
29
24
|
import { removeUndefinedProperties } from '../utils/object.js';
|
|
30
25
|
import { Time } from '../utils/time.js';
|
|
26
|
+
import {
|
|
27
|
+
createAttestation,
|
|
28
|
+
createEncryptionProperty,
|
|
29
|
+
createSignerSignature,
|
|
30
|
+
validateAttestationIntegrity,
|
|
31
|
+
} from './records-write-signing.js';
|
|
31
32
|
import { DwnError, DwnErrorCode } from '../core/dwn-error.js';
|
|
32
33
|
import { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
34
|
+
import {
|
|
35
|
+
fetchInitialRecordsWrite,
|
|
36
|
+
fetchInitialRecordsWriteMessage,
|
|
37
|
+
fetchNewestRecordsWrite,
|
|
38
|
+
getAttesters,
|
|
39
|
+
getInitialWrite,
|
|
40
|
+
verifyEqualityOfImmutableProperties,
|
|
41
|
+
} from './records-write-query.js';
|
|
33
42
|
import { normalizeProtocolUrl, normalizeSchemaUrl, validateProtocolUrlNormalized, validateSchemaUrlNormalized } from '../utils/url.js';
|
|
34
43
|
|
|
35
44
|
export type RecordsWriteOptions = {
|
|
@@ -226,7 +235,7 @@ export class RecordsWrite implements MessageInterface<RecordsWriteMessage> {
|
|
|
226
235
|
}
|
|
227
236
|
}
|
|
228
237
|
|
|
229
|
-
this.attesters =
|
|
238
|
+
this.attesters = getAttesters(message);
|
|
230
239
|
|
|
231
240
|
// consider converting isInitialWrite() & getEntryId() into properties for performance and convenience
|
|
232
241
|
}
|
|
@@ -254,7 +263,7 @@ export class RecordsWrite implements MessageInterface<RecordsWriteMessage> {
|
|
|
254
263
|
await Message.validateSignatureStructure(message.authorization.ownerSignature, message.descriptor);
|
|
255
264
|
}
|
|
256
265
|
|
|
257
|
-
await
|
|
266
|
+
await validateAttestationIntegrity(message);
|
|
258
267
|
|
|
259
268
|
const recordsWrite = new RecordsWrite(message);
|
|
260
269
|
|
|
@@ -334,10 +343,10 @@ export class RecordsWrite implements MessageInterface<RecordsWriteMessage> {
|
|
|
334
343
|
|
|
335
344
|
// `attestation` generation
|
|
336
345
|
const descriptorCid = await Cid.computeCid(descriptor);
|
|
337
|
-
const attestation = await
|
|
346
|
+
const attestation = await createAttestation(descriptorCid, options.attestationSigners);
|
|
338
347
|
|
|
339
348
|
// `encryption` generation
|
|
340
|
-
const encryption = await
|
|
349
|
+
const encryption = await createEncryptionProperty(descriptor, options.encryptionInput);
|
|
341
350
|
|
|
342
351
|
const message: InternalRecordsWriteMessage = {
|
|
343
352
|
recordId,
|
|
@@ -465,7 +474,7 @@ export class RecordsWrite implements MessageInterface<RecordsWriteMessage> {
|
|
|
465
474
|
}
|
|
466
475
|
|
|
467
476
|
// Build only the new recipients (reuses createEncryptionProperty for ECDH-ES+A256KW logic)
|
|
468
|
-
const newEncryption = await
|
|
477
|
+
const newEncryption = await createEncryptionProperty(this._message.descriptor, encryptionInput);
|
|
469
478
|
if (newEncryption) {
|
|
470
479
|
this._message.encryption.recipients.push(...newEncryption.recipients);
|
|
471
480
|
}
|
|
@@ -484,7 +493,7 @@ export class RecordsWrite implements MessageInterface<RecordsWriteMessage> {
|
|
|
484
493
|
// the contextKey schema. We chose the in-record approach because it keeps
|
|
485
494
|
// records self-contained and the read/decrypt path unchanged.
|
|
486
495
|
} else {
|
|
487
|
-
this._message.encryption = await
|
|
496
|
+
this._message.encryption = await createEncryptionProperty(this._message.descriptor, encryptionInput);
|
|
488
497
|
|
|
489
498
|
// Full replacement invalidates the authorization — caller must re-sign.
|
|
490
499
|
delete this._message.authorization;
|
|
@@ -534,7 +543,7 @@ export class RecordsWrite implements MessageInterface<RecordsWriteMessage> {
|
|
|
534
543
|
}
|
|
535
544
|
|
|
536
545
|
// `signature` generation
|
|
537
|
-
const signature = await
|
|
546
|
+
const signature = await createSignerSignature({
|
|
538
547
|
recordId : this._message.recordId,
|
|
539
548
|
contextId : this._message.contextId,
|
|
540
549
|
descriptorCid,
|
|
@@ -705,43 +714,11 @@ export class RecordsWrite implements MessageInterface<RecordsWriteMessage> {
|
|
|
705
714
|
}
|
|
706
715
|
|
|
707
716
|
/**
|
|
708
|
-
*
|
|
709
|
-
* NOTE: Cryptographic verification of attestation signatures is performed in `authenticate()`.
|
|
717
|
+
* Delegate to the standalone `validateAttestationIntegrity` function for backward compatibility.
|
|
710
718
|
*/
|
|
711
719
|
private static async validateAttestationIntegrity(message: RecordsWriteMessage): Promise<void> {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
// TODO: multi-attesters to be unblocked by #205 - Revisit database interfaces (https://github.com/enboxorg/enbox/issues/205)
|
|
717
|
-
if (message.attestation.signatures.length !== 1) {
|
|
718
|
-
throw new DwnError(
|
|
719
|
-
DwnErrorCode.RecordsWriteAttestationIntegrityMoreThanOneSignature,
|
|
720
|
-
`Currently implementation only supports 1 attester, but got ${message.attestation.signatures.length}`
|
|
721
|
-
);
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
const payloadJson = Jws.decodePlainObjectPayload(message.attestation);
|
|
725
|
-
const { descriptorCid } = payloadJson;
|
|
726
|
-
|
|
727
|
-
// `descriptorCid` validation - ensure that the provided descriptorCid matches the CID of the actual message
|
|
728
|
-
const expectedDescriptorCid = await Cid.computeCid(message.descriptor);
|
|
729
|
-
if (descriptorCid !== expectedDescriptorCid) {
|
|
730
|
-
throw new DwnError(
|
|
731
|
-
DwnErrorCode.RecordsWriteAttestationIntegrityDescriptorCidMismatch,
|
|
732
|
-
`descriptorCid ${descriptorCid} does not match expected descriptorCid ${expectedDescriptorCid}`
|
|
733
|
-
);
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
// check to ensure that no other unexpected properties exist in payload.
|
|
737
|
-
const propertyCount = Object.keys(payloadJson).length;
|
|
738
|
-
if (propertyCount > 1) {
|
|
739
|
-
throw new DwnError(
|
|
740
|
-
DwnErrorCode.RecordsWriteAttestationIntegrityInvalidPayloadProperty,
|
|
741
|
-
`Only 'descriptorCid' is allowed in attestation payload, but got ${propertyCount} properties.`
|
|
742
|
-
);
|
|
743
|
-
}
|
|
744
|
-
};
|
|
720
|
+
return validateAttestationIntegrity(message);
|
|
721
|
+
}
|
|
745
722
|
|
|
746
723
|
/**
|
|
747
724
|
* Computes the deterministic Entry ID of this message.
|
|
@@ -799,7 +776,7 @@ export class RecordsWrite implements MessageInterface<RecordsWriteMessage> {
|
|
|
799
776
|
}
|
|
800
777
|
|
|
801
778
|
// add additional indexes to optional values if given
|
|
802
|
-
// TODO: index
|
|
779
|
+
// TODO: index multiple attesters (https://github.com/enboxorg/enbox/issues/223)
|
|
803
780
|
if (this.attesters.length > 0) { indexes.attester = this.attesters[0]; }
|
|
804
781
|
if (message.contextId !== undefined) { indexes.contextId = message.contextId; }
|
|
805
782
|
|
|
@@ -852,73 +829,20 @@ export class RecordsWrite implements MessageInterface<RecordsWriteMessage> {
|
|
|
852
829
|
return (entryId === recordsWriteMessage.recordId);
|
|
853
830
|
}
|
|
854
831
|
|
|
855
|
-
/**
|
|
856
|
-
* Creates the JWE `encryption` property if encryption input is given. Else `undefined` is returned.
|
|
857
|
-
* Uses ECDH-ES+A256KW key agreement with X25519 and AEAD content encryption (A256GCM or XC20P).
|
|
858
|
-
* @param descriptor Descriptor of the `RecordsWrite` message which contains the information needed by key path derivation schemes.
|
|
859
|
-
*/
|
|
860
|
-
/**
|
|
861
|
-
* Creates the JWE `encryption` property if encryption input is given. Else `undefined` is returned.
|
|
862
|
-
* Uses ECDH-ES+A256KW key agreement with X25519 and AEAD content encryption (A256GCM or XC20P).
|
|
863
|
-
* @param descriptor Descriptor of the `RecordsWrite` message which contains the information needed by key path derivation schemes.
|
|
864
|
-
* @param encryptionInput The encryption input containing CEK, IV, and recipient key encryption inputs.
|
|
865
|
-
* @param tag The authentication tag from the AEAD content encryption (stored in the JWE, separate from the ciphertext).
|
|
866
|
-
*/
|
|
867
|
-
/**
|
|
868
|
-
* Creates the JWE `encryption` property if encryption input is given. Else `undefined` is returned.
|
|
869
|
-
* Uses ECDH-ES+A256KW key agreement with X25519 and AEAD content encryption (A256GCM or XC20P).
|
|
870
|
-
* @param descriptor Descriptor of the `RecordsWrite` message which contains the information needed by key path derivation schemes.
|
|
871
|
-
* @param encryptionInput The encryption input containing CEK, IV, authentication tag, and recipient key encryption inputs.
|
|
872
|
-
*/
|
|
832
|
+
/** Delegate to `createEncryptionProperty` in `records-write-signing.ts`. */
|
|
873
833
|
private static async createEncryptionProperty(
|
|
874
834
|
descriptor: RecordsWriteDescriptor,
|
|
875
835
|
encryptionInput: EncryptionInput | undefined,
|
|
876
836
|
): Promise<JweEncryption | undefined> {
|
|
877
|
-
|
|
878
|
-
return undefined;
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
// Validate derivation scheme prerequisites
|
|
882
|
-
for (const keyEncryptionInput of encryptionInput.keyEncryptionInputs) {
|
|
883
|
-
if (keyEncryptionInput.derivationScheme === KeyDerivationScheme.ProtocolPath && descriptor.protocol === undefined) {
|
|
884
|
-
throw new DwnError(
|
|
885
|
-
DwnErrorCode.RecordsWriteMissingProtocol,
|
|
886
|
-
'`protocols` encryption scheme cannot be applied to record without the `protocol` property.'
|
|
887
|
-
);
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
if (keyEncryptionInput.derivationScheme === KeyDerivationScheme.Schemas && descriptor.schema === undefined) {
|
|
891
|
-
throw new DwnError(
|
|
892
|
-
DwnErrorCode.RecordsWriteMissingSchema,
|
|
893
|
-
'`schemas` encryption scheme cannot be applied to record without the `schema` property.'
|
|
894
|
-
);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
// Build the JWE structure. The authentication tag comes from the AEAD encryption of record data.
|
|
899
|
-
const jwe = await Encryption.buildJwe(encryptionInput, encryptionInput.authenticationTag);
|
|
900
|
-
|
|
901
|
-
return jwe;
|
|
837
|
+
return createEncryptionProperty(descriptor, encryptionInput);
|
|
902
838
|
}
|
|
903
839
|
|
|
904
|
-
/**
|
|
905
|
-
* Creates the `attestation` property of a RecordsWrite message if given signature inputs; returns `undefined` otherwise.
|
|
906
|
-
*/
|
|
840
|
+
/** Delegate to `createAttestation` in `records-write-signing.ts`. */
|
|
907
841
|
public static async createAttestation(descriptorCid: string, signers?: MessageSigner[]): Promise<GeneralJws | undefined> {
|
|
908
|
-
|
|
909
|
-
return undefined;
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
const attestationPayload: RecordsWriteAttestationPayload = { descriptorCid };
|
|
913
|
-
const attestationPayloadBytes = Encoder.objectToBytes(attestationPayload);
|
|
914
|
-
|
|
915
|
-
const builder = await GeneralJwsBuilder.create(attestationPayloadBytes, signers);
|
|
916
|
-
return builder.getJws();
|
|
842
|
+
return createAttestation(descriptorCid, signers);
|
|
917
843
|
}
|
|
918
844
|
|
|
919
|
-
/**
|
|
920
|
-
* Creates the `signature` property in the `authorization` of a `RecordsWrite` message.
|
|
921
|
-
*/
|
|
845
|
+
/** Delegate to `createSignerSignature` in `records-write-signing.ts`. */
|
|
922
846
|
public static async createSignerSignature(input: {
|
|
923
847
|
recordId: string,
|
|
924
848
|
contextId: string | undefined,
|
|
@@ -930,140 +854,44 @@ export class RecordsWrite implements MessageInterface<RecordsWriteMessage> {
|
|
|
930
854
|
permissionGrantId?: string,
|
|
931
855
|
protocolRole?: string
|
|
932
856
|
}): Promise<GeneralJws> {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
const attestationCid = attestation ? await Cid.computeCid(attestation) : undefined;
|
|
936
|
-
const encryptionCid = encryption ? await Cid.computeCid(encryption) : undefined;
|
|
937
|
-
|
|
938
|
-
const signaturePayload: RecordsWriteSignaturePayload = {
|
|
939
|
-
recordId,
|
|
940
|
-
descriptorCid,
|
|
941
|
-
contextId,
|
|
942
|
-
attestationCid,
|
|
943
|
-
encryptionCid,
|
|
944
|
-
delegatedGrantId,
|
|
945
|
-
permissionGrantId,
|
|
946
|
-
protocolRole
|
|
947
|
-
};
|
|
948
|
-
removeUndefinedProperties(signaturePayload);
|
|
949
|
-
|
|
950
|
-
const signaturePayloadBytes = Encoder.objectToBytes(signaturePayload);
|
|
951
|
-
|
|
952
|
-
const builder = await GeneralJwsBuilder.create(signaturePayloadBytes, [signer]);
|
|
953
|
-
const signature = builder.getJws();
|
|
954
|
-
|
|
955
|
-
return signature;
|
|
857
|
+
return createSignerSignature(input);
|
|
956
858
|
}
|
|
957
859
|
|
|
958
|
-
/**
|
|
959
|
-
* Gets the initial write from the given list of `RecordsWrite`.
|
|
960
|
-
*/
|
|
860
|
+
/** Delegate to `getInitialWrite` in `records-write-query.ts`. */
|
|
961
861
|
public static async getInitialWrite(messages: GenericMessage[]): Promise<RecordsWriteMessage> {
|
|
962
|
-
|
|
963
|
-
if (await RecordsWrite.isInitialWrite(message)) {
|
|
964
|
-
return message as RecordsWriteMessage;
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
throw new DwnError(DwnErrorCode.RecordsWriteGetInitialWriteNotFound, `Initial write is not found.`);
|
|
862
|
+
return getInitialWrite(messages);
|
|
969
863
|
}
|
|
970
864
|
|
|
971
|
-
/**
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
const mutableDescriptorProperties = ['dataCid', 'dataSize', 'dataFormat', 'datePublished', 'published', 'messageTimestamp', 'tags'];
|
|
977
|
-
|
|
978
|
-
// get distinct property names that exist in either the existing message given or new message
|
|
979
|
-
let descriptorPropertyNames: string[] = [];
|
|
980
|
-
descriptorPropertyNames.push(...Object.keys(existingWriteMessage.descriptor));
|
|
981
|
-
descriptorPropertyNames.push(...Object.keys(newMessage.descriptor));
|
|
982
|
-
descriptorPropertyNames = [...new Set(descriptorPropertyNames)]; // step to remove duplicates
|
|
983
|
-
|
|
984
|
-
// ensure all immutable properties are not modified
|
|
985
|
-
for (const descriptorPropertyName of descriptorPropertyNames) {
|
|
986
|
-
// if property is supposed to be immutable
|
|
987
|
-
if (mutableDescriptorProperties.indexOf(descriptorPropertyName) === -1) {
|
|
988
|
-
const valueInExistingWrite = (existingWriteMessage.descriptor as Record<string, unknown>)[descriptorPropertyName];
|
|
989
|
-
const valueInNewMessage = (newMessage.descriptor as Record<string, unknown>)[descriptorPropertyName];
|
|
990
|
-
if (valueInNewMessage !== valueInExistingWrite) {
|
|
991
|
-
throw new DwnError(
|
|
992
|
-
DwnErrorCode.RecordsWriteImmutablePropertyChanged,
|
|
993
|
-
`${descriptorPropertyName} is an immutable property: cannot change '${valueInExistingWrite}' to '${valueInNewMessage}'`
|
|
994
|
-
);
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
return true;
|
|
865
|
+
/** Delegate to `verifyEqualityOfImmutableProperties` in `records-write-query.ts`. */
|
|
866
|
+
public static verifyEqualityOfImmutableProperties(
|
|
867
|
+
existingWriteMessage: RecordsWriteMessage, newMessage: RecordsWriteMessage
|
|
868
|
+
): boolean {
|
|
869
|
+
return verifyEqualityOfImmutableProperties(existingWriteMessage, newMessage);
|
|
1000
870
|
}
|
|
1001
871
|
|
|
1002
|
-
/**
|
|
1003
|
-
* Gets the DID of the attesters of the given message.
|
|
1004
|
-
*/
|
|
872
|
+
/** Delegate to `getAttesters` in `records-write-query.ts`. */
|
|
1005
873
|
public static getAttesters(message: InternalRecordsWriteMessage): string[] {
|
|
1006
|
-
|
|
1007
|
-
const attesters = attestationSignatures.map((signature) => Jws.getSignerDid(signature));
|
|
1008
|
-
return attesters;
|
|
874
|
+
return getAttesters(message);
|
|
1009
875
|
}
|
|
1010
876
|
|
|
877
|
+
/** Delegate to `fetchNewestRecordsWrite` in `records-write-query.ts`. */
|
|
1011
878
|
public static async fetchNewestRecordsWrite(
|
|
1012
|
-
messageStore: MessageStore,
|
|
1013
|
-
tenant: string,
|
|
1014
|
-
recordId: string,
|
|
879
|
+
messageStore: MessageStore, tenant: string, recordId: string,
|
|
1015
880
|
): Promise<RecordsWriteMessage> {
|
|
1016
|
-
|
|
1017
|
-
const query = {
|
|
1018
|
-
interface : DwnInterfaceName.Records,
|
|
1019
|
-
method : DwnMethodName.Write,
|
|
1020
|
-
recordId : recordId
|
|
1021
|
-
};
|
|
1022
|
-
|
|
1023
|
-
const { messages: existingMessages } = await messageStore.query(tenant, [ query ]);
|
|
1024
|
-
const newestWrite = await Message.getNewestMessage(existingMessages);
|
|
1025
|
-
if (newestWrite !== undefined) {
|
|
1026
|
-
return newestWrite as RecordsWriteMessage;
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
throw new DwnError(DwnErrorCode.RecordsWriteGetNewestWriteRecordNotFound, 'record not found');
|
|
881
|
+
return fetchNewestRecordsWrite(messageStore, tenant, recordId);
|
|
1030
882
|
}
|
|
1031
883
|
|
|
1032
|
-
/**
|
|
1033
|
-
* Fetches the initial RecordsWrite of a record.
|
|
1034
|
-
* @returns The initial RecordsWrite if found; `undefined` otherwise.
|
|
1035
|
-
*/
|
|
884
|
+
/** Delegate to `fetchInitialRecordsWrite` in `records-write-query.ts`. */
|
|
1036
885
|
public static async fetchInitialRecordsWrite(
|
|
1037
|
-
messageStore: MessageStore,
|
|
1038
|
-
tenant: string,
|
|
1039
|
-
recordId: string
|
|
886
|
+
messageStore: MessageStore, tenant: string, recordId: string
|
|
1040
887
|
): Promise<RecordsWrite | undefined> {
|
|
1041
|
-
|
|
1042
|
-
const initialRecordsWriteMessage = await RecordsWrite.fetchInitialRecordsWriteMessage(messageStore, tenant, recordId);
|
|
1043
|
-
if (initialRecordsWriteMessage === undefined) {
|
|
1044
|
-
return undefined;
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
const initialRecordsWrite = await RecordsWrite.parse(initialRecordsWriteMessage);
|
|
1048
|
-
return initialRecordsWrite;
|
|
888
|
+
return fetchInitialRecordsWrite(messageStore, tenant, recordId) as Promise<RecordsWrite | undefined>;
|
|
1049
889
|
}
|
|
1050
890
|
|
|
1051
|
-
/**
|
|
1052
|
-
* Fetches the initial RecordsWrite message of a record.
|
|
1053
|
-
* @returns The initial RecordsWriteMessage if found; `undefined` otherwise.
|
|
1054
|
-
*/
|
|
891
|
+
/** Delegate to `fetchInitialRecordsWriteMessage` in `records-write-query.ts`. */
|
|
1055
892
|
public static async fetchInitialRecordsWriteMessage(
|
|
1056
|
-
messageStore: MessageStore,
|
|
1057
|
-
tenant: string,
|
|
1058
|
-
recordId: string
|
|
893
|
+
messageStore: MessageStore, tenant: string, recordId: string
|
|
1059
894
|
): Promise<RecordsWriteMessage | undefined> {
|
|
1060
|
-
|
|
1061
|
-
const { messages } = await messageStore.query(tenant, [query]);
|
|
1062
|
-
|
|
1063
|
-
if (messages.length === 0) {
|
|
1064
|
-
return undefined;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
return messages[0] as RecordsWriteMessage;
|
|
895
|
+
return fetchInitialRecordsWriteMessage(messageStore, tenant, recordId);
|
|
1068
896
|
}
|
|
1069
897
|
}
|