@enbox/dwn-sdk-js 0.3.8 → 0.3.9
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 +2 -2
- package/dist/browser.mjs.map +3 -3
- package/dist/esm/src/handlers/records-write.js +18 -12
- package/dist/esm/src/handlers/records-write.js.map +1 -1
- package/dist/esm/tests/features/records-record-limit.spec.js +14 -0
- package/dist/esm/tests/features/records-record-limit.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-write.spec.js +41 -0
- package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
- package/dist/types/src/handlers/records-write.d.ts.map +1 -1
- package/dist/types/tests/features/records-record-limit.spec.d.ts.map +1 -1
- package/dist/types/tests/handlers/records-write.spec.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/handlers/records-write.ts +18 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records-write.d.ts","sourceRoot":"","sources":["../../../../src/handlers/records-write.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAqB7F,KAAK,WAAW,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAC;IAAC,UAAU,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;CAAC,CAAC;AAE5G,qBAAa,mBAAoB,YAAW,aAAa;IAE3C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,mBAAmB;IAEzC,MAAM,CAAC,EAClB,MAAM,EACN,OAAO,EACP,UAAU,EACX,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"records-write.d.ts","sourceRoot":"","sources":["../../../../src/handlers/records-write.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAqB7F,KAAK,WAAW,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAC;IAAC,UAAU,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;CAAC,CAAC;AAE5G,qBAAa,mBAAoB,YAAW,aAAa;IAE3C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,mBAAmB;IAEzC,MAAM,CAAC,EAClB,MAAM,EACN,OAAO,EACP,UAAU,EACX,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAoO7C;;OAEG;IACU,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,UAAU,GAAE,OAAO,CAAC,sBAAsB,CAAC;YAM1G,4BAA4B;YA8C5B,6BAA6B;YA2B7B,+BAA+B;IAyC7C;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAqBpC;;;;;;OAMG;YACW,qBAAqB;YA4ErB,qBAAqB;CAsCpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records-record-limit.spec.d.ts","sourceRoot":"","sources":["../../../../tests/features/records-record-limit.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"records-record-limit.spec.d.ts","sourceRoot":"","sources":["../../../../tests/features/records-record-limit.spec.ts"],"names":[],"mappings":"AAkBA,wBAAgB,sBAAsB,IAAI,IAAI,CAioB7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records-write.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-write.spec.ts"],"names":[],"mappings":"AAmDA,wBAAgB,uBAAuB,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"records-write.spec.d.ts","sourceRoot":"","sources":["../../../../tests/handlers/records-write.spec.ts"],"names":[],"mappings":"AAmDA,wBAAgB,uBAAuB,IAAI,IAAI,CA4jJ9C"}
|
package/package.json
CHANGED
|
@@ -37,20 +37,10 @@ export class RecordsWriteHandler implements MethodHandler {
|
|
|
37
37
|
let recordsWrite: RecordsWrite;
|
|
38
38
|
try {
|
|
39
39
|
recordsWrite = await RecordsWrite.parse(message);
|
|
40
|
-
|
|
41
|
-
await ProtocolAuthorization.validateReferentialIntegrity(tenant, recordsWrite, this.deps.messageStore, this.deps.coreProtocols);
|
|
42
40
|
} catch (e) {
|
|
43
41
|
return messageReplyFromError(e, 400);
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
// authentication & authorization
|
|
47
|
-
try {
|
|
48
|
-
await authenticate(message.authorization, this.deps.didResolver, message.attestation);
|
|
49
|
-
await this.authorizeRecordsWrite(tenant, recordsWrite, this.deps.messageStore);
|
|
50
|
-
} catch (e) {
|
|
51
|
-
return messageReplyFromError(e, 401);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
44
|
// get existing messages matching the `recordId`
|
|
55
45
|
const query = {
|
|
56
46
|
interface : DwnInterfaceName.Records,
|
|
@@ -58,9 +48,10 @@ export class RecordsWriteHandler implements MethodHandler {
|
|
|
58
48
|
};
|
|
59
49
|
const { messages: existingMessages } = await this.deps.messageStore.query(tenant, [ query ]);
|
|
60
50
|
|
|
61
|
-
// If the exact same message already exists, return 409
|
|
62
|
-
//
|
|
63
|
-
//
|
|
51
|
+
// If the exact same message already exists, return 409 before re-running
|
|
52
|
+
// mutable validation. An already-stored message has already passed
|
|
53
|
+
// admission; replay should not be reinterpreted against current protocol,
|
|
54
|
+
// parent, role, grant, or record-limit state.
|
|
64
55
|
//
|
|
65
56
|
// Exception: an initial write may have been stored earlier without data
|
|
66
57
|
// (204). A later delivery of the same message with data must be allowed
|
|
@@ -83,6 +74,20 @@ export class RecordsWriteHandler implements MethodHandler {
|
|
|
83
74
|
}
|
|
84
75
|
}
|
|
85
76
|
|
|
77
|
+
try {
|
|
78
|
+
await ProtocolAuthorization.validateReferentialIntegrity(tenant, recordsWrite, this.deps.messageStore, this.deps.coreProtocols);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
return messageReplyFromError(e, 400);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// authentication & authorization
|
|
84
|
+
try {
|
|
85
|
+
await authenticate(message.authorization, this.deps.didResolver, message.attestation);
|
|
86
|
+
await this.authorizeRecordsWrite(tenant, recordsWrite, this.deps.messageStore);
|
|
87
|
+
} catch (e) {
|
|
88
|
+
return messageReplyFromError(e, 401);
|
|
89
|
+
}
|
|
90
|
+
|
|
86
91
|
// if the incoming write is not the initial write, then it must not modify any immutable properties defined by the initial write
|
|
87
92
|
const newMessageIsInitialWrite = await recordsWrite.isInitialWrite();
|
|
88
93
|
let initialWrite: RecordsWriteMessage | undefined;
|