@enbox/dwn-sdk-js 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.mjs +8 -8
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/generated/precompiled-validators.js +766 -1224
- package/dist/esm/generated/precompiled-validators.js.map +1 -1
- package/dist/esm/src/core/abstract-message.js +3 -3
- package/dist/esm/src/core/abstract-message.js.map +1 -1
- package/dist/esm/src/core/grant-authorization.js +6 -2
- package/dist/esm/src/core/grant-authorization.js.map +1 -1
- package/dist/esm/src/core/message.js +4 -4
- package/dist/esm/src/core/message.js.map +1 -1
- package/dist/esm/src/core/protocol-authorization-action.js +3 -3
- package/dist/esm/src/core/protocol-authorization-action.js.map +1 -1
- package/dist/esm/src/core/protocol-authorization-validation.js +1 -1
- package/dist/esm/src/core/protocol-authorization-validation.js.map +1 -1
- package/dist/esm/src/core/protocol-authorization.js +11 -11
- package/dist/esm/src/core/protocol-authorization.js.map +1 -1
- package/dist/esm/src/core/records-grant-authorization.js +1 -1
- package/dist/esm/src/core/records-grant-authorization.js.map +1 -1
- package/dist/esm/src/core/resumable-task-manager.js.map +1 -1
- package/dist/esm/src/dwn.js +9 -4
- package/dist/esm/src/dwn.js.map +1 -1
- package/dist/esm/src/event-stream/event-emitter-event-log.js +12 -12
- package/dist/esm/src/event-stream/event-emitter-event-log.js.map +1 -1
- package/dist/esm/src/handlers/messages-read.js +7 -7
- package/dist/esm/src/handlers/messages-read.js.map +1 -1
- 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 +18 -18
- package/dist/esm/src/handlers/messages-sync.js.map +1 -1
- package/dist/esm/src/handlers/protocols-configure.js +1 -1
- package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
- package/dist/esm/src/handlers/protocols-query.js +1 -1
- package/dist/esm/src/handlers/protocols-query.js.map +1 -1
- package/dist/esm/src/handlers/records-count.js.map +1 -1
- package/dist/esm/src/handlers/records-delete.js.map +1 -1
- package/dist/esm/src/handlers/records-query.js.map +1 -1
- package/dist/esm/src/handlers/records-read.js +6 -6
- package/dist/esm/src/handlers/records-read.js.map +1 -1
- package/dist/esm/src/handlers/records-subscribe.js +1 -1
- package/dist/esm/src/handlers/records-subscribe.js.map +1 -1
- package/dist/esm/src/handlers/records-write.js +16 -16
- package/dist/esm/src/handlers/records-write.js.map +1 -1
- package/dist/esm/src/index.js +2 -2
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/interfaces/messages-subscribe.js +1 -1
- package/dist/esm/src/interfaces/messages-subscribe.js.map +1 -1
- package/dist/esm/src/interfaces/messages-sync.js +1 -1
- package/dist/esm/src/interfaces/messages-sync.js.map +1 -1
- package/dist/esm/src/interfaces/protocols-configure.js +9 -9
- package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
- package/dist/esm/src/interfaces/protocols-query.js +1 -1
- package/dist/esm/src/interfaces/protocols-query.js.map +1 -1
- package/dist/esm/src/interfaces/records-count.js +1 -1
- package/dist/esm/src/interfaces/records-count.js.map +1 -1
- package/dist/esm/src/interfaces/records-delete.js +1 -1
- package/dist/esm/src/interfaces/records-delete.js.map +1 -1
- package/dist/esm/src/interfaces/records-query.js +1 -1
- package/dist/esm/src/interfaces/records-query.js.map +1 -1
- package/dist/esm/src/interfaces/records-read.js +1 -1
- package/dist/esm/src/interfaces/records-read.js.map +1 -1
- package/dist/esm/src/interfaces/records-subscribe.js +1 -1
- package/dist/esm/src/interfaces/records-subscribe.js.map +1 -1
- package/dist/esm/src/interfaces/records-write-signing.js +1 -1
- package/dist/esm/src/interfaces/records-write-signing.js.map +1 -1
- package/dist/esm/src/interfaces/records-write.js +9 -9
- package/dist/esm/src/interfaces/records-write.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 +30 -2
- package/dist/esm/src/jose/jws/general/verifier.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/smt/smt-store-level.js.map +1 -1
- package/dist/esm/src/smt/smt-store-memory.js.map +1 -1
- package/dist/esm/src/smt/sparse-merkle-tree.js +2 -2
- package/dist/esm/src/smt/sparse-merkle-tree.js.map +1 -1
- package/dist/esm/src/state-index/state-index-level.js.map +1 -1
- package/dist/esm/src/store/index-level-compound.js +10 -10
- package/dist/esm/src/store/index-level-compound.js.map +1 -1
- package/dist/esm/src/store/index-level.js +3 -3
- package/dist/esm/src/store/index-level.js.map +1 -1
- package/dist/esm/src/store/level-wrapper.js +1 -1
- package/dist/esm/src/store/level-wrapper.js.map +1 -1
- package/dist/esm/src/store/storage-controller.js +23 -10
- package/dist/esm/src/store/storage-controller.js.map +1 -1
- package/dist/esm/src/types/permission-types.js.map +1 -1
- package/dist/esm/src/utils/memory-cache.js.map +1 -1
- package/dist/esm/src/utils/messages.js +2 -2
- package/dist/esm/src/utils/messages.js.map +1 -1
- package/dist/esm/src/utils/private-key-signer.js.map +1 -1
- package/dist/esm/src/utils/records.js +1 -1
- package/dist/esm/src/utils/records.js.map +1 -1
- package/dist/esm/src/utils/time.js +5 -9
- package/dist/esm/src/utils/time.js.map +1 -1
- package/dist/esm/tests/core/grant-authorization.spec.js +38 -0
- package/dist/esm/tests/core/grant-authorization.spec.js.map +1 -0
- package/dist/esm/tests/features/permissions.spec.js +1 -1
- package/dist/esm/tests/features/permissions.spec.js.map +1 -1
- package/dist/esm/tests/features/records-prune-cross-protocol.spec.js +422 -0
- package/dist/esm/tests/features/records-prune-cross-protocol.spec.js.map +1 -0
- package/dist/esm/tests/fuzz/object.fuzz.spec.js +1 -1
- package/dist/esm/tests/fuzz/object.fuzz.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-subscribe.spec.js +3 -26
- package/dist/esm/tests/handlers/messages-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-sync.spec.js +3 -26
- package/dist/esm/tests/handlers/messages-sync.spec.js.map +1 -1
- package/dist/esm/tests/handlers/protocols-query.spec.js +4 -3
- package/dist/esm/tests/handlers/protocols-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-subscribe.spec.js +2 -1
- package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/jose/jws/general.spec.js +115 -0
- package/dist/esm/tests/jose/jws/general.spec.js.map +1 -1
- package/dist/esm/tests/test-suite.js +2 -0
- package/dist/esm/tests/test-suite.js.map +1 -1
- package/dist/esm/tests/utils/poller.js +2 -2
- package/dist/esm/tests/utils/poller.js.map +1 -1
- package/dist/esm/tests/utils/test-data-generator.js +1 -1
- package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
- package/dist/types/generated/precompiled-validators.d.ts.map +1 -1
- package/dist/types/src/core/abstract-message.d.ts +4 -4
- package/dist/types/src/core/abstract-message.d.ts.map +1 -1
- package/dist/types/src/core/grant-authorization.d.ts.map +1 -1
- package/dist/types/src/core/resumable-task-manager.d.ts +2 -2
- package/dist/types/src/core/resumable-task-manager.d.ts.map +1 -1
- package/dist/types/src/dwn.d.ts +12 -12
- package/dist/types/src/dwn.d.ts.map +1 -1
- package/dist/types/src/event-stream/event-emitter-event-log.d.ts +5 -5
- package/dist/types/src/event-stream/event-emitter-event-log.d.ts.map +1 -1
- package/dist/types/src/handlers/messages-read.d.ts +1 -1
- package/dist/types/src/handlers/messages-read.d.ts.map +1 -1
- package/dist/types/src/handlers/messages-subscribe.d.ts +1 -1
- package/dist/types/src/handlers/messages-subscribe.d.ts.map +1 -1
- package/dist/types/src/handlers/messages-sync.d.ts +1 -1
- package/dist/types/src/handlers/messages-sync.d.ts.map +1 -1
- package/dist/types/src/handlers/protocols-configure.d.ts +1 -1
- package/dist/types/src/handlers/protocols-configure.d.ts.map +1 -1
- package/dist/types/src/handlers/protocols-query.d.ts +1 -1
- package/dist/types/src/handlers/protocols-query.d.ts.map +1 -1
- package/dist/types/src/handlers/records-count.d.ts +1 -1
- package/dist/types/src/handlers/records-count.d.ts.map +1 -1
- package/dist/types/src/handlers/records-delete.d.ts +1 -1
- package/dist/types/src/handlers/records-delete.d.ts.map +1 -1
- package/dist/types/src/handlers/records-query.d.ts +1 -1
- package/dist/types/src/handlers/records-query.d.ts.map +1 -1
- package/dist/types/src/handlers/records-read.d.ts +1 -1
- package/dist/types/src/handlers/records-read.d.ts.map +1 -1
- package/dist/types/src/handlers/records-subscribe.d.ts +1 -1
- package/dist/types/src/handlers/records-subscribe.d.ts.map +1 -1
- package/dist/types/src/handlers/records-write.d.ts +1 -1
- package/dist/types/src/handlers/records-write.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +5 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-write.d.ts +2 -2
- package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
- package/dist/types/src/jose/jws/general/builder.d.ts +1 -1
- package/dist/types/src/jose/jws/general/builder.d.ts.map +1 -1
- package/dist/types/src/jose/jws/general/verifier.d.ts +13 -0
- package/dist/types/src/jose/jws/general/verifier.d.ts.map +1 -1
- package/dist/types/src/smt/smt-store-level.d.ts +1 -1
- package/dist/types/src/smt/smt-store-level.d.ts.map +1 -1
- package/dist/types/src/smt/smt-store-memory.d.ts +1 -1
- package/dist/types/src/smt/smt-store-memory.d.ts.map +1 -1
- package/dist/types/src/smt/sparse-merkle-tree.d.ts +1 -1
- package/dist/types/src/smt/sparse-merkle-tree.d.ts.map +1 -1
- package/dist/types/src/state-index/state-index-level.d.ts +3 -3
- package/dist/types/src/state-index/state-index-level.d.ts.map +1 -1
- package/dist/types/src/store/index-level.d.ts +2 -2
- package/dist/types/src/store/index-level.d.ts.map +1 -1
- package/dist/types/src/store/storage-controller.d.ts +19 -5
- package/dist/types/src/store/storage-controller.d.ts.map +1 -1
- package/dist/types/src/types/permission-types.d.ts +3 -4
- package/dist/types/src/types/permission-types.d.ts.map +1 -1
- package/dist/types/src/utils/memory-cache.d.ts +2 -2
- package/dist/types/src/utils/memory-cache.d.ts.map +1 -1
- package/dist/types/src/utils/private-key-signer.d.ts +2 -2
- package/dist/types/src/utils/private-key-signer.d.ts.map +1 -1
- package/dist/types/src/utils/time.d.ts +3 -6
- package/dist/types/src/utils/time.d.ts.map +1 -1
- package/dist/types/tests/core/grant-authorization.spec.d.ts +2 -0
- package/dist/types/tests/core/grant-authorization.spec.d.ts.map +1 -0
- package/dist/types/tests/features/records-prune-cross-protocol.spec.d.ts +29 -0
- package/dist/types/tests/features/records-prune-cross-protocol.spec.d.ts.map +1 -0
- package/dist/types/tests/handlers/messages-subscribe.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/messages-sync.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/protocols-query.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-subscribe.spec.d.ts.map +1 -1
- package/dist/types/tests/test-suite.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/core/abstract-message.ts +8 -8
- package/src/core/grant-authorization.ts +9 -2
- package/src/core/message.ts +4 -4
- package/src/core/protocol-authorization-action.ts +3 -3
- package/src/core/protocol-authorization-validation.ts +9 -9
- package/src/core/protocol-authorization.ts +24 -24
- package/src/core/records-grant-authorization.ts +1 -1
- package/src/core/resumable-task-manager.ts +2 -2
- package/src/dwn.ts +34 -17
- package/src/event-stream/event-emitter-event-log.ts +15 -15
- package/src/handlers/messages-read.ts +7 -7
- package/src/handlers/messages-subscribe.ts +2 -2
- package/src/handlers/messages-sync.ts +19 -19
- package/src/handlers/protocols-configure.ts +2 -2
- package/src/handlers/protocols-query.ts +2 -2
- package/src/handlers/records-count.ts +1 -1
- package/src/handlers/records-delete.ts +1 -1
- package/src/handlers/records-query.ts +1 -1
- package/src/handlers/records-read.ts +6 -6
- package/src/handlers/records-subscribe.ts +2 -2
- package/src/handlers/records-write.ts +18 -18
- package/src/index.ts +5 -5
- package/src/interfaces/messages-subscribe.ts +1 -1
- package/src/interfaces/messages-sync.ts +1 -1
- package/src/interfaces/protocols-configure.ts +12 -12
- package/src/interfaces/protocols-query.ts +1 -1
- package/src/interfaces/records-count.ts +1 -1
- package/src/interfaces/records-delete.ts +2 -2
- package/src/interfaces/records-query.ts +1 -1
- package/src/interfaces/records-read.ts +1 -1
- package/src/interfaces/records-subscribe.ts +1 -1
- package/src/interfaces/records-write-signing.ts +1 -1
- package/src/interfaces/records-write.ts +13 -13
- package/src/jose/jws/general/builder.ts +1 -1
- package/src/jose/jws/general/verifier.ts +44 -3
- package/src/protocols/permissions.ts +1 -1
- package/src/smt/smt-store-level.ts +1 -1
- package/src/smt/smt-store-memory.ts +1 -1
- package/src/smt/sparse-merkle-tree.ts +10 -10
- package/src/state-index/state-index-level.ts +3 -3
- package/src/store/index-level-compound.ts +11 -11
- package/src/store/index-level.ts +5 -5
- package/src/store/level-wrapper.ts +1 -1
- package/src/store/storage-controller.ts +31 -16
- package/src/types/permission-types.ts +3 -4
- package/src/utils/memory-cache.ts +2 -2
- package/src/utils/messages.ts +3 -3
- package/src/utils/private-key-signer.ts +2 -2
- package/src/utils/records.ts +2 -2
- package/src/utils/time.ts +5 -10
- package/dist/esm/src/utils/object.js +0 -40
- package/dist/esm/src/utils/object.js.map +0 -1
- package/dist/esm/tests/utils/object.spec.js +0 -36
- package/dist/esm/tests/utils/object.spec.js.map +0 -1
- package/dist/types/src/utils/object.d.ts +0 -13
- package/dist/types/src/utils/object.d.ts.map +0 -1
- package/dist/types/tests/utils/object.spec.d.ts +0 -2
- package/dist/types/tests/utils/object.spec.d.ts.map +0 -1
- package/src/utils/object.ts +0 -43
|
@@ -16,10 +16,10 @@ export type ResumableRecordsSquashData = {
|
|
|
16
16
|
* A class that provides an abstraction for the usage of MessageStore, DataStore, and StateIndex.
|
|
17
17
|
*/
|
|
18
18
|
export declare class StorageController {
|
|
19
|
-
private messageStore;
|
|
20
|
-
private dataStore;
|
|
21
|
-
private stateIndex;
|
|
22
|
-
private eventLog?;
|
|
19
|
+
private readonly messageStore;
|
|
20
|
+
private readonly dataStore;
|
|
21
|
+
private readonly stateIndex;
|
|
22
|
+
private readonly eventLog?;
|
|
23
23
|
constructor({ messageStore, dataStore, stateIndex, eventLog }: {
|
|
24
24
|
messageStore: MessageStore;
|
|
25
25
|
dataStore: DataStore;
|
|
@@ -43,7 +43,21 @@ export declare class StorageController {
|
|
|
43
43
|
*/
|
|
44
44
|
private static deleteFromDataStoreIfNeeded;
|
|
45
45
|
/**
|
|
46
|
-
* Purges (permanent hard-delete) all
|
|
46
|
+
* Purges (permanent hard-delete) all descendants of the given `recordId`, recursively.
|
|
47
|
+
*
|
|
48
|
+
* The cascade is intentionally protocol-agnostic: `parentContextId` is a structural link,
|
|
49
|
+
* so pruning a parent removes every record hanging off it regardless of which protocol a
|
|
50
|
+
* descendant lives in. Cross-protocol composing children (records in a different protocol
|
|
51
|
+
* that reference the parent via `$ref` / `uses`) are included in the cascade.
|
|
52
|
+
*
|
|
53
|
+
* Rationale (closes #298 as working-as-intended):
|
|
54
|
+
* - A DWN is tenant-owned storage. The tenant's prune authority extends across the whole
|
|
55
|
+
* subtree they rooted, regardless of which protocol a descendant declares itself under.
|
|
56
|
+
* - Preserving cross-protocol orphans creates a half-alive state (readable but not
|
|
57
|
+
* updatable, since `validateReferentialIntegrity` requires the pruned parent) that is
|
|
58
|
+
* worse for callers than simply cascading.
|
|
59
|
+
* - Same-protocol cascade is already protocol-agnostic at every hop via `parentId`,
|
|
60
|
+
* so treating cross-protocol boundaries differently was inconsistent.
|
|
47
61
|
*/
|
|
48
62
|
static purgeRecordDescendants(tenant: string, recordId: string, messageStore: MessageStore, dataStore: DataStore, stateIndex: StateIndex): Promise<void>;
|
|
49
63
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-controller.d.ts","sourceRoot":"","sources":["../../../../src/store/storage-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,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AAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC;CAqCjB"}
|
|
@@ -73,13 +73,12 @@ export type ProtocolPermissionScope = {
|
|
|
73
73
|
/**
|
|
74
74
|
* Permission scope for the Messages interface.
|
|
75
75
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* functionally equivalent to `Read` — new grants SHOULD use `Read` exclusively.
|
|
76
|
+
* `Read` is the only valid method and acts as a unified scope that authorizes
|
|
77
|
+
* `MessagesRead`, `MessagesSubscribe`, and `MessagesSync` operations.
|
|
79
78
|
*/
|
|
80
79
|
export type MessagesPermissionScope = {
|
|
81
80
|
interface: DwnInterfaceName.Messages;
|
|
82
|
-
method: DwnMethodName.Read
|
|
81
|
+
method: DwnMethodName.Read;
|
|
83
82
|
protocol?: string;
|
|
84
83
|
};
|
|
85
84
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-types.d.ts","sourceRoot":"","sources":["../../../../src/types/permission-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAExF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAElC;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,eAAe,CAAC;IAEvB,UAAU,CAAC,EAAE,oBAAoB,CAAA;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;SAEK;IACL,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,KAAK,EAAE,eAAe,CAAC;IAEvB,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAElC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACnC,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,uBAAuB,GAAG,uBAAuB,GAAG,sBAAsB,CAAC;AAEzG,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,gBAAgB,CAAC,SAAS,CAAC;IACtC,MAAM,EAAE,aAAa,CAAC,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"permission-types.d.ts","sourceRoot":"","sources":["../../../../src/types/permission-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAExF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAElC;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,eAAe,CAAC;IAEvB,UAAU,CAAC,EAAE,oBAAoB,CAAA;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;SAEK;IACL,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,KAA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U,eAAe;CAC1B;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;;OAIG;IACH,WAAW,CAAC,EAAE,8BAA8B,CAAC;CAC9C,CAAC"}
|
|
@@ -3,8 +3,8 @@ import type { Cache } from '../types/cache.js';
|
|
|
3
3
|
* A cache using local memory.
|
|
4
4
|
*/
|
|
5
5
|
export declare class MemoryCache implements Cache {
|
|
6
|
-
private timeToLiveInSeconds;
|
|
7
|
-
private cache;
|
|
6
|
+
private readonly timeToLiveInSeconds;
|
|
7
|
+
private readonly cache;
|
|
8
8
|
/**
|
|
9
9
|
* @param timeToLiveInSeconds time-to-live for every key-value pair set in the cache
|
|
10
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-cache.d.ts","sourceRoot":"","sources":["../../../../src/utils/memory-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C;;GAEG;AACH,qBAAa,WAAY,YAAW,KAAK;IAMnB,OAAO,CAAC,mBAAmB;
|
|
1
|
+
{"version":3,"file":"memory-cache.d.ts","sourceRoot":"","sources":["../../../../src/utils/memory-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C;;GAEG;AACH,qBAAa,WAAY,YAAW,KAAK;IAMnB,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IALxD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwB;IAE9C;;OAEG;gBACkC,mBAAmB,EAAE,MAAM;IAO1D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC;CAGjD"}
|
|
@@ -23,8 +23,8 @@ export type PrivateKeySignerOptions = {
|
|
|
23
23
|
export declare class PrivateKeySigner implements MessageSigner {
|
|
24
24
|
keyId: string;
|
|
25
25
|
algorithm: string;
|
|
26
|
-
private privateJwk;
|
|
27
|
-
private signatureAlgorithm;
|
|
26
|
+
private readonly privateJwk;
|
|
27
|
+
private readonly signatureAlgorithm;
|
|
28
28
|
constructor(options: PrivateKeySignerOptions);
|
|
29
29
|
/**
|
|
30
30
|
* Signs the given content and returns the signature as bytes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-key-signer.d.ts","sourceRoot":"","sources":["../../../../src/utils/private-key-signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAK5D;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,UAAU,EAAE,aAAa,CAAC;IAE1B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IAC7C,KAAK,SAAC;IACN,SAAS,SAAC;IACjB,OAAO,CAAC,UAAU,CAAgB;
|
|
1
|
+
{"version":3,"file":"private-key-signer.d.ts","sourceRoot":"","sources":["../../../../src/utils/private-key-signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAK5D;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,UAAU,EAAE,aAAa,CAAC;IAE1B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IAC7C,KAAK,SAAC;IACN,SAAS,SAAC;IACjB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgB;IAC3C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC;gBAEjB,OAAO,EAAE,uBAAuB;IA8BnD;;OAEG;IACU,IAAI,CAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAI7D"}
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
* Time related utilities.
|
|
3
3
|
*/
|
|
4
4
|
export declare class Time {
|
|
5
|
-
/**
|
|
6
|
-
* sleeps for the desired duration
|
|
7
|
-
* @param durationInMillisecond the desired amount of sleep time
|
|
8
|
-
* @returns when the provided duration has passed
|
|
9
|
-
*/
|
|
10
|
-
static sleep(durationInMillisecond: number): Promise<void>;
|
|
11
5
|
/**
|
|
12
6
|
* We must sleep for at least 2ms to avoid timestamp collisions during testing.
|
|
13
7
|
* https://github.com/enboxorg/enbox/issues/481
|
|
8
|
+
*
|
|
9
|
+
* For arbitrary-duration sleeps, use `sleep` from `@enbox/common`
|
|
10
|
+
* directly — this class only retains the DWN-specific minimum.
|
|
14
11
|
*/
|
|
15
12
|
static minimalSleep(): Promise<void>;
|
|
16
13
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../../src/utils/time.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../../src/utils/time.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,qBAAa,IAAI;IACf;;;;;;OAMG;WACiB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjD;;;OAGG;WACW,mBAAmB,IAAI,MAAM;IAI3C;;;;OAIG;WACW,eAAe,CAAC,OAAO,EAAE;QACrC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KACzI,GAAG,MAAM;IAeV;;;OAGG;WACW,qBAAqB,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;IAO5F;;;;OAIG;WACW,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAOzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grant-authorization.spec.d.ts","sourceRoot":"","sources":["../../../../tests/core/grant-authorization.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression tests for cross-protocol prune cascade — closes #298.
|
|
3
|
+
*
|
|
4
|
+
* Semantics (decision under #298):
|
|
5
|
+
* A `RecordsDelete` with `prune: true` cascades to every descendant of the
|
|
6
|
+
* pruned record, regardless of which protocol a descendant declares itself
|
|
7
|
+
* under. `parentContextId` is a structural link — pruning a parent removes
|
|
8
|
+
* the entire subtree it rooted. Cross-protocol composing children (records
|
|
9
|
+
* in a different protocol that reference the parent via `$ref` / `uses`)
|
|
10
|
+
* participate in the cascade on equal footing with same-protocol children.
|
|
11
|
+
*
|
|
12
|
+
* Rationale:
|
|
13
|
+
* - A DWN is tenant-owned storage. The tenant's prune authority extends
|
|
14
|
+
* across the whole subtree they rooted, so walking the `parentId` chain
|
|
15
|
+
* unconditionally is the correct semantic.
|
|
16
|
+
* - Preserving cross-protocol orphans creates a half-alive state — readable
|
|
17
|
+
* but not updatable, since `validateReferentialIntegrity` in the
|
|
18
|
+
* `RecordsWrite` handler rejects any write whose parent is missing —
|
|
19
|
+
* which is worse for callers than cascading.
|
|
20
|
+
* - Same-protocol descendants at arbitrary depth already cascade via
|
|
21
|
+
* `parentId` with no protocol filter; treating a cross-protocol hop
|
|
22
|
+
* specially was inconsistent.
|
|
23
|
+
*
|
|
24
|
+
* These tests install multiple protocols linked via `uses` + `$ref`, write
|
|
25
|
+
* records across protocol boundaries, and assert that the entire subtree —
|
|
26
|
+
* same protocol or cross protocol, at any depth — is fully purged on prune.
|
|
27
|
+
*/
|
|
28
|
+
export declare function testRecordsPruneCrossProtocol(): void;
|
|
29
|
+
//# sourceMappingURL=records-prune-cross-protocol.spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records-prune-cross-protocol.spec.d.ts","sourceRoot":"","sources":["../../../../tests/features/records-prune-cross-protocol.spec.ts"],"names":[],"mappings":"AA8BA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,6BAA6B,IAAI,IAAI,CAyfpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages-subscribe.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/messages-subscribe.spec.ts"],"names":[],"mappings":"AAsBA,wBAAgB,4BAA4B,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"messages-subscribe.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/messages-subscribe.spec.ts"],"names":[],"mappings":"AAsBA,wBAAgB,4BAA4B,IAAI,IAAI,CAu6BnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages-sync.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/messages-sync.spec.ts"],"names":[],"mappings":"AAwBA,wBAAgB,uBAAuB,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"messages-sync.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/messages-sync.spec.ts"],"names":[],"mappings":"AAwBA,wBAAgB,uBAAuB,IAAI,IAAI,CA8zB9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocols-query.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/protocols-query.spec.ts"],"names":[],"mappings":"AAwBA,wBAAgB,yBAAyB,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"protocols-query.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/protocols-query.spec.ts"],"names":[],"mappings":"AAwBA,wBAAgB,yBAAyB,IAAI,IAAI,CA+gBhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records-subscribe.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-subscribe.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"records-subscribe.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-subscribe.spec.ts"],"names":[],"mappings":"AAyBA,wBAAgB,2BAA2B,IAAI,IAAI,CAwuClD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-suite.d.ts","sourceRoot":"","sources":["../../../tests/test-suite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"test-suite.d.ts","sourceRoot":"","sources":["../../../tests/test-suite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAwCzG;;GAEG;AACH,qBAAa,SAAS;IAEpB;;;OAGG;WACW,2BAA2B,CAAC,SAAS,CAAC,EAAE;QACpD,YAAY,CAAC,EAAE,YAAY,CAAC;QAC5B,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACpB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;KACzC,GAAG,IAAI;CA+CT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enbox/dwn-sdk-js",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "A reference implementation of https://identity.foundation/decentralized-web-node/spec/",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,8 +64,9 @@
|
|
|
64
64
|
},
|
|
65
65
|
"react-native": "./dist/esm/src/index.js",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@enbox/
|
|
68
|
-
"@enbox/
|
|
67
|
+
"@enbox/common": "0.1.1",
|
|
68
|
+
"@enbox/crypto": "0.1.1",
|
|
69
|
+
"@enbox/dids": "0.1.1",
|
|
69
70
|
"@ipld/dag-cbor": "9.0.5",
|
|
70
71
|
"@js-temporal/polyfill": "0.4.4",
|
|
71
72
|
"@noble/ciphers": "0.5.3",
|
|
@@ -8,22 +8,22 @@ import { Message } from './message.js';
|
|
|
8
8
|
* An abstract implementation of the `MessageInterface` interface.
|
|
9
9
|
*/
|
|
10
10
|
export abstract class AbstractMessage<M extends GenericMessage> implements MessageInterface<M> {
|
|
11
|
-
private _message: M;
|
|
11
|
+
private readonly _message: M;
|
|
12
12
|
public get message(): M {
|
|
13
|
-
return this._message
|
|
13
|
+
return this._message;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
private _signer: string | undefined;
|
|
16
|
+
private readonly _signer: string | undefined;
|
|
17
17
|
public get signer(): string | undefined {
|
|
18
18
|
return this._signer;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
private _author: string | undefined;
|
|
21
|
+
private readonly _author: string | undefined;
|
|
22
22
|
public get author(): string | undefined {
|
|
23
23
|
return this._author;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
private _signaturePayload: GenericSignaturePayload | undefined;
|
|
26
|
+
private readonly _signaturePayload: GenericSignaturePayload | undefined;
|
|
27
27
|
public get signaturePayload(): GenericSignaturePayload | undefined {
|
|
28
28
|
return this._signaturePayload;
|
|
29
29
|
}
|
|
@@ -43,10 +43,10 @@ export abstract class AbstractMessage<M extends GenericMessage> implements Messa
|
|
|
43
43
|
|
|
44
44
|
// if the message authorization contains author delegated grant, the author would be the grantor of the grant
|
|
45
45
|
// else the author would be the signer of the message
|
|
46
|
-
if (message.authorization.authorDelegatedGrant
|
|
47
|
-
this._author = Message.getSigner(message.authorization.authorDelegatedGrant);
|
|
48
|
-
} else {
|
|
46
|
+
if (message.authorization.authorDelegatedGrant === undefined) {
|
|
49
47
|
this._author = this._signer;
|
|
48
|
+
} else {
|
|
49
|
+
this._author = Message.getSigner(message.authorization.authorDelegatedGrant);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
this._signaturePayload = Jws.decodePlainObjectPayload(message.authorization.signature);
|
|
@@ -146,8 +146,15 @@ export class GrantAuthorization {
|
|
|
146
146
|
);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
//
|
|
150
|
-
|
|
149
|
+
// Messages.Read is the only valid Messages scope and covers Read, Subscribe, and Sync operations.
|
|
150
|
+
// Reject any Messages grant with method !== Read (malformed or legacy stored data).
|
|
151
|
+
if (dwnInterface === DwnInterfaceName.Messages) {
|
|
152
|
+
if (permissionGrant.scope.method !== DwnMethodName.Read) {
|
|
153
|
+
throw new DwnError(
|
|
154
|
+
DwnErrorCode.GrantAuthorizationMethodMismatch,
|
|
155
|
+
`messages permission grant must have method 'Read', got '${permissionGrant.scope.method}' for grant ${permissionGrant.id}`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
151
158
|
const allowedMethods = [DwnMethodName.Read, DwnMethodName.Subscribe, DwnMethodName.Sync];
|
|
152
159
|
if (!allowedMethods.includes(dwnMethod as DwnMethodName)) {
|
|
153
160
|
throw new DwnError(
|
package/src/core/message.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { Encoder } from '../utils/encoder.js';
|
|
|
8
8
|
import { GeneralJwsBuilder } from '../jose/jws/general/builder.js';
|
|
9
9
|
import { Jws } from '../utils/jws.js';
|
|
10
10
|
import { lexicographicalCompare } from '../utils/string.js';
|
|
11
|
-
import { removeUndefinedProperties } from '
|
|
11
|
+
import { removeUndefinedProperties } from '@enbox/common';
|
|
12
12
|
import { validateJsonSchema } from '../schema-validator.js';
|
|
13
13
|
import { DwnError, DwnErrorCode } from './dwn-error.js';
|
|
14
14
|
|
|
@@ -26,10 +26,10 @@ export class Message {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
let author;
|
|
29
|
-
if (message.authorization.authorDelegatedGrant
|
|
30
|
-
author = Message.getSigner(message.authorization.authorDelegatedGrant);
|
|
31
|
-
} else {
|
|
29
|
+
if (message.authorization.authorDelegatedGrant === undefined) {
|
|
32
30
|
author = Message.getSigner(message);
|
|
31
|
+
} else {
|
|
32
|
+
author = Message.getSigner(message.authorization.authorDelegatedGrant);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return author;
|
|
@@ -53,7 +53,7 @@ export async function verifyInvokedRole(
|
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
if (protocolDefinition.uses
|
|
56
|
+
if (protocolDefinition.uses?.[parsed.alias] === undefined) {
|
|
57
57
|
throw new DwnError(
|
|
58
58
|
DwnErrorCode.ProtocolAuthorizationNotARole,
|
|
59
59
|
`Cross-protocol role alias '${parsed.alias}' in '${protocolRole}' does not exist in the protocol's 'uses' map.`
|
|
@@ -68,7 +68,7 @@ export async function verifyInvokedRole(
|
|
|
68
68
|
tenant, roleProtocolUri, messageStore, governingTimestamp
|
|
69
69
|
);
|
|
70
70
|
const roleRuleSet = getRuleSetAtPath(roleProtocolPath, refDefinition.structure);
|
|
71
|
-
if (
|
|
71
|
+
if (!roleRuleSet?.$role) {
|
|
72
72
|
throw new DwnError(
|
|
73
73
|
DwnErrorCode.ProtocolAuthorizationNotARole,
|
|
74
74
|
`Cross-protocol role path ${protocolRole} does not match role record type.`
|
|
@@ -77,7 +77,7 @@ export async function verifyInvokedRole(
|
|
|
77
77
|
} else {
|
|
78
78
|
// Local role: validate in the composing protocol's definition
|
|
79
79
|
const roleRuleSet = getRuleSetAtPath(protocolRole, protocolDefinition.structure);
|
|
80
|
-
if (
|
|
80
|
+
if (!roleRuleSet?.$role) {
|
|
81
81
|
throw new DwnError(
|
|
82
82
|
DwnErrorCode.ProtocolAuthorizationNotARole,
|
|
83
83
|
`Protocol path ${protocolRole} does not match role record type.`
|
|
@@ -28,7 +28,7 @@ export async function verifyProtocolPathAndContextId(
|
|
|
28
28
|
fetchProtocolDefinition: FetchProtocolDefinitionFn,
|
|
29
29
|
governingTimestamp?: string,
|
|
30
30
|
): Promise<void> {
|
|
31
|
-
const declaredProtocolPath = inboundMessage.message.descriptor.protocolPath
|
|
31
|
+
const declaredProtocolPath = inboundMessage.message.descriptor.protocolPath;
|
|
32
32
|
const declaredTypeName = getTypeName(declaredProtocolPath);
|
|
33
33
|
|
|
34
34
|
const parentId = inboundMessage.message.descriptor.parentId;
|
|
@@ -47,7 +47,7 @@ export async function verifyProtocolPathAndContextId(
|
|
|
47
47
|
|
|
48
48
|
// Determine the protocol URI for the parent query.
|
|
49
49
|
// If the parent path segment has a `$ref` in the composing protocol, the parent lives in a different protocol.
|
|
50
|
-
const childProtocol = inboundMessage.message.descriptor.protocol
|
|
50
|
+
const childProtocol = inboundMessage.message.descriptor.protocol;
|
|
51
51
|
const parentProtocolUri = await resolveParentProtocolUri(
|
|
52
52
|
tenant, childProtocol, declaredProtocolPath, messageStore, fetchProtocolDefinition, governingTimestamp
|
|
53
53
|
);
|
|
@@ -174,7 +174,7 @@ export async function verifyTypeWithComposition(
|
|
|
174
174
|
fetchProtocolDefinition: FetchProtocolDefinitionFn,
|
|
175
175
|
governingTimestamp?: string,
|
|
176
176
|
): Promise<void> {
|
|
177
|
-
const declaredProtocolPath = inboundMessage.descriptor.protocolPath
|
|
177
|
+
const declaredProtocolPath = inboundMessage.descriptor.protocolPath;
|
|
178
178
|
const declaredTypeName = getTypeName(declaredProtocolPath);
|
|
179
179
|
|
|
180
180
|
// Resolve which protocol types map to use.
|
|
@@ -231,7 +231,7 @@ export function verifyType(
|
|
|
231
231
|
protocolTypes: ProtocolTypes,
|
|
232
232
|
typeName?: string,
|
|
233
233
|
): void {
|
|
234
|
-
const declaredTypeName = typeName ?? getTypeName(inboundMessage.descriptor.protocolPath
|
|
234
|
+
const declaredTypeName = typeName ?? getTypeName(inboundMessage.descriptor.protocolPath);
|
|
235
235
|
const typeNames = Object.keys(protocolTypes);
|
|
236
236
|
|
|
237
237
|
if (!typeNames.includes(declaredTypeName)) {
|
|
@@ -361,12 +361,12 @@ export async function verifyAsRoleRecordIfNeeded(
|
|
|
361
361
|
);
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
const protocolPath = incomingRecordsWrite.message.descriptor.protocolPath
|
|
364
|
+
const protocolPath = incomingRecordsWrite.message.descriptor.protocolPath;
|
|
365
365
|
const filter: Filter = {
|
|
366
366
|
interface : DwnInterfaceName.Records,
|
|
367
367
|
method : DwnMethodName.Write,
|
|
368
368
|
isLatestBaseState : true,
|
|
369
|
-
protocol : incomingRecordsWrite.message.descriptor.protocol
|
|
369
|
+
protocol : incomingRecordsWrite.message.descriptor.protocol,
|
|
370
370
|
protocolPath,
|
|
371
371
|
recipient,
|
|
372
372
|
};
|
|
@@ -422,12 +422,12 @@ export async function verifyRecordLimit(
|
|
|
422
422
|
const { max, strategy } = ruleSet.$recordLimit;
|
|
423
423
|
|
|
424
424
|
// Build a filter to count existing records at the same protocol path and parent context.
|
|
425
|
-
const protocolPath = incomingMessage.message.descriptor.protocolPath
|
|
425
|
+
const protocolPath = incomingMessage.message.descriptor.protocolPath;
|
|
426
426
|
const filter: Filter = {
|
|
427
427
|
interface : DwnInterfaceName.Records,
|
|
428
428
|
method : DwnMethodName.Write,
|
|
429
429
|
isLatestBaseState : true,
|
|
430
|
-
protocol : incomingMessage.message.descriptor.protocol
|
|
430
|
+
protocol : incomingMessage.message.descriptor.protocol,
|
|
431
431
|
protocolPath,
|
|
432
432
|
};
|
|
433
433
|
|
|
@@ -445,7 +445,7 @@ export async function verifyRecordLimit(
|
|
|
445
445
|
throw new DwnError(
|
|
446
446
|
DwnErrorCode.ProtocolAuthorizationRecordLimitExceeded,
|
|
447
447
|
`record limit of ${max} reached at protocol path '${protocolPath}'` +
|
|
448
|
-
`${parentContextId
|
|
448
|
+
`${parentContextId === '' ? '' : ` under parent context '${parentContextId}'`}` +
|
|
449
449
|
`: new records are rejected until existing records are deleted.`
|
|
450
450
|
);
|
|
451
451
|
}
|
|
@@ -61,7 +61,7 @@ export class ProtocolAuthorization {
|
|
|
61
61
|
// fetch the protocol definition that was active at the governing timestamp
|
|
62
62
|
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(
|
|
63
63
|
tenant,
|
|
64
|
-
incomingMessage.message.descriptor.protocol
|
|
64
|
+
incomingMessage.message.descriptor.protocol,
|
|
65
65
|
messageStore,
|
|
66
66
|
governingTimestamp,
|
|
67
67
|
coreProtocols,
|
|
@@ -85,7 +85,7 @@ export class ProtocolAuthorization {
|
|
|
85
85
|
|
|
86
86
|
// get the rule set for the inbound message
|
|
87
87
|
const ruleSet = ProtocolAuthorization.getRuleSet(
|
|
88
|
-
incomingMessage.message.descriptor.protocolPath
|
|
88
|
+
incomingMessage.message.descriptor.protocolPath,
|
|
89
89
|
protocolDefinition,
|
|
90
90
|
);
|
|
91
91
|
|
|
@@ -143,7 +143,7 @@ export class ProtocolAuthorization {
|
|
|
143
143
|
// fetch the protocol definition that was active at the governing timestamp
|
|
144
144
|
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(
|
|
145
145
|
tenant,
|
|
146
|
-
incomingMessage.message.descriptor.protocol
|
|
146
|
+
incomingMessage.message.descriptor.protocol,
|
|
147
147
|
messageStore,
|
|
148
148
|
governingTimestamp,
|
|
149
149
|
coreProtocols,
|
|
@@ -151,7 +151,7 @@ export class ProtocolAuthorization {
|
|
|
151
151
|
|
|
152
152
|
// get the rule set for the inbound message
|
|
153
153
|
const ruleSet = ProtocolAuthorization.getRuleSet(
|
|
154
|
-
incomingMessage.message.descriptor.protocolPath
|
|
154
|
+
incomingMessage.message.descriptor.protocolPath,
|
|
155
155
|
protocolDefinition,
|
|
156
156
|
);
|
|
157
157
|
|
|
@@ -161,8 +161,8 @@ export class ProtocolAuthorization {
|
|
|
161
161
|
await verifyInvokedRole(
|
|
162
162
|
tenant,
|
|
163
163
|
incomingMessage,
|
|
164
|
-
incomingMessage.message.descriptor.protocol
|
|
165
|
-
incomingMessage.message.contextId
|
|
164
|
+
incomingMessage.message.descriptor.protocol,
|
|
165
|
+
incomingMessage.message.contextId,
|
|
166
166
|
protocolDefinition,
|
|
167
167
|
messageStore,
|
|
168
168
|
boundFetchDefinition,
|
|
@@ -201,14 +201,14 @@ export class ProtocolAuthorization {
|
|
|
201
201
|
const initialWrite = await fetchInitialWrite(
|
|
202
202
|
tenant, newestRecordsWrite.message.recordId, messageStore
|
|
203
203
|
);
|
|
204
|
-
const governingTimestamp = initialWrite
|
|
205
|
-
?
|
|
206
|
-
:
|
|
204
|
+
const governingTimestamp = initialWrite === undefined
|
|
205
|
+
? newestRecordsWrite.message.descriptor.messageTimestamp
|
|
206
|
+
: initialWrite.descriptor.messageTimestamp;
|
|
207
207
|
|
|
208
208
|
// fetch the protocol definition that was active when the record was created
|
|
209
209
|
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(
|
|
210
210
|
tenant,
|
|
211
|
-
newestRecordsWrite.message.descriptor.protocol
|
|
211
|
+
newestRecordsWrite.message.descriptor.protocol,
|
|
212
212
|
messageStore,
|
|
213
213
|
governingTimestamp,
|
|
214
214
|
coreProtocols,
|
|
@@ -216,7 +216,7 @@ export class ProtocolAuthorization {
|
|
|
216
216
|
|
|
217
217
|
// get the rule set for the inbound message
|
|
218
218
|
const ruleSet = ProtocolAuthorization.getRuleSet(
|
|
219
|
-
newestRecordsWrite.message.descriptor.protocolPath
|
|
219
|
+
newestRecordsWrite.message.descriptor.protocolPath,
|
|
220
220
|
protocolDefinition,
|
|
221
221
|
);
|
|
222
222
|
|
|
@@ -226,8 +226,8 @@ export class ProtocolAuthorization {
|
|
|
226
226
|
await verifyInvokedRole(
|
|
227
227
|
tenant,
|
|
228
228
|
incomingMessage,
|
|
229
|
-
newestRecordsWrite.message.descriptor.protocol
|
|
230
|
-
newestRecordsWrite.message.contextId
|
|
229
|
+
newestRecordsWrite.message.descriptor.protocol,
|
|
230
|
+
newestRecordsWrite.message.contextId,
|
|
231
231
|
protocolDefinition,
|
|
232
232
|
messageStore,
|
|
233
233
|
boundFetchDefinition,
|
|
@@ -312,14 +312,14 @@ export class ProtocolAuthorization {
|
|
|
312
312
|
const initialWrite = await fetchInitialWrite(
|
|
313
313
|
tenant, incomingMessage.message.descriptor.recordId, messageStore
|
|
314
314
|
);
|
|
315
|
-
const governingTimestamp = initialWrite
|
|
316
|
-
?
|
|
317
|
-
:
|
|
315
|
+
const governingTimestamp = initialWrite === undefined
|
|
316
|
+
? recordsWrite.message.descriptor.messageTimestamp
|
|
317
|
+
: initialWrite.descriptor.messageTimestamp;
|
|
318
318
|
|
|
319
319
|
// fetch the protocol definition that was active when the record was created
|
|
320
320
|
const protocolDefinition = await ProtocolAuthorization.fetchProtocolDefinition(
|
|
321
321
|
tenant,
|
|
322
|
-
recordsWrite.message.descriptor.protocol
|
|
322
|
+
recordsWrite.message.descriptor.protocol,
|
|
323
323
|
messageStore,
|
|
324
324
|
governingTimestamp,
|
|
325
325
|
coreProtocols,
|
|
@@ -327,7 +327,7 @@ export class ProtocolAuthorization {
|
|
|
327
327
|
|
|
328
328
|
// get the rule set for the inbound message
|
|
329
329
|
const ruleSet = ProtocolAuthorization.getRuleSet(
|
|
330
|
-
recordsWrite.message.descriptor.protocolPath
|
|
330
|
+
recordsWrite.message.descriptor.protocolPath,
|
|
331
331
|
protocolDefinition,
|
|
332
332
|
);
|
|
333
333
|
|
|
@@ -337,8 +337,8 @@ export class ProtocolAuthorization {
|
|
|
337
337
|
await verifyInvokedRole(
|
|
338
338
|
tenant,
|
|
339
339
|
incomingMessage,
|
|
340
|
-
recordsWrite.message.descriptor.protocol
|
|
341
|
-
recordsWrite.message.contextId
|
|
340
|
+
recordsWrite.message.descriptor.protocol,
|
|
341
|
+
recordsWrite.message.contextId,
|
|
342
342
|
protocolDefinition,
|
|
343
343
|
messageStore,
|
|
344
344
|
boundFetchDefinition,
|
|
@@ -389,12 +389,12 @@ export class ProtocolAuthorization {
|
|
|
389
389
|
protocol : protocolUri,
|
|
390
390
|
};
|
|
391
391
|
|
|
392
|
-
if (messageTimestamp
|
|
393
|
-
// temporal lookup: find the protocol definition active at the given timestamp
|
|
394
|
-
query.messageTimestamp = { lte: messageTimestamp };
|
|
395
|
-
} else {
|
|
392
|
+
if (messageTimestamp === undefined) {
|
|
396
393
|
// default: return only the latest protocol definition
|
|
397
394
|
query.isLatestBaseState = true;
|
|
395
|
+
} else {
|
|
396
|
+
// temporal lookup: find the protocol definition active at the given timestamp
|
|
397
|
+
query.messageTimestamp = { lte: messageTimestamp };
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
const { messages: protocols } = await messageStore.query(
|
|
@@ -153,7 +153,7 @@ export class RecordsGrantAuthorization {
|
|
|
153
153
|
|
|
154
154
|
// If grant specifies a contextId, check that record falls under that contextId
|
|
155
155
|
if (grantScope.contextId !== undefined) {
|
|
156
|
-
if (
|
|
156
|
+
if (!recordsWriteMessage.contextId?.startsWith(grantScope.contextId)) {
|
|
157
157
|
throw new DwnError(
|
|
158
158
|
DwnErrorCode.RecordsGrantAuthorizationScopeContextIdMismatch,
|
|
159
159
|
`Grant scope specifies different contextId than what appears in the record`
|
|
@@ -20,9 +20,9 @@ export class ResumableTaskManager {
|
|
|
20
20
|
public static readonly timeoutExtensionFrequencyInSeconds = 30;
|
|
21
21
|
|
|
22
22
|
private resumableTaskBatchSize = 100;
|
|
23
|
-
private resumableTaskHandlers: { [key:string]: (taskData: any) => Promise<void> };
|
|
23
|
+
private readonly resumableTaskHandlers: { [key:string]: (taskData: any) => Promise<void> };
|
|
24
24
|
|
|
25
|
-
public constructor(private resumableTaskStore: ResumableTaskStore, storageController: StorageController) {
|
|
25
|
+
public constructor(private readonly resumableTaskStore: ResumableTaskStore, storageController: StorageController) {
|
|
26
26
|
// assign resumable task handlers
|
|
27
27
|
this.resumableTaskHandlers = {
|
|
28
28
|
// NOTE: The arrow function is IMPORTANT here, else the `this` context will be lost within the invoked method.
|