@brightchain/brightchain-api-lib 0.23.0 → 0.23.2
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/package.json +3 -3
- package/src/lib/controllers/api/quorum.d.ts.map +1 -1
- package/src/lib/controllers/api/quorum.js +24 -10
- package/src/lib/controllers/api/quorum.js.map +1 -1
- package/src/lib/plugins/brightchain-database-plugin.d.ts +11 -1
- package/src/lib/plugins/brightchain-database-plugin.d.ts.map +1 -1
- package/src/lib/plugins/brightchain-database-plugin.js +35 -6
- package/src/lib/plugins/brightchain-database-plugin.js.map +1 -1
- package/src/lib/services/brightchain-member-init.service.d.ts +3 -0
- package/src/lib/services/brightchain-member-init.service.d.ts.map +1 -1
- package/src/lib/services/brightchain-member-init.service.js +5 -3
- package/src/lib/services/brightchain-member-init.service.js.map +1 -1
- package/src/lib/services/brightpass.js.map +1 -1
- package/src/lib/services/rbac-input-builder.d.ts +5 -0
- package/src/lib/services/rbac-input-builder.d.ts.map +1 -1
- package/src/lib/services/rbac-input-builder.js +26 -4
- package/src/lib/services/rbac-input-builder.js.map +1 -1
- package/src/lib/stores/availabilityAwareBlockStore.d.ts.map +1 -1
- package/src/lib/stores/availabilityAwareBlockStore.js.map +1 -1
- package/src/lib/stores/diskBlockMetadataStore.d.ts.map +1 -1
- package/src/lib/stores/diskBlockMetadataStore.js +3 -3
- package/src/lib/stores/diskBlockMetadataStore.js.map +1 -1
- package/src/lib/stores/diskMessageMetadataStore.d.ts.map +1 -1
- package/src/lib/stores/diskMessageMetadataStore.js.map +1 -1
- package/src/lib/utils/serialization.d.ts +6 -3
- package/src/lib/utils/serialization.d.ts.map +1 -1
- package/src/lib/utils/serialization.js +28 -5
- package/src/lib/utils/serialization.js.map +1 -1
|
@@ -3,18 +3,32 @@
|
|
|
3
3
|
* @fileoverview Serialization utility for converting typed RBAC documents
|
|
4
4
|
* to their stored (all-string) representation for BrightChainDb.
|
|
5
5
|
*
|
|
6
|
-
* Converts
|
|
6
|
+
* Converts GUID values (GuidV4Buffer / GuidUint8Array) to short hex strings,
|
|
7
|
+
* BSON ObjectId values to hex strings, Date values to ISO strings, and plain
|
|
8
|
+
* Buffers to hex strings.
|
|
7
9
|
* This is the inverse of the rehydration functions in ./rehydration.ts.
|
|
8
10
|
*/
|
|
9
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
12
|
exports.serializeForStorage = serializeForStorage;
|
|
13
|
+
/**
|
|
14
|
+
* Type guard: does this value have an `asShortHexGuid` string property?
|
|
15
|
+
* Matches both GuidV4Buffer (Buffer subclass, node-ecies-lib) and
|
|
16
|
+
* GuidUint8Array (Uint8Array subclass, ecies-lib browser build).
|
|
17
|
+
*/
|
|
18
|
+
function hasShortHexGuid(value) {
|
|
19
|
+
return (value !== null &&
|
|
20
|
+
typeof value === 'object' &&
|
|
21
|
+
'asShortHexGuid' in value &&
|
|
22
|
+
typeof value['asShortHexGuid'] === 'string');
|
|
23
|
+
}
|
|
11
24
|
/**
|
|
12
25
|
* Serialize a typed document for storage.
|
|
13
26
|
*
|
|
14
27
|
* Converts:
|
|
15
28
|
* - Date → ISO-8601 string
|
|
16
|
-
* - GuidV4Buffer →
|
|
17
|
-
* - Buffer → hex string
|
|
29
|
+
* - GuidV4Buffer / GuidUint8Array (has asShortHexGuid) → 32-char short hex GUID string
|
|
30
|
+
* - Plain Buffer → hex string
|
|
31
|
+
* - Object with toHexString() (e.g. BSON ObjectId) → hex string via toHexString()
|
|
18
32
|
* - Everything else passes through unchanged
|
|
19
33
|
*
|
|
20
34
|
* @template T - The input typed document
|
|
@@ -26,12 +40,21 @@ function serializeForStorage(doc) {
|
|
|
26
40
|
if (value instanceof Date) {
|
|
27
41
|
result[key] = value.toISOString();
|
|
28
42
|
}
|
|
29
|
-
else if (
|
|
30
|
-
|
|
43
|
+
else if (hasShortHexGuid(value)) {
|
|
44
|
+
// GuidV4Buffer (Buffer subclass) or GuidUint8Array (Uint8Array subclass)
|
|
45
|
+
// — use the 32-char no-dashes hex form the schema expects
|
|
46
|
+
result[key] = value.asShortHexGuid;
|
|
31
47
|
}
|
|
32
48
|
else if (Buffer.isBuffer(value)) {
|
|
49
|
+
// Plain Buffer (no GUID properties)
|
|
33
50
|
result[key] = value.toString('hex');
|
|
34
51
|
}
|
|
52
|
+
else if (value !== null &&
|
|
53
|
+
typeof value === 'object' &&
|
|
54
|
+
typeof value['toHexString'] === 'function') {
|
|
55
|
+
// BSON ObjectId (and any other ID type with toHexString())
|
|
56
|
+
result[key] = value.toHexString();
|
|
57
|
+
}
|
|
35
58
|
else {
|
|
36
59
|
result[key] = value;
|
|
37
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/utils/serialization.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/utils/serialization.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AA6BH,kDA2BC;AAtDD;;;;GAIG;AACH,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,CACL,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,gBAAgB,IAAI,KAAK;QACzB,OAAQ,KAAiC,CAAC,gBAAgB,CAAC,KAAK,QAAQ,CACzE,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,mBAAmB,CAGjC,GAAM;IACN,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;YAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QACpC,CAAC;aAAM,IAAI,eAAe,CAAC,KAAK,CAAC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