@brightchain/brightchain-api-lib 0.22.0 → 0.23.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/package.json +5 -5
- package/src/lib/application.d.ts.map +1 -1
- package/src/lib/application.js +1 -1
- package/src/lib/application.js.map +1 -1
- package/src/lib/availability/availabilityService.d.ts +10 -9
- package/src/lib/availability/availabilityService.d.ts.map +1 -1
- package/src/lib/availability/availabilityService.js +1 -1
- package/src/lib/availability/availabilityService.js.map +1 -1
- package/src/lib/availability/blockRegistry.d.ts +5 -4
- package/src/lib/availability/blockRegistry.d.ts.map +1 -1
- package/src/lib/availability/blockRegistry.js +3 -2
- package/src/lib/availability/blockRegistry.js.map +1 -1
- package/src/lib/availability/discoveryProtocol.d.ts +6 -5
- package/src/lib/availability/discoveryProtocol.d.ts.map +1 -1
- package/src/lib/availability/discoveryProtocol.js.map +1 -1
- package/src/lib/availability/gossipService.d.ts +5 -4
- package/src/lib/availability/gossipService.d.ts.map +1 -1
- package/src/lib/availability/gossipService.js +1 -1
- package/src/lib/availability/gossipService.js.map +1 -1
- package/src/lib/availability/quorumGossipHandler.d.ts.map +1 -1
- package/src/lib/availability/quorumGossipHandler.js.map +1 -1
- package/src/lib/availability/reconciliationService.d.ts +8 -7
- package/src/lib/availability/reconciliationService.d.ts.map +1 -1
- package/src/lib/availability/reconciliationService.js.map +1 -1
- package/src/lib/blockFetch/blockFetcher.d.ts.map +1 -1
- package/src/lib/blockFetch/blockFetcher.js.map +1 -1
- package/src/lib/controllers/api/blocks.d.ts.map +1 -1
- package/src/lib/controllers/api/blocks.js +14 -8
- package/src/lib/controllers/api/blocks.js.map +1 -1
- package/src/lib/controllers/api/explodingMessages.js +1 -1
- package/src/lib/controllers/api/explodingMessages.js.map +1 -1
- package/src/lib/controllers/api/members.d.ts.map +1 -1
- package/src/lib/controllers/api/members.js +27 -18
- package/src/lib/controllers/api/members.js.map +1 -1
- package/src/lib/controllers/api/nodes.d.ts.map +1 -1
- package/src/lib/controllers/api/nodes.js.map +1 -1
- package/src/lib/controllers/api/quorum.d.ts +4 -2
- package/src/lib/controllers/api/quorum.d.ts.map +1 -1
- package/src/lib/controllers/api/quorum.js +30 -10
- package/src/lib/controllers/api/quorum.js.map +1 -1
- package/src/lib/controllers/api/sync.d.ts.map +1 -1
- package/src/lib/controllers/api/sync.js +9 -6
- package/src/lib/controllers/api/sync.js.map +1 -1
- package/src/lib/datastore/block-document-store.d.ts +22 -15
- package/src/lib/datastore/block-document-store.d.ts.map +1 -1
- package/src/lib/datastore/block-document-store.js +34 -9
- package/src/lib/datastore/block-document-store.js.map +1 -1
- package/src/lib/datastore/memory-document-store.d.ts +3 -0
- package/src/lib/datastore/memory-document-store.d.ts.map +1 -1
- package/src/lib/datastore/memory-document-store.js +27 -8
- package/src/lib/datastore/memory-document-store.js.map +1 -1
- package/src/lib/interfaces/blockResponses.d.ts +8 -8
- package/src/lib/interfaces/blockResponses.d.ts.map +1 -1
- package/src/lib/interfaces/blockService.d.ts +6 -6
- package/src/lib/interfaces/blockService.d.ts.map +1 -1
- package/src/lib/interfaces/member/memberProfileResponse.d.ts +18 -26
- package/src/lib/interfaces/member/memberProfileResponse.d.ts.map +1 -1
- package/src/lib/interfaces/responses/block-data-response.d.ts +2 -1
- package/src/lib/interfaces/responses/block-data-response.d.ts.map +1 -1
- package/src/lib/interfaces/responses/block-location-response.d.ts +2 -1
- package/src/lib/interfaces/responses/block-location-response.d.ts.map +1 -1
- package/src/lib/interfaces/websocketMessages.d.ts +9 -8
- package/src/lib/interfaces/websocketMessages.d.ts.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 +37 -8
- package/src/lib/plugins/brightchain-database-plugin.js.map +1 -1
- package/src/lib/services/blocks.d.ts +6 -6
- package/src/lib/services/blocks.d.ts.map +1 -1
- package/src/lib/services/blocks.js +3 -2
- package/src/lib/services/blocks.js.map +1 -1
- package/src/lib/services/brightchain-authentication-provider.d.ts.map +1 -1
- package/src/lib/services/brightchain-authentication-provider.js +3 -4
- package/src/lib/services/brightchain-authentication-provider.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 +7 -5
- package/src/lib/services/brightchain-member-init.service.js.map +1 -1
- package/src/lib/services/brightpass.d.ts.map +1 -1
- package/src/lib/services/brightpass.js +5 -2
- package/src/lib/services/brightpass.js.map +1 -1
- package/src/lib/services/cliOperatorPrompt.d.ts +3 -3
- package/src/lib/services/cliOperatorPrompt.d.ts.map +1 -1
- package/src/lib/services/cliOperatorPrompt.js.map +1 -1
- package/src/lib/services/contentAwareBlocksService.d.ts +0 -9
- package/src/lib/services/contentAwareBlocksService.d.ts.map +1 -1
- package/src/lib/services/contentAwareBlocksService.js +0 -9
- package/src/lib/services/contentAwareBlocksService.js.map +1 -1
- package/src/lib/services/diskQuorumService.d.ts +11 -16
- package/src/lib/services/diskQuorumService.d.ts.map +1 -1
- package/src/lib/services/diskQuorumService.js +43 -28
- package/src/lib/services/diskQuorumService.js.map +1 -1
- package/src/lib/services/identityExpirationScheduler.d.ts +3 -2
- package/src/lib/services/identityExpirationScheduler.d.ts.map +1 -1
- package/src/lib/services/identityExpirationScheduler.js +5 -4
- package/src/lib/services/identityExpirationScheduler.js.map +1 -1
- package/src/lib/services/quorumDatabaseAdapter.d.ts +11 -10
- package/src/lib/services/quorumDatabaseAdapter.d.ts.map +1 -1
- package/src/lib/services/quorumDatabaseAdapter.js +167 -81
- package/src/lib/services/quorumDatabaseAdapter.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 +1 -1
- package/src/lib/stores/availabilityAwareBlockStore.js.map +1 -1
- package/src/lib/stores/diskBlockAsyncStore.d.ts +2 -2
- package/src/lib/stores/diskBlockAsyncStore.d.ts.map +1 -1
- package/src/lib/stores/diskBlockAsyncStore.js +27 -11
- package/src/lib/stores/diskBlockAsyncStore.js.map +1 -1
- package/src/lib/stores/diskBlockMetadataStore.d.ts.map +1 -1
- package/src/lib/stores/diskBlockMetadataStore.js +10 -2
- package/src/lib/stores/diskBlockMetadataStore.js.map +1 -1
- package/src/lib/stores/diskBlockStore.d.ts +2 -2
- package/src/lib/stores/diskBlockStore.d.ts.map +1 -1
- package/src/lib/stores/diskBlockStore.js +25 -14
- package/src/lib/stores/diskBlockStore.js.map +1 -1
- package/src/lib/stores/diskCBLStore.d.ts.map +1 -1
- package/src/lib/stores/diskCBLStore.js.map +1 -1
- package/src/lib/stores/diskMessageMetadataStore.d.ts.map +1 -1
- package/src/lib/stores/diskMessageMetadataStore.js +12 -3
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identityExpirationScheduler.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/services/identityExpirationScheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAEL,eAAe,EAEf,gBAAgB,EAChB,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,
|
|
1
|
+
{"version":3,"file":"identityExpirationScheduler.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/services/identityExpirationScheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAEL,eAAe,EAEf,gBAAg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|
13
13
|
const brightchain_lib_1 = require("@brightchain/brightchain-lib");
|
|
14
|
-
const uuid_1 = require("uuid");
|
|
15
14
|
/** Default interval: 24 hours in milliseconds */
|
|
16
15
|
const DEFAULT_INTERVAL_MS = 86400000;
|
|
17
16
|
/** Default batch size for processing expired records */
|
|
@@ -28,13 +27,15 @@ const DEFAULT_BATCH_SIZE = 100;
|
|
|
28
27
|
* @template TID - Platform ID type for frontend/backend DTO compatibility
|
|
29
28
|
*/
|
|
30
29
|
class IdentityExpirationScheduler {
|
|
31
|
-
constructor(db, auditLogService, config) {
|
|
30
|
+
constructor(db, auditLogService, config, idProvider) {
|
|
32
31
|
this.db = db;
|
|
33
32
|
this.auditLogService = auditLogService;
|
|
34
33
|
this.timer = null;
|
|
35
34
|
this.running = false;
|
|
36
35
|
this.intervalMs = config?.intervalMs ?? DEFAULT_INTERVAL_MS;
|
|
37
36
|
this.batchSize = config?.batchSize ?? DEFAULT_BATCH_SIZE;
|
|
37
|
+
this.idProvider =
|
|
38
|
+
idProvider ?? brightchain_lib_1.ServiceProvider.getInstance().idProvider;
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* Start the periodic expiration check.
|
|
@@ -96,7 +97,7 @@ class IdentityExpirationScheduler {
|
|
|
96
97
|
deletedCount++;
|
|
97
98
|
}
|
|
98
99
|
catch {
|
|
99
|
-
failedIds.push(record.id);
|
|
100
|
+
failedIds.push(this.idProvider.idToString(record.id));
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
const nextBatchAvailable = expiredRecords.length === this.batchSize;
|
|
@@ -140,7 +141,7 @@ class IdentityExpirationScheduler {
|
|
|
140
141
|
*/
|
|
141
142
|
async emitAuditEntry(eventType, details) {
|
|
142
143
|
const entry = {
|
|
143
|
-
id: (
|
|
144
|
+
id: this.idProvider.fromBytes(this.idProvider.generate()),
|
|
144
145
|
eventType,
|
|
145
146
|
details,
|
|
146
147
|
timestamp: new Date(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identityExpirationScheduler.js","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/services/identityExpirationScheduler.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"identityExpirationScheduler.js","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/services/identityExpirationScheduler.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,kEAWsC;AAGtC,iDAAiD;AACjD,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AAErC,wDAAwD;AACxD,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B;;;;;;;;;;GAUG;AACH,MAAa,2BAA2B;IAUtC,YACmB,EAAwB,EACxB,eAAsC,EACvD,MAA2C,EAC3C,UAA6B;QAHZ,OAAE,GAAF,EAAE,CAAsB;QACxB,oBAAe,GAAf,eAAe,CAAuB;QAPjD,UAAK,GAA0C,IAAI,CAAC;QACpD,YAAO,GAAG,KAAK,CAAC;QAUtB,IAAI,CAAC,UAAU,GAAG,MAAM,EAAE,UAAU,IAAI,mBAAmB,CAAC;QAC5D,IAAI,CAAC,SAAS,GAAG,MAAM,EAAE,SAAS,IAAI,kBAAkB,CAAC;QACzD,IAAI,CAAC,UAAU;YACb,UAAU,IAAI,iCAAe,CAAC,WAAW,EAAO,CAAC,UAAU,CAAC;IAChE,CAAC;IAED;;;OAGG;IACH,KAAK;QACH,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;YAC5B,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,aAAa,CAAC,IA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ChainedAuditLogEntry, IdentityRecoveryRecord, IQuorumDatabase, IQuorumMember, OperationalState, Proposal, QuorumAuditLogEntry, QuorumDataRecord, QuorumEpoch, RedistributionJournalEntry, StatuteOfLimitationsConfig, Vote } from '@brightchain/brightchain-lib';
|
|
13
13
|
import type { BrightChainDb } from '@brightchain/db';
|
|
14
|
-
import {
|
|
14
|
+
import { IIdProvider, PlatformID } from '@digitaldefiance/ecies-lib';
|
|
15
15
|
/** Dedicated pool ID for quorum data isolation */
|
|
16
16
|
export declare const QUORUM_SYSTEM_POOL_ID = "quorum-system";
|
|
17
17
|
/**
|
|
@@ -24,29 +24,30 @@ export declare const QUORUM_SYSTEM_POOL_ID = "quorum-system";
|
|
|
24
24
|
*/
|
|
25
25
|
export declare class QuorumDatabaseAdapter<TID extends PlatformID = Uint8Array> implements IQuorumDatabase<TID> {
|
|
26
26
|
private readonly db;
|
|
27
|
-
|
|
27
|
+
private readonly idProvider;
|
|
28
|
+
constructor(db: BrightChainDb, idProvider: IIdProvider<TID>);
|
|
28
29
|
saveEpoch(epoch: QuorumEpoch<TID>): Promise<void>;
|
|
29
30
|
getEpoch(epochNumber: number): Promise<QuorumEpoch<TID> | null>;
|
|
30
31
|
getCurrentEpoch(): Promise<QuorumEpoch<TID>>;
|
|
31
32
|
saveMember(member: IQuorumMember<TID>): Promise<void>;
|
|
32
|
-
getMember(memberId:
|
|
33
|
+
getMember(memberId: TID): Promise<IQuorumMember<TID> | null>;
|
|
33
34
|
listActiveMembers(): Promise<IQuorumMember<TID>[]>;
|
|
34
35
|
saveDocument(doc: QuorumDataRecord<TID>): Promise<void>;
|
|
35
|
-
getDocument(docId:
|
|
36
|
+
getDocument(docId: TID): Promise<QuorumDataRecord<TID> | null>;
|
|
36
37
|
listDocumentsByEpoch(epochNumber: number, page: number, pageSize: number): Promise<QuorumDataRecord<TID>[]>;
|
|
37
38
|
saveProposal(proposal: Proposal<TID>): Promise<void>;
|
|
38
|
-
getProposal(proposalId:
|
|
39
|
+
getProposal(proposalId: TID): Promise<Proposal<TID> | null>;
|
|
39
40
|
saveVote(vote: Vote<TID>): Promise<void>;
|
|
40
|
-
getVotesForProposal(proposalId:
|
|
41
|
+
getVotesForProposal(proposalId: TID): Promise<Vote<TID>[]>;
|
|
41
42
|
saveIdentityRecord(record: IdentityRecoveryRecord<TID>): Promise<void>;
|
|
42
|
-
getIdentityRecord(recordId:
|
|
43
|
-
deleteIdentityRecord(recordId:
|
|
43
|
+
getIdentityRecord(recordId: TID): Promise<IdentityRecoveryRecord<TID> | null>;
|
|
44
|
+
deleteIdentityRecord(recordId: TID): Promise<void>;
|
|
44
45
|
listExpiredIdentityRecords(before: Date, page: number, pageSize: number): Promise<IdentityRecoveryRecord<TID>[]>;
|
|
45
46
|
saveAlias(alias: AliasRecord<TID>): Promise<void>;
|
|
46
47
|
getAlias(aliasName: string): Promise<AliasRecord<TID> | null>;
|
|
47
48
|
isAliasAvailable(aliasName: string): Promise<boolean>;
|
|
48
|
-
appendAuditEntry(entry: QuorumAuditLogEntry): Promise<void>;
|
|
49
|
-
getLatestAuditEntry(): Promise<ChainedAuditLogEntry | null>;
|
|
49
|
+
appendAuditEntry(entry: QuorumAuditLogEntry<TID>): Promise<void>;
|
|
50
|
+
getLatestAuditEntry(): Promise<ChainedAuditLogEntry<TID> | null>;
|
|
50
51
|
saveJournalEntry(entry: RedistributionJournalEntry): Promise<void>;
|
|
51
52
|
getJournalEntries(epochNumber: number): Promise<RedistributionJournalEntry[]>;
|
|
52
53
|
deleteJournalEntries(epochNumber: number): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quorumDatabaseAdapter.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/services/quorumDatabaseAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,0BAA0B,EAC1B,0BAA0B,EAC1B,IAAI,EACL,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,iBAAiB,CAAC;AACnE,OAAO,
|
|
1
|
+
{"version":3,"file":"quorumDatabaseAdapter.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/services/quorumDatabaseAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,0BAA0B,EAC1B,0BAA0B,EAC1B,IAAI,EACL,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAEL,WAAW,EACX,UAAU,EAEX,MAAM,4BAA4B,CAAC;AAgBpC,kDAAkD;AAClD,eAAO,MAAM,qBAAqB,kBAAkB,CAAC;AA6hBrD;;;;;;;GAOG;AACH,qBAAa,qBAAqB,CAChC,GAAG,SAAS,UAAU,GAAG,UAAU,CACnC,YAAW,eAAe,CAAC,GAAG,CAAC;IAC/B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAgB;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;gBAElC,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,CAAC,GAAG,CAAC;IAOrD,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBjD,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAO/D,eAAe,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAe5C,UAAU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|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
// ─── Member Serialization ───────────────────────────────────────────────────
|
|
88
|
-
function serializeMember(member) {
|
|
88
|
+
function serializeMember(member, idProvider) {
|
|
89
89
|
return {
|
|
90
|
-
id: member.id,
|
|
90
|
+
id: idProvider.idToString(member.id),
|
|
91
91
|
publicKey: serializeUint8Array(member.publicKey),
|
|
92
92
|
metadata: member.metadata,
|
|
93
93
|
isActive: member.isActive,
|
|
@@ -95,9 +95,14 @@ function serializeMember(member) {
|
|
|
95
95
|
updatedAt: member.updatedAt.toISOString(),
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
function deserializeMember(data) {
|
|
98
|
+
function deserializeMember(data, idProvider) {
|
|
99
|
+
const rawId = data['id'];
|
|
100
|
+
const id = idProvider.parseSafe(String(rawId));
|
|
101
|
+
if (id === undefined) {
|
|
102
|
+
throw new Error(`Invalid member ID in stored document: ${rawId}`);
|
|
103
|
+
}
|
|
99
104
|
return {
|
|
100
|
-
id
|
|
105
|
+
id,
|
|
101
106
|
publicKey: deserializeUint8Array(data['publicKey']),
|
|
102
107
|
metadata: data['metadata'],
|
|
103
108
|
isActive: data['isActive'],
|
|
@@ -106,13 +111,13 @@ function deserializeMember(data) {
|
|
|
106
111
|
};
|
|
107
112
|
}
|
|
108
113
|
// ─── Proposal Serialization ─────────────────────────────────────────────────
|
|
109
|
-
function serializeProposal(proposal) {
|
|
114
|
+
function serializeProposal(proposal, idProvider) {
|
|
110
115
|
return {
|
|
111
|
-
id: proposal.id,
|
|
116
|
+
id: idProvider.idToString(proposal.id),
|
|
112
117
|
description: proposal.description,
|
|
113
118
|
actionType: proposal.actionType,
|
|
114
119
|
actionPayload: proposal.actionPayload,
|
|
115
|
-
proposerMemberId: proposal.proposerMemberId,
|
|
120
|
+
proposerMemberId: idProvider.idToString(proposal.proposerMemberId),
|
|
116
121
|
status: proposal.status,
|
|
117
122
|
requiredThreshold: proposal.requiredThreshold,
|
|
118
123
|
expiresAt: proposal.expiresAt.toISOString(),
|
|
@@ -121,13 +126,23 @@ function serializeProposal(proposal) {
|
|
|
121
126
|
epochNumber: proposal.epochNumber,
|
|
122
127
|
};
|
|
123
128
|
}
|
|
124
|
-
function deserializeProposal(data) {
|
|
129
|
+
function deserializeProposal(data, idProvider) {
|
|
130
|
+
const rawId = data['id'];
|
|
131
|
+
const id = idProvider.parseSafe(String(rawId));
|
|
132
|
+
if (id === undefined) {
|
|
133
|
+
throw new Error(`Invalid proposal ID in stored document: ${rawId}`);
|
|
134
|
+
}
|
|
135
|
+
const rawProposerId = data['proposerMemberId'];
|
|
136
|
+
const proposerMemberId = idProvider.parseSafe(String(rawProposerId));
|
|
137
|
+
if (proposerMemberId === undefined) {
|
|
138
|
+
throw new Error(`Invalid proposerMemberId in stored document: ${rawProposerId}`);
|
|
139
|
+
}
|
|
125
140
|
return {
|
|
126
|
-
id
|
|
141
|
+
id,
|
|
127
142
|
description: data['description'],
|
|
128
143
|
actionType: data['actionType'],
|
|
129
144
|
actionPayload: data['actionPayload'],
|
|
130
|
-
proposerMemberId
|
|
145
|
+
proposerMemberId,
|
|
131
146
|
status: data['status'],
|
|
132
147
|
requiredThreshold: data['requiredThreshold'],
|
|
133
148
|
expiresAt: new Date(data['expiresAt']),
|
|
@@ -137,10 +152,10 @@ function deserializeProposal(data) {
|
|
|
137
152
|
};
|
|
138
153
|
}
|
|
139
154
|
// ─── Vote Serialization ─────────────────────────────────────────────────────
|
|
140
|
-
function serializeVote(vote) {
|
|
155
|
+
function serializeVote(vote, idProvider) {
|
|
141
156
|
return {
|
|
142
|
-
proposalId: vote.proposalId,
|
|
143
|
-
voterMemberId: vote.voterMemberId,
|
|
157
|
+
proposalId: idProvider.idToString(vote.proposalId),
|
|
158
|
+
voterMemberId: idProvider.idToString(vote.voterMemberId),
|
|
144
159
|
decision: vote.decision,
|
|
145
160
|
comment: vote.comment,
|
|
146
161
|
encryptedShare: vote.encryptedShare
|
|
@@ -149,10 +164,20 @@ function serializeVote(vote) {
|
|
|
149
164
|
createdAt: vote.createdAt.toISOString(),
|
|
150
165
|
};
|
|
151
166
|
}
|
|
152
|
-
function deserializeVote(data) {
|
|
167
|
+
function deserializeVote(data, idProvider) {
|
|
168
|
+
const rawProposalId = data['proposalId'];
|
|
169
|
+
const proposalId = idProvider.parseSafe(String(rawProposalId));
|
|
170
|
+
if (proposalId === undefined) {
|
|
171
|
+
throw new Error(`Invalid proposalId in stored vote: ${rawProposalId}`);
|
|
172
|
+
}
|
|
173
|
+
const rawVoterId = data['voterMemberId'];
|
|
174
|
+
const voterMemberId = idProvider.parseSafe(String(rawVoterId));
|
|
175
|
+
if (voterMemberId === undefined) {
|
|
176
|
+
throw new Error(`Invalid voterMemberId in stored vote: ${rawVoterId}`);
|
|
177
|
+
}
|
|
153
178
|
return {
|
|
154
|
-
proposalId
|
|
155
|
-
voterMemberId
|
|
179
|
+
proposalId,
|
|
180
|
+
voterMemberId,
|
|
156
181
|
decision: data['decision'],
|
|
157
182
|
comment: data['comment'],
|
|
158
183
|
encryptedShare: data['encryptedShare']
|
|
@@ -162,13 +187,13 @@ function deserializeVote(data) {
|
|
|
162
187
|
};
|
|
163
188
|
}
|
|
164
189
|
// ─── IdentityRecoveryRecord Serialization ───────────────────────────────────
|
|
165
|
-
function serializeIdentityRecord(record) {
|
|
190
|
+
function serializeIdentityRecord(record, idProvider) {
|
|
166
191
|
return {
|
|
167
|
-
id: record.id,
|
|
168
|
-
contentId: record.contentId,
|
|
192
|
+
id: idProvider.idToString(record.id),
|
|
193
|
+
contentId: idProvider.idToString(record.contentId),
|
|
169
194
|
contentType: record.contentType,
|
|
170
195
|
encryptedShardsByMemberId: serializeMap(record.encryptedShardsByMemberId),
|
|
171
|
-
memberIds: record.memberIds,
|
|
196
|
+
memberIds: record.memberIds.map((mid) => idProvider.idToString(mid)),
|
|
172
197
|
threshold: record.threshold,
|
|
173
198
|
epochNumber: record.epochNumber,
|
|
174
199
|
expiresAt: record.expiresAt.toISOString(),
|
|
@@ -177,13 +202,31 @@ function serializeIdentityRecord(record) {
|
|
|
177
202
|
aliasName: record.aliasName,
|
|
178
203
|
};
|
|
179
204
|
}
|
|
180
|
-
function deserializeIdentityRecord(data) {
|
|
205
|
+
function deserializeIdentityRecord(data, idProvider) {
|
|
206
|
+
const rawId = data['id'];
|
|
207
|
+
const id = idProvider.parseSafe(String(rawId));
|
|
208
|
+
if (id === undefined) {
|
|
209
|
+
throw new Error(`Invalid identity record ID in stored document: ${rawId}`);
|
|
210
|
+
}
|
|
211
|
+
const rawContentId = data['contentId'];
|
|
212
|
+
const contentId = idProvider.parseSafe(String(rawContentId));
|
|
213
|
+
if (contentId === undefined) {
|
|
214
|
+
throw new Error(`Invalid contentId in stored identity record: ${rawContentId}`);
|
|
215
|
+
}
|
|
216
|
+
const rawMemberIds = data['memberIds'];
|
|
217
|
+
const memberIds = rawMemberIds.map((rawMid, i) => {
|
|
218
|
+
const mid = idProvider.parseSafe(String(rawMid));
|
|
219
|
+
if (mid === undefined) {
|
|
220
|
+
throw new Error(`Invalid memberIds[${i}] in stored identity record: ${rawMid}`);
|
|
221
|
+
}
|
|
222
|
+
return mid;
|
|
223
|
+
});
|
|
181
224
|
return {
|
|
182
|
-
id
|
|
183
|
-
contentId
|
|
225
|
+
id,
|
|
226
|
+
contentId,
|
|
184
227
|
contentType: data['contentType'],
|
|
185
228
|
encryptedShardsByMemberId: deserializeMap(data['encryptedShardsByMemberId']),
|
|
186
|
-
memberIds
|
|
229
|
+
memberIds,
|
|
187
230
|
threshold: data['threshold'],
|
|
188
231
|
epochNumber: data['epochNumber'],
|
|
189
232
|
expiresAt: new Date(data['expiresAt']),
|
|
@@ -193,24 +236,34 @@ function deserializeIdentityRecord(data) {
|
|
|
193
236
|
};
|
|
194
237
|
}
|
|
195
238
|
// ─── AliasRecord Serialization ──────────────────────────────────────────────
|
|
196
|
-
function serializeAlias(alias) {
|
|
239
|
+
function serializeAlias(alias, idProvider) {
|
|
197
240
|
return {
|
|
198
241
|
aliasName: alias.aliasName,
|
|
199
|
-
ownerMemberId: alias.ownerMemberId,
|
|
242
|
+
ownerMemberId: idProvider.idToString(alias.ownerMemberId),
|
|
200
243
|
aliasPublicKey: serializeUint8Array(alias.aliasPublicKey),
|
|
201
|
-
identityRecoveryRecordId: alias.identityRecoveryRecordId,
|
|
244
|
+
identityRecoveryRecordId: idProvider.idToString(alias.identityRecoveryRecordId),
|
|
202
245
|
isActive: alias.isActive,
|
|
203
246
|
registeredAt: alias.registeredAt.toISOString(),
|
|
204
247
|
deactivatedAt: alias.deactivatedAt?.toISOString(),
|
|
205
248
|
epochNumber: alias.epochNumber,
|
|
206
249
|
};
|
|
207
250
|
}
|
|
208
|
-
function deserializeAlias(data) {
|
|
251
|
+
function deserializeAlias(data, idProvider) {
|
|
252
|
+
const rawOwnerId = data['ownerMemberId'];
|
|
253
|
+
const ownerMemberId = idProvider.parseSafe(String(rawOwnerId));
|
|
254
|
+
if (ownerMemberId === undefined) {
|
|
255
|
+
throw new Error(`Invalid ownerMemberId in stored alias: ${rawOwnerId}`);
|
|
256
|
+
}
|
|
257
|
+
const rawRecordId = data['identityRecoveryRecordId'];
|
|
258
|
+
const identityRecoveryRecordId = idProvider.parseSafe(String(rawRecordId));
|
|
259
|
+
if (identityRecoveryRecordId === undefined) {
|
|
260
|
+
throw new Error(`Invalid identityRecoveryRecordId in stored alias: ${rawRecordId}`);
|
|
261
|
+
}
|
|
209
262
|
return {
|
|
210
263
|
aliasName: data['aliasName'],
|
|
211
|
-
ownerMemberId
|
|
264
|
+
ownerMemberId,
|
|
212
265
|
aliasPublicKey: deserializeUint8Array(data['aliasPublicKey']),
|
|
213
|
-
identityRecoveryRecordId
|
|
266
|
+
identityRecoveryRecordId,
|
|
214
267
|
isActive: data['isActive'],
|
|
215
268
|
registeredAt: new Date(data['registeredAt']),
|
|
216
269
|
deactivatedAt: data['deactivatedAt']
|
|
@@ -220,13 +273,19 @@ function deserializeAlias(data) {
|
|
|
220
273
|
};
|
|
221
274
|
}
|
|
222
275
|
// ─── AuditLogEntry Serialization ────────────────────────────────────────────
|
|
223
|
-
function serializeAuditEntry(entry) {
|
|
276
|
+
function serializeAuditEntry(entry, idProvider) {
|
|
224
277
|
const base = {
|
|
225
|
-
id: entry.id,
|
|
278
|
+
id: idProvider.idToString(entry.id),
|
|
226
279
|
eventType: entry.eventType,
|
|
227
|
-
proposalId: entry.proposalId
|
|
228
|
-
|
|
229
|
-
|
|
280
|
+
proposalId: entry.proposalId !== undefined
|
|
281
|
+
? idProvider.idToString(entry.proposalId)
|
|
282
|
+
: undefined,
|
|
283
|
+
targetMemberId: entry.targetMemberId !== undefined
|
|
284
|
+
? idProvider.idToString(entry.targetMemberId)
|
|
285
|
+
: undefined,
|
|
286
|
+
proposerMemberId: entry.proposerMemberId !== undefined
|
|
287
|
+
? idProvider.idToString(entry.proposerMemberId)
|
|
288
|
+
: undefined,
|
|
230
289
|
attachmentCblId: entry.attachmentCblId,
|
|
231
290
|
details: entry.details,
|
|
232
291
|
timestamp: entry.timestamp.toISOString(),
|
|
@@ -244,13 +303,28 @@ function serializeAuditEntry(entry) {
|
|
|
244
303
|
}
|
|
245
304
|
return base;
|
|
246
305
|
}
|
|
247
|
-
function deserializeChainedAuditEntry(data) {
|
|
306
|
+
function deserializeChainedAuditEntry(data, idProvider) {
|
|
307
|
+
const rawId = data['id'];
|
|
308
|
+
const id = idProvider.parseSafe(String(rawId));
|
|
309
|
+
if (id === undefined) {
|
|
310
|
+
throw new Error(`Invalid audit entry ID in stored document: ${rawId}`);
|
|
311
|
+
}
|
|
312
|
+
// Optional TID fields — validate if present
|
|
313
|
+
const parseOptionalId = (raw) => {
|
|
314
|
+
if (raw === undefined || raw === null)
|
|
315
|
+
return undefined;
|
|
316
|
+
const parsed = idProvider.parseSafe(String(raw));
|
|
317
|
+
if (parsed === undefined) {
|
|
318
|
+
throw new Error(`Invalid optional ID in stored audit entry: ${raw}`);
|
|
319
|
+
}
|
|
320
|
+
return parsed;
|
|
321
|
+
};
|
|
248
322
|
return {
|
|
249
|
-
id
|
|
323
|
+
id,
|
|
250
324
|
eventType: data['eventType'],
|
|
251
|
-
proposalId: data['proposalId'],
|
|
252
|
-
targetMemberId: data['targetMemberId'],
|
|
253
|
-
proposerMemberId: data['proposerMemberId'],
|
|
325
|
+
proposalId: parseOptionalId(data['proposalId']),
|
|
326
|
+
targetMemberId: parseOptionalId(data['targetMemberId']),
|
|
327
|
+
proposerMemberId: parseOptionalId(data['proposerMemberId']),
|
|
254
328
|
attachmentCblId: data['attachmentCblId'],
|
|
255
329
|
details: data['details'],
|
|
256
330
|
timestamp: new Date(data['timestamp']),
|
|
@@ -320,8 +394,9 @@ function deserializeOperationalState(data) {
|
|
|
320
394
|
* @template TID - Platform ID type for frontend/backend DTO compatibility
|
|
321
395
|
*/
|
|
322
396
|
class QuorumDatabaseAdapter {
|
|
323
|
-
constructor(db) {
|
|
397
|
+
constructor(db, idProvider) {
|
|
324
398
|
this.db = db;
|
|
399
|
+
this.idProvider = idProvider;
|
|
325
400
|
}
|
|
326
401
|
// === Epoch Management ===
|
|
327
402
|
async saveEpoch(epoch) {
|
|
@@ -361,34 +436,36 @@ class QuorumDatabaseAdapter {
|
|
|
361
436
|
// === Member Management ===
|
|
362
437
|
async saveMember(member) {
|
|
363
438
|
const col = this.db.collection(COLLECTION_MEMBERS);
|
|
364
|
-
const
|
|
439
|
+
const serializedId = this.idProvider.idToString(member.id);
|
|
440
|
+
const existing = await col.findOne({ memberId: serializedId });
|
|
365
441
|
if (existing) {
|
|
366
|
-
await col.updateOne({ memberId:
|
|
442
|
+
await col.updateOne({ memberId: serializedId }, {
|
|
367
443
|
$set: {
|
|
368
444
|
isActive: member.isActive,
|
|
369
|
-
data: serializeMember(member),
|
|
445
|
+
data: serializeMember(member, this.idProvider),
|
|
370
446
|
},
|
|
371
447
|
});
|
|
372
448
|
}
|
|
373
449
|
else {
|
|
374
450
|
await col.insertOne({
|
|
375
|
-
memberId:
|
|
451
|
+
memberId: serializedId,
|
|
376
452
|
isActive: member.isActive,
|
|
377
|
-
data: serializeMember(member),
|
|
453
|
+
data: serializeMember(member, this.idProvider),
|
|
378
454
|
});
|
|
379
455
|
}
|
|
380
456
|
}
|
|
381
457
|
async getMember(memberId) {
|
|
382
458
|
const col = this.db.collection(COLLECTION_MEMBERS);
|
|
383
|
-
const
|
|
459
|
+
const serializedId = this.idProvider.idToString(memberId);
|
|
460
|
+
const doc = await col.findOne({ memberId: serializedId });
|
|
384
461
|
if (!doc)
|
|
385
462
|
return null;
|
|
386
|
-
return deserializeMember(doc.data);
|
|
463
|
+
return deserializeMember(doc.data, this.idProvider);
|
|
387
464
|
}
|
|
388
465
|
async listActiveMembers() {
|
|
389
466
|
const col = this.db.collection(COLLECTION_MEMBERS);
|
|
390
467
|
const docs = await col.find({ isActive: true }).toArray();
|
|
391
|
-
return docs.map((doc) => deserializeMember(doc.data));
|
|
468
|
+
return docs.map((doc) => deserializeMember(doc.data, this.idProvider));
|
|
392
469
|
}
|
|
393
470
|
// === Sealed Documents ===
|
|
394
471
|
async saveDocument(doc) {
|
|
@@ -414,7 +491,8 @@ class QuorumDatabaseAdapter {
|
|
|
414
491
|
}
|
|
415
492
|
async getDocument(docId) {
|
|
416
493
|
const col = this.db.collection(COLLECTION_DOCUMENTS);
|
|
417
|
-
const
|
|
494
|
+
const serializedId = this.idProvider.idToString(docId);
|
|
495
|
+
const doc = await col.findOne({ docId: serializedId });
|
|
418
496
|
if (!doc)
|
|
419
497
|
return null;
|
|
420
498
|
// Return the stored DTO data — callers use QuorumDataRecord.fromDto
|
|
@@ -433,79 +511,87 @@ class QuorumDatabaseAdapter {
|
|
|
433
511
|
// === Proposals and Votes ===
|
|
434
512
|
async saveProposal(proposal) {
|
|
435
513
|
const col = this.db.collection(COLLECTION_PROPOSALS);
|
|
436
|
-
const
|
|
514
|
+
const serializedId = this.idProvider.idToString(proposal.id);
|
|
515
|
+
const existing = await col.findOne({ proposalId: serializedId });
|
|
437
516
|
if (existing) {
|
|
438
|
-
await col.updateOne({ proposalId:
|
|
517
|
+
await col.updateOne({ proposalId: serializedId }, { $set: { data: serializeProposal(proposal, this.idProvider) } });
|
|
439
518
|
}
|
|
440
519
|
else {
|
|
441
520
|
await col.insertOne({
|
|
442
|
-
proposalId:
|
|
443
|
-
data: serializeProposal(proposal),
|
|
521
|
+
proposalId: serializedId,
|
|
522
|
+
data: serializeProposal(proposal, this.idProvider),
|
|
444
523
|
});
|
|
445
524
|
}
|
|
446
525
|
}
|
|
447
526
|
async getProposal(proposalId) {
|
|
448
527
|
const col = this.db.collection(COLLECTION_PROPOSALS);
|
|
449
|
-
const
|
|
528
|
+
const serializedId = this.idProvider.idToString(proposalId);
|
|
529
|
+
const doc = await col.findOne({ proposalId: serializedId });
|
|
450
530
|
if (!doc)
|
|
451
531
|
return null;
|
|
452
|
-
return deserializeProposal(doc.data);
|
|
532
|
+
return deserializeProposal(doc.data, this.idProvider);
|
|
453
533
|
}
|
|
454
534
|
async saveVote(vote) {
|
|
455
535
|
const col = this.db.collection(COLLECTION_VOTES);
|
|
536
|
+
const serializedProposalId = this.idProvider.idToString(vote.proposalId);
|
|
537
|
+
const serializedVoterId = this.idProvider.idToString(vote.voterMemberId);
|
|
456
538
|
const existing = await col.findOne({
|
|
457
|
-
proposalId:
|
|
458
|
-
voterMemberId:
|
|
539
|
+
proposalId: serializedProposalId,
|
|
540
|
+
voterMemberId: serializedVoterId,
|
|
459
541
|
});
|
|
460
542
|
if (existing) {
|
|
461
543
|
await col.updateOne({
|
|
462
|
-
proposalId:
|
|
463
|
-
voterMemberId:
|
|
464
|
-
}, { $set: { data: serializeVote(vote) } });
|
|
544
|
+
proposalId: serializedProposalId,
|
|
545
|
+
voterMemberId: serializedVoterId,
|
|
546
|
+
}, { $set: { data: serializeVote(vote, this.idProvider) } });
|
|
465
547
|
}
|
|
466
548
|
else {
|
|
467
549
|
await col.insertOne({
|
|
468
|
-
proposalId:
|
|
469
|
-
voterMemberId:
|
|
470
|
-
data: serializeVote(vote),
|
|
550
|
+
proposalId: serializedProposalId,
|
|
551
|
+
voterMemberId: serializedVoterId,
|
|
552
|
+
data: serializeVote(vote, this.idProvider),
|
|
471
553
|
});
|
|
472
554
|
}
|
|
473
555
|
}
|
|
474
556
|
async getVotesForProposal(proposalId) {
|
|
475
557
|
const col = this.db.collection(COLLECTION_VOTES);
|
|
476
|
-
const
|
|
477
|
-
|
|
558
|
+
const serializedId = this.idProvider.idToString(proposalId);
|
|
559
|
+
const docs = await col.find({ proposalId: serializedId }).toArray();
|
|
560
|
+
return docs.map((d) => deserializeVote(d.data, this.idProvider));
|
|
478
561
|
}
|
|
479
562
|
// === Identity Recovery Records ===
|
|
480
563
|
async saveIdentityRecord(record) {
|
|
481
564
|
const col = this.db.collection(COLLECTION_IDENTITY_RECORDS);
|
|
482
|
-
const
|
|
565
|
+
const serializedId = this.idProvider.idToString(record.id);
|
|
566
|
+
const existing = await col.findOne({ recordId: serializedId });
|
|
483
567
|
if (existing) {
|
|
484
|
-
await col.updateOne({ recordId:
|
|
568
|
+
await col.updateOne({ recordId: serializedId }, {
|
|
485
569
|
$set: {
|
|
486
570
|
expiresAt: record.expiresAt.toISOString(),
|
|
487
|
-
data: serializeIdentityRecord(record),
|
|
571
|
+
data: serializeIdentityRecord(record, this.idProvider),
|
|
488
572
|
},
|
|
489
573
|
});
|
|
490
574
|
}
|
|
491
575
|
else {
|
|
492
576
|
await col.insertOne({
|
|
493
|
-
recordId:
|
|
577
|
+
recordId: serializedId,
|
|
494
578
|
expiresAt: record.expiresAt.toISOString(),
|
|
495
|
-
data: serializeIdentityRecord(record),
|
|
579
|
+
data: serializeIdentityRecord(record, this.idProvider),
|
|
496
580
|
});
|
|
497
581
|
}
|
|
498
582
|
}
|
|
499
583
|
async getIdentityRecord(recordId) {
|
|
500
584
|
const col = this.db.collection(COLLECTION_IDENTITY_RECORDS);
|
|
501
|
-
const
|
|
585
|
+
const serializedId = this.idProvider.idToString(recordId);
|
|
586
|
+
const doc = await col.findOne({ recordId: serializedId });
|
|
502
587
|
if (!doc)
|
|
503
588
|
return null;
|
|
504
|
-
return deserializeIdentityRecord(doc.data);
|
|
589
|
+
return deserializeIdentityRecord(doc.data, this.idProvider);
|
|
505
590
|
}
|
|
506
591
|
async deleteIdentityRecord(recordId) {
|
|
507
592
|
const col = this.db.collection(COLLECTION_IDENTITY_RECORDS);
|
|
508
|
-
|
|
593
|
+
const serializedId = this.idProvider.idToString(recordId);
|
|
594
|
+
await col.deleteOne({ recordId: serializedId });
|
|
509
595
|
}
|
|
510
596
|
async listExpiredIdentityRecords(before, page, pageSize) {
|
|
511
597
|
const col = this.db.collection(COLLECTION_IDENTITY_RECORDS);
|
|
@@ -518,7 +604,7 @@ class QuorumDatabaseAdapter {
|
|
|
518
604
|
.sort((a, b) => a.expiresAt.localeCompare(b.expiresAt));
|
|
519
605
|
const start = page * pageSize;
|
|
520
606
|
const paged = expired.slice(start, start + pageSize);
|
|
521
|
-
return paged.map((d) => deserializeIdentityRecord(d.data));
|
|
607
|
+
return paged.map((d) => deserializeIdentityRecord(d.data, this.idProvider));
|
|
522
608
|
}
|
|
523
609
|
// === Alias Registry ===
|
|
524
610
|
async saveAlias(alias) {
|
|
@@ -528,7 +614,7 @@ class QuorumDatabaseAdapter {
|
|
|
528
614
|
await col.updateOne({ aliasName: alias.aliasName }, {
|
|
529
615
|
$set: {
|
|
530
616
|
isActive: alias.isActive,
|
|
531
|
-
data: serializeAlias(alias),
|
|
617
|
+
data: serializeAlias(alias, this.idProvider),
|
|
532
618
|
},
|
|
533
619
|
});
|
|
534
620
|
}
|
|
@@ -536,7 +622,7 @@ class QuorumDatabaseAdapter {
|
|
|
536
622
|
await col.insertOne({
|
|
537
623
|
aliasName: alias.aliasName,
|
|
538
624
|
isActive: alias.isActive,
|
|
539
|
-
data: serializeAlias(alias),
|
|
625
|
+
data: serializeAlias(alias, this.idProvider),
|
|
540
626
|
});
|
|
541
627
|
}
|
|
542
628
|
}
|
|
@@ -545,7 +631,7 @@ class QuorumDatabaseAdapter {
|
|
|
545
631
|
const doc = await col.findOne({ aliasName });
|
|
546
632
|
if (!doc)
|
|
547
633
|
return null;
|
|
548
|
-
return deserializeAlias(doc.data);
|
|
634
|
+
return deserializeAlias(doc.data, this.idProvider);
|
|
549
635
|
}
|
|
550
636
|
async isAliasAvailable(aliasName) {
|
|
551
637
|
const col = this.db.collection(COLLECTION_ALIASES);
|
|
@@ -557,9 +643,9 @@ class QuorumDatabaseAdapter {
|
|
|
557
643
|
async appendAuditEntry(entry) {
|
|
558
644
|
const col = this.db.collection(COLLECTION_AUDIT_LOG);
|
|
559
645
|
await col.insertOne({
|
|
560
|
-
entryId: entry.id,
|
|
646
|
+
entryId: this.idProvider.idToString(entry.id),
|
|
561
647
|
timestamp: entry.timestamp.toISOString(),
|
|
562
|
-
data: serializeAuditEntry(entry),
|
|
648
|
+
data: serializeAuditEntry(entry, this.idProvider),
|
|
563
649
|
});
|
|
564
650
|
}
|
|
565
651
|
async getLatestAuditEntry() {
|
|
@@ -567,7 +653,7 @@ class QuorumDatabaseAdapter {
|
|
|
567
653
|
const docs = await col.find({}).sort({ timestamp: -1 }).limit(1).toArray();
|
|
568
654
|
if (docs.length === 0)
|
|
569
655
|
return null;
|
|
570
|
-
return deserializeChainedAuditEntry(docs[0].data);
|
|
656
|
+
return deserializeChainedAuditEntry(docs[0].data, this.idProvider);
|
|
571
657
|
}
|
|
572
658
|
// === Redistribution Journal ===
|
|
573
659
|
async saveJournalEntry(entry) {
|