@enbox/dwn-sdk-js 0.0.2 → 0.0.4
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/README.md +52 -301
- package/dist/bundles/dwn.js +19 -21
- package/dist/esm/generated/precompiled-validators.js +2764 -1773
- package/dist/esm/generated/precompiled-validators.js.map +1 -1
- package/dist/esm/src/core/dwn-error.js +27 -3
- package/dist/esm/src/core/dwn-error.js.map +1 -1
- package/dist/esm/src/core/message.js.map +1 -1
- package/dist/esm/src/core/messages-grant-authorization.js +17 -6
- package/dist/esm/src/core/messages-grant-authorization.js.map +1 -1
- package/dist/esm/src/core/protocol-authorization.js +245 -69
- package/dist/esm/src/core/protocol-authorization.js.map +1 -1
- package/dist/esm/src/core/resumable-task-manager.js +4 -4
- package/dist/esm/src/core/resumable-task-manager.js.map +1 -1
- package/dist/esm/src/dwn.js +10 -8
- package/dist/esm/src/dwn.js.map +1 -1
- package/dist/esm/src/enums/dwn-interface-method.js +4 -2
- package/dist/esm/src/enums/dwn-interface-method.js.map +1 -1
- package/dist/esm/src/event-stream/event-emitter-stream.js.map +1 -0
- package/dist/esm/src/handlers/messages-subscribe.js +1 -1
- package/dist/esm/src/handlers/messages-subscribe.js.map +1 -1
- package/dist/esm/src/handlers/messages-sync.js +116 -0
- package/dist/esm/src/handlers/messages-sync.js.map +1 -0
- package/dist/esm/src/handlers/protocols-configure.js +149 -16
- package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
- package/dist/esm/src/handlers/protocols-query.js +2 -2
- package/dist/esm/src/handlers/protocols-query.js.map +1 -1
- package/dist/esm/src/handlers/records-count.js +143 -0
- package/dist/esm/src/handlers/records-count.js.map +1 -0
- package/dist/esm/src/handlers/records-query.js +4 -0
- package/dist/esm/src/handlers/records-query.js.map +1 -1
- package/dist/esm/src/handlers/records-read.js +4 -6
- package/dist/esm/src/handlers/records-read.js.map +1 -1
- package/dist/esm/src/handlers/records-write.js +17 -18
- package/dist/esm/src/handlers/records-write.js.map +1 -1
- package/dist/esm/src/index.js +9 -5
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/interfaces/messages-read.js +2 -7
- package/dist/esm/src/interfaces/messages-read.js.map +1 -1
- package/dist/esm/src/interfaces/messages-subscribe.js +1 -0
- package/dist/esm/src/interfaces/messages-subscribe.js.map +1 -1
- package/dist/esm/src/interfaces/{messages-query.js → messages-sync.js} +11 -12
- package/dist/esm/src/interfaces/messages-sync.js.map +1 -0
- package/dist/esm/src/interfaces/protocols-configure.js +153 -30
- package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
- package/dist/esm/src/interfaces/protocols-query.js +1 -0
- package/dist/esm/src/interfaces/protocols-query.js.map +1 -1
- package/dist/esm/src/interfaces/records-count.js +91 -0
- package/dist/esm/src/interfaces/records-count.js.map +1 -0
- package/dist/esm/src/interfaces/records-read.js +15 -1
- package/dist/esm/src/interfaces/records-read.js.map +1 -1
- package/dist/esm/src/interfaces/records-write.js +64 -15
- package/dist/esm/src/interfaces/records-write.js.map +1 -1
- package/dist/esm/src/jose/algorithms/signing/ed25519.js.map +1 -1
- package/dist/esm/src/jose/algorithms/signing/signature-algorithms.js.map +1 -1
- package/dist/esm/src/jose/jws/general/builder.js.map +1 -1
- package/dist/esm/src/jose/jws/general/verifier.js.map +1 -1
- package/dist/esm/src/protocols/permission-grant.js +30 -0
- package/dist/esm/src/protocols/permission-grant.js.map +1 -1
- package/dist/esm/src/protocols/permission-request.js +24 -0
- package/dist/esm/src/protocols/permission-request.js.map +1 -1
- package/dist/esm/src/protocols/permissions.js +1 -1
- package/dist/esm/src/protocols/permissions.js.map +1 -1
- package/dist/esm/src/schema-validator.js +0 -1
- package/dist/esm/src/schema-validator.js.map +1 -1
- package/dist/esm/src/smt/smt-store-level.js +125 -0
- package/dist/esm/src/smt/smt-store-level.js.map +1 -0
- package/dist/esm/src/smt/smt-store-memory.js +67 -0
- package/dist/esm/src/smt/smt-store-memory.js.map +1 -0
- package/dist/esm/src/smt/smt-utils.js +146 -0
- package/dist/esm/src/smt/smt-utils.js.map +1 -0
- package/dist/esm/src/smt/sparse-merkle-tree.js +622 -0
- package/dist/esm/src/smt/sparse-merkle-tree.js.map +1 -0
- package/dist/esm/src/state-index/state-index-level.js +228 -0
- package/dist/esm/src/state-index/state-index-level.js.map +1 -0
- package/dist/esm/src/store/data-store-level.js +6 -6
- package/dist/esm/src/store/data-store-level.js.map +1 -1
- package/dist/esm/src/store/index-level.js +375 -17
- package/dist/esm/src/store/index-level.js.map +1 -1
- package/dist/esm/src/store/message-store-level.js +56 -0
- package/dist/esm/src/store/message-store-level.js.map +1 -1
- package/dist/esm/src/store/storage-controller.js +19 -16
- package/dist/esm/src/store/storage-controller.js.map +1 -1
- package/dist/esm/src/types/encryption-types.js +2 -0
- package/dist/esm/src/types/encryption-types.js.map +1 -0
- package/dist/esm/src/types/message-types.js.map +1 -1
- package/dist/esm/src/types/protocols-types.js +0 -2
- package/dist/esm/src/types/protocols-types.js.map +1 -1
- package/dist/esm/src/types/records-types.js +2 -0
- package/dist/esm/src/types/records-types.js.map +1 -1
- package/dist/esm/src/types/smt-types.js +5 -0
- package/dist/esm/src/types/smt-types.js.map +1 -0
- package/dist/esm/src/types/state-index.js +2 -0
- package/dist/esm/src/types/state-index.js.map +1 -0
- package/dist/esm/src/utils/cid.js +2 -1
- package/dist/esm/src/utils/cid.js.map +1 -1
- package/dist/esm/src/utils/data-stream.js +84 -29
- package/dist/esm/src/utils/data-stream.js.map +1 -1
- package/dist/esm/src/utils/encryption.js +22 -31
- package/dist/esm/src/utils/encryption.js.map +1 -1
- package/dist/esm/src/utils/hd-key.js +3 -3
- package/dist/esm/src/utils/hd-key.js.map +1 -1
- package/dist/esm/src/utils/jws.js +4 -4
- package/dist/esm/src/utils/jws.js.map +1 -1
- package/dist/esm/src/utils/private-key-signer.js +4 -3
- package/dist/esm/src/utils/private-key-signer.js.map +1 -1
- package/dist/esm/src/utils/protocols.js +82 -9
- package/dist/esm/src/utils/protocols.js.map +1 -1
- package/dist/esm/src/utils/records.js +82 -26
- package/dist/esm/src/utils/records.js.map +1 -1
- package/dist/esm/src/utils/secp256k1.js +4 -3
- package/dist/esm/src/utils/secp256k1.js.map +1 -1
- package/dist/esm/src/utils/secp256r1.js +3 -2
- package/dist/esm/src/utils/secp256r1.js.map +1 -1
- package/dist/esm/src/utils/time.js +1 -1
- package/dist/esm/src/utils/url.js +1 -1
- package/dist/esm/src/utils/url.js.map +1 -1
- package/dist/esm/tests/core/auth.spec.js +2 -2
- package/dist/esm/tests/core/auth.spec.js.map +1 -1
- package/dist/esm/tests/core/message-reply.spec.js +3 -3
- package/dist/esm/tests/core/message-reply.spec.js.map +1 -1
- package/dist/esm/tests/core/message.spec.js +13 -13
- package/dist/esm/tests/core/message.spec.js.map +1 -1
- package/dist/esm/tests/core/protocol-authorization.spec.js +3 -3
- package/dist/esm/tests/core/protocol-authorization.spec.js.map +1 -1
- package/dist/esm/tests/dwn.spec.js +27 -37
- package/dist/esm/tests/dwn.spec.js.map +1 -1
- package/dist/esm/tests/{event-log → event-stream}/event-emitter-stream.spec.js +14 -15
- package/dist/esm/tests/event-stream/event-emitter-stream.spec.js.map +1 -0
- package/dist/esm/tests/{event-log → event-stream}/event-stream.spec.js +13 -15
- package/dist/esm/tests/event-stream/event-stream.spec.js.map +1 -0
- package/dist/esm/tests/features/author-delegated-grant.spec.js +281 -135
- package/dist/esm/tests/features/author-delegated-grant.spec.js.map +1 -1
- package/dist/esm/tests/features/owner-delegated-grant.spec.js +57 -59
- package/dist/esm/tests/features/owner-delegated-grant.spec.js.map +1 -1
- package/dist/esm/tests/features/owner-signature.spec.js +32 -34
- package/dist/esm/tests/features/owner-signature.spec.js.map +1 -1
- package/dist/esm/tests/features/permissions.spec.js +73 -95
- package/dist/esm/tests/features/permissions.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-composition.spec.js +1645 -0
- package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -0
- package/dist/esm/tests/features/protocol-create-action.spec.js +25 -27
- package/dist/esm/tests/features/protocol-create-action.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-delete-action.spec.js +42 -44
- package/dist/esm/tests/features/protocol-delete-action.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-update-action.spec.js +53 -55
- package/dist/esm/tests/features/protocol-update-action.spec.js.map +1 -1
- package/dist/esm/tests/features/records-prune.spec.js +126 -100
- package/dist/esm/tests/features/records-prune.spec.js.map +1 -1
- package/dist/esm/tests/features/records-tags.spec.js +272 -272
- package/dist/esm/tests/features/records-tags.spec.js.map +1 -1
- package/dist/esm/tests/features/resumable-tasks.spec.js +35 -37
- package/dist/esm/tests/features/resumable-tasks.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-read.spec.js +112 -112
- package/dist/esm/tests/handlers/messages-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-subscribe.spec.js +78 -76
- package/dist/esm/tests/handlers/messages-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-sync.spec.js +528 -0
- package/dist/esm/tests/handlers/messages-sync.spec.js.map +1 -0
- package/dist/esm/tests/handlers/protocols-configure.spec.js +545 -152
- package/dist/esm/tests/handlers/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/handlers/protocols-query.spec.js +70 -72
- package/dist/esm/tests/handlers/protocols-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-count.spec.js +313 -0
- package/dist/esm/tests/handlers/records-count.spec.js.map +1 -0
- package/dist/esm/tests/handlers/records-delete.spec.js +106 -109
- package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-query.spec.js +863 -463
- package/dist/esm/tests/handlers/records-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-read.spec.js +439 -209
- package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-subscribe.spec.js +292 -97
- package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-write.spec.js +481 -483
- package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/messages-get.spec.js +31 -11
- package/dist/esm/tests/interfaces/messages-get.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/messages-subscribe.spec.js +5 -5
- package/dist/esm/tests/interfaces/messages-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/protocols-configure.spec.js +64 -134
- package/dist/esm/tests/interfaces/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/protocols-query.spec.js +4 -6
- package/dist/esm/tests/interfaces/protocols-query.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-delete.spec.js +3 -5
- package/dist/esm/tests/interfaces/records-delete.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-query.spec.js +9 -11
- package/dist/esm/tests/interfaces/records-query.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-read.spec.js +76 -7
- package/dist/esm/tests/interfaces/records-read.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-subscribe.spec.js +7 -9
- package/dist/esm/tests/interfaces/records-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-write.spec.js +244 -48
- package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -1
- package/dist/esm/tests/jose/jws/general.spec.js +15 -18
- package/dist/esm/tests/jose/jws/general.spec.js.map +1 -1
- package/dist/esm/tests/protocols/permission-grant.spec.js +114 -0
- package/dist/esm/tests/protocols/permission-grant.spec.js.map +1 -0
- package/dist/esm/tests/protocols/permission-request.spec.js +43 -7
- package/dist/esm/tests/protocols/permission-request.spec.js.map +1 -1
- package/dist/esm/tests/protocols/permissions.spec.js +9 -11
- package/dist/esm/tests/protocols/permissions.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/aggregator.spec.js +90 -92
- package/dist/esm/tests/scenarios/aggregator.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/deleted-record.spec.js +17 -19
- package/dist/esm/tests/scenarios/deleted-record.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +27 -29
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/nested-roles.spec.js +37 -39
- package/dist/esm/tests/scenarios/nested-roles.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/subscriptions.spec.js +163 -163
- package/dist/esm/tests/scenarios/subscriptions.spec.js.map +1 -1
- package/dist/esm/tests/smt/smt-store-level.spec.js +143 -0
- package/dist/esm/tests/smt/smt-store-level.spec.js.map +1 -0
- package/dist/esm/tests/smt/sparse-merkle-tree.spec.js +741 -0
- package/dist/esm/tests/smt/sparse-merkle-tree.spec.js.map +1 -0
- package/dist/esm/tests/state-index/state-index-level.spec.js +254 -0
- package/dist/esm/tests/state-index/state-index-level.spec.js.map +1 -0
- package/dist/esm/tests/store/blockstore-level.spec.js +136 -0
- package/dist/esm/tests/store/blockstore-level.spec.js.map +1 -0
- package/dist/esm/tests/store/blockstore-mock.spec.js +29 -28
- package/dist/esm/tests/store/blockstore-mock.spec.js.map +1 -1
- package/dist/esm/tests/store/data-store-level.spec.js +23 -25
- package/dist/esm/tests/store/data-store-level.spec.js.map +1 -1
- package/dist/esm/tests/store/index-level.spec.js +544 -194
- package/dist/esm/tests/store/index-level.spec.js.map +1 -1
- package/dist/esm/tests/store/message-store-level.spec.js +4 -4
- package/dist/esm/tests/store/message-store-level.spec.js.map +1 -1
- package/dist/esm/tests/store/message-store.spec.js +147 -73
- package/dist/esm/tests/store/message-store.spec.js.map +1 -1
- package/dist/esm/tests/store-dependent-tests.spec.js +1 -0
- package/dist/esm/tests/store-dependent-tests.spec.js.map +1 -1
- package/dist/esm/tests/test-stores.js +5 -5
- package/dist/esm/tests/test-stores.js.map +1 -1
- package/dist/esm/tests/test-suite.js +9 -8
- package/dist/esm/tests/test-suite.js.map +1 -1
- package/dist/esm/tests/utils/cid.spec.js +8 -11
- package/dist/esm/tests/utils/cid.spec.js.map +1 -1
- package/dist/esm/tests/utils/data-stream.spec.js +167 -13
- package/dist/esm/tests/utils/data-stream.spec.js.map +1 -1
- package/dist/esm/tests/utils/encryption-callbacks.spec.js +233 -0
- package/dist/esm/tests/utils/encryption-callbacks.spec.js.map +1 -0
- package/dist/esm/tests/utils/encryption.spec.js +34 -85
- package/dist/esm/tests/utils/encryption.spec.js.map +1 -1
- package/dist/esm/tests/utils/filters.spec.js +67 -69
- package/dist/esm/tests/utils/filters.spec.js.map +1 -1
- package/dist/esm/tests/utils/hd-key.spec.js +3 -3
- package/dist/esm/tests/utils/hd-key.spec.js.map +1 -1
- package/dist/esm/tests/utils/jws.spec.js +54 -3
- package/dist/esm/tests/utils/jws.spec.js.map +1 -1
- package/dist/esm/tests/utils/memory-cache.spec.js +6 -9
- package/dist/esm/tests/utils/memory-cache.spec.js.map +1 -1
- package/dist/esm/tests/utils/messages.spec.js +63 -29
- package/dist/esm/tests/utils/messages.spec.js.map +1 -1
- package/dist/esm/tests/utils/object.spec.js +3 -3
- package/dist/esm/tests/utils/object.spec.js.map +1 -1
- package/dist/esm/tests/utils/poller.js +1 -1
- package/dist/esm/tests/utils/poller.js.map +1 -1
- package/dist/esm/tests/utils/private-key-signer.spec.js +6 -6
- package/dist/esm/tests/utils/private-key-signer.spec.js.map +1 -1
- package/dist/esm/tests/utils/records.spec.js +37 -5
- package/dist/esm/tests/utils/records.spec.js.map +1 -1
- package/dist/esm/tests/utils/secp256k1.spec.js +7 -7
- package/dist/esm/tests/utils/secp256k1.spec.js.map +1 -1
- package/dist/esm/tests/utils/secp256r1.spec.js +7 -7
- package/dist/esm/tests/utils/secp256r1.spec.js.map +1 -1
- package/dist/esm/tests/utils/test-data-generator.js +47 -28
- package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
- package/dist/esm/tests/utils/time.spec.js +7 -7
- package/dist/esm/tests/utils/time.spec.js.map +1 -1
- package/dist/esm/tests/utils/url.spec.js +25 -27
- package/dist/esm/tests/utils/url.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/definitions.spec.js +4 -4
- 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 +15 -3
- 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 -8
- 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 +8 -18
- 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 +3 -3
- 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 +9 -9
- 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 +106 -0
- package/dist/esm/tests/validation/json-schemas/records/records-read.spec.js.map +1 -0
- package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js +18 -18
- package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js.map +1 -1
- package/dist/esm/tests/vectors/protocol-definitions/email.json +1 -1
- package/dist/esm/tests/vectors/protocol-definitions/friend-role.json +2 -4
- package/dist/esm/tests/vectors/protocol-definitions/slack.json +2 -6
- package/dist/esm/tests/vectors/protocol-definitions/thread-role.json +2 -6
- package/dist/types/generated/precompiled-validators.d.ts +82 -64
- package/dist/types/generated/precompiled-validators.d.ts.map +1 -1
- package/dist/types/src/core/dwn-error.d.ts +27 -3
- package/dist/types/src/core/dwn-error.d.ts.map +1 -1
- package/dist/types/src/core/message-reply.d.ts +1 -1
- package/dist/types/src/core/message.d.ts +3 -3
- package/dist/types/src/core/message.d.ts.map +1 -1
- package/dist/types/src/core/messages-grant-authorization.d.ts +4 -4
- package/dist/types/src/core/messages-grant-authorization.d.ts.map +1 -1
- package/dist/types/src/core/protocol-authorization.d.ts +43 -2
- package/dist/types/src/core/protocol-authorization.d.ts.map +1 -1
- package/dist/types/src/core/records-grant-authorization.d.ts +2 -2
- package/dist/types/src/core/records-grant-authorization.d.ts.map +1 -1
- package/dist/types/src/core/resumable-task-manager.d.ts +1 -0
- package/dist/types/src/core/resumable-task-manager.d.ts.map +1 -1
- package/dist/types/src/dwn.d.ts +8 -8
- package/dist/types/src/dwn.d.ts.map +1 -1
- package/dist/types/src/enums/dwn-interface-method.d.ts +5 -3
- package/dist/types/src/enums/dwn-interface-method.d.ts.map +1 -1
- package/dist/types/src/event-stream/event-emitter-stream.d.ts.map +1 -0
- package/dist/types/src/handlers/messages-sync.d.ts +21 -0
- package/dist/types/src/handlers/messages-sync.d.ts.map +1 -0
- package/dist/types/src/handlers/protocols-configure.d.ts +24 -4
- package/dist/types/src/handlers/protocols-configure.d.ts.map +1 -1
- package/dist/types/src/handlers/protocols-query.d.ts.map +1 -1
- package/dist/types/src/handlers/records-count.d.ts +43 -0
- package/dist/types/src/handlers/records-count.d.ts.map +1 -0
- package/dist/types/src/handlers/records-query.d.ts.map +1 -1
- package/dist/types/src/handlers/records-read.d.ts.map +1 -1
- package/dist/types/src/handlers/records-write.d.ts +5 -5
- package/dist/types/src/handlers/records-write.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +72 -37
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/interfaces/messages-read.d.ts +2 -2
- package/dist/types/src/interfaces/messages-read.d.ts.map +1 -1
- package/dist/types/src/interfaces/messages-subscribe.d.ts +2 -2
- package/dist/types/src/interfaces/messages-subscribe.d.ts.map +1 -1
- package/dist/types/src/interfaces/messages-sync.d.ts +16 -0
- package/dist/types/src/interfaces/messages-sync.d.ts.map +1 -0
- package/dist/types/src/interfaces/protocols-configure.d.ts +22 -2
- package/dist/types/src/interfaces/protocols-configure.d.ts.map +1 -1
- package/dist/types/src/interfaces/protocols-query.d.ts +2 -2
- package/dist/types/src/interfaces/protocols-query.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-count.d.ts +27 -0
- package/dist/types/src/interfaces/records-count.d.ts.map +1 -0
- package/dist/types/src/interfaces/records-delete.d.ts +2 -2
- package/dist/types/src/interfaces/records-delete.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-query.d.ts +2 -2
- package/dist/types/src/interfaces/records-query.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-read.d.ts +4 -2
- package/dist/types/src/interfaces/records-read.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-subscribe.d.ts +2 -2
- package/dist/types/src/interfaces/records-subscribe.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-write.d.ts +37 -15
- package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
- package/dist/types/src/jose/algorithms/signing/ed25519.d.ts.map +1 -1
- package/dist/types/src/jose/algorithms/signing/signature-algorithms.d.ts +5 -1
- package/dist/types/src/jose/algorithms/signing/signature-algorithms.d.ts.map +1 -1
- package/dist/types/src/jose/jws/general/builder.d.ts +3 -3
- package/dist/types/src/jose/jws/general/builder.d.ts.map +1 -1
- package/dist/types/src/protocols/permission-grant.d.ts +11 -0
- package/dist/types/src/protocols/permission-grant.d.ts.map +1 -1
- package/dist/types/src/protocols/permission-request.d.ts +11 -0
- package/dist/types/src/protocols/permission-request.d.ts.map +1 -1
- package/dist/types/src/protocols/permissions.d.ts +4 -4
- package/dist/types/src/protocols/permissions.d.ts.map +1 -1
- package/dist/types/src/schema-validator.d.ts +1 -1
- package/dist/types/src/schema-validator.d.ts.map +1 -1
- package/dist/types/src/smt/smt-store-level.d.ts +32 -0
- package/dist/types/src/smt/smt-store-level.d.ts.map +1 -0
- package/dist/types/src/smt/smt-store-memory.d.ts +22 -0
- package/dist/types/src/smt/smt-store-memory.d.ts.map +1 -0
- package/dist/types/src/smt/smt-utils.d.ts +58 -0
- package/dist/types/src/smt/smt-utils.d.ts.map +1 -0
- package/dist/types/src/smt/sparse-merkle-tree.d.ts +124 -0
- package/dist/types/src/smt/sparse-merkle-tree.d.ts.map +1 -0
- package/dist/types/src/state-index/state-index-level.d.ts +83 -0
- package/dist/types/src/state-index/state-index-level.d.ts.map +1 -0
- package/dist/types/src/store/data-store-level.d.ts +1 -2
- package/dist/types/src/store/data-store-level.d.ts.map +1 -1
- package/dist/types/src/store/index-level.d.ts +98 -2
- package/dist/types/src/store/index-level.d.ts.map +1 -1
- package/dist/types/src/store/level-wrapper.d.ts.map +1 -1
- package/dist/types/src/store/message-store-level.d.ts +5 -0
- package/dist/types/src/store/message-store-level.d.ts.map +1 -1
- package/dist/types/src/store/storage-controller.d.ts +7 -7
- package/dist/types/src/store/storage-controller.d.ts.map +1 -1
- package/dist/types/src/types/data-store.d.ts +2 -3
- package/dist/types/src/types/data-store.d.ts.map +1 -1
- package/dist/types/src/types/encryption-types.d.ts +48 -0
- package/dist/types/src/types/encryption-types.d.ts.map +1 -0
- package/dist/types/src/types/jose-types.d.ts +9 -40
- package/dist/types/src/types/jose-types.d.ts.map +1 -1
- package/dist/types/src/types/message-store.d.ts +5 -0
- package/dist/types/src/types/message-store.d.ts.map +1 -1
- package/dist/types/src/types/message-types.d.ts +19 -0
- package/dist/types/src/types/message-types.d.ts.map +1 -1
- package/dist/types/src/types/messages-types.d.ts +16 -11
- package/dist/types/src/types/messages-types.d.ts.map +1 -1
- package/dist/types/src/types/method-handler.d.ts +1 -2
- package/dist/types/src/types/method-handler.d.ts.map +1 -1
- package/dist/types/src/types/permission-types.d.ts +2 -2
- package/dist/types/src/types/permission-types.d.ts.map +1 -1
- package/dist/types/src/types/protocols-types.d.ts +49 -5
- package/dist/types/src/types/protocols-types.d.ts.map +1 -1
- package/dist/types/src/types/records-types.d.ts +23 -7
- package/dist/types/src/types/records-types.d.ts.map +1 -1
- package/dist/types/src/types/signer.d.ts +1 -1
- package/dist/types/src/types/signer.d.ts.map +1 -1
- package/dist/types/src/types/smt-types.d.ts +81 -0
- package/dist/types/src/types/smt-types.d.ts.map +1 -0
- package/dist/types/src/types/state-index.d.ts +90 -0
- package/dist/types/src/types/state-index.d.ts.map +1 -0
- package/dist/types/src/utils/cid.d.ts +1 -2
- package/dist/types/src/utils/cid.d.ts.map +1 -1
- package/dist/types/src/utils/data-stream.d.ts +14 -7
- package/dist/types/src/utils/data-stream.d.ts.map +1 -1
- package/dist/types/src/utils/encryption.d.ts +2 -3
- package/dist/types/src/utils/encryption.d.ts.map +1 -1
- package/dist/types/src/utils/hd-key.d.ts +4 -4
- package/dist/types/src/utils/hd-key.d.ts.map +1 -1
- package/dist/types/src/utils/jws.d.ts +7 -7
- package/dist/types/src/utils/jws.d.ts.map +1 -1
- package/dist/types/src/utils/private-key-signer.d.ts +4 -4
- package/dist/types/src/utils/private-key-signer.d.ts.map +1 -1
- package/dist/types/src/utils/protocols.d.ts +46 -3
- package/dist/types/src/utils/protocols.d.ts.map +1 -1
- package/dist/types/src/utils/records.d.ts +33 -6
- package/dist/types/src/utils/records.d.ts.map +1 -1
- package/dist/types/src/utils/secp256k1.d.ts +11 -11
- package/dist/types/src/utils/secp256k1.d.ts.map +1 -1
- package/dist/types/src/utils/secp256r1.d.ts +8 -8
- package/dist/types/src/utils/secp256r1.d.ts.map +1 -1
- package/dist/types/src/utils/time.d.ts +1 -1
- package/dist/types/tests/dwn.spec.d.ts.map +1 -1
- package/dist/types/tests/event-stream/event-emitter-stream.spec.d.ts.map +1 -0
- package/dist/types/tests/event-stream/event-stream.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 +5 -0
- package/dist/types/tests/features/protocol-composition.spec.d.ts.map +1 -0
- package/dist/types/tests/features/protocol-create-action.spec.d.ts.map +1 -1
- package/dist/types/tests/features/protocol-delete-action.spec.d.ts.map +1 -1
- package/dist/types/tests/features/protocol-update-action.spec.d.ts.map +1 -1
- package/dist/types/tests/features/records-prune.spec.d.ts.map +1 -1
- 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 +2 -0
- package/dist/types/tests/handlers/messages-sync.spec.d.ts.map +1 -0
- package/dist/types/tests/handlers/protocols-configure.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/protocols-query.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-count.spec.d.ts +2 -0
- package/dist/types/tests/handlers/records-count.spec.d.ts.map +1 -0
- 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/protocols/permission-grant.spec.d.ts +2 -0
- package/dist/types/tests/protocols/permission-grant.spec.d.ts.map +1 -0
- package/dist/types/tests/scenarios/deleted-record.spec.d.ts.map +1 -1
- package/dist/types/tests/scenarios/end-to-end-tests.spec.d.ts.map +1 -1
- package/dist/types/tests/scenarios/nested-roles.spec.d.ts.map +1 -1
- package/dist/types/tests/smt/smt-store-level.spec.d.ts +2 -0
- package/dist/types/tests/smt/smt-store-level.spec.d.ts.map +1 -0
- package/dist/types/tests/smt/sparse-merkle-tree.spec.d.ts +2 -0
- package/dist/types/tests/smt/sparse-merkle-tree.spec.d.ts.map +1 -0
- package/dist/types/tests/state-index/state-index-level.spec.d.ts +2 -0
- package/dist/types/tests/state-index/state-index-level.spec.d.ts.map +1 -0
- package/dist/types/tests/store/blockstore-level.spec.d.ts +2 -0
- package/dist/types/tests/store/blockstore-level.spec.d.ts.map +1 -0
- package/dist/types/tests/store/message-store.spec.d.ts.map +1 -1
- package/dist/types/tests/test-stores.d.ts +4 -4
- package/dist/types/tests/test-stores.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/encryption-callbacks.spec.d.ts +2 -0
- package/dist/types/tests/utils/encryption-callbacks.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/test-data-generator.d.ts +31 -28
- package/dist/types/tests/utils/test-data-generator.d.ts.map +1 -1
- package/dist/types/tests/validation/json-schemas/records/records-read.spec.d.ts +2 -0
- package/dist/types/tests/validation/json-schemas/records/records-read.spec.d.ts.map +1 -0
- package/package.json +27 -46
- package/src/core/dwn-error.ts +27 -3
- package/src/core/message-reply.ts +1 -1
- package/src/core/message.ts +5 -5
- package/src/core/messages-grant-authorization.ts +22 -8
- package/src/core/protocol-authorization.ts +345 -68
- package/src/core/records-grant-authorization.ts +2 -2
- package/src/core/resumable-task-manager.ts +4 -5
- package/src/dwn.ts +25 -20
- package/src/enums/dwn-interface-method.ts +5 -3
- package/src/handlers/messages-subscribe.ts +1 -1
- package/src/handlers/messages-sync.ts +129 -0
- package/src/handlers/protocols-configure.ts +195 -17
- package/src/handlers/protocols-query.ts +7 -5
- package/src/handlers/records-count.ts +184 -0
- package/src/handlers/records-query.ts +4 -0
- package/src/handlers/records-read.ts +4 -8
- package/src/handlers/records-write.ts +20 -21
- package/src/index.ts +74 -37
- package/src/interfaces/messages-read.ts +6 -5
- package/src/interfaces/messages-subscribe.ts +7 -6
- package/src/interfaces/messages-sync.ts +59 -0
- package/src/interfaces/protocols-configure.ts +211 -33
- package/src/interfaces/protocols-query.ts +7 -6
- package/src/interfaces/records-count.ts +106 -0
- package/src/interfaces/records-delete.ts +2 -2
- package/src/interfaces/records-query.ts +2 -2
- package/src/interfaces/records-read.ts +26 -3
- package/src/interfaces/records-subscribe.ts +2 -2
- package/src/interfaces/records-write.ts +115 -46
- package/src/jose/algorithms/signing/ed25519.ts +13 -12
- package/src/jose/algorithms/signing/signature-algorithms.ts +6 -1
- package/src/jose/jws/general/builder.ts +3 -3
- package/src/jose/jws/general/verifier.ts +3 -3
- package/src/protocols/permission-grant.ts +51 -0
- package/src/protocols/permission-request.ts +37 -0
- package/src/protocols/permissions.ts +5 -5
- package/src/schema-validator.ts +11 -3
- package/src/smt/smt-store-level.ts +143 -0
- package/src/smt/smt-store-memory.ts +53 -0
- package/src/smt/smt-utils.ts +149 -0
- package/src/smt/sparse-merkle-tree.ts +698 -0
- package/src/state-index/state-index-level.ts +241 -0
- package/src/store/data-store-level.ts +8 -7
- package/src/store/index-level.ts +415 -19
- package/src/store/level-wrapper.ts +1 -1
- package/src/store/message-store-level.ts +62 -0
- package/src/store/storage-controller.ts +21 -19
- package/src/types/data-store.ts +2 -4
- package/src/types/encryption-types.ts +52 -0
- package/src/types/jose-types.ts +10 -42
- package/src/types/message-store.ts +11 -0
- package/src/types/message-types.ts +21 -0
- package/src/types/messages-types.ts +21 -15
- package/src/types/method-handler.ts +1 -2
- package/src/types/permission-types.ts +2 -2
- package/src/types/protocols-types.ts +55 -6
- package/src/types/records-types.ts +26 -7
- package/src/types/signer.ts +1 -1
- package/src/types/smt-types.ts +95 -0
- package/src/types/state-index.ts +100 -0
- package/src/utils/cid.ts +3 -4
- package/src/utils/data-stream.ts +75 -38
- package/src/utils/encryption.ts +24 -39
- package/src/utils/hd-key.ts +6 -6
- package/src/utils/jws.ts +9 -9
- package/src/utils/private-key-signer.ts +9 -8
- package/src/utils/protocols.ts +132 -6
- package/src/utils/records.ts +118 -29
- package/src/utils/secp256k1.ts +23 -21
- package/src/utils/secp256r1.ts +17 -15
- package/src/utils/time.ts +1 -1
- package/src/utils/url.ts +1 -1
- package/dist/cjs/index.js +0 -36749
- package/dist/cjs/package.json +0 -1
- package/dist/esm/src/event-log/event-emitter-stream.js.map +0 -1
- package/dist/esm/src/event-log/event-log-level.js +0 -63
- package/dist/esm/src/event-log/event-log-level.js.map +0 -1
- package/dist/esm/src/handlers/messages-query.js +0 -71
- package/dist/esm/src/handlers/messages-query.js.map +0 -1
- package/dist/esm/src/interfaces/messages-query.js.map +0 -1
- package/dist/esm/src/types/event-log.js +0 -2
- package/dist/esm/src/types/event-log.js.map +0 -1
- package/dist/esm/tests/event-log/event-emitter-stream.spec.js.map +0 -1
- package/dist/esm/tests/event-log/event-log-level.spec.js +0 -44
- package/dist/esm/tests/event-log/event-log-level.spec.js.map +0 -1
- package/dist/esm/tests/event-log/event-log.spec.js +0 -236
- package/dist/esm/tests/event-log/event-log.spec.js.map +0 -1
- package/dist/esm/tests/event-log/event-stream.spec.js.map +0 -1
- package/dist/esm/tests/handlers/messages-query.spec.js +0 -349
- package/dist/esm/tests/handlers/messages-query.spec.js.map +0 -1
- package/dist/esm/tests/interfaces/messagess-query.spec.js +0 -127
- package/dist/esm/tests/interfaces/messagess-query.spec.js.map +0 -1
- package/dist/esm/tests/scenarios/messages-query.spec.js +0 -395
- package/dist/esm/tests/scenarios/messages-query.spec.js.map +0 -1
- package/dist/types/src/event-log/event-emitter-stream.d.ts.map +0 -1
- package/dist/types/src/event-log/event-log-level.d.ts +0 -35
- package/dist/types/src/event-log/event-log-level.d.ts.map +0 -1
- package/dist/types/src/handlers/messages-query.d.ts +0 -17
- package/dist/types/src/handlers/messages-query.d.ts.map +0 -1
- package/dist/types/src/interfaces/messages-query.d.ts +0 -16
- package/dist/types/src/interfaces/messages-query.d.ts.map +0 -1
- package/dist/types/src/types/event-log.d.ts +0 -52
- package/dist/types/src/types/event-log.d.ts.map +0 -1
- package/dist/types/tests/event-log/event-emitter-stream.spec.d.ts.map +0 -1
- package/dist/types/tests/event-log/event-log-level.spec.d.ts +0 -2
- package/dist/types/tests/event-log/event-log-level.spec.d.ts.map +0 -1
- package/dist/types/tests/event-log/event-log.spec.d.ts +0 -2
- package/dist/types/tests/event-log/event-log.spec.d.ts.map +0 -1
- package/dist/types/tests/event-log/event-stream.spec.d.ts.map +0 -1
- package/dist/types/tests/handlers/messages-query.spec.d.ts +0 -2
- package/dist/types/tests/handlers/messages-query.spec.d.ts.map +0 -1
- package/dist/types/tests/interfaces/messagess-query.spec.d.ts +0 -2
- package/dist/types/tests/interfaces/messagess-query.spec.d.ts.map +0 -1
- package/dist/types/tests/scenarios/messages-query.spec.d.ts +0 -2
- package/dist/types/tests/scenarios/messages-query.spec.d.ts.map +0 -1
- package/src/event-log/event-log-level.ts +0 -72
- package/src/handlers/messages-query.ts +0 -67
- package/src/interfaces/messages-query.ts +0 -60
- package/src/types/event-log.ts +0 -52
- /package/dist/esm/src/{event-log → event-stream}/event-emitter-stream.js +0 -0
- /package/dist/types/src/{event-log → event-stream}/event-emitter-stream.d.ts +0 -0
- /package/dist/types/tests/{event-log → event-stream}/event-emitter-stream.spec.d.ts +0 -0
- /package/dist/types/tests/{event-log → event-stream}/event-stream.spec.d.ts +0 -0
- /package/src/{event-log → event-stream}/event-emitter-stream.ts +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DataStore } from '../types/data-store.js';
|
|
2
|
-
import type { EventLog } from '../types/event-log.js';
|
|
3
2
|
import type { EventStream } from '../types/subscriptions.js';
|
|
4
3
|
import type { GenericMessage } from '../types/message-types.js';
|
|
5
4
|
import type { MessageStore } from '../types/message-store.js';
|
|
5
|
+
import type { StateIndex } from '../types/state-index.js';
|
|
6
6
|
import type { RecordsDeleteMessage, RecordsQueryReplyEntry, RecordsWriteMessage } from '../types/records-types.js';
|
|
7
7
|
|
|
8
8
|
import { DwnConstant } from '../core/dwn-constant.js';
|
|
@@ -19,24 +19,24 @@ export type ResumableRecordsDeleteData = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* A class that provides an abstraction for the usage of MessageStore, DataStore, and
|
|
22
|
+
* A class that provides an abstraction for the usage of MessageStore, DataStore, and StateIndex.
|
|
23
23
|
*/
|
|
24
24
|
export class StorageController {
|
|
25
25
|
|
|
26
26
|
private messageStore: MessageStore;
|
|
27
27
|
private dataStore: DataStore;
|
|
28
|
-
private
|
|
28
|
+
private stateIndex: StateIndex;
|
|
29
29
|
private eventStream?: EventStream;
|
|
30
30
|
|
|
31
|
-
public constructor({ messageStore, dataStore,
|
|
31
|
+
public constructor({ messageStore, dataStore, stateIndex, eventStream }: {
|
|
32
32
|
messageStore: MessageStore,
|
|
33
33
|
dataStore: DataStore,
|
|
34
|
-
|
|
34
|
+
stateIndex: StateIndex,
|
|
35
35
|
eventStream?: EventStream}
|
|
36
36
|
) {
|
|
37
37
|
this.messageStore = messageStore;
|
|
38
38
|
this.dataStore = dataStore;
|
|
39
|
-
this.
|
|
39
|
+
this.stateIndex = stateIndex;
|
|
40
40
|
this.eventStream = eventStream;
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -64,7 +64,7 @@ export class StorageController {
|
|
|
64
64
|
const indexes = recordsDelete.constructIndexes(initialWrite);
|
|
65
65
|
const messageCid = await Message.getCid(message);
|
|
66
66
|
await this.messageStore.put(tenant, message, indexes);
|
|
67
|
-
await this.
|
|
67
|
+
await this.stateIndex.insert(tenant, messageCid, indexes);
|
|
68
68
|
|
|
69
69
|
// only emit if the event stream is set
|
|
70
70
|
if (this.eventStream !== undefined) {
|
|
@@ -73,12 +73,12 @@ export class StorageController {
|
|
|
73
73
|
|
|
74
74
|
if (message.descriptor.prune) {
|
|
75
75
|
// purge/hard-delete all descendent records
|
|
76
|
-
await StorageController.purgeRecordDescendants(tenant, message.descriptor.recordId, this.messageStore, this.dataStore, this.
|
|
76
|
+
await StorageController.purgeRecordDescendants(tenant, message.descriptor.recordId, this.messageStore, this.dataStore, this.stateIndex);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// delete all existing messages that are not newest, except for the initial write
|
|
80
80
|
await StorageController.deleteAllOlderMessagesButKeepInitialWrite(
|
|
81
|
-
tenant, existingMessages, message, this.messageStore, this.dataStore, this.
|
|
81
|
+
tenant, existingMessages, message, this.messageStore, this.dataStore, this.stateIndex
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -121,7 +121,7 @@ export class StorageController {
|
|
|
121
121
|
recordId: string,
|
|
122
122
|
messageStore: MessageStore,
|
|
123
123
|
dataStore: DataStore,
|
|
124
|
-
|
|
124
|
+
stateIndex: StateIndex
|
|
125
125
|
): Promise<void> {
|
|
126
126
|
const filter = {
|
|
127
127
|
interface : DwnInterfaceName.Records,
|
|
@@ -140,21 +140,23 @@ export class StorageController {
|
|
|
140
140
|
recordId = (message as RecordsDeleteMessage).descriptor.recordId;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
const existingMessages = recordIdToMessagesMap.get(recordId);
|
|
144
|
+
if (existingMessages) {
|
|
145
|
+
existingMessages.push(message);
|
|
146
|
+
} else {
|
|
147
|
+
recordIdToMessagesMap.set(recordId, [message]);
|
|
145
148
|
}
|
|
146
|
-
recordIdToMessagesMap.get(recordId)!.push(message);
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
// purge all child's descendants first
|
|
150
152
|
for (const childRecordId of recordIdToMessagesMap.keys()) {
|
|
151
153
|
// purge the child's descendent messages first
|
|
152
|
-
await StorageController.purgeRecordDescendants(tenant, childRecordId, messageStore, dataStore,
|
|
154
|
+
await StorageController.purgeRecordDescendants(tenant, childRecordId, messageStore, dataStore, stateIndex);
|
|
153
155
|
}
|
|
154
156
|
|
|
155
157
|
// then purge the child messages themselves
|
|
156
158
|
for (const childRecordId of recordIdToMessagesMap.keys()) {
|
|
157
|
-
await StorageController.purgeRecordMessages(tenant, recordIdToMessagesMap.get(childRecordId)!, messageStore, dataStore,
|
|
159
|
+
await StorageController.purgeRecordMessages(tenant, recordIdToMessagesMap.get(childRecordId)!, messageStore, dataStore, stateIndex);
|
|
158
160
|
}
|
|
159
161
|
}
|
|
160
162
|
|
|
@@ -167,7 +169,7 @@ export class StorageController {
|
|
|
167
169
|
recordMessages: GenericMessage[],
|
|
168
170
|
messageStore: MessageStore,
|
|
169
171
|
dataStore: DataStore,
|
|
170
|
-
|
|
172
|
+
stateIndex: StateIndex
|
|
171
173
|
): Promise<void> {
|
|
172
174
|
// delete the data from the data store first so no chance of orphaned data (not having a message referencing it) in case of server crash
|
|
173
175
|
// NOTE: only the `RecordsWrite` with latest timestamp can possibly have data associated with it so we do this filtering as an optimization
|
|
@@ -183,7 +185,7 @@ export class StorageController {
|
|
|
183
185
|
|
|
184
186
|
// then delete all events associated with the record messages before deleting the messages so we don't have orphaned events
|
|
185
187
|
const messageCids = await Promise.all(recordMessages.map((message) => Message.getCid(message)));
|
|
186
|
-
await
|
|
188
|
+
await stateIndex.delete(tenant, messageCids);
|
|
187
189
|
|
|
188
190
|
// finally delete all record messages
|
|
189
191
|
await Promise.all(messageCids.map((messageCid) => messageStore.delete(tenant, messageCid)));
|
|
@@ -199,7 +201,7 @@ export class StorageController {
|
|
|
199
201
|
newestMessage: GenericMessage,
|
|
200
202
|
messageStore: MessageStore,
|
|
201
203
|
dataStore: DataStore,
|
|
202
|
-
|
|
204
|
+
stateIndex: StateIndex
|
|
203
205
|
): Promise<void> {
|
|
204
206
|
const deletedMessageCids: string[] = [];
|
|
205
207
|
|
|
@@ -234,7 +236,7 @@ export class StorageController {
|
|
|
234
236
|
}
|
|
235
237
|
}
|
|
236
238
|
|
|
237
|
-
await
|
|
239
|
+
await stateIndex.delete(tenant, deletedMessageCids);
|
|
238
240
|
}
|
|
239
241
|
}
|
|
240
242
|
}
|
package/src/types/data-store.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { Readable } from 'readable-stream';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* The interface that defines how to store and fetch data associated with a message.
|
|
5
3
|
*/
|
|
@@ -19,7 +17,7 @@ export interface DataStore {
|
|
|
19
17
|
* @param recordId The logical ID of the record that references the data.
|
|
20
18
|
* @param dataCid The IPFS CID of the data.
|
|
21
19
|
*/
|
|
22
|
-
put(tenant: string, recordId: string, dataCid: string, dataStream:
|
|
20
|
+
put(tenant: string, recordId: string, dataCid: string, dataStream: ReadableStream<Uint8Array>): Promise<DataStorePutResult>;
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
23
|
* Fetches the specified data.
|
|
@@ -60,5 +58,5 @@ export type DataStoreGetResult = {
|
|
|
60
58
|
* The number of bytes of the data stored.
|
|
61
59
|
*/
|
|
62
60
|
dataSize: number;
|
|
63
|
-
dataStream:
|
|
61
|
+
dataStream: ReadableStream<Uint8Array>;
|
|
64
62
|
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { EciesEncryptionOutput } from '../utils/encryption.js';
|
|
2
|
+
import type { KeyDerivationScheme } from '../utils/hd-key.js';
|
|
3
|
+
import type { PublicKeyJwk } from './jose-types.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A callback interface for deriving HD public encryption keys.
|
|
7
|
+
* The implementor performs HKDF key derivation and public key computation
|
|
8
|
+
* internally — the private key never leaves the implementation boundary.
|
|
9
|
+
*
|
|
10
|
+
* Analogous to `MessageSigner` for signing operations.
|
|
11
|
+
*/
|
|
12
|
+
export interface EncryptionKeyDeriver {
|
|
13
|
+
/** Fully qualified key ID (e.g. did:example:alice#enc) */
|
|
14
|
+
rootKeyId: string;
|
|
15
|
+
/** The derivation scheme (e.g. KeyDerivationScheme.ProtocolPath) */
|
|
16
|
+
derivationScheme: KeyDerivationScheme;
|
|
17
|
+
/**
|
|
18
|
+
* Derives an HD child public key for the given full derivation path.
|
|
19
|
+
* The private key material stays within the implementor's boundary.
|
|
20
|
+
*
|
|
21
|
+
* @param fullDerivationPath - The complete HKDF path segments
|
|
22
|
+
* (e.g. ['protocolPath', 'https://chat.example', 'thread', 'message'])
|
|
23
|
+
* @returns The derived child public key as a JWK
|
|
24
|
+
*/
|
|
25
|
+
derivePublicKey(fullDerivationPath: string[]): Promise<PublicKeyJwk>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A callback interface for decrypting ECIES-encrypted data encryption keys.
|
|
30
|
+
* The implementor performs HKDF key derivation and ECIES decryption
|
|
31
|
+
* internally — the private key never leaves the implementation boundary.
|
|
32
|
+
*
|
|
33
|
+
* Analogous to `MessageSigner` for signing operations.
|
|
34
|
+
*/
|
|
35
|
+
export interface KeyDecrypter {
|
|
36
|
+
/** Fully qualified key ID (e.g. did:example:alice#enc) */
|
|
37
|
+
rootKeyId: string;
|
|
38
|
+
/** The derivation scheme (e.g. KeyDerivationScheme.ProtocolPath) */
|
|
39
|
+
derivationScheme: KeyDerivationScheme;
|
|
40
|
+
/**
|
|
41
|
+
* Decrypts an ECIES-SECP256K1 encrypted payload after deriving the
|
|
42
|
+
* leaf decryption key via HKDF through the given derivation path.
|
|
43
|
+
*
|
|
44
|
+
* @param fullDerivationPath - The complete HKDF path to derive the leaf key
|
|
45
|
+
* @param eciesEncryptedPayload - The ECIES ciphertext components
|
|
46
|
+
* @returns The decrypted plaintext bytes (typically a 32-byte DEK)
|
|
47
|
+
*/
|
|
48
|
+
decrypt(
|
|
49
|
+
fullDerivationPath: string[],
|
|
50
|
+
eciesEncryptedPayload: EciesEncryptionOutput,
|
|
51
|
+
): Promise<Uint8Array>;
|
|
52
|
+
}
|
package/src/types/jose-types.ts
CHANGED
|
@@ -1,45 +1,13 @@
|
|
|
1
|
+
import type { Jwk, PrivateKeyJwk, PublicKeyJwk } from '@enbox/crypto';
|
|
2
|
+
|
|
3
|
+
export type { Jwk, PrivateKeyJwk, PublicKeyJwk };
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Contains a public-private key pair and the associated key ID.
|
|
3
7
|
*/
|
|
4
8
|
export type KeyMaterial = {
|
|
5
9
|
keyId: string,
|
|
6
|
-
keyPair: { publicJwk:
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type Jwk = {
|
|
10
|
-
/** The "alg" (algorithm) parameter identifies the algorithm intended for use with the key. */
|
|
11
|
-
alg?: string;
|
|
12
|
-
/** The "alg" (algorithm) parameter identifies the algorithm intended for use with the key. */
|
|
13
|
-
kid?: string;
|
|
14
|
-
/** identifies the cryptographic algorithm family used with the key, such "EC". */
|
|
15
|
-
kty: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type PublicJwk = Jwk & {
|
|
19
|
-
/** The "crv" (curve) parameter identifies the cryptographic curve used with the key.
|
|
20
|
-
* MUST be present for all EC public keys
|
|
21
|
-
*/
|
|
22
|
-
crv: 'Ed25519' | 'secp256k1' | 'P-256';
|
|
23
|
-
/**
|
|
24
|
-
* the x coordinate for the Elliptic Curve point.
|
|
25
|
-
* Represented as the base64url encoding of the octet string representation of the coordinate.
|
|
26
|
-
* MUST be present for all EC public keys
|
|
27
|
-
*/
|
|
28
|
-
x: string;
|
|
29
|
-
/**
|
|
30
|
-
* the y coordinate for the Elliptic Curve point.
|
|
31
|
-
* Represented as the base64url encoding of the octet string representation of the coordinate.
|
|
32
|
-
*/
|
|
33
|
-
y?: string;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export type PrivateJwk = PublicJwk & {
|
|
37
|
-
/**
|
|
38
|
-
* the Elliptic Curve private key value.
|
|
39
|
-
* It is represented as the base64url encoding of the octet string representation of the private key value
|
|
40
|
-
* MUST be present to represent Elliptic Curve private keys.
|
|
41
|
-
*/
|
|
42
|
-
d: string;
|
|
10
|
+
keyPair: { publicJwk: PublicKeyJwk, privateJwk: PrivateKeyJwk }
|
|
43
11
|
};
|
|
44
12
|
|
|
45
13
|
export interface SignatureAlgorithm {
|
|
@@ -49,7 +17,7 @@ export interface SignatureAlgorithm {
|
|
|
49
17
|
* @param privateJwk - the key to sign with
|
|
50
18
|
* @returns the signed content (aka signature)
|
|
51
19
|
*/
|
|
52
|
-
sign(content: Uint8Array, privateJwk:
|
|
20
|
+
sign(content: Uint8Array, privateJwk: PrivateKeyJwk): Promise<Uint8Array>;
|
|
53
21
|
|
|
54
22
|
/**
|
|
55
23
|
* Verifies a signature against the provided payload hash and public key.
|
|
@@ -58,13 +26,13 @@ export interface SignatureAlgorithm {
|
|
|
58
26
|
* @param publicJwk - the key to verify with
|
|
59
27
|
* @returns a boolean indicating whether the signature matches
|
|
60
28
|
*/
|
|
61
|
-
verify(content: Uint8Array, signature: Uint8Array, publicJwk:
|
|
29
|
+
verify(content: Uint8Array, signature: Uint8Array, publicJwk: PublicKeyJwk): Promise<boolean>;
|
|
62
30
|
|
|
63
31
|
/**
|
|
64
32
|
* generates a random key pair
|
|
65
33
|
* @returns the public and private keys as JWKs
|
|
66
34
|
*/
|
|
67
|
-
generateKeyPair(): Promise<{ publicJwk:
|
|
35
|
+
generateKeyPair(): Promise<{ publicJwk: PublicKeyJwk, privateJwk: PrivateKeyJwk }>
|
|
68
36
|
|
|
69
37
|
|
|
70
38
|
/**
|
|
@@ -72,5 +40,5 @@ export interface SignatureAlgorithm {
|
|
|
72
40
|
* @param publicKeyBytes - the public key to convert into JWK
|
|
73
41
|
* @returns the public key in JWK format
|
|
74
42
|
*/
|
|
75
|
-
publicKeyToJwk(publicKeyBytes: Uint8Array): Promise<
|
|
76
|
-
}
|
|
43
|
+
publicKeyToJwk(publicKeyBytes: Uint8Array): Promise<PublicKeyJwk>
|
|
44
|
+
}
|
|
@@ -45,6 +45,17 @@ export interface MessageStore {
|
|
|
45
45
|
options?: MessageStoreOptions
|
|
46
46
|
): Promise<{ messages: GenericMessage[], cursor?: PaginationCursor}>;
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Counts the number of messages matching the provided filters without loading full message data.
|
|
50
|
+
* More efficient than query() when only the count is needed, especially when compound indexes are available.
|
|
51
|
+
*/
|
|
52
|
+
count(
|
|
53
|
+
tenant: string,
|
|
54
|
+
filters: Filter[],
|
|
55
|
+
messageSort?: MessageSort,
|
|
56
|
+
options?: MessageStoreOptions
|
|
57
|
+
): Promise<number>;
|
|
58
|
+
|
|
48
59
|
/**
|
|
49
60
|
* Deletes the message associated with the id provided.
|
|
50
61
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GeneralJws } from './jws-types.js';
|
|
2
|
+
import type { PublicKeyJwk } from './jose-types.js';
|
|
2
3
|
import type { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
3
4
|
import type { PaginationCursor, SortDirection } from './query-types.js';
|
|
4
5
|
|
|
@@ -8,6 +9,13 @@ import type { PaginationCursor, SortDirection } from './query-types.js';
|
|
|
8
9
|
export type GenericMessage = {
|
|
9
10
|
descriptor: Descriptor;
|
|
10
11
|
authorization?: AuthorizationModel;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Base64url-encoded data that the message store may attach to small RecordsWrite messages.
|
|
15
|
+
* This is a runtime-only property — it is stripped before CID computation and not part of the
|
|
16
|
+
* canonical message schema, but it flows through the store layer for performance optimisation.
|
|
17
|
+
*/
|
|
18
|
+
encodedData?: string;
|
|
11
19
|
};
|
|
12
20
|
|
|
13
21
|
/**
|
|
@@ -34,6 +42,19 @@ export type AuthorizationModel = {
|
|
|
34
42
|
* The delegated grant required when the message is signed by an owner-delegate.
|
|
35
43
|
*/
|
|
36
44
|
ownerDelegatedGrant?: DelegatedGrantRecordsWriteMessage;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The author's ProtocolPath-derived public key for the key-delivery protocol's
|
|
48
|
+
* `contextKey` path. Included by external authors on cross-DWN encrypted
|
|
49
|
+
* protocol records so the DWN owner can encrypt a context key back to them
|
|
50
|
+
* without needing to query the author's DWN.
|
|
51
|
+
*/
|
|
52
|
+
authorKeyDeliveryPublicKey?: {
|
|
53
|
+
/** Fully-qualified verification method ID (e.g. `did:example:bob#enc`). */
|
|
54
|
+
rootKeyId: string;
|
|
55
|
+
/** The author's ProtocolPath-derived public key in JWK format. */
|
|
56
|
+
publicKeyJwk: PublicKeyJwk;
|
|
57
|
+
};
|
|
37
58
|
};
|
|
38
59
|
|
|
39
60
|
export type DelegatedGrantRecordsWriteMessage = {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { MessageEvent } from './subscriptions.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RangeCriterion } from './query-types.js';
|
|
3
3
|
import type { AuthorizationModel, GenericMessage, GenericMessageReply, MessageSubscription } from './message-types.js';
|
|
4
4
|
import type { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
5
|
-
import type { PaginationCursor, RangeCriterion } from './query-types.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* filters used when filtering for any type of Message across interfaces
|
|
@@ -19,6 +18,7 @@ export type MessagesReadDescriptor = {
|
|
|
19
18
|
method: DwnMethodName.Read;
|
|
20
19
|
messageCid: string;
|
|
21
20
|
messageTimestamp: string;
|
|
21
|
+
permissionGrantId?: string;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export type MessagesReadMessage = GenericMessage & {
|
|
@@ -29,29 +29,34 @@ export type MessagesReadMessage = GenericMessage & {
|
|
|
29
29
|
export type MessagesReadReplyEntry = {
|
|
30
30
|
messageCid: string;
|
|
31
31
|
message: GenericMessage;
|
|
32
|
-
data?:
|
|
32
|
+
data?: ReadableStream<Uint8Array>;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
export type MessagesReadReply = GenericMessageReply & {
|
|
36
36
|
entry?: MessagesReadReplyEntry;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
export type
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
export type MessagesSyncAction = 'root' | 'subtree' | 'leaves';
|
|
40
|
+
|
|
41
|
+
export type MessagesSyncDescriptor = {
|
|
42
|
+
interface : DwnInterfaceName.Messages;
|
|
43
|
+
method : DwnMethodName.Sync;
|
|
44
|
+
messageTimestamp : string;
|
|
45
|
+
action : MessagesSyncAction;
|
|
46
|
+
protocol? : string; // optional protocol scope
|
|
47
|
+
prefix? : string; // bit path for subtree/leaves (e.g. "0110101...")
|
|
48
|
+
permissionGrantId? : string;
|
|
45
49
|
};
|
|
46
50
|
|
|
47
|
-
export type
|
|
48
|
-
authorization: AuthorizationModel;
|
|
49
|
-
descriptor:
|
|
51
|
+
export type MessagesSyncMessage = GenericMessage & {
|
|
52
|
+
authorization : AuthorizationModel; // overriding `GenericMessage` with `authorization` being required
|
|
53
|
+
descriptor : MessagesSyncDescriptor;
|
|
50
54
|
};
|
|
51
55
|
|
|
52
|
-
export type
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
export type MessagesSyncReply = GenericMessageReply & {
|
|
57
|
+
root? : string; // hex-encoded root hash (for 'root' action)
|
|
58
|
+
hash? : string; // hex-encoded subtree hash (for 'subtree' action)
|
|
59
|
+
entries? : string[]; // messageCid[] (for 'leaves' action)
|
|
55
60
|
};
|
|
56
61
|
|
|
57
62
|
export type MessageSubscriptionHandler = (event: MessageEvent) => void;
|
|
@@ -74,4 +79,5 @@ export type MessagesSubscribeDescriptor = {
|
|
|
74
79
|
method: DwnMethodName.Subscribe;
|
|
75
80
|
messageTimestamp: string;
|
|
76
81
|
filters: MessagesFilter[];
|
|
82
|
+
permissionGrantId?: string;
|
|
77
83
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { MessageSubscriptionHandler } from './messages-types.js';
|
|
2
|
-
import type { Readable } from 'readable-stream';
|
|
3
2
|
import type { RecordSubscriptionHandler } from './records-types.js';
|
|
4
3
|
import type { GenericMessage, GenericMessageReply } from './message-types.js';
|
|
5
4
|
|
|
@@ -13,7 +12,7 @@ export interface MethodHandler {
|
|
|
13
12
|
handle(input: {
|
|
14
13
|
tenant: string;
|
|
15
14
|
message: GenericMessage;
|
|
16
|
-
dataStream?:
|
|
15
|
+
dataStream?: ReadableStream<Uint8Array>
|
|
17
16
|
subscriptionHandler?: MessageSubscriptionHandler | RecordSubscriptionHandler;
|
|
18
17
|
}): Promise<GenericMessageReply>;
|
|
19
18
|
}
|
|
@@ -78,7 +78,7 @@ export type ProtocolPermissionScope = {
|
|
|
78
78
|
|
|
79
79
|
export type MessagesPermissionScope = {
|
|
80
80
|
interface: DwnInterfaceName.Messages;
|
|
81
|
-
method: DwnMethodName.
|
|
81
|
+
method: DwnMethodName.Read | DwnMethodName.Subscribe | DwnMethodName.Sync;
|
|
82
82
|
protocol?: string;
|
|
83
83
|
};
|
|
84
84
|
|
|
@@ -87,7 +87,7 @@ export type MessagesPermissionScope = {
|
|
|
87
87
|
*/
|
|
88
88
|
export type RecordsPermissionScope = {
|
|
89
89
|
interface: DwnInterfaceName.Records;
|
|
90
|
-
method: DwnMethodName.Read | DwnMethodName.Write | DwnMethodName.Query | DwnMethodName.Subscribe | DwnMethodName.Delete;
|
|
90
|
+
method: DwnMethodName.Count | DwnMethodName.Read | DwnMethodName.Write | DwnMethodName.Query | DwnMethodName.Subscribe | DwnMethodName.Delete;
|
|
91
91
|
protocol: string;
|
|
92
92
|
/** May only be present when `protocol` is defined and `protocolPath` is undefined */
|
|
93
93
|
contextId?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PublicKeyJwk } from './jose-types.js';
|
|
2
2
|
import type { AuthorizationModel, GenericMessage, GenericMessageReply } from './message-types.js';
|
|
3
3
|
import type { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
4
4
|
|
|
@@ -7,6 +7,7 @@ export type ProtocolsConfigureDescriptor = {
|
|
|
7
7
|
method: DwnMethodName.Configure;
|
|
8
8
|
messageTimestamp: string;
|
|
9
9
|
definition: ProtocolDefinition;
|
|
10
|
+
permissionGrantId?: string;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export type ProtocolDefinition = {
|
|
@@ -15,15 +16,45 @@ export type ProtocolDefinition = {
|
|
|
15
16
|
* Denotes if this Protocol Definition can be returned by unauthenticated or unauthorized `ProtocolsQuery`.
|
|
16
17
|
*/
|
|
17
18
|
published: boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Maps alias names to external protocol URIs that this protocol composes with.
|
|
22
|
+
* Each alias can be used in `$ref` values and cross-protocol `role`/`of` references
|
|
23
|
+
* using the `alias:path` syntax.
|
|
24
|
+
*
|
|
25
|
+
* Example:
|
|
26
|
+
* ```
|
|
27
|
+
* "uses": { "threads": "https://threads.example.com" }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
uses?: ProtocolUses;
|
|
31
|
+
|
|
18
32
|
types: ProtocolTypes;
|
|
19
33
|
structure: {
|
|
20
34
|
[key: string]: ProtocolRuleSet;
|
|
21
35
|
}
|
|
22
36
|
};
|
|
23
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Maps alias names to external protocol URIs for composition.
|
|
40
|
+
*/
|
|
41
|
+
export type ProtocolUses = {
|
|
42
|
+
[alias: string]: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
24
45
|
export type ProtocolType = {
|
|
25
46
|
schema?: string,
|
|
26
47
|
dataFormats?: string[],
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* When `true`, records of this type **must** be encrypted at the DWN record
|
|
51
|
+
* level using the tenant's ProtocolPath-derived encryption key. The tenant
|
|
52
|
+
* DID must have a secp256k1 keyAgreement key; protocol installation will
|
|
53
|
+
* fail if it does not.
|
|
54
|
+
*
|
|
55
|
+
* When `false` or omitted, encryption is not required for this type.
|
|
56
|
+
*/
|
|
57
|
+
encryptionRequired?: boolean,
|
|
27
58
|
};
|
|
28
59
|
|
|
29
60
|
export type ProtocolTypes = {
|
|
@@ -43,9 +74,7 @@ export enum ProtocolAction {
|
|
|
43
74
|
Create = 'create',
|
|
44
75
|
Delete = 'delete',
|
|
45
76
|
Prune = 'prune',
|
|
46
|
-
Query = 'query',
|
|
47
77
|
Read = 'read',
|
|
48
|
-
Subscribe = 'subscribe',
|
|
49
78
|
Update = 'update'
|
|
50
79
|
}
|
|
51
80
|
|
|
@@ -95,7 +124,7 @@ export type ProtocolActionRule = {
|
|
|
95
124
|
/**
|
|
96
125
|
* Array of actions that the actor/role can perform.
|
|
97
126
|
* See {ProtocolAction} for possible values.
|
|
98
|
-
* '
|
|
127
|
+
* 'read' authorizes read, query, and subscribe access.
|
|
99
128
|
*/
|
|
100
129
|
can: string[];
|
|
101
130
|
};
|
|
@@ -112,7 +141,7 @@ export type ProtocolPathEncryption = {
|
|
|
112
141
|
/**
|
|
113
142
|
* Public key for encrypting the symmetric key used for data encryption.
|
|
114
143
|
*/
|
|
115
|
-
publicKeyJwk:
|
|
144
|
+
publicKeyJwk: PublicKeyJwk;
|
|
116
145
|
};
|
|
117
146
|
|
|
118
147
|
export type ProtocolRuleSet = {
|
|
@@ -128,6 +157,25 @@ export type ProtocolRuleSet = {
|
|
|
128
157
|
*/
|
|
129
158
|
$role?: boolean;
|
|
130
159
|
|
|
160
|
+
/**
|
|
161
|
+
* References a type from an external protocol declared in `uses`.
|
|
162
|
+
* Format: `"alias:typePath"` where `alias` is a key in the protocol definition's `uses` map
|
|
163
|
+
* and `typePath` is the protocol path of the type in the external protocol's structure.
|
|
164
|
+
*
|
|
165
|
+
* A `$ref` node is a pure attachment point — it must NOT have `$actions`, `$role`, `$size`,
|
|
166
|
+
* `$tags`, or `$encryption`. Authorization for the referenced type is governed by its own
|
|
167
|
+
* protocol. Only children defined under the `$ref` node get `$actions` from the composing protocol.
|
|
168
|
+
*
|
|
169
|
+
* Example:
|
|
170
|
+
* ```
|
|
171
|
+
* "thread": {
|
|
172
|
+
* "$ref": "threads:thread",
|
|
173
|
+
* "comment": { "$actions": [{ "who": "anyone", "can": ["create", "read"] }] }
|
|
174
|
+
* }
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
$ref?: string;
|
|
178
|
+
|
|
131
179
|
/**
|
|
132
180
|
* If $size is set, the record size in bytes must be within the limits.
|
|
133
181
|
*/
|
|
@@ -165,7 +213,8 @@ export type ProtocolsQueryDescriptor = {
|
|
|
165
213
|
interface : DwnInterfaceName.Protocols,
|
|
166
214
|
method: DwnMethodName.Query;
|
|
167
215
|
messageTimestamp: string;
|
|
168
|
-
filter?: ProtocolsQueryFilter
|
|
216
|
+
filter?: ProtocolsQueryFilter;
|
|
217
|
+
permissionGrantId?: string;
|
|
169
218
|
};
|
|
170
219
|
|
|
171
220
|
export type ProtocolsQueryMessage = GenericMessage & {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { EncryptionAlgorithm } from '../utils/encryption.js';
|
|
2
2
|
import type { GeneralJws } from './jws-types.js';
|
|
3
3
|
import type { KeyDerivationScheme } from '../utils/hd-key.js';
|
|
4
|
-
import type {
|
|
5
|
-
import type { Readable } from 'readable-stream';
|
|
4
|
+
import type { PublicKeyJwk } from './jose-types.js';
|
|
6
5
|
import type { AuthorizationModel, GenericMessage, GenericMessageReply, GenericSignaturePayload, MessageSubscription, Pagination } from './message-types.js';
|
|
7
6
|
import type { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
8
7
|
import type { PaginationCursor, RangeCriterion, RangeFilter, StartsWithFilter } from './query-types.js';
|
|
@@ -11,7 +10,9 @@ export enum DateSort {
|
|
|
11
10
|
CreatedAscending = 'createdAscending',
|
|
12
11
|
CreatedDescending = 'createdDescending',
|
|
13
12
|
PublishedAscending = 'publishedAscending',
|
|
14
|
-
PublishedDescending = 'publishedDescending'
|
|
13
|
+
PublishedDescending = 'publishedDescending',
|
|
14
|
+
UpdatedAscending = 'updatedAscending',
|
|
15
|
+
UpdatedDescending = 'updatedDescending'
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export type RecordsWriteTagValue = string | number | boolean | string[] | number[];
|
|
@@ -37,10 +38,11 @@ export type RecordsWriteDescriptor = {
|
|
|
37
38
|
published?: boolean;
|
|
38
39
|
datePublished?: string;
|
|
39
40
|
dataFormat: string;
|
|
41
|
+
permissionGrantId?: string;
|
|
40
42
|
};
|
|
41
43
|
|
|
42
44
|
export type RecordsWriteMessageOptions = {
|
|
43
|
-
dataStream?:
|
|
45
|
+
dataStream?: ReadableStream<Uint8Array>;
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
/**
|
|
@@ -78,11 +80,11 @@ export type EncryptedKey = {
|
|
|
78
80
|
/**
|
|
79
81
|
* The actual derived public key.
|
|
80
82
|
*/
|
|
81
|
-
derivedPublicKey?:
|
|
83
|
+
derivedPublicKey?: PublicKeyJwk;
|
|
82
84
|
derivationScheme: KeyDerivationScheme;
|
|
83
85
|
algorithm: EncryptionAlgorithm;
|
|
84
86
|
initializationVector: string;
|
|
85
|
-
ephemeralPublicKey:
|
|
87
|
+
ephemeralPublicKey: PublicKeyJwk;
|
|
86
88
|
messageAuthenticationCode: string;
|
|
87
89
|
encryptedKey: string;
|
|
88
90
|
};
|
|
@@ -115,6 +117,21 @@ export type DataEncodedRecordsWriteMessage = RecordsWriteMessage & {
|
|
|
115
117
|
encodedData: string;
|
|
116
118
|
};
|
|
117
119
|
|
|
120
|
+
export type RecordsCountDescriptor = {
|
|
121
|
+
interface: DwnInterfaceName.Records;
|
|
122
|
+
method: DwnMethodName.Count;
|
|
123
|
+
messageTimestamp: string;
|
|
124
|
+
filter: RecordsFilter;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export type RecordsCountMessage = GenericMessage & {
|
|
128
|
+
descriptor: RecordsCountDescriptor;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export type RecordsCountReply = GenericMessageReply & {
|
|
132
|
+
count?: number;
|
|
133
|
+
};
|
|
134
|
+
|
|
118
135
|
export type RecordsQueryDescriptor = {
|
|
119
136
|
interface: DwnInterfaceName.Records;
|
|
120
137
|
method: DwnMethodName.Query;
|
|
@@ -235,7 +252,7 @@ export type RecordsReadReplyEntry = {
|
|
|
235
252
|
/**
|
|
236
253
|
* The data stream associated with the record if the records exists (not deleted).
|
|
237
254
|
*/
|
|
238
|
-
data?:
|
|
255
|
+
data?: ReadableStream<Uint8Array>;
|
|
239
256
|
};
|
|
240
257
|
|
|
241
258
|
export type RecordsReadDescriptor = {
|
|
@@ -243,6 +260,8 @@ export type RecordsReadDescriptor = {
|
|
|
243
260
|
method: DwnMethodName.Read;
|
|
244
261
|
filter: RecordsFilter;
|
|
245
262
|
messageTimestamp: string;
|
|
263
|
+
permissionGrantId?: string;
|
|
264
|
+
dateSort?: DateSort;
|
|
246
265
|
};
|
|
247
266
|
|
|
248
267
|
export type RecordsDeleteMessage = GenericMessage & {
|
package/src/types/signer.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A signer that is capable of generating a digital signature over any given bytes.
|
|
3
3
|
*/
|
|
4
|
-
export interface
|
|
4
|
+
export interface MessageSigner {
|
|
5
5
|
/**
|
|
6
6
|
* The ID of the key used by this signer.
|
|
7
7
|
* This needs to be a fully-qualified ID (ie. prefixed with DID) so that author can be parsed out for processing such as `recordId` computation.
|