@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.
@@ -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;IA+N7C;;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
+ {"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":"AAiBA,wBAAgB,sBAAsB,IAAI,IAAI,CAknB7C"}
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,CA6gJ9C"}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enbox/dwn-sdk-js",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "A reference implementation of https://identity.foundation/decentralized-web-node/spec/",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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 immediately.
62
- // This prevents duplicate delivery races from re-processing large data
63
- // streams and hitting unique constraints in SQL-backed data stores.
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;