@enbox/dwn-sdk-js 0.0.1
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/LICENSE +201 -0
- package/README.md +352 -0
- package/dist/bundles/dwn.js +153 -0
- package/dist/cjs/index.js +36749 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/generated/precompiled-validators.js +11973 -0
- package/dist/esm/generated/precompiled-validators.js.map +1 -0
- package/dist/esm/json-schemas/definitions.json +23 -0
- package/dist/esm/src/core/abstract-message.js +47 -0
- package/dist/esm/src/core/abstract-message.js.map +1 -0
- package/dist/esm/src/core/auth.js +39 -0
- package/dist/esm/src/core/auth.js.map +1 -0
- package/dist/esm/src/core/dwn-constant.js +10 -0
- package/dist/esm/src/core/dwn-constant.js.map +1 -0
- package/dist/esm/src/core/dwn-error.js +169 -0
- package/dist/esm/src/core/dwn-error.js.map +1 -0
- package/dist/esm/src/core/grant-authorization.js +97 -0
- package/dist/esm/src/core/grant-authorization.js.map +1 -0
- package/dist/esm/src/core/message-reply.js +5 -0
- package/dist/esm/src/core/message-reply.js.map +1 -0
- package/dist/esm/src/core/message.js +233 -0
- package/dist/esm/src/core/message.js.map +1 -0
- package/dist/esm/src/core/messages-grant-authorization.js +101 -0
- package/dist/esm/src/core/messages-grant-authorization.js.map +1 -0
- package/dist/esm/src/core/protocol-authorization.js +608 -0
- package/dist/esm/src/core/protocol-authorization.js.map +1 -0
- package/dist/esm/src/core/protocols-grant-authorization.js +66 -0
- package/dist/esm/src/core/protocols-grant-authorization.js.map +1 -0
- package/dist/esm/src/core/records-grant-authorization.js +132 -0
- package/dist/esm/src/core/records-grant-authorization.js.map +1 -0
- package/dist/esm/src/core/resumable-task-manager.js +109 -0
- package/dist/esm/src/core/resumable-task-manager.js.map +1 -0
- package/dist/esm/src/core/tenant-gate.js +20 -0
- package/dist/esm/src/core/tenant-gate.js.map +1 -0
- package/dist/esm/src/dwn.js +164 -0
- package/dist/esm/src/dwn.js.map +1 -0
- package/dist/esm/src/enums/dwn-interface-method.js +16 -0
- package/dist/esm/src/enums/dwn-interface-method.js.map +1 -0
- package/dist/esm/src/event-log/event-emitter-stream.js +60 -0
- package/dist/esm/src/event-log/event-emitter-stream.js.map +1 -0
- package/dist/esm/src/event-log/event-log-level.js +63 -0
- package/dist/esm/src/event-log/event-log-level.js.map +1 -0
- package/dist/esm/src/handlers/messages-query.js +71 -0
- package/dist/esm/src/handlers/messages-query.js.map +1 -0
- package/dist/esm/src/handlers/messages-read.js +102 -0
- package/dist/esm/src/handlers/messages-read.js.map +1 -0
- package/dist/esm/src/handlers/messages-subscribe.js +81 -0
- package/dist/esm/src/handlers/messages-subscribe.js.map +1 -0
- package/dist/esm/src/handlers/protocols-configure.js +133 -0
- package/dist/esm/src/handlers/protocols-configure.js.map +1 -0
- package/dist/esm/src/handlers/protocols-query.js +73 -0
- package/dist/esm/src/handlers/protocols-query.js.map +1 -0
- package/dist/esm/src/handlers/records-delete.js +107 -0
- package/dist/esm/src/handlers/records-delete.js.map +1 -0
- package/dist/esm/src/handlers/records-query.js +210 -0
- package/dist/esm/src/handlers/records-query.js.map +1 -0
- package/dist/esm/src/handlers/records-read.js +169 -0
- package/dist/esm/src/handlers/records-read.js.map +1 -0
- package/dist/esm/src/handlers/records-subscribe.js +172 -0
- package/dist/esm/src/handlers/records-subscribe.js.map +1 -0
- package/dist/esm/src/handlers/records-write.js +344 -0
- package/dist/esm/src/handlers/records-write.js.map +1 -0
- package/dist/esm/src/index.js +49 -0
- package/dist/esm/src/index.js.map +1 -0
- package/dist/esm/src/interfaces/messages-query.js +53 -0
- package/dist/esm/src/interfaces/messages-query.js.map +1 -0
- package/dist/esm/src/interfaces/messages-read.js +61 -0
- package/dist/esm/src/interfaces/messages-read.js.map +1 -0
- package/dist/esm/src/interfaces/messages-subscribe.js +58 -0
- package/dist/esm/src/interfaces/messages-subscribe.js.map +1 -0
- package/dist/esm/src/interfaces/protocols-configure.js +271 -0
- package/dist/esm/src/interfaces/protocols-configure.js.map +1 -0
- package/dist/esm/src/interfaces/protocols-query.js +84 -0
- package/dist/esm/src/interfaces/protocols-query.js.map +1 -0
- package/dist/esm/src/interfaces/records-delete.js +89 -0
- package/dist/esm/src/interfaces/records-delete.js.map +1 -0
- package/dist/esm/src/interfaces/records-query.js +104 -0
- package/dist/esm/src/interfaces/records-query.js.map +1 -0
- package/dist/esm/src/interfaces/records-read.js +84 -0
- package/dist/esm/src/interfaces/records-read.js.map +1 -0
- package/dist/esm/src/interfaces/records-subscribe.js +91 -0
- package/dist/esm/src/interfaces/records-subscribe.js.map +1 -0
- package/dist/esm/src/interfaces/records-write.js +795 -0
- package/dist/esm/src/interfaces/records-write.js.map +1 -0
- package/dist/esm/src/jose/algorithms/signing/ed25519.js +51 -0
- package/dist/esm/src/jose/algorithms/signing/ed25519.js.map +1 -0
- package/dist/esm/src/jose/algorithms/signing/signature-algorithms.js +20 -0
- package/dist/esm/src/jose/algorithms/signing/signature-algorithms.js.map +1 -0
- package/dist/esm/src/jose/jws/general/builder.js +47 -0
- package/dist/esm/src/jose/jws/general/builder.js.map +1 -0
- package/dist/esm/src/jose/jws/general/verifier.js +97 -0
- package/dist/esm/src/jose/jws/general/verifier.js.map +1 -0
- package/dist/esm/src/protocols/permission-grant.js +39 -0
- package/dist/esm/src/protocols/permission-grant.js.map +1 -0
- package/dist/esm/src/protocols/permission-request.js +35 -0
- package/dist/esm/src/protocols/permission-request.js.map +1 -0
- package/dist/esm/src/protocols/permissions.js +357 -0
- package/dist/esm/src/protocols/permissions.js.map +1 -0
- package/dist/esm/src/schema-validator.js +37 -0
- package/dist/esm/src/schema-validator.js.map +1 -0
- package/dist/esm/src/store/blockstore-level.js +187 -0
- package/dist/esm/src/store/blockstore-level.js.map +1 -0
- package/dist/esm/src/store/blockstore-mock.js +168 -0
- package/dist/esm/src/store/blockstore-mock.js.map +1 -0
- package/dist/esm/src/store/data-store-level.js +136 -0
- package/dist/esm/src/store/data-store-level.js.map +1 -0
- package/dist/esm/src/store/index-level.js +660 -0
- package/dist/esm/src/store/index-level.js.map +1 -0
- package/dist/esm/src/store/level-wrapper.js +305 -0
- package/dist/esm/src/store/level-wrapper.js.map +1 -0
- package/dist/esm/src/store/message-store-level.js +159 -0
- package/dist/esm/src/store/message-store-level.js.map +1 -0
- package/dist/esm/src/store/resumable-task-store-level.js +131 -0
- package/dist/esm/src/store/resumable-task-store-level.js.map +1 -0
- package/dist/esm/src/store/storage-controller.js +184 -0
- package/dist/esm/src/store/storage-controller.js.map +1 -0
- package/dist/esm/src/types/cache.js +2 -0
- package/dist/esm/src/types/cache.js.map +1 -0
- package/dist/esm/src/types/data-store.js +2 -0
- package/dist/esm/src/types/data-store.js.map +1 -0
- package/dist/esm/src/types/event-log.js +2 -0
- package/dist/esm/src/types/event-log.js.map +1 -0
- package/dist/esm/src/types/jose-types.js +2 -0
- package/dist/esm/src/types/jose-types.js.map +1 -0
- package/dist/esm/src/types/jws-types.js +2 -0
- package/dist/esm/src/types/jws-types.js.map +1 -0
- package/dist/esm/src/types/message-interface.js +2 -0
- package/dist/esm/src/types/message-interface.js.map +1 -0
- package/dist/esm/src/types/message-store.js +2 -0
- package/dist/esm/src/types/message-store.js.map +1 -0
- package/dist/esm/src/types/message-types.js +3 -0
- package/dist/esm/src/types/message-types.js.map +1 -0
- package/dist/esm/src/types/messages-types.js +2 -0
- package/dist/esm/src/types/messages-types.js.map +1 -0
- package/dist/esm/src/types/method-handler.js +2 -0
- package/dist/esm/src/types/method-handler.js.map +1 -0
- package/dist/esm/src/types/permission-types.js +6 -0
- package/dist/esm/src/types/permission-types.js.map +1 -0
- package/dist/esm/src/types/protocols-types.js +20 -0
- package/dist/esm/src/types/protocols-types.js.map +1 -0
- package/dist/esm/src/types/query-types.js +6 -0
- package/dist/esm/src/types/query-types.js.map +1 -0
- package/dist/esm/src/types/records-types.js +8 -0
- package/dist/esm/src/types/records-types.js.map +1 -0
- package/dist/esm/src/types/resumable-task-store.js +2 -0
- package/dist/esm/src/types/resumable-task-store.js.map +1 -0
- package/dist/esm/src/types/signer.js +2 -0
- package/dist/esm/src/types/signer.js.map +1 -0
- package/dist/esm/src/types/subscriptions.js +2 -0
- package/dist/esm/src/types/subscriptions.js.map +1 -0
- package/dist/esm/src/utils/abort.js +40 -0
- package/dist/esm/src/utils/abort.js.map +1 -0
- package/dist/esm/src/utils/array.js +72 -0
- package/dist/esm/src/utils/array.js.map +1 -0
- package/dist/esm/src/utils/cid.js +130 -0
- package/dist/esm/src/utils/cid.js.map +1 -0
- package/dist/esm/src/utils/data-stream.js +100 -0
- package/dist/esm/src/utils/data-stream.js.map +1 -0
- package/dist/esm/src/utils/encoder.js +45 -0
- package/dist/esm/src/utils/encoder.js.map +1 -0
- package/dist/esm/src/utils/encryption.js +128 -0
- package/dist/esm/src/utils/encryption.js.map +1 -0
- package/dist/esm/src/utils/filter.js +229 -0
- package/dist/esm/src/utils/filter.js.map +1 -0
- package/dist/esm/src/utils/hd-key.js +114 -0
- package/dist/esm/src/utils/hd-key.js.map +1 -0
- package/dist/esm/src/utils/jws.js +89 -0
- package/dist/esm/src/utils/jws.js.map +1 -0
- package/dist/esm/src/utils/memory-cache.js +41 -0
- package/dist/esm/src/utils/memory-cache.js.map +1 -0
- package/dist/esm/src/utils/messages.js +84 -0
- package/dist/esm/src/utils/messages.js.map +1 -0
- package/dist/esm/src/utils/object.js +40 -0
- package/dist/esm/src/utils/object.js.map +1 -0
- package/dist/esm/src/utils/private-key-signer.js +43 -0
- package/dist/esm/src/utils/private-key-signer.js.map +1 -0
- package/dist/esm/src/utils/protocols.js +51 -0
- package/dist/esm/src/utils/protocols.js.map +1 -0
- package/dist/esm/src/utils/records.js +454 -0
- package/dist/esm/src/utils/records.js.map +1 -0
- package/dist/esm/src/utils/secp256k1.js +166 -0
- package/dist/esm/src/utils/secp256k1.js.map +1 -0
- package/dist/esm/src/utils/secp256r1.js +120 -0
- package/dist/esm/src/utils/secp256r1.js.map +1 -0
- package/dist/esm/src/utils/string.js +16 -0
- package/dist/esm/src/utils/string.js.map +1 -0
- package/dist/esm/src/utils/time.js +85 -0
- package/dist/esm/src/utils/time.js.map +1 -0
- package/dist/esm/src/utils/url.js +62 -0
- package/dist/esm/src/utils/url.js.map +1 -0
- package/dist/esm/tests/core/auth.spec.js +22 -0
- package/dist/esm/tests/core/auth.spec.js.map +1 -0
- package/dist/esm/tests/core/message-reply.spec.js +16 -0
- package/dist/esm/tests/core/message-reply.spec.js.map +1 -0
- package/dist/esm/tests/core/message.spec.js +146 -0
- package/dist/esm/tests/core/message.spec.js.map +1 -0
- package/dist/esm/tests/core/protocol-authorization.spec.js +48 -0
- package/dist/esm/tests/core/protocol-authorization.spec.js.map +1 -0
- package/dist/esm/tests/dwn.spec.js +166 -0
- package/dist/esm/tests/dwn.spec.js.map +1 -0
- package/dist/esm/tests/event-log/event-emitter-stream.spec.js +78 -0
- package/dist/esm/tests/event-log/event-emitter-stream.spec.js.map +1 -0
- package/dist/esm/tests/event-log/event-log-level.spec.js +44 -0
- package/dist/esm/tests/event-log/event-log-level.spec.js.map +1 -0
- package/dist/esm/tests/event-log/event-log.spec.js +236 -0
- package/dist/esm/tests/event-log/event-log.spec.js.map +1 -0
- package/dist/esm/tests/event-log/event-stream.spec.js +125 -0
- package/dist/esm/tests/event-log/event-stream.spec.js.map +1 -0
- package/dist/esm/tests/features/author-delegated-grant.spec.js +1273 -0
- package/dist/esm/tests/features/author-delegated-grant.spec.js.map +1 -0
- package/dist/esm/tests/features/owner-delegated-grant.spec.js +584 -0
- package/dist/esm/tests/features/owner-delegated-grant.spec.js.map +1 -0
- package/dist/esm/tests/features/owner-signature.spec.js +192 -0
- package/dist/esm/tests/features/owner-signature.spec.js.map +1 -0
- package/dist/esm/tests/features/permissions.spec.js +815 -0
- package/dist/esm/tests/features/permissions.spec.js.map +1 -0
- package/dist/esm/tests/features/protocol-create-action.spec.js +248 -0
- package/dist/esm/tests/features/protocol-create-action.spec.js.map +1 -0
- package/dist/esm/tests/features/protocol-delete-action.spec.js +492 -0
- package/dist/esm/tests/features/protocol-delete-action.spec.js.map +1 -0
- package/dist/esm/tests/features/protocol-update-action.spec.js +572 -0
- package/dist/esm/tests/features/protocol-update-action.spec.js.map +1 -0
- package/dist/esm/tests/features/records-prune.spec.js +812 -0
- package/dist/esm/tests/features/records-prune.spec.js.map +1 -0
- package/dist/esm/tests/features/records-tags.spec.js +2516 -0
- package/dist/esm/tests/features/records-tags.spec.js.map +1 -0
- package/dist/esm/tests/features/resumable-tasks.spec.js +349 -0
- package/dist/esm/tests/features/resumable-tasks.spec.js.map +1 -0
- package/dist/esm/tests/handlers/messages-query.spec.js +349 -0
- package/dist/esm/tests/handlers/messages-query.spec.js.map +1 -0
- package/dist/esm/tests/handlers/messages-read.spec.js +647 -0
- package/dist/esm/tests/handlers/messages-read.spec.js.map +1 -0
- package/dist/esm/tests/handlers/messages-subscribe.spec.js +432 -0
- package/dist/esm/tests/handlers/messages-subscribe.spec.js.map +1 -0
- package/dist/esm/tests/handlers/protocols-configure.spec.js +608 -0
- package/dist/esm/tests/handlers/protocols-configure.spec.js.map +1 -0
- package/dist/esm/tests/handlers/protocols-query.spec.js +454 -0
- package/dist/esm/tests/handlers/protocols-query.spec.js.map +1 -0
- package/dist/esm/tests/handlers/records-delete.spec.js +662 -0
- package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -0
- package/dist/esm/tests/handlers/records-query.spec.js +2695 -0
- package/dist/esm/tests/handlers/records-query.spec.js.map +1 -0
- package/dist/esm/tests/handlers/records-read.spec.js +1724 -0
- package/dist/esm/tests/handlers/records-read.spec.js.map +1 -0
- package/dist/esm/tests/handlers/records-subscribe.spec.js +684 -0
- package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -0
- package/dist/esm/tests/handlers/records-write.spec.js +3637 -0
- package/dist/esm/tests/handlers/records-write.spec.js.map +1 -0
- package/dist/esm/tests/interfaces/messages-get.spec.js +78 -0
- package/dist/esm/tests/interfaces/messages-get.spec.js.map +1 -0
- package/dist/esm/tests/interfaces/messages-subscribe.spec.js +30 -0
- package/dist/esm/tests/interfaces/messages-subscribe.spec.js.map +1 -0
- package/dist/esm/tests/interfaces/messagess-query.spec.js +127 -0
- package/dist/esm/tests/interfaces/messagess-query.spec.js.map +1 -0
- package/dist/esm/tests/interfaces/protocols-configure.spec.js +489 -0
- package/dist/esm/tests/interfaces/protocols-configure.spec.js.map +1 -0
- package/dist/esm/tests/interfaces/protocols-query.spec.js +46 -0
- package/dist/esm/tests/interfaces/protocols-query.spec.js.map +1 -0
- package/dist/esm/tests/interfaces/records-delete.spec.js +39 -0
- package/dist/esm/tests/interfaces/records-delete.spec.js.map +1 -0
- package/dist/esm/tests/interfaces/records-query.spec.js +85 -0
- package/dist/esm/tests/interfaces/records-query.spec.js.map +1 -0
- package/dist/esm/tests/interfaces/records-read.spec.js +62 -0
- package/dist/esm/tests/interfaces/records-read.spec.js.map +1 -0
- package/dist/esm/tests/interfaces/records-subscribe.spec.js +72 -0
- package/dist/esm/tests/interfaces/records-subscribe.spec.js.map +1 -0
- package/dist/esm/tests/interfaces/records-write.spec.js +423 -0
- package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -0
- package/dist/esm/tests/jose/jws/general.spec.js +243 -0
- package/dist/esm/tests/jose/jws/general.spec.js.map +1 -0
- package/dist/esm/tests/protocols/permission-request.spec.js +40 -0
- package/dist/esm/tests/protocols/permission-request.spec.js.map +1 -0
- package/dist/esm/tests/protocols/permissions.spec.js +123 -0
- package/dist/esm/tests/protocols/permissions.spec.js.map +1 -0
- package/dist/esm/tests/scenarios/aggregator.spec.js +670 -0
- package/dist/esm/tests/scenarios/aggregator.spec.js.map +1 -0
- package/dist/esm/tests/scenarios/deleted-record.spec.js +102 -0
- package/dist/esm/tests/scenarios/deleted-record.spec.js.map +1 -0
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +220 -0
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -0
- package/dist/esm/tests/scenarios/messages-query.spec.js +395 -0
- package/dist/esm/tests/scenarios/messages-query.spec.js.map +1 -0
- package/dist/esm/tests/scenarios/nested-roles.spec.js +300 -0
- package/dist/esm/tests/scenarios/nested-roles.spec.js.map +1 -0
- package/dist/esm/tests/scenarios/subscriptions.spec.js +886 -0
- package/dist/esm/tests/scenarios/subscriptions.spec.js.map +1 -0
- package/dist/esm/tests/store/blockstore-mock.spec.js +192 -0
- package/dist/esm/tests/store/blockstore-mock.spec.js.map +1 -0
- package/dist/esm/tests/store/data-store-level.spec.js +146 -0
- package/dist/esm/tests/store/data-store-level.spec.js.map +1 -0
- package/dist/esm/tests/store/index-level.spec.js +1208 -0
- package/dist/esm/tests/store/index-level.spec.js.map +1 -0
- package/dist/esm/tests/store/message-store-level.spec.js +48 -0
- package/dist/esm/tests/store/message-store-level.spec.js.map +1 -0
- package/dist/esm/tests/store/message-store.spec.js +404 -0
- package/dist/esm/tests/store/message-store.spec.js.map +1 -0
- package/dist/esm/tests/store-dependent-tests.spec.js +5 -0
- package/dist/esm/tests/store-dependent-tests.spec.js.map +1 -0
- package/dist/esm/tests/test-event-stream.js +25 -0
- package/dist/esm/tests/test-event-stream.js.map +1 -0
- package/dist/esm/tests/test-stores.js +45 -0
- package/dist/esm/tests/test-stores.js.map +1 -0
- package/dist/esm/tests/test-suite.js +88 -0
- package/dist/esm/tests/test-suite.js.map +1 -0
- package/dist/esm/tests/utils/cid.spec.js +80 -0
- package/dist/esm/tests/utils/cid.spec.js.map +1 -0
- package/dist/esm/tests/utils/data-stream.spec.js +27 -0
- package/dist/esm/tests/utils/data-stream.spec.js.map +1 -0
- package/dist/esm/tests/utils/encryption.spec.js +148 -0
- package/dist/esm/tests/utils/encryption.spec.js.map +1 -0
- package/dist/esm/tests/utils/filters.spec.js +295 -0
- package/dist/esm/tests/utils/filters.spec.js.map +1 -0
- package/dist/esm/tests/utils/hd-key.spec.js +35 -0
- package/dist/esm/tests/utils/hd-key.spec.js.map +1 -0
- package/dist/esm/tests/utils/jws.spec.js +8 -0
- package/dist/esm/tests/utils/jws.spec.js.map +1 -0
- package/dist/esm/tests/utils/memory-cache.spec.js +35 -0
- package/dist/esm/tests/utils/memory-cache.spec.js.map +1 -0
- package/dist/esm/tests/utils/messages.spec.js +101 -0
- package/dist/esm/tests/utils/messages.spec.js.map +1 -0
- package/dist/esm/tests/utils/object.spec.js +36 -0
- package/dist/esm/tests/utils/object.spec.js.map +1 -0
- package/dist/esm/tests/utils/poller.js +49 -0
- package/dist/esm/tests/utils/poller.js.map +1 -0
- package/dist/esm/tests/utils/private-key-signer.spec.js +44 -0
- package/dist/esm/tests/utils/private-key-signer.spec.js.map +1 -0
- package/dist/esm/tests/utils/records.spec.js +53 -0
- package/dist/esm/tests/utils/records.spec.js.map +1 -0
- package/dist/esm/tests/utils/secp256k1.spec.js +50 -0
- package/dist/esm/tests/utils/secp256k1.spec.js.map +1 -0
- package/dist/esm/tests/utils/secp256r1.spec.js +56 -0
- package/dist/esm/tests/utils/secp256r1.spec.js.map +1 -0
- package/dist/esm/tests/utils/test-data-generator.js +643 -0
- package/dist/esm/tests/utils/test-data-generator.js.map +1 -0
- package/dist/esm/tests/utils/test-stub-generator.js +39 -0
- package/dist/esm/tests/utils/test-stub-generator.js.map +1 -0
- package/dist/esm/tests/utils/time.spec.js +64 -0
- package/dist/esm/tests/utils/time.spec.js.map +1 -0
- package/dist/esm/tests/utils/url.spec.js +43 -0
- package/dist/esm/tests/utils/url.spec.js.map +1 -0
- package/dist/esm/tests/validation/json-schemas/definitions.spec.js +33 -0
- package/dist/esm/tests/validation/json-schemas/definitions.spec.js.map +1 -0
- package/dist/esm/tests/validation/json-schemas/jwk/general-jwk.spec.js +50 -0
- package/dist/esm/tests/validation/json-schemas/jwk/general-jwk.spec.js.map +1 -0
- package/dist/esm/tests/validation/json-schemas/jwk/public-jwk.spec.js +36 -0
- package/dist/esm/tests/validation/json-schemas/jwk/public-jwk.spec.js.map +1 -0
- package/dist/esm/tests/validation/json-schemas/jwk-verification-method.spec.js +82 -0
- package/dist/esm/tests/validation/json-schemas/jwk-verification-method.spec.js.map +1 -0
- package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js +75 -0
- package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js.map +1 -0
- package/dist/esm/tests/validation/json-schemas/records/records-query.spec.js +148 -0
- package/dist/esm/tests/validation/json-schemas/records/records-query.spec.js.map +1 -0
- package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js +421 -0
- package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js.map +1 -0
- package/dist/esm/tests/vectors/protocol-definitions/anyone-collaborate.json +21 -0
- package/dist/esm/tests/vectors/protocol-definitions/author-can.json +33 -0
- package/dist/esm/tests/vectors/protocol-definitions/chat.json +70 -0
- package/dist/esm/tests/vectors/protocol-definitions/credential-issuance.json +41 -0
- package/dist/esm/tests/vectors/protocol-definitions/dex.json +58 -0
- package/dist/esm/tests/vectors/protocol-definitions/email.json +62 -0
- package/dist/esm/tests/vectors/protocol-definitions/free-for-all.json +45 -0
- package/dist/esm/tests/vectors/protocol-definitions/friend-role.json +48 -0
- package/dist/esm/tests/vectors/protocol-definitions/message.json +37 -0
- package/dist/esm/tests/vectors/protocol-definitions/minimal.json +10 -0
- package/dist/esm/tests/vectors/protocol-definitions/nested.json +31 -0
- package/dist/esm/tests/vectors/protocol-definitions/private-protocol.json +15 -0
- package/dist/esm/tests/vectors/protocol-definitions/recipient-can.json +33 -0
- package/dist/esm/tests/vectors/protocol-definitions/slack.json +242 -0
- package/dist/esm/tests/vectors/protocol-definitions/social-media.json +106 -0
- package/dist/esm/tests/vectors/protocol-definitions/thread-role.json +70 -0
- package/dist/types/generated/precompiled-validators.d.ts +597 -0
- package/dist/types/generated/precompiled-validators.d.ts.map +1 -0
- package/dist/types/src/core/abstract-message.d.ts +25 -0
- package/dist/types/src/core/abstract-message.d.ts.map +1 -0
- package/dist/types/src/core/auth.d.ts +9 -0
- package/dist/types/src/core/auth.d.ts.map +1 -0
- package/dist/types/src/core/dwn-constant.d.ts +10 -0
- package/dist/types/src/core/dwn-constant.d.ts.map +1 -0
- package/dist/types/src/core/dwn-error.d.ts +164 -0
- package/dist/types/src/core/dwn-error.d.ts.map +1 -0
- package/dist/types/src/core/grant-authorization.d.ts +43 -0
- package/dist/types/src/core/grant-authorization.d.ts.map +1 -0
- package/dist/types/src/core/message-reply.d.ts +32 -0
- package/dist/types/src/core/message-reply.d.ts.map +1 -0
- package/dist/types/src/core/message.d.ts +94 -0
- package/dist/types/src/core/message.d.ts.map +1 -0
- package/dist/types/src/core/messages-grant-authorization.d.ts +34 -0
- package/dist/types/src/core/messages-grant-authorization.d.ts.map +1 -0
- package/dist/types/src/core/protocol-authorization.d.ts +103 -0
- package/dist/types/src/core/protocol-authorization.d.ts.map +1 -0
- package/dist/types/src/core/protocols-grant-authorization.d.ts +31 -0
- package/dist/types/src/core/protocols-grant-authorization.d.ts.map +1 -0
- package/dist/types/src/core/records-grant-authorization.d.ts +60 -0
- package/dist/types/src/core/records-grant-authorization.d.ts.map +1 -0
- package/dist/types/src/core/resumable-task-manager.d.ts +43 -0
- package/dist/types/src/core/resumable-task-manager.d.ts.map +1 -0
- package/dist/types/src/core/tenant-gate.d.ts +29 -0
- package/dist/types/src/core/tenant-gate.d.ts.map +1 -0
- package/dist/types/src/dwn.d.ts +85 -0
- package/dist/types/src/dwn.d.ts.map +1 -0
- package/dist/types/src/enums/dwn-interface-method.d.ts +14 -0
- package/dist/types/src/enums/dwn-interface-method.d.ts.map +1 -0
- package/dist/types/src/event-log/event-emitter-stream.d.ts +23 -0
- package/dist/types/src/event-log/event-emitter-stream.d.ts.map +1 -0
- package/dist/types/src/event-log/event-log-level.d.ts +35 -0
- package/dist/types/src/event-log/event-log-level.d.ts.map +1 -0
- package/dist/types/src/handlers/messages-query.d.ts +17 -0
- package/dist/types/src/handlers/messages-query.d.ts.map +1 -0
- package/dist/types/src/handlers/messages-read.d.ts +22 -0
- package/dist/types/src/handlers/messages-read.d.ts.map +1 -0
- package/dist/types/src/handlers/messages-subscribe.d.ts +18 -0
- package/dist/types/src/handlers/messages-subscribe.d.ts.map +1 -0
- package/dist/types/src/handlers/protocols-configure.d.ts +24 -0
- package/dist/types/src/handlers/protocols-configure.d.ts.map +1 -0
- package/dist/types/src/handlers/protocols-query.d.ts +20 -0
- package/dist/types/src/handlers/protocols-query.d.ts.map +1 -0
- package/dist/types/src/handlers/records-delete.d.ts +23 -0
- package/dist/types/src/handlers/records-delete.d.ts.map +1 -0
- package/dist/types/src/handlers/records-query.d.ts +70 -0
- package/dist/types/src/handlers/records-query.d.ts.map +1 -0
- package/dist/types/src/handlers/records-read.d.ts +20 -0
- package/dist/types/src/handlers/records-read.d.ts.map +1 -0
- package/dist/types/src/handlers/records-subscribe.d.ts +62 -0
- package/dist/types/src/handlers/records-subscribe.d.ts.map +1 -0
- package/dist/types/src/handlers/records-write.d.ts +51 -0
- package/dist/types/src/handlers/records-write.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +63 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/interfaces/messages-query.d.ts +16 -0
- package/dist/types/src/interfaces/messages-query.d.ts.map +1 -0
- package/dist/types/src/interfaces/messages-read.d.ts +20 -0
- package/dist/types/src/interfaces/messages-read.d.ts.map +1 -0
- package/dist/types/src/interfaces/messages-subscribe.d.ts +20 -0
- package/dist/types/src/interfaces/messages-subscribe.d.ts.map +1 -0
- package/dist/types/src/interfaces/protocols-configure.d.ts +40 -0
- package/dist/types/src/interfaces/protocols-configure.d.ts.map +1 -0
- package/dist/types/src/interfaces/protocols-query.d.ts +17 -0
- package/dist/types/src/interfaces/protocols-query.d.ts.map +1 -0
- package/dist/types/src/interfaces/records-delete.d.ts +34 -0
- package/dist/types/src/interfaces/records-delete.d.ts.map +1 -0
- package/dist/types/src/interfaces/records-query.d.ts +31 -0
- package/dist/types/src/interfaces/records-query.d.ts.map +1 -0
- package/dist/types/src/interfaces/records-read.d.ts +36 -0
- package/dist/types/src/interfaces/records-read.d.ts.map +1 -0
- package/dist/types/src/interfaces/records-subscribe.d.ts +27 -0
- package/dist/types/src/interfaces/records-subscribe.d.ts.map +1 -0
- package/dist/types/src/interfaces/records-write.d.ts +309 -0
- package/dist/types/src/interfaces/records-write.d.ts.map +1 -0
- package/dist/types/src/jose/algorithms/signing/ed25519.d.ts +3 -0
- package/dist/types/src/jose/algorithms/signing/ed25519.d.ts.map +1 -0
- package/dist/types/src/jose/algorithms/signing/signature-algorithms.d.ts +3 -0
- package/dist/types/src/jose/algorithms/signing/signature-algorithms.d.ts.map +1 -0
- package/dist/types/src/jose/jws/general/builder.d.ts +10 -0
- package/dist/types/src/jose/jws/general/builder.d.ts.map +1 -0
- package/dist/types/src/jose/jws/general/verifier.d.ts +32 -0
- package/dist/types/src/jose/jws/general/verifier.d.ts.map +1 -0
- package/dist/types/src/protocols/permission-grant.d.ts +50 -0
- package/dist/types/src/protocols/permission-grant.d.ts.map +1 -0
- package/dist/types/src/protocols/permission-request.d.ts +35 -0
- package/dist/types/src/protocols/permission-request.d.ts.map +1 -0
- package/dist/types/src/protocols/permissions.d.ts +150 -0
- package/dist/types/src/protocols/permissions.d.ts.map +1 -0
- package/dist/types/src/schema-validator.d.ts +8 -0
- package/dist/types/src/schema-validator.d.ts.map +1 -0
- package/dist/types/src/store/blockstore-level.d.ts +34 -0
- package/dist/types/src/store/blockstore-level.d.ts.map +1 -0
- package/dist/types/src/store/blockstore-mock.d.ts +27 -0
- package/dist/types/src/store/blockstore-mock.d.ts.map +1 -0
- package/dist/types/src/store/data-store-level.d.ts +34 -0
- package/dist/types/src/store/data-store-level.d.ts.map +1 -0
- package/dist/types/src/store/index-level.d.ts +171 -0
- package/dist/types/src/store/index-level.d.ts.map +1 -0
- package/dist/types/src/store/level-wrapper.d.ts +48 -0
- package/dist/types/src/store/level-wrapper.d.ts.map +1 -0
- package/dist/types/src/store/message-store-level.d.ts +46 -0
- package/dist/types/src/store/message-store-level.d.ts.map +1 -0
- package/dist/types/src/store/resumable-task-store-level.d.ts +28 -0
- package/dist/types/src/store/resumable-task-store-level.d.ts.map +1 -0
- package/dist/types/src/store/storage-controller.d.ts +46 -0
- package/dist/types/src/store/storage-controller.d.ts.map +1 -0
- package/dist/types/src/types/cache.d.ts +16 -0
- package/dist/types/src/types/cache.d.ts.map +1 -0
- package/dist/types/src/types/data-store.d.ts +57 -0
- package/dist/types/src/types/data-store.d.ts.map +1 -0
- package/dist/types/src/types/event-log.d.ts +52 -0
- package/dist/types/src/types/event-log.d.ts.map +1 -0
- package/dist/types/src/types/jose-types.d.ts +75 -0
- package/dist/types/src/types/jose-types.d.ts.map +1 -0
- package/dist/types/src/types/jws-types.d.ts +27 -0
- package/dist/types/src/types/jws-types.d.ts.map +1 -0
- package/dist/types/src/types/message-interface.d.ts +27 -0
- package/dist/types/src/types/message-interface.d.ts.map +1 -0
- package/dist/types/src/types/message-store.d.ts +42 -0
- package/dist/types/src/types/message-store.d.ts.map +1 -0
- package/dist/types/src/types/message-types.d.ts +116 -0
- package/dist/types/src/types/message-types.d.ts.map +1 -0
- package/dist/types/src/types/messages-types.d.ts +65 -0
- package/dist/types/src/types/messages-types.d.ts.map +1 -0
- package/dist/types/src/types/method-handler.d.ts +19 -0
- package/dist/types/src/types/method-handler.d.ts.map +1 -0
- package/dist/types/src/types/permission-types.d.ts +93 -0
- package/dist/types/src/types/permission-types.d.ts.map +1 -0
- package/dist/types/src/types/protocols-types.d.ts +154 -0
- package/dist/types/src/types/protocols-types.d.ts.map +1 -0
- package/dist/types/src/types/query-types.d.ts +66 -0
- package/dist/types/src/types/query-types.d.ts.map +1 -0
- package/dist/types/src/types/records-types.d.ts +230 -0
- package/dist/types/src/types/records-types.d.ts.map +1 -0
- package/dist/types/src/types/resumable-task-store.d.ts +89 -0
- package/dist/types/src/types/resumable-task-store.d.ts.map +1 -0
- package/dist/types/src/types/signer.d.ts +26 -0
- package/dist/types/src/types/signer.d.ts.map +1 -0
- package/dist/types/src/types/subscriptions.d.ts +30 -0
- package/dist/types/src/types/subscriptions.d.ts.map +1 -0
- package/dist/types/src/utils/abort.d.ts +5 -0
- package/dist/types/src/utils/abort.d.ts.map +1 -0
- package/dist/types/src/utils/array.d.ts +18 -0
- package/dist/types/src/utils/array.d.ts.map +1 -0
- package/dist/types/src/utils/cid.d.ts +30 -0
- package/dist/types/src/utils/cid.d.ts.map +1 -0
- package/dist/types/src/utils/data-stream.d.ts +31 -0
- package/dist/types/src/utils/data-stream.d.ts.map +1 -0
- package/dist/types/src/utils/encoder.d.ts +14 -0
- package/dist/types/src/utils/encoder.d.ts.map +1 -0
- package/dist/types/src/utils/encryption.d.ts +44 -0
- package/dist/types/src/utils/encryption.d.ts.map +1 -0
- package/dist/types/src/utils/filter.d.ts +60 -0
- package/dist/types/src/utils/filter.d.ts.map +1 -0
- package/dist/types/src/utils/hd-key.d.ts +54 -0
- package/dist/types/src/utils/hd-key.d.ts.map +1 -0
- package/dist/types/src/utils/jws.d.ts +39 -0
- package/dist/types/src/utils/jws.d.ts.map +1 -0
- package/dist/types/src/utils/memory-cache.d.ts +15 -0
- package/dist/types/src/utils/memory-cache.d.ts.map +1 -0
- package/dist/types/src/utils/messages.d.ts +27 -0
- package/dist/types/src/utils/messages.d.ts.map +1 -0
- package/dist/types/src/utils/object.d.ts +13 -0
- package/dist/types/src/utils/object.d.ts.map +1 -0
- package/dist/types/src/utils/private-key-signer.d.ts +34 -0
- package/dist/types/src/utils/private-key-signer.d.ts.map +1 -0
- package/dist/types/src/utils/protocols.d.ts +14 -0
- package/dist/types/src/utils/protocols.d.ts.map +1 -0
- package/dist/types/src/utils/records.d.ts +122 -0
- package/dist/types/src/utils/records.d.ts.map +1 -0
- package/dist/types/src/utils/secp256k1.d.ts +59 -0
- package/dist/types/src/utils/secp256k1.d.ts.map +1 -0
- package/dist/types/src/utils/secp256r1.d.ts +39 -0
- package/dist/types/src/utils/secp256r1.d.ts.map +1 -0
- package/dist/types/src/utils/string.d.ts +6 -0
- package/dist/types/src/utils/string.d.ts.map +1 -0
- package/dist/types/src/utils/time.d.ts +50 -0
- package/dist/types/src/utils/time.d.ts.map +1 -0
- package/dist/types/src/utils/url.d.ts +5 -0
- package/dist/types/src/utils/url.d.ts.map +1 -0
- package/dist/types/tests/core/auth.spec.d.ts +2 -0
- package/dist/types/tests/core/auth.spec.d.ts.map +1 -0
- package/dist/types/tests/core/message-reply.spec.d.ts +2 -0
- package/dist/types/tests/core/message-reply.spec.d.ts.map +1 -0
- package/dist/types/tests/core/message.spec.d.ts +2 -0
- package/dist/types/tests/core/message.spec.d.ts.map +1 -0
- package/dist/types/tests/core/protocol-authorization.spec.d.ts +2 -0
- package/dist/types/tests/core/protocol-authorization.spec.d.ts.map +1 -0
- package/dist/types/tests/dwn.spec.d.ts +2 -0
- package/dist/types/tests/dwn.spec.d.ts.map +1 -0
- package/dist/types/tests/event-log/event-emitter-stream.spec.d.ts +2 -0
- package/dist/types/tests/event-log/event-emitter-stream.spec.d.ts.map +1 -0
- package/dist/types/tests/event-log/event-log-level.spec.d.ts +2 -0
- package/dist/types/tests/event-log/event-log-level.spec.d.ts.map +1 -0
- package/dist/types/tests/event-log/event-log.spec.d.ts +2 -0
- package/dist/types/tests/event-log/event-log.spec.d.ts.map +1 -0
- package/dist/types/tests/event-log/event-stream.spec.d.ts +2 -0
- package/dist/types/tests/event-log/event-stream.spec.d.ts.map +1 -0
- package/dist/types/tests/features/author-delegated-grant.spec.d.ts +2 -0
- package/dist/types/tests/features/author-delegated-grant.spec.d.ts.map +1 -0
- package/dist/types/tests/features/owner-delegated-grant.spec.d.ts +2 -0
- package/dist/types/tests/features/owner-delegated-grant.spec.d.ts.map +1 -0
- package/dist/types/tests/features/owner-signature.spec.d.ts +2 -0
- package/dist/types/tests/features/owner-signature.spec.d.ts.map +1 -0
- package/dist/types/tests/features/permissions.spec.d.ts +2 -0
- package/dist/types/tests/features/permissions.spec.d.ts.map +1 -0
- package/dist/types/tests/features/protocol-create-action.spec.d.ts +2 -0
- package/dist/types/tests/features/protocol-create-action.spec.d.ts.map +1 -0
- package/dist/types/tests/features/protocol-delete-action.spec.d.ts +2 -0
- package/dist/types/tests/features/protocol-delete-action.spec.d.ts.map +1 -0
- package/dist/types/tests/features/protocol-update-action.spec.d.ts +2 -0
- package/dist/types/tests/features/protocol-update-action.spec.d.ts.map +1 -0
- package/dist/types/tests/features/records-prune.spec.d.ts +2 -0
- package/dist/types/tests/features/records-prune.spec.d.ts.map +1 -0
- package/dist/types/tests/features/records-tags.spec.d.ts +2 -0
- package/dist/types/tests/features/records-tags.spec.d.ts.map +1 -0
- package/dist/types/tests/features/resumable-tasks.spec.d.ts +2 -0
- package/dist/types/tests/features/resumable-tasks.spec.d.ts.map +1 -0
- package/dist/types/tests/handlers/messages-query.spec.d.ts +2 -0
- package/dist/types/tests/handlers/messages-query.spec.d.ts.map +1 -0
- package/dist/types/tests/handlers/messages-read.spec.d.ts +2 -0
- package/dist/types/tests/handlers/messages-read.spec.d.ts.map +1 -0
- package/dist/types/tests/handlers/messages-subscribe.spec.d.ts +2 -0
- package/dist/types/tests/handlers/messages-subscribe.spec.d.ts.map +1 -0
- package/dist/types/tests/handlers/protocols-configure.spec.d.ts +2 -0
- package/dist/types/tests/handlers/protocols-configure.spec.d.ts.map +1 -0
- package/dist/types/tests/handlers/protocols-query.spec.d.ts +2 -0
- package/dist/types/tests/handlers/protocols-query.spec.d.ts.map +1 -0
- package/dist/types/tests/handlers/records-delete.spec.d.ts +2 -0
- package/dist/types/tests/handlers/records-delete.spec.d.ts.map +1 -0
- package/dist/types/tests/handlers/records-query.spec.d.ts +2 -0
- package/dist/types/tests/handlers/records-query.spec.d.ts.map +1 -0
- package/dist/types/tests/handlers/records-read.spec.d.ts +2 -0
- package/dist/types/tests/handlers/records-read.spec.d.ts.map +1 -0
- package/dist/types/tests/handlers/records-subscribe.spec.d.ts +2 -0
- package/dist/types/tests/handlers/records-subscribe.spec.d.ts.map +1 -0
- package/dist/types/tests/handlers/records-write.spec.d.ts +2 -0
- package/dist/types/tests/handlers/records-write.spec.d.ts.map +1 -0
- package/dist/types/tests/interfaces/messages-get.spec.d.ts +2 -0
- package/dist/types/tests/interfaces/messages-get.spec.d.ts.map +1 -0
- package/dist/types/tests/interfaces/messages-subscribe.spec.d.ts +2 -0
- package/dist/types/tests/interfaces/messages-subscribe.spec.d.ts.map +1 -0
- package/dist/types/tests/interfaces/messagess-query.spec.d.ts +2 -0
- package/dist/types/tests/interfaces/messagess-query.spec.d.ts.map +1 -0
- package/dist/types/tests/interfaces/protocols-configure.spec.d.ts +2 -0
- package/dist/types/tests/interfaces/protocols-configure.spec.d.ts.map +1 -0
- package/dist/types/tests/interfaces/protocols-query.spec.d.ts +2 -0
- package/dist/types/tests/interfaces/protocols-query.spec.d.ts.map +1 -0
- package/dist/types/tests/interfaces/records-delete.spec.d.ts +2 -0
- package/dist/types/tests/interfaces/records-delete.spec.d.ts.map +1 -0
- package/dist/types/tests/interfaces/records-query.spec.d.ts +2 -0
- package/dist/types/tests/interfaces/records-query.spec.d.ts.map +1 -0
- package/dist/types/tests/interfaces/records-read.spec.d.ts +2 -0
- package/dist/types/tests/interfaces/records-read.spec.d.ts.map +1 -0
- package/dist/types/tests/interfaces/records-subscribe.spec.d.ts +2 -0
- package/dist/types/tests/interfaces/records-subscribe.spec.d.ts.map +1 -0
- package/dist/types/tests/interfaces/records-write.spec.d.ts +2 -0
- package/dist/types/tests/interfaces/records-write.spec.d.ts.map +1 -0
- package/dist/types/tests/jose/jws/general.spec.d.ts +2 -0
- package/dist/types/tests/jose/jws/general.spec.d.ts.map +1 -0
- package/dist/types/tests/protocols/permission-request.spec.d.ts +2 -0
- package/dist/types/tests/protocols/permission-request.spec.d.ts.map +1 -0
- package/dist/types/tests/protocols/permissions.spec.d.ts +2 -0
- package/dist/types/tests/protocols/permissions.spec.d.ts.map +1 -0
- package/dist/types/tests/scenarios/aggregator.spec.d.ts +2 -0
- package/dist/types/tests/scenarios/aggregator.spec.d.ts.map +1 -0
- package/dist/types/tests/scenarios/deleted-record.spec.d.ts +2 -0
- package/dist/types/tests/scenarios/deleted-record.spec.d.ts.map +1 -0
- package/dist/types/tests/scenarios/end-to-end-tests.spec.d.ts +2 -0
- package/dist/types/tests/scenarios/end-to-end-tests.spec.d.ts.map +1 -0
- package/dist/types/tests/scenarios/messages-query.spec.d.ts +2 -0
- package/dist/types/tests/scenarios/messages-query.spec.d.ts.map +1 -0
- package/dist/types/tests/scenarios/nested-roles.spec.d.ts +2 -0
- package/dist/types/tests/scenarios/nested-roles.spec.d.ts.map +1 -0
- package/dist/types/tests/scenarios/subscriptions.spec.d.ts +2 -0
- package/dist/types/tests/scenarios/subscriptions.spec.d.ts.map +1 -0
- package/dist/types/tests/store/blockstore-mock.spec.d.ts +2 -0
- package/dist/types/tests/store/blockstore-mock.spec.d.ts.map +1 -0
- package/dist/types/tests/store/data-store-level.spec.d.ts +2 -0
- package/dist/types/tests/store/data-store-level.spec.d.ts.map +1 -0
- package/dist/types/tests/store/index-level.spec.d.ts +2 -0
- package/dist/types/tests/store/index-level.spec.d.ts.map +1 -0
- package/dist/types/tests/store/message-store-level.spec.d.ts +2 -0
- package/dist/types/tests/store/message-store-level.spec.d.ts.map +1 -0
- package/dist/types/tests/store/message-store.spec.d.ts +2 -0
- package/dist/types/tests/store/message-store.spec.d.ts.map +1 -0
- package/dist/types/tests/store-dependent-tests.spec.d.ts +2 -0
- package/dist/types/tests/store-dependent-tests.spec.d.ts.map +1 -0
- package/dist/types/tests/test-event-stream.d.ts +22 -0
- package/dist/types/tests/test-event-stream.d.ts.map +1 -0
- package/dist/types/tests/test-stores.d.ts +33 -0
- package/dist/types/tests/test-stores.d.ts.map +1 -0
- package/dist/types/tests/test-suite.d.ts +18 -0
- package/dist/types/tests/test-suite.d.ts.map +1 -0
- package/dist/types/tests/utils/cid.spec.d.ts +2 -0
- package/dist/types/tests/utils/cid.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/data-stream.spec.d.ts +2 -0
- package/dist/types/tests/utils/data-stream.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/encryption.spec.d.ts +2 -0
- package/dist/types/tests/utils/encryption.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/filters.spec.d.ts +2 -0
- package/dist/types/tests/utils/filters.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/hd-key.spec.d.ts +2 -0
- package/dist/types/tests/utils/hd-key.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/jws.spec.d.ts +2 -0
- package/dist/types/tests/utils/jws.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/memory-cache.spec.d.ts +2 -0
- package/dist/types/tests/utils/memory-cache.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/messages.spec.d.ts +2 -0
- package/dist/types/tests/utils/messages.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/object.spec.d.ts +2 -0
- package/dist/types/tests/utils/object.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/poller.d.ts +21 -0
- package/dist/types/tests/utils/poller.d.ts.map +1 -0
- package/dist/types/tests/utils/private-key-signer.spec.d.ts +2 -0
- package/dist/types/tests/utils/private-key-signer.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/records.spec.d.ts +2 -0
- package/dist/types/tests/utils/records.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/secp256k1.spec.d.ts +2 -0
- package/dist/types/tests/utils/secp256k1.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/secp256r1.spec.d.ts +2 -0
- package/dist/types/tests/utils/secp256r1.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/test-data-generator.d.ts +342 -0
- package/dist/types/tests/utils/test-data-generator.d.ts.map +1 -0
- package/dist/types/tests/utils/test-stub-generator.d.ts +16 -0
- package/dist/types/tests/utils/test-stub-generator.d.ts.map +1 -0
- package/dist/types/tests/utils/time.spec.d.ts +2 -0
- package/dist/types/tests/utils/time.spec.d.ts.map +1 -0
- package/dist/types/tests/utils/url.spec.d.ts +2 -0
- package/dist/types/tests/utils/url.spec.d.ts.map +1 -0
- package/dist/types/tests/validation/json-schemas/definitions.spec.d.ts +2 -0
- package/dist/types/tests/validation/json-schemas/definitions.spec.d.ts.map +1 -0
- package/dist/types/tests/validation/json-schemas/jwk/general-jwk.spec.d.ts +2 -0
- package/dist/types/tests/validation/json-schemas/jwk/general-jwk.spec.d.ts.map +1 -0
- package/dist/types/tests/validation/json-schemas/jwk/public-jwk.spec.d.ts +2 -0
- package/dist/types/tests/validation/json-schemas/jwk/public-jwk.spec.d.ts.map +1 -0
- package/dist/types/tests/validation/json-schemas/jwk-verification-method.spec.d.ts +2 -0
- package/dist/types/tests/validation/json-schemas/jwk-verification-method.spec.d.ts.map +1 -0
- package/dist/types/tests/validation/json-schemas/protocols/protocols-configure.spec.d.ts +2 -0
- package/dist/types/tests/validation/json-schemas/protocols/protocols-configure.spec.d.ts.map +1 -0
- package/dist/types/tests/validation/json-schemas/records/records-query.spec.d.ts +2 -0
- package/dist/types/tests/validation/json-schemas/records/records-query.spec.d.ts.map +1 -0
- package/dist/types/tests/validation/json-schemas/records/records-write.spec.d.ts +2 -0
- package/dist/types/tests/validation/json-schemas/records/records-write.spec.d.ts.map +1 -0
- package/package.json +167 -0
- package/src/core/abstract-message.ts +62 -0
- package/src/core/auth.ts +36 -0
- package/src/core/dwn-constant.ts +9 -0
- package/src/core/dwn-error.ts +167 -0
- package/src/core/grant-authorization.ts +148 -0
- package/src/core/message-reply.ts +41 -0
- package/src/core/message.ts +259 -0
- package/src/core/messages-grant-authorization.ts +134 -0
- package/src/core/protocol-authorization.ts +903 -0
- package/src/core/protocols-grant-authorization.ts +88 -0
- package/src/core/records-grant-authorization.ts +197 -0
- package/src/core/resumable-task-manager.ts +114 -0
- package/src/core/tenant-gate.ts +33 -0
- package/src/dwn.ts +264 -0
- package/src/enums/dwn-interface-method.ts +14 -0
- package/src/event-log/event-emitter-stream.ts +69 -0
- package/src/event-log/event-log-level.ts +72 -0
- package/src/handlers/messages-query.ts +67 -0
- package/src/handlers/messages-read.ts +103 -0
- package/src/handlers/messages-subscribe.ts +89 -0
- package/src/handlers/protocols-configure.ts +137 -0
- package/src/handlers/protocols-query.ts +82 -0
- package/src/handlers/records-delete.ts +124 -0
- package/src/handlers/records-query.ts +262 -0
- package/src/handlers/records-read.ts +187 -0
- package/src/handlers/records-subscribe.ts +218 -0
- package/src/handlers/records-write.ts +404 -0
- package/src/index.ts +67 -0
- package/src/interfaces/messages-query.ts +60 -0
- package/src/interfaces/messages-read.ts +63 -0
- package/src/interfaces/messages-subscribe.ts +64 -0
- package/src/interfaces/protocols-configure.ts +340 -0
- package/src/interfaces/protocols-query.ts +96 -0
- package/src/interfaces/records-delete.ts +117 -0
- package/src/interfaces/records-query.ts +131 -0
- package/src/interfaces/records-read.ts +100 -0
- package/src/interfaces/records-subscribe.ts +104 -0
- package/src/interfaces/records-write.ts +1072 -0
- package/src/jose/algorithms/signing/ed25519.ts +58 -0
- package/src/jose/algorithms/signing/signature-algorithms.ts +22 -0
- package/src/jose/jws/general/builder.ts +48 -0
- package/src/jose/jws/general/verifier.ts +112 -0
- package/src/protocols/permission-grant.ts +86 -0
- package/src/protocols/permission-request.ts +63 -0
- package/src/protocols/permissions.ts +508 -0
- package/src/schema-validator.ts +46 -0
- package/src/store/blockstore-level.ts +113 -0
- package/src/store/blockstore-mock.ts +80 -0
- package/src/store/data-store-level.ts +120 -0
- package/src/store/index-level.ts +691 -0
- package/src/store/level-wrapper.ts +272 -0
- package/src/store/message-store-level.ts +195 -0
- package/src/store/resumable-task-store-level.ts +120 -0
- package/src/store/storage-controller.ts +240 -0
- package/src/types/cache.ts +16 -0
- package/src/types/data-store.ts +64 -0
- package/src/types/event-log.ts +52 -0
- package/src/types/jose-types.ts +76 -0
- package/src/types/jws-types.ts +28 -0
- package/src/types/message-interface.ts +30 -0
- package/src/types/message-store.ts +57 -0
- package/src/types/message-types.ts +132 -0
- package/src/types/messages-types.ts +77 -0
- package/src/types/method-handler.ts +19 -0
- package/src/types/permission-types.ts +110 -0
- package/src/types/protocols-types.ts +177 -0
- package/src/types/query-types.ts +61 -0
- package/src/types/records-types.ts +263 -0
- package/src/types/resumable-task-store.ts +96 -0
- package/src/types/signer.ts +27 -0
- package/src/types/subscriptions.ts +34 -0
- package/src/utils/abort.ts +31 -0
- package/src/utils/array.ts +39 -0
- package/src/utils/cid.ts +101 -0
- package/src/utils/data-stream.ts +99 -0
- package/src/utils/encoder.ts +54 -0
- package/src/utils/encryption.ts +145 -0
- package/src/utils/filter.ts +245 -0
- package/src/utils/hd-key.ts +126 -0
- package/src/utils/jws.ts +95 -0
- package/src/utils/memory-cache.ts +31 -0
- package/src/utils/messages.ts +109 -0
- package/src/utils/object.ts +43 -0
- package/src/utils/private-key-signer.ts +72 -0
- package/src/utils/protocols.ts +50 -0
- package/src/utils/records.ts +559 -0
- package/src/utils/secp256k1.ts +157 -0
- package/src/utils/secp256r1.ts +142 -0
- package/src/utils/string.ts +13 -0
- package/src/utils/time.ts +78 -0
- package/src/utils/url.ts +65 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import type { EncryptionAlgorithm } from '../utils/encryption.js';
|
|
2
|
+
import type { GeneralJws } from './jws-types.js';
|
|
3
|
+
import type { KeyDerivationScheme } from '../utils/hd-key.js';
|
|
4
|
+
import type { PublicJwk } from './jose-types.js';
|
|
5
|
+
import type { Readable } from 'readable-stream';
|
|
6
|
+
import type { AuthorizationModel, GenericMessage, GenericMessageReply, GenericSignaturePayload, MessageSubscription, Pagination } from './message-types.js';
|
|
7
|
+
import type { DwnInterfaceName, DwnMethodName } from '../enums/dwn-interface-method.js';
|
|
8
|
+
import type { PaginationCursor, RangeCriterion, RangeFilter, StartsWithFilter } from './query-types.js';
|
|
9
|
+
|
|
10
|
+
export enum DateSort {
|
|
11
|
+
CreatedAscending = 'createdAscending',
|
|
12
|
+
CreatedDescending = 'createdDescending',
|
|
13
|
+
PublishedAscending = 'publishedAscending',
|
|
14
|
+
PublishedDescending = 'publishedDescending'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type RecordsWriteTagValue = string | number | boolean | string[] | number[];
|
|
18
|
+
export type RecordsWriteTags = {
|
|
19
|
+
[property: string]: RecordsWriteTagValue;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type RecordsWriteTagsFilter = StartsWithFilter | RangeFilter | string | number | boolean;
|
|
23
|
+
|
|
24
|
+
export type RecordsWriteDescriptor = {
|
|
25
|
+
interface: DwnInterfaceName.Records;
|
|
26
|
+
method: DwnMethodName.Write;
|
|
27
|
+
protocol?: string;
|
|
28
|
+
protocolPath?: string;
|
|
29
|
+
recipient?: string;
|
|
30
|
+
schema?: string;
|
|
31
|
+
tags?: RecordsWriteTags;
|
|
32
|
+
parentId?: string;
|
|
33
|
+
dataCid: string;
|
|
34
|
+
dataSize: number;
|
|
35
|
+
dateCreated: string;
|
|
36
|
+
messageTimestamp: string;
|
|
37
|
+
published?: boolean;
|
|
38
|
+
datePublished?: string;
|
|
39
|
+
dataFormat: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type RecordsWriteMessageOptions = {
|
|
43
|
+
dataStream?: Readable;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Internal RecordsWrite message representation that can be in an incomplete state.
|
|
48
|
+
*/
|
|
49
|
+
export type InternalRecordsWriteMessage = GenericMessage & {
|
|
50
|
+
recordId?: string,
|
|
51
|
+
contextId?: string;
|
|
52
|
+
descriptor: RecordsWriteDescriptor;
|
|
53
|
+
attestation?: GeneralJws;
|
|
54
|
+
encryption?: EncryptionProperty;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type RecordsWriteMessage = {
|
|
58
|
+
authorization: AuthorizationModel; // overriding `GenericMessage` with `authorization` being required
|
|
59
|
+
recordId: string,
|
|
60
|
+
contextId?: string;
|
|
61
|
+
descriptor: RecordsWriteDescriptor;
|
|
62
|
+
attestation?: GeneralJws;
|
|
63
|
+
encryption?: EncryptionProperty;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type EncryptionProperty = {
|
|
67
|
+
algorithm: EncryptionAlgorithm;
|
|
68
|
+
initializationVector: string;
|
|
69
|
+
keyEncryption: EncryptedKey[]
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type EncryptedKey = {
|
|
73
|
+
/**
|
|
74
|
+
* The fully qualified key ID (e.g. did:example:abc#encryption-key-id) of the root public key used to encrypt the symmetric encryption key.
|
|
75
|
+
*/
|
|
76
|
+
rootKeyId: string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The actual derived public key.
|
|
80
|
+
*/
|
|
81
|
+
derivedPublicKey?: PublicJwk;
|
|
82
|
+
derivationScheme: KeyDerivationScheme;
|
|
83
|
+
algorithm: EncryptionAlgorithm;
|
|
84
|
+
initializationVector: string;
|
|
85
|
+
ephemeralPublicKey: PublicJwk;
|
|
86
|
+
messageAuthenticationCode: string;
|
|
87
|
+
encryptedKey: string;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Data structure returned in a `RecordsQuery` reply entry.
|
|
92
|
+
* NOTE: the message structure is a modified version of the message received, the most notable differences are:
|
|
93
|
+
* 1. May include an initial RecordsWrite message
|
|
94
|
+
* 2. May include encoded data
|
|
95
|
+
*/
|
|
96
|
+
export type RecordsQueryReplyEntry = RecordsWriteMessage & {
|
|
97
|
+
/**
|
|
98
|
+
* The initial write of the record if the returned RecordsWrite message itself is not the initial write.
|
|
99
|
+
*/
|
|
100
|
+
initialWrite?: RecordsWriteMessage;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The encoded data of the record if the data associated with the record is equal or smaller than `DwnConstant.maxDataSizeAllowedToBeEncoded`.
|
|
104
|
+
*/
|
|
105
|
+
encodedData?: string;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Represents a RecordsWrite message with encoded data attached.
|
|
110
|
+
*/
|
|
111
|
+
export type DataEncodedRecordsWriteMessage = RecordsWriteMessage & {
|
|
112
|
+
/**
|
|
113
|
+
* The encoded data of the record if the data associated with the record is equal or smaller than `DwnConstant.maxDataSizeAllowedToBeEncoded`.
|
|
114
|
+
*/
|
|
115
|
+
encodedData: string;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export type RecordsQueryDescriptor = {
|
|
119
|
+
interface: DwnInterfaceName.Records;
|
|
120
|
+
method: DwnMethodName.Query;
|
|
121
|
+
messageTimestamp: string;
|
|
122
|
+
filter: RecordsFilter;
|
|
123
|
+
dateSort?: DateSort;
|
|
124
|
+
pagination?: Pagination;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export type RecordsSubscribeDescriptor = {
|
|
128
|
+
interface: DwnInterfaceName.Records;
|
|
129
|
+
method: DwnMethodName.Subscribe;
|
|
130
|
+
messageTimestamp: string;
|
|
131
|
+
filter: RecordsFilter;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export type RecordsFilter = {
|
|
135
|
+
/**
|
|
136
|
+
* The logical author of the record
|
|
137
|
+
*/
|
|
138
|
+
author?: string | string[];
|
|
139
|
+
attester?: string;
|
|
140
|
+
recipient?: string | string[];
|
|
141
|
+
protocol?: string;
|
|
142
|
+
protocolPath?: string;
|
|
143
|
+
published?: boolean;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* When given all Records message under the context of the given `contextId` will be returned.
|
|
147
|
+
*/
|
|
148
|
+
contextId?: string;
|
|
149
|
+
schema?: string;
|
|
150
|
+
tags?: { [property:string]: RecordsWriteTagsFilter }
|
|
151
|
+
recordId?: string;
|
|
152
|
+
parentId?: string;
|
|
153
|
+
dataFormat?: string;
|
|
154
|
+
dataSize?: RangeFilter;
|
|
155
|
+
dataCid?: string;
|
|
156
|
+
dateCreated?: RangeCriterion;
|
|
157
|
+
datePublished?: RangeCriterion;
|
|
158
|
+
dateUpdated?: RangeCriterion;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export type RecordsWriteAttestationPayload = {
|
|
162
|
+
descriptorCid: string;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export type RecordsWriteSignaturePayload = GenericSignaturePayload & {
|
|
166
|
+
recordId: string;
|
|
167
|
+
contextId?: string;
|
|
168
|
+
attestationCid?: string;
|
|
169
|
+
encryptionCid?: string;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export type RecordsQueryMessage = GenericMessage & {
|
|
173
|
+
descriptor: RecordsQueryDescriptor;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export type RecordsQueryReply = GenericMessageReply & {
|
|
177
|
+
entries?: RecordsQueryReplyEntry[];
|
|
178
|
+
cursor?: PaginationCursor;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export type RecordEvent = {
|
|
182
|
+
message: RecordsWriteMessage | RecordsDeleteMessage
|
|
183
|
+
initialWrite?: RecordsWriteMessage;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export type RecordSubscriptionHandler = (event: RecordEvent) => void;
|
|
187
|
+
|
|
188
|
+
export type RecordsSubscribeMessageOptions = {
|
|
189
|
+
subscriptionHandler: RecordSubscriptionHandler;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export type RecordsSubscribeMessage = GenericMessage & {
|
|
193
|
+
descriptor: RecordsSubscribeDescriptor;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export type RecordsSubscribeReply = GenericMessageReply & {
|
|
197
|
+
subscription?: MessageSubscription;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export type RecordsReadMessage = {
|
|
201
|
+
authorization?: AuthorizationModel;
|
|
202
|
+
descriptor: RecordsReadDescriptor;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The reply to a RecordsRead message.
|
|
207
|
+
*/
|
|
208
|
+
export type RecordsReadReply = GenericMessageReply & {
|
|
209
|
+
/**
|
|
210
|
+
* A container for the data returned from a `RecordsRead`.
|
|
211
|
+
* `undefined` if no data needs to be returned.
|
|
212
|
+
*/
|
|
213
|
+
entry?: RecordsReadReplyEntry;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The structure of the `entry` container property in `RecordsReadReplyEntry`.
|
|
218
|
+
*/
|
|
219
|
+
export type RecordsReadReplyEntry = {
|
|
220
|
+
/**
|
|
221
|
+
* The latest RecordsWrite message of the record if record exists (not deleted).
|
|
222
|
+
*/
|
|
223
|
+
recordsWrite?: RecordsWriteMessage;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The RecordsDelete if the record is deleted.
|
|
227
|
+
*/
|
|
228
|
+
recordsDelete?: RecordsDeleteMessage;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* The initial write of the record if the returned RecordsWrite message itself is not the initial write or if a RecordsDelete is returned.
|
|
232
|
+
*/
|
|
233
|
+
initialWrite?: RecordsWriteMessage;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The data stream associated with the record if the records exists (not deleted).
|
|
237
|
+
*/
|
|
238
|
+
data?: Readable;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export type RecordsReadDescriptor = {
|
|
242
|
+
interface: DwnInterfaceName.Records;
|
|
243
|
+
method: DwnMethodName.Read;
|
|
244
|
+
filter: RecordsFilter;
|
|
245
|
+
messageTimestamp: string;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export type RecordsDeleteMessage = GenericMessage & {
|
|
249
|
+
authorization: AuthorizationModel; // overriding `GenericMessage` with `authorization` being required
|
|
250
|
+
descriptor: RecordsDeleteDescriptor;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export type RecordsDeleteDescriptor = {
|
|
254
|
+
interface: DwnInterfaceName.Records;
|
|
255
|
+
method: DwnMethodName.Delete;
|
|
256
|
+
messageTimestamp: string;
|
|
257
|
+
recordId: string;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Denotes if all the descendent records should be purged.
|
|
261
|
+
*/
|
|
262
|
+
prune: boolean
|
|
263
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An managed resumable task model.
|
|
3
|
+
*/
|
|
4
|
+
export type ManagedResumableTask = {
|
|
5
|
+
/** Globally unique ID. Used to extend or delete the task. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Task specific data. This is deliberately of type `any` because this store should not have to be ware of its type. */
|
|
8
|
+
task: any;
|
|
9
|
+
/** Task timeout in Epoch Time. */
|
|
10
|
+
timeout: number;
|
|
11
|
+
/** Number of retries */
|
|
12
|
+
retryCount: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Interface for interacting with the resumable task store.
|
|
17
|
+
*
|
|
18
|
+
* Implementer's Note:
|
|
19
|
+
* The store implementation used in a horizontally scalable deployment, such as in a Kubernetes cluster,
|
|
20
|
+
* must account for concurrent access by multiple `ResumableTaskStore` instances.
|
|
21
|
+
* It would be undesirable to have many kubernetes pods all trying to handle the same resumable task.
|
|
22
|
+
* A minimal viable implementation can use a per tenant exclusive lock on the store when `grab()` and method is called.
|
|
23
|
+
* This would prevent issues that occur from concurrent modification to the same task to the store,
|
|
24
|
+
* but negatively impacts the throughput performance of the DWN.
|
|
25
|
+
* Requirements for a more performant implementation that allows distributed processing of resumable tasks across multiple clients:
|
|
26
|
+
* 1. The implementation probably requires both:
|
|
27
|
+
* a. a persistent store for storing the data of each resumable task; and
|
|
28
|
+
* b. an message streaming queue/service for distributing the each task exclusively to one of multiple handling clients.
|
|
29
|
+
* 2. The `grab()` and/or `open()` implementation will need to copy the timed-out tasks from persistent store into the message queue/service
|
|
30
|
+
* for distributed processing by multiple clients when there is no resumable tasks to grab in the message queue.
|
|
31
|
+
* During the move, the persistent store should be locked to prevent multiple copies of the same tasks from being copied.
|
|
32
|
+
* 3. Both Google's pub-sub and Amazon's SQS require an Ack ID / Receipt Handle to acknowledge the message,
|
|
33
|
+
* The value of Ack ID / Receipt Handle is not known until the message is received,
|
|
34
|
+
* therefore the implementer will likely need to have an in-memory mapping of task ID -> Ack ID / Receipt Handle
|
|
35
|
+
* so that `delete()` can be called with task ID.
|
|
36
|
+
*/
|
|
37
|
+
export interface ResumableTaskStore {
|
|
38
|
+
/**
|
|
39
|
+
* Opens a connection to the underlying store and initializes it.
|
|
40
|
+
*/
|
|
41
|
+
open(): Promise<void>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Closes the connection to the underlying store.
|
|
45
|
+
*/
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Registers a new resumable task that is currently in-flight/under processing to the store.
|
|
50
|
+
* If the task is timed out, a client will be able to grab it through the `grab()` method and resume the task.
|
|
51
|
+
* @param task Task specific data. This is deliberately of type `any` because this store should not have to be ware of its type.
|
|
52
|
+
* @param timeoutInSeconds Timeout in seconds from the current time.
|
|
53
|
+
* @returns A `ManagedResumableTask` object that can be used to extend or delete the task.
|
|
54
|
+
* @throws {Error} with `code` set to `ResumableTaskAlreadyExists` if the same task is already registered.
|
|
55
|
+
*/
|
|
56
|
+
register(task: any, timeoutInSeconds: number): Promise<ManagedResumableTask>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Grabs a number of unhandled tasks from the store.
|
|
60
|
+
* Unhandled tasks are tasks that are not currently in-flight/under processing (ie. tasks that have timed-out).
|
|
61
|
+
* NOTE: The implementation must make sure that once a task is grabbed by a client,
|
|
62
|
+
* tis timeout must be updated so that it is considered in-flight/under processing
|
|
63
|
+
* and cannot be grabbed by another client until it is timed-out.
|
|
64
|
+
* @param count Desired number of tasks to grab.
|
|
65
|
+
* @returns A list of tasks exclusive for the caller to handle; or empty array if there is no tasks, or if all tasks are already grabbed by others.
|
|
66
|
+
*/
|
|
67
|
+
grab(count: number): Promise<ManagedResumableTask[]>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Reads the task associated with the task ID provided regardless of whether it is in-flight/under processing or not.
|
|
71
|
+
* This is mainly introduced for testing purposes: ie. to check the status of a task for easy test verification.
|
|
72
|
+
* @param taskId ID of the task to read.
|
|
73
|
+
*/
|
|
74
|
+
read(taskId: string): Promise<ManagedResumableTask | undefined>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Extends the timeout of the task associated with the task ID provided.
|
|
78
|
+
* No-op if the task is not found, as this implies that the task has already been completed.
|
|
79
|
+
* This allows the client that is executing the task to continue working on it before the task is considered timed out.
|
|
80
|
+
* @param taskId ID of the task to extend the timeout for.
|
|
81
|
+
* @param timeoutInSeconds Timeout in seconds from the current time.
|
|
82
|
+
*/
|
|
83
|
+
extend(taskId: string, timeoutInSeconds: number): Promise<void>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Deletes the task associated with the task ID provided.
|
|
87
|
+
* No-op if the task is not found, as this implies that the task has already been completed.
|
|
88
|
+
* Called when the task has been successfully completed.
|
|
89
|
+
*/
|
|
90
|
+
delete(taskId: string): Promise<void>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Clears the entire store. Mainly used for cleaning up in test environment.
|
|
94
|
+
*/
|
|
95
|
+
clear(): Promise<void>;
|
|
96
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A signer that is capable of generating a digital signature over any given bytes.
|
|
3
|
+
*/
|
|
4
|
+
export interface Signer {
|
|
5
|
+
/**
|
|
6
|
+
* The ID of the key used by this signer.
|
|
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.
|
|
8
|
+
* Example: did:example:alice#key1
|
|
9
|
+
* This value will be used as the "kid" parameter in JWS produced.
|
|
10
|
+
* While this property is not a required property per JWS specification, it is required for DWN authentication.
|
|
11
|
+
*/
|
|
12
|
+
keyId: string
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The name of the signature algorithm used by this signer.
|
|
16
|
+
* This value will be used as the "alg" parameter in JWS produced.
|
|
17
|
+
* This parameter is not used by the DWN but is unfortunately a required header property for a JWS as per:
|
|
18
|
+
* https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.1
|
|
19
|
+
* Valid signature algorithm values can be found at https://www.iana.org/assignments/jose/jose.xhtml
|
|
20
|
+
*/
|
|
21
|
+
algorithm: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Signs the given content and returns the signature as bytes.
|
|
25
|
+
*/
|
|
26
|
+
sign (content: Uint8Array): Promise<Uint8Array>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { GenericMessageReply } from '../types/message-types.js';
|
|
2
|
+
import type { KeyValues } from './query-types.js';
|
|
3
|
+
import type { RecordsWriteMessage } from './records-types.js';
|
|
4
|
+
import type { GenericMessage, MessageSubscription } from './message-types.js';
|
|
5
|
+
|
|
6
|
+
export type EventListener = (tenant: string, event: MessageEvent, indexes: KeyValues) => void;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* MessageEvent contains the message being emitted and an optional initial write message.
|
|
10
|
+
*/
|
|
11
|
+
export type MessageEvent = {
|
|
12
|
+
message: GenericMessage;
|
|
13
|
+
/** the initial write of the RecordsWrite or RecordsDelete message */
|
|
14
|
+
initialWrite?: RecordsWriteMessage
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The EventStream interface implements a pub/sub system based on Message filters.
|
|
19
|
+
*/
|
|
20
|
+
export interface EventStream {
|
|
21
|
+
subscribe(tenant: string, id: string, listener: EventListener): Promise<EventSubscription>;
|
|
22
|
+
emit(tenant: string, event: MessageEvent, indexes: KeyValues): void;
|
|
23
|
+
open(): Promise<void>;
|
|
24
|
+
close(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface EventSubscription {
|
|
28
|
+
id: string;
|
|
29
|
+
close: () => Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type SubscriptionReply = GenericMessageReply & {
|
|
33
|
+
subscription?: MessageSubscription;
|
|
34
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps the given `AbortSignal` in a `Promise` that rejects if it is programmatically triggered,
|
|
3
|
+
* otherwise the promise will remain in await state (will never resolve).
|
|
4
|
+
*/
|
|
5
|
+
function promisifySignal<T>(signal: AbortSignal): Promise<T> {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
// immediately reject if the given is signal is already aborted
|
|
8
|
+
if (signal.aborted) {
|
|
9
|
+
reject(signal.reason);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
signal.addEventListener('abort', () => {
|
|
14
|
+
reject(signal.reason);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Wraps the given `Promise` such that it will reject if the `AbortSignal` is triggered.
|
|
21
|
+
*/
|
|
22
|
+
export async function executeUnlessAborted<T>(promise: Promise<T>, signal: AbortSignal | undefined): Promise<T> {
|
|
23
|
+
if (!signal) {
|
|
24
|
+
return promise;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return Promise.race([
|
|
28
|
+
promise,
|
|
29
|
+
promisifySignal<T>(signal),
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array utility methods.
|
|
3
|
+
*/
|
|
4
|
+
export class ArrayUtility {
|
|
5
|
+
/**
|
|
6
|
+
* Returns `true` if content of the two given byte arrays are equal; `false` otherwise.
|
|
7
|
+
*/
|
|
8
|
+
public static byteArraysEqual(array1: Uint8Array, array2:Uint8Array): boolean {
|
|
9
|
+
const equal = array1.length === array2.length && array1.every((value, index) => value === array2[index]);
|
|
10
|
+
return equal;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Asynchronously iterates an {AsyncGenerator} to return all the values in an array.
|
|
15
|
+
*/
|
|
16
|
+
public static async fromAsyncGenerator<T>(iterator: AsyncGenerator<T>): Promise<Array<T>> {
|
|
17
|
+
const array: Array<T> = [ ];
|
|
18
|
+
for await (const value of iterator) {
|
|
19
|
+
array.push(value);
|
|
20
|
+
}
|
|
21
|
+
return array;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Generic asynchronous sort method.
|
|
26
|
+
*/
|
|
27
|
+
public static async asyncSort<T>(array: T[], asyncComparer: (a: T, b: T) => Promise<number>): Promise<T[]> {
|
|
28
|
+
// this is a bubble sort implementation
|
|
29
|
+
for (let i = 0; i < array.length; i++) {
|
|
30
|
+
for (let j = i + 1; j < array.length; j++) {
|
|
31
|
+
const comparison = await asyncComparer(array[i], array[j]);
|
|
32
|
+
if (comparison > 0) {
|
|
33
|
+
[array[i], array[j]] = [array[j], array[i]]; // Swap
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return array;
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/utils/cid.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as cbor from '@ipld/dag-cbor';
|
|
2
|
+
|
|
3
|
+
import type { Readable } from 'readable-stream';
|
|
4
|
+
|
|
5
|
+
import { BlockstoreMock } from '../store/blockstore-mock.js';
|
|
6
|
+
import { CID } from 'multiformats/cid';
|
|
7
|
+
import { importer } from 'ipfs-unixfs-importer';
|
|
8
|
+
import { sha256 } from 'multiformats/hashes/sha2';
|
|
9
|
+
import { DwnError, DwnErrorCode } from '../core/dwn-error.js';
|
|
10
|
+
|
|
11
|
+
// a map of all supported CID hashing algorithms. This map is used to select the appropriate hasher
|
|
12
|
+
// when generating a CID to compare against a provided CID
|
|
13
|
+
const hashers = {
|
|
14
|
+
[sha256.code as number]: sha256,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// a map of all support codecs.This map is used to select the appropriate codec
|
|
18
|
+
// when generating a CID to compare against a provided CID
|
|
19
|
+
const codecs = {
|
|
20
|
+
[cbor.code as number]: cbor
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Utility class for creating CIDs. Exported for the convenience of developers.
|
|
25
|
+
*/
|
|
26
|
+
export class Cid {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Computes a V1 CID for the provided payload
|
|
30
|
+
* @param codecCode - the codec to use. Defaults to cbor
|
|
31
|
+
* @param multihashCode - the multihasher to use. Defaults to sha256
|
|
32
|
+
* @returns payload CID
|
|
33
|
+
* @throws {Error} codec is not supported
|
|
34
|
+
* @throws {Error} encoding fails
|
|
35
|
+
* @throws {Error} if hasher is not supported
|
|
36
|
+
*/
|
|
37
|
+
public static async computeCid(
|
|
38
|
+
payload: any,
|
|
39
|
+
codecCode: number = cbor.code,
|
|
40
|
+
multihashCode: number = sha256.code
|
|
41
|
+
): Promise<string> {
|
|
42
|
+
const codec = codecs[codecCode];
|
|
43
|
+
if (!codec) {
|
|
44
|
+
throw new DwnError(DwnErrorCode.ComputeCidCodecNotSupported, `codec [${codecCode}] not supported`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const hasher = hashers[multihashCode];
|
|
48
|
+
if (!hasher) {
|
|
49
|
+
throw new DwnError(DwnErrorCode.ComputeCidMultihashNotSupported, `multihash code [${multihashCode}] not supported`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const payloadBytes = codec.encode(payload);
|
|
53
|
+
const payloadHash = await hasher.digest(payloadBytes);
|
|
54
|
+
|
|
55
|
+
const cid = await CID.createV1(codec.code, payloadHash);
|
|
56
|
+
return cid.toString();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Parses the given CID string into a {CID}.
|
|
61
|
+
*/
|
|
62
|
+
public static parseCid(str: string): CID {
|
|
63
|
+
const cid: CID = CID.parse(str).toV1();
|
|
64
|
+
|
|
65
|
+
if (!codecs[cid.code]) {
|
|
66
|
+
throw new DwnError(DwnErrorCode.ParseCidCodecNotSupported, `codec [${cid.code}] not supported`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!hashers[cid.multihash.code]) {
|
|
70
|
+
throw new DwnError(DwnErrorCode.ParseCidMultihashNotSupported, `multihash code [${cid.multihash.code}] not supported`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return cid;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @returns V1 CID of the DAG comprised by chunking data into unixfs DAG-PB encoded blocks
|
|
78
|
+
*/
|
|
79
|
+
public static async computeDagPbCidFromBytes(content: Uint8Array): Promise<string> {
|
|
80
|
+
const asyncDataBlocks = importer([{ content }], new BlockstoreMock(), { cidVersion: 1 });
|
|
81
|
+
|
|
82
|
+
// NOTE: the last block contains the root CID
|
|
83
|
+
let block;
|
|
84
|
+
for await (block of asyncDataBlocks) { ; }
|
|
85
|
+
|
|
86
|
+
return block ? block.cid.toString() : '';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @returns V1 CID of the DAG comprised by chunking data into unixfs DAG-PB encoded blocks
|
|
91
|
+
*/
|
|
92
|
+
public static async computeDagPbCidFromStream(dataStream: Readable): Promise<string> {
|
|
93
|
+
const asyncDataBlocks = importer([{ content: dataStream }], new BlockstoreMock(), { cidVersion: 1 });
|
|
94
|
+
|
|
95
|
+
// NOTE: the last block contains the root CID
|
|
96
|
+
let block;
|
|
97
|
+
for await (block of asyncDataBlocks) { ; }
|
|
98
|
+
|
|
99
|
+
return block ? block.cid.toString() : '';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Encoder } from './encoder.js';
|
|
2
|
+
import { PassThrough, Readable } from 'readable-stream';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Utility class for readable data stream, intentionally named to disambiguate from ReadableStream, readable-stream, Readable etc.
|
|
6
|
+
*/
|
|
7
|
+
export class DataStream {
|
|
8
|
+
/**
|
|
9
|
+
* Reads the entire readable stream given into array of bytes.
|
|
10
|
+
*/
|
|
11
|
+
public static async toBytes(readableStream: Readable): Promise<Uint8Array> {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const chunks: any[] = [];
|
|
14
|
+
readableStream.on('data', chunk => {
|
|
15
|
+
chunks.push(chunk);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
readableStream.on('end', () => {
|
|
19
|
+
const uint8Array = DataStream.concatenateArrayOfBytes(chunks);
|
|
20
|
+
resolve(uint8Array);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
readableStream.on('error', reject);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Reads the entire readable stream and JSON parses it into an object.
|
|
29
|
+
*/
|
|
30
|
+
public static async toObject(readableStream: Readable): Promise<object> {
|
|
31
|
+
const contentBytes = await DataStream.toBytes(readableStream);
|
|
32
|
+
const contentObject = Encoder.bytesToObject(contentBytes);
|
|
33
|
+
return contentObject;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Concatenates the array of bytes given into one Uint8Array.
|
|
38
|
+
*/
|
|
39
|
+
private static concatenateArrayOfBytes(arrayOfBytes: Uint8Array[]): Uint8Array {
|
|
40
|
+
// sum of individual array lengths
|
|
41
|
+
const totalLength = arrayOfBytes.reduce((accumulatedValue, currentValue) => accumulatedValue + currentValue.length, 0);
|
|
42
|
+
|
|
43
|
+
const result = new Uint8Array(totalLength);
|
|
44
|
+
|
|
45
|
+
let length = 0;
|
|
46
|
+
for (const bytes of arrayOfBytes) {
|
|
47
|
+
result.set(bytes, length);
|
|
48
|
+
length += bytes.length;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Creates a readable stream from the bytes given.
|
|
56
|
+
*/
|
|
57
|
+
public static fromBytes(bytes: Uint8Array): Readable {
|
|
58
|
+
// chunk up the bytes to simulate a more real-world like behavior
|
|
59
|
+
const chunkLength = 100_000;
|
|
60
|
+
let currentIndex = 0;
|
|
61
|
+
const readableStream = new Readable({
|
|
62
|
+
read(_size): void {
|
|
63
|
+
// if this is the last chunk
|
|
64
|
+
if (currentIndex + chunkLength > bytes.length) {
|
|
65
|
+
this.push(bytes.subarray(currentIndex));
|
|
66
|
+
this.push(null);
|
|
67
|
+
} else {
|
|
68
|
+
this.push(bytes.subarray(currentIndex, currentIndex + chunkLength));
|
|
69
|
+
|
|
70
|
+
currentIndex = currentIndex + chunkLength;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return readableStream;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Creates a readable stream from the object given.
|
|
80
|
+
*/
|
|
81
|
+
public static fromObject(object: Record<string, any>): Readable {
|
|
82
|
+
const bytes = Encoder.objectToBytes(object);
|
|
83
|
+
return DataStream.fromBytes(bytes);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Duplicates the given data stream into the number of streams specified so that multiple handlers can consume the same data stream.
|
|
88
|
+
*/
|
|
89
|
+
public static duplicateDataStream(dataStream: Readable, count: number): Readable[] {
|
|
90
|
+
const streams: Readable[] = [];
|
|
91
|
+
for (let i = 0; i < count; i++) {
|
|
92
|
+
const passThrough = new PassThrough();
|
|
93
|
+
dataStream.pipe(passThrough);
|
|
94
|
+
streams.push(passThrough as unknown as Readable);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return streams;
|
|
98
|
+
}
|
|
99
|
+
}
|