@brightchain/brightchain-api-lib 0.18.2 → 0.21.0
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 +8 -3
- package/src/index.d.ts +0 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +0 -1
- package/src/index.js.map +1 -1
- package/src/lib/application.d.ts +12 -3
- package/src/lib/application.d.ts.map +1 -1
- package/src/lib/application.js +153 -7
- package/src/lib/application.js.map +1 -1
- package/src/lib/availability/gossipService.d.ts +59 -1
- package/src/lib/availability/gossipService.d.ts.map +1 -1
- package/src/lib/availability/gossipService.js +125 -1
- package/src/lib/availability/gossipService.js.map +1 -1
- package/src/lib/availability/index.d.ts +1 -0
- package/src/lib/availability/index.d.ts.map +1 -1
- package/src/lib/availability/index.js +1 -0
- package/src/lib/availability/index.js.map +1 -1
- package/src/lib/availability/quorumGossipHandler.d.ts +126 -0
- package/src/lib/availability/quorumGossipHandler.d.ts.map +1 -0
- package/src/lib/availability/quorumGossipHandler.js +246 -0
- package/src/lib/availability/quorumGossipHandler.js.map +1 -0
- package/src/lib/constants.d.ts.map +1 -1
- package/src/lib/constants.js +4 -0
- package/src/lib/constants.js.map +1 -1
- package/src/lib/controllers/api/quorum.d.ts +110 -2
- package/src/lib/controllers/api/quorum.d.ts.map +1 -1
- package/src/lib/controllers/api/quorum.js +389 -0
- package/src/lib/controllers/api/quorum.js.map +1 -1
- package/src/lib/controllers/api/user.d.ts +12 -15
- package/src/lib/controllers/api/user.d.ts.map +1 -1
- package/src/lib/controllers/api/user.js +312 -94
- package/src/lib/controllers/api/user.js.map +1 -1
- package/src/lib/databaseInit.d.ts +3 -2
- package/src/lib/databaseInit.d.ts.map +1 -1
- package/src/lib/databaseInit.js +24 -12
- package/src/lib/databaseInit.js.map +1 -1
- package/src/lib/datastore/index.d.ts +0 -1
- package/src/lib/datastore/index.d.ts.map +1 -1
- package/src/lib/datastore/index.js +0 -1
- package/src/lib/datastore/index.js.map +1 -1
- package/src/lib/environment.d.ts +6 -0
- package/src/lib/environment.d.ts.map +1 -1
- package/src/lib/environment.js +14 -0
- package/src/lib/environment.js.map +1 -1
- package/src/lib/hydration/energyAccountHydration.d.ts +17 -0
- package/src/lib/hydration/energyAccountHydration.d.ts.map +1 -0
- package/src/lib/hydration/energyAccountHydration.js +24 -0
- package/src/lib/hydration/energyAccountHydration.js.map +1 -0
- package/src/lib/hydration/index.d.ts +13 -0
- package/src/lib/hydration/index.d.ts.map +1 -0
- package/src/lib/hydration/index.js +21 -0
- package/src/lib/hydration/index.js.map +1 -0
- package/src/lib/hydration/rbacHydration.d.ts +28 -0
- package/src/lib/hydration/rbacHydration.d.ts.map +1 -0
- package/src/lib/hydration/rbacHydration.js +56 -0
- package/src/lib/hydration/rbacHydration.js.map +1 -0
- package/src/lib/interfaces/environment.d.ts +7 -1
- package/src/lib/interfaces/environment.d.ts.map +1 -1
- package/src/lib/interfaces/responses/api-backup-codes-response.d.ts +1 -1
- package/src/lib/interfaces/responses/api-code-count-response.d.ts +1 -1
- package/src/lib/interfaces/responses/api-password-change-response.d.ts +9 -0
- package/src/lib/interfaces/responses/api-password-change-response.d.ts.map +1 -0
- package/src/lib/interfaces/responses/api-password-change-response.js +3 -0
- package/src/lib/interfaces/responses/api-password-change-response.js.map +1 -0
- package/src/lib/interfaces/responses/api-recovery-response.d.ts +9 -0
- package/src/lib/interfaces/responses/api-recovery-response.d.ts.map +1 -0
- package/src/lib/interfaces/responses/api-recovery-response.js +3 -0
- package/src/lib/interfaces/responses/api-recovery-response.js.map +1 -0
- package/src/lib/interfaces/responses/index.d.ts +2 -0
- package/src/lib/interfaces/responses/index.d.ts.map +1 -1
- package/src/lib/interfaces/storage/client-session.d.ts +1 -1
- package/src/lib/interfaces/storage/client-session.d.ts.map +1 -1
- package/src/lib/interfaces/storage/collection.d.ts +1 -1
- package/src/lib/interfaces/storage/collection.d.ts.map +1 -1
- package/src/lib/interfaces/storage/database-lifecycle-hooks.d.ts +1 -1
- package/src/lib/interfaces/storage/database-lifecycle-hooks.d.ts.map +1 -1
- package/src/lib/interfaces/storage/database.d.ts +1 -1
- package/src/lib/interfaces/storage/database.d.ts.map +1 -1
- package/src/lib/interfaces/storage/document-types.d.ts +1 -1
- package/src/lib/interfaces/storage/document-types.d.ts.map +1 -1
- package/src/lib/interfaces/storage/index.d.ts +1 -0
- package/src/lib/interfaces/storage/index.d.ts.map +1 -1
- package/src/lib/interfaces/storage/index.js.map +1 -1
- package/src/lib/interfaces/storage/storedDocumentTypes.d.ts +73 -0
- package/src/lib/interfaces/storage/storedDocumentTypes.d.ts.map +1 -0
- package/src/lib/interfaces/storage/storedDocumentTypes.js +15 -0
- package/src/lib/interfaces/storage/storedDocumentTypes.js.map +1 -0
- package/src/lib/plugins/brightchain-database-plugin.d.ts +31 -21
- package/src/lib/plugins/brightchain-database-plugin.d.ts.map +1 -1
- package/src/lib/plugins/brightchain-database-plugin.js +103 -53
- package/src/lib/plugins/brightchain-database-plugin.js.map +1 -1
- package/src/lib/plugins/configure-brightchain-app.d.ts.map +1 -1
- package/src/lib/plugins/configure-brightchain-app.js +5 -0
- package/src/lib/plugins/configure-brightchain-app.js.map +1 -1
- package/src/lib/services/auth.d.ts +6 -2
- package/src/lib/services/auth.d.ts.map +1 -1
- package/src/lib/services/auth.js +43 -7
- package/src/lib/services/auth.js.map +1 -1
- package/src/lib/services/backupCodeService.d.ts +35 -0
- package/src/lib/services/backupCodeService.d.ts.map +1 -0
- package/src/lib/services/backupCodeService.js +109 -0
- package/src/lib/services/backupCodeService.js.map +1 -0
- package/src/lib/services/brightchain-authentication-provider.d.ts.map +1 -1
- package/src/lib/services/brightchain-authentication-provider.js +28 -9
- package/src/lib/services/brightchain-authentication-provider.js.map +1 -1
- package/src/lib/services/brightchain-member-init.service.d.ts +39 -20
- package/src/lib/services/brightchain-member-init.service.d.ts.map +1 -1
- package/src/lib/services/brightchain-member-init.service.js +139 -53
- package/src/lib/services/brightchain-member-init.service.js.map +1 -1
- package/src/lib/services/cliOperatorPrompt.d.ts +81 -0
- package/src/lib/services/cliOperatorPrompt.d.ts.map +1 -0
- package/src/lib/services/cliOperatorPrompt.js +177 -0
- package/src/lib/services/cliOperatorPrompt.js.map +1 -0
- package/src/lib/services/contentAwareBlocksService.d.ts +92 -0
- package/src/lib/services/contentAwareBlocksService.d.ts.map +1 -0
- package/src/lib/services/contentAwareBlocksService.js +102 -0
- package/src/lib/services/contentAwareBlocksService.js.map +1 -0
- package/src/lib/services/contentIngestionService.d.ts +68 -0
- package/src/lib/services/contentIngestionService.d.ts.map +1 -0
- package/src/lib/services/contentIngestionService.js +139 -0
- package/src/lib/services/contentIngestionService.js.map +1 -0
- package/src/lib/services/identityExpirationScheduler.d.ts +77 -0
- package/src/lib/services/identityExpirationScheduler.d.ts.map +1 -0
- package/src/lib/services/identityExpirationScheduler.js +157 -0
- package/src/lib/services/identityExpirationScheduler.js.map +1 -0
- package/src/lib/services/index.d.ts +7 -0
- package/src/lib/services/index.d.ts.map +1 -1
- package/src/lib/services/index.js +7 -0
- package/src/lib/services/index.js.map +1 -1
- package/src/lib/services/quorumDatabaseAdapter.d.ts +60 -0
- package/src/lib/services/quorumDatabaseAdapter.d.ts.map +1 -0
- package/src/lib/services/quorumDatabaseAdapter.js +652 -0
- package/src/lib/services/quorumDatabaseAdapter.js.map +1 -0
- package/src/lib/services/secureKeyStorage.js +3 -3
- package/src/lib/services/secureKeyStorage.js.map +1 -1
- package/src/lib/services/sessionAdapter.d.ts +62 -0
- package/src/lib/services/sessionAdapter.d.ts.map +1 -0
- package/src/lib/services/sessionAdapter.js +105 -0
- package/src/lib/services/sessionAdapter.js.map +1 -0
- package/src/lib/utils/rehydration.d.ts +31 -0
- package/src/lib/utils/rehydration.d.ts.map +1 -0
- package/src/lib/utils/rehydration.js +111 -0
- package/src/lib/utils/rehydration.js.map +1 -0
- package/src/lib/utils/serialization.d.ts +21 -0
- package/src/lib/utils/serialization.d.ts.map +1 -0
- package/src/lib/utils/serialization.js +41 -0
- package/src/lib/utils/serialization.js.map +1 -0
- package/src/lib/validation/userValidation.d.ts +17 -0
- package/src/lib/validation/userValidation.d.ts.map +1 -1
- package/src/lib/validation/userValidation.js +77 -0
- package/src/lib/validation/userValidation.js.map +1 -1
- package/src/lib/adapters/brightChainDbDocumentStoreAdapter.d.ts +0 -24
- package/src/lib/adapters/brightChainDbDocumentStoreAdapter.d.ts.map +0 -1
- package/src/lib/adapters/brightChainDbDocumentStoreAdapter.js +0 -53
- package/src/lib/adapters/brightChainDbDocumentStoreAdapter.js.map +0 -1
- package/src/lib/datastore/document-model-adapter.d.ts +0 -48
- package/src/lib/datastore/document-model-adapter.d.ts.map +0 -1
- package/src/lib/datastore/document-model-adapter.js +0 -178
- package/src/lib/datastore/document-model-adapter.js.map +0 -1
- /package/{brightchain-api-lib/README.md → README.md} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/collection.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,YAAY,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/collection.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* This type is now defined in @digitaldefiance/node-express-suite and
|
|
5
5
|
* re-exported here for backward compatibility.
|
|
6
6
|
*/
|
|
7
|
-
export type { IDatabaseLifecycleHooks } from '@digitaldefiance/
|
|
7
|
+
export type { IDatabaseLifecycleHooks } from '@digitaldefiance/suite-core-lib';
|
|
8
8
|
//# sourceMappingURL=database-lifecycle-hooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-lifecycle-hooks.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/database-lifecycle-hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"database-lifecycle-hooks.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/database-lifecycle-hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* This type is now defined in @digitaldefiance/node-express-suite and
|
|
6
6
|
* re-exported here for backward compatibility.
|
|
7
7
|
*/
|
|
8
|
-
export type { IDatabase } from '@digitaldefiance/
|
|
8
|
+
export type { IDatabase } from '@digitaldefiance/suite-core-lib';
|
|
9
9
|
//# sourceMappingURL=database.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/database.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,YAAY,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/database.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,YAAY,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* are defined in @brightchain/brightchain-lib — import them directly from there.
|
|
6
6
|
* This file only re-exports Node.js-specific types from node-express-suite.
|
|
7
7
|
*/
|
|
8
|
-
export type { AggregationStage, BulkWriteOperation, BulkWriteOptions, BulkWriteResult, ChangeEvent, ChangeEventType, ChangeListener, ClientSession, CollectionOptions, CollectionSchema, CollectionSchemaFieldType, CursorSession, DeleteResult, FilterOperator, FilterQuery, FindOptions, IndexOptions, IndexSpec, InsertManyResult, InsertOneResult, LogicalOperators, ProjectionSpec, ReadPreference, ReplaceResult, SortSpec, TextIndexOptions, UpdateOperators, UpdateOptions, UpdateQuery, UpdateResult, WriteConcern, WriteOptions, } from '@digitaldefiance/
|
|
8
|
+
export type { AggregationStage, BulkWriteOperation, BulkWriteOptions, BulkWriteResult, ChangeEvent, ChangeEventType, ChangeListener, ClientSession, CollectionOptions, CollectionSchema, CollectionSchemaFieldType, CursorSession, DeleteResult, FilterOperator, FilterQuery, FindOptions, IndexOptions, IndexSpec, InsertManyResult, InsertOneResult, LogicalOperators, ProjectionSpec, ReadPreference, ReplaceResult, SortSpec, TextIndexOptions, UpdateOperators, UpdateOptions, UpdateQuery, UpdateResult, WriteConcern, WriteOptions, } from '@digitaldefiance/suite-core-lib';
|
|
9
9
|
//# sourceMappingURL=document-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-types.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/document-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,eAAe,EACf,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,
|
|
1
|
+
{"version":3,"file":"document-types.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/document-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,eAAe,EACf,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,iCAAiC,CAAC"}
|
|
@@ -3,6 +3,7 @@ export type * from './collection';
|
|
|
3
3
|
export type * from './database';
|
|
4
4
|
export type * from './database-lifecycle-hooks';
|
|
5
5
|
export type * from './document-types';
|
|
6
|
+
export type * from './storedDocumentTypes';
|
|
6
7
|
export { MEMBER_INDEX_SCHEMA } from './memberIndexSchema';
|
|
7
8
|
export { MNEMONICS_COLLECTION, MNEMONIC_SCHEMA } from './mnemonicSchema';
|
|
8
9
|
export { ROLES_COLLECTION, ROLE_SCHEMA } from './roleSchema';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,uBAAuB,CAAC;AAG3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/index.ts"],"names":[],"mappings":";;;AAOA,sCAAsC;AACtC,yDAA0D;AAAjD,wHAAA,mBAAmB,OAAA;AAC5B,mDAAyE;AAAhE,sHAAA,oBAAoB,OAAA;AAAE,iHAAA,eAAe,OAAA;AAC9C,2CAA6D;AAApD,8GAAA,gBAAgB,OAAA;AAAE,yGAAA,WAAW,OAAA;AACtC,mDAA2E;AAAlE,uHAAA,qBAAqB,OAAA;AAAE,kHAAA,gBAAgB,OAAA;AAChD,2CAA6D;AAApD,8GAAA,gBAAgB,OAAA;AAAE,yGAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Serialized ("stored") document interfaces for BrightChainDb collections.
|
|
3
|
+
*
|
|
4
|
+
* These represent the actual shape of documents as they exist in the database:
|
|
5
|
+
* all IDs are hex strings, all dates are ISO-8601 strings, and every interface
|
|
6
|
+
* extends BsonDocument so it can be used directly as a collection generic.
|
|
7
|
+
*
|
|
8
|
+
* The typed in-memory counterparts (IRoleBase<TID>, IUserBase<TID>, etc.) use
|
|
9
|
+
* GuidV4Buffer IDs and Date objects. Use the rehydration utilities in
|
|
10
|
+
* ../rehydration.ts to convert stored → typed, and serializeForStorage() in
|
|
11
|
+
* BrightChainMemberInitService to go typed → stored.
|
|
12
|
+
*/
|
|
13
|
+
import type { BsonDocument } from '@brightchain/brightchain-lib';
|
|
14
|
+
import type { IBackupCode } from '@digitaldefiance/suite-core-lib';
|
|
15
|
+
interface IStoredSoftDelete {
|
|
16
|
+
deletedAt?: string;
|
|
17
|
+
deletedBy?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface IStoredRole extends BsonDocument, IStoredSoftDelete {
|
|
20
|
+
_id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
admin: boolean;
|
|
23
|
+
member: boolean;
|
|
24
|
+
child: boolean;
|
|
25
|
+
system: boolean;
|
|
26
|
+
createdBy: string;
|
|
27
|
+
updatedBy: string;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
updatedAt: string;
|
|
30
|
+
}
|
|
31
|
+
export interface IStoredUser extends BsonDocument, IStoredSoftDelete {
|
|
32
|
+
_id: string;
|
|
33
|
+
username: string;
|
|
34
|
+
email: string;
|
|
35
|
+
publicKey: string;
|
|
36
|
+
passwordWrappedPrivateKey?: {
|
|
37
|
+
salt: string;
|
|
38
|
+
iv: string;
|
|
39
|
+
authTag: string;
|
|
40
|
+
ciphertext: string;
|
|
41
|
+
iterations: number;
|
|
42
|
+
};
|
|
43
|
+
mnemonicRecovery: string;
|
|
44
|
+
mnemonicId?: string;
|
|
45
|
+
backupCodes: Array<IBackupCode>;
|
|
46
|
+
accountStatus: string;
|
|
47
|
+
emailVerified: boolean;
|
|
48
|
+
directChallenge: boolean;
|
|
49
|
+
timezone: string;
|
|
50
|
+
siteLanguage: string;
|
|
51
|
+
currency: string;
|
|
52
|
+
darkMode: boolean;
|
|
53
|
+
lastLogin?: string;
|
|
54
|
+
createdBy: string;
|
|
55
|
+
updatedBy: string;
|
|
56
|
+
createdAt: string;
|
|
57
|
+
updatedAt: string;
|
|
58
|
+
}
|
|
59
|
+
export interface IStoredUserRole extends BsonDocument, IStoredSoftDelete {
|
|
60
|
+
_id: string;
|
|
61
|
+
userId: string;
|
|
62
|
+
roleId: string;
|
|
63
|
+
createdBy: string;
|
|
64
|
+
updatedBy: string;
|
|
65
|
+
createdAt: string;
|
|
66
|
+
updatedAt: string;
|
|
67
|
+
}
|
|
68
|
+
export interface IStoredMnemonic extends BsonDocument {
|
|
69
|
+
_id: string;
|
|
70
|
+
hmac: string;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=storedDocumentTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storedDocumentTypes.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/storedDocumentTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAInE,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,MAAM,WAAW,WAAY,SAAQ,YAAY,EAAE,iBAAiB;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAID,MAAM,WAAW,WAAY,SAAQ,YAAY,EAAE,iBAAiB;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,E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
+
* These represent the actual shape of documents as they exist in the database:
|
|
6
|
+
* all IDs are hex strings, all dates are ISO-8601 strings, and every interface
|
|
7
|
+
* extends BsonDocument so it can be used directly as a collection generic.
|
|
8
|
+
*
|
|
9
|
+
* The typed in-memory counterparts (IRoleBase<TID>, IUserBase<TID>, etc.) use
|
|
10
|
+
* GuidV4Buffer IDs and Date objects. Use the rehydration utilities in
|
|
11
|
+
* ../rehydration.ts to convert stored → typed, and serializeForStorage() in
|
|
12
|
+
* BrightChainMemberInitService to go typed → stored.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
//# sourceMappingURL=storedDocumentTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storedDocumentTypes.js","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/interfaces/storage/storedDocumentTypes.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG"}
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @module plugins/brightchain-database-plugin
|
|
13
13
|
*/
|
|
14
|
-
import type { IBlockStore,
|
|
14
|
+
import type { IBlockStore, IBrightChainBaseInitResult, IBrightChainMemberInitInput } from '@brightchain/brightchain-lib';
|
|
15
15
|
import { EnergyAccountStore, MemberStore } from '@brightchain/brightchain-lib';
|
|
16
16
|
import type { BrightChainDb } from '@brightchain/db';
|
|
17
17
|
import type { PlatformID } from '@digitaldefiance/node-ecies-lib';
|
|
18
|
-
import type { IApplication, IAuthenticationProvider,
|
|
18
|
+
import type { IApplication, IAuthenticationProvider, IDatabasePlugin } from '@digitaldefiance/node-express-suite';
|
|
19
|
+
import type { IDatabase } from '@digitaldefiance/suite-core-lib';
|
|
19
20
|
import type { Environment } from '../environment';
|
|
21
|
+
import type { IBrightChainMemberInitConfig } from '../interfaces/member-init-config';
|
|
20
22
|
/**
|
|
21
23
|
* BrightChain database plugin implementing IDatabasePlugin<TID>.
|
|
22
24
|
*
|
|
@@ -26,7 +28,7 @@ import type { Environment } from '../environment';
|
|
|
26
28
|
* - stop() → delegates to disconnect()
|
|
27
29
|
* - disconnect() → releases all references (idempotent)
|
|
28
30
|
*
|
|
29
|
-
* Typed accessors (blockStore, memberStore, energyStore, brightChainDb
|
|
31
|
+
* Typed accessors (blockStore, memberStore, energyStore, brightChainDb)
|
|
30
32
|
* throw descriptive errors when the plugin is not connected.
|
|
31
33
|
*/
|
|
32
34
|
export declare class BrightChainDatabasePlugin<TID extends PlatformID> implements IDatabasePlugin<TID> {
|
|
@@ -36,7 +38,6 @@ export declare class BrightChainDatabasePlugin<TID extends PlatformID> implement
|
|
|
36
38
|
private _connected;
|
|
37
39
|
private _blockStore;
|
|
38
40
|
private _brightChainDb;
|
|
39
|
-
private _documentStore;
|
|
40
41
|
private _memberStore;
|
|
41
42
|
private _energyStore;
|
|
42
43
|
private _authProvider;
|
|
@@ -56,8 +57,7 @@ export declare class BrightChainDatabasePlugin<TID extends PlatformID> implement
|
|
|
56
57
|
* Connect the BrightChain database stack.
|
|
57
58
|
*
|
|
58
59
|
* Calls brightchainDatabaseInit(environment) and stores the resulting
|
|
59
|
-
* backend references (blockStore,
|
|
60
|
-
* memberStore, energyStore).
|
|
60
|
+
* backend references (blockStore, BrightChainDb, memberStore, energyStore).
|
|
61
61
|
*
|
|
62
62
|
* @param _uri - Ignored; BrightChain uses environment-based configuration.
|
|
63
63
|
* @throws Error if brightchainDatabaseInit() returns a failure result.
|
|
@@ -106,10 +106,10 @@ export declare class BrightChainDatabasePlugin<TID extends PlatformID> implement
|
|
|
106
106
|
* Seed the dev database after connection.
|
|
107
107
|
*
|
|
108
108
|
* Called by Application.start() after connect() and init() when
|
|
109
|
-
* environment.devDatabase is truthy.
|
|
110
|
-
*
|
|
109
|
+
* environment.devDatabase is truthy. Invokes BrightChainMemberInitService
|
|
110
|
+
* to persist system/admin/member seed users into the in-memory database.
|
|
111
111
|
*/
|
|
112
|
-
initializeDevStore(): Promise<
|
|
112
|
+
initializeDevStore(): Promise<IBrightChainBaseInitResult<BrightChainDb, TID>>;
|
|
113
113
|
/**
|
|
114
114
|
* The block store backing the BrightChain database.
|
|
115
115
|
* @throws Error if the plugin is not connected.
|
|
@@ -120,11 +120,6 @@ export declare class BrightChainDatabasePlugin<TID extends PlatformID> implement
|
|
|
120
120
|
* @throws Error if the plugin is not connected.
|
|
121
121
|
*/
|
|
122
122
|
get brightChainDb(): BrightChainDb;
|
|
123
|
-
/**
|
|
124
|
-
* The document store (BrightChainDbDocumentStoreAdapter wrapping BrightChainDb).
|
|
125
|
-
* @throws Error if the plugin is not connected.
|
|
126
|
-
*/
|
|
127
|
-
get documentStore(): IDocumentStore;
|
|
128
123
|
/**
|
|
129
124
|
* The member store for user/member operations.
|
|
130
125
|
* @throws Error if the plugin is not connected.
|
|
@@ -136,15 +131,30 @@ export declare class BrightChainDatabasePlugin<TID extends PlatformID> implement
|
|
|
136
131
|
*/
|
|
137
132
|
get energyStore(): EnergyAccountStore;
|
|
138
133
|
/**
|
|
139
|
-
*
|
|
134
|
+
* Build an IBrightChainMemberInitConfig from the environment.
|
|
135
|
+
*
|
|
136
|
+
* Derives `useMemoryStore` from `!!environment.devDatabasePoolName` by default.
|
|
137
|
+
* When a dev pool name is set the store is in-memory; otherwise disk-backed.
|
|
138
|
+
*
|
|
139
|
+
* @param useMemoryStore - Optional override. Defaults to `!!environment.devDatabasePoolName`.
|
|
140
|
+
*/
|
|
141
|
+
buildMemberInitConfig(useMemoryStore?: boolean): IBrightChainMemberInitConfig;
|
|
142
|
+
/**
|
|
143
|
+
* Build an IBrightChainMemberInitInput from the environment's
|
|
144
|
+
* system/admin/member IDs and their associated member types.
|
|
145
|
+
*
|
|
146
|
+
* @throws Error if any of the required IDs are not set in the environment.
|
|
147
|
+
*/
|
|
148
|
+
buildMemberInitInput(): IBrightChainMemberInitInput<TID>;
|
|
149
|
+
/**
|
|
150
|
+
* Seed system/admin/member users into the database using
|
|
151
|
+
* BrightChainMemberInitService.
|
|
140
152
|
*
|
|
141
|
-
*
|
|
142
|
-
* BrightChainDbDocumentStoreAdapter. We need the raw BrightChainDb
|
|
143
|
-
* for the IDatabasePlugin.database property (IDatabase contract).
|
|
153
|
+
* Reusable by both dev mode (initializeDevStore) and production mode paths.
|
|
144
154
|
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
155
|
+
* @param config - The member init configuration.
|
|
156
|
+
* @returns The init result from BrightChainMemberInitService.
|
|
147
157
|
*/
|
|
148
|
-
|
|
158
|
+
seedMembers(config: IBrightChainMemberInitConfig): Promise<IBrightChainBaseInitResult<BrightChainDb, TID>>;
|
|
149
159
|
}
|
|
150
160
|
//# sourceMappingURL=brightchain-database-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brightchain-database-plugin.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/plugins/brightchain-database-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"brightchain-database-plugin.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/plugins/brightchain-database-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,0BAA0B,EAC1B,2BAA2B,EAE5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,kBAAkB,EAElB,WAAW,EACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACvB,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBA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UAAU,IAAI,WAAW,CAO5B;IAED;;;OAGG;IACH,IAAI,aAAa,IAAI,aAAa,CAOjC;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,WAAW,CAO7B;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,kBAAkB,CAOpC;IAID;;;;;;;OAOG;IACH,qBAAqB,CACnB,cAAc,GAAE,OAAiD,GAChE,4BAA4B;IAY/B;;;;;OAKG;IACH,oBAAoB,IAAI,2BAA2B,CAAC,GAAG,CAAC;IAiBxD;;;;;;;;OAQG;IACG,WAAW,CACf,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,0BAA0B,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;CA4D3D"}
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.BrightChainDatabasePlugin = void 0;
|
|
17
|
-
const
|
|
17
|
+
const brightchain_lib_1 = require("@brightchain/brightchain-lib");
|
|
18
|
+
const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
|
|
18
19
|
const databaseInit_1 = require("../databaseInit");
|
|
19
20
|
const brightchain_authentication_provider_1 = require("../services/brightchain-authentication-provider");
|
|
20
21
|
/**
|
|
@@ -26,7 +27,7 @@ const brightchain_authentication_provider_1 = require("../services/brightchain-a
|
|
|
26
27
|
* - stop() → delegates to disconnect()
|
|
27
28
|
* - disconnect() → releases all references (idempotent)
|
|
28
29
|
*
|
|
29
|
-
* Typed accessors (blockStore, memberStore, energyStore, brightChainDb
|
|
30
|
+
* Typed accessors (blockStore, memberStore, energyStore, brightChainDb)
|
|
30
31
|
* throw descriptive errors when the plugin is not connected.
|
|
31
32
|
*/
|
|
32
33
|
class BrightChainDatabasePlugin {
|
|
@@ -36,7 +37,6 @@ class BrightChainDatabasePlugin {
|
|
|
36
37
|
this._connected = false;
|
|
37
38
|
this._blockStore = null;
|
|
38
39
|
this._brightChainDb = null;
|
|
39
|
-
this._documentStore = null;
|
|
40
40
|
this._memberStore = null;
|
|
41
41
|
this._energyStore = null;
|
|
42
42
|
this._authProvider = null;
|
|
@@ -65,8 +65,7 @@ class BrightChainDatabasePlugin {
|
|
|
65
65
|
* Connect the BrightChain database stack.
|
|
66
66
|
*
|
|
67
67
|
* Calls brightchainDatabaseInit(environment) and stores the resulting
|
|
68
|
-
* backend references (blockStore,
|
|
69
|
-
* memberStore, energyStore).
|
|
68
|
+
* backend references (blockStore, BrightChainDb, memberStore, energyStore).
|
|
70
69
|
*
|
|
71
70
|
* @param _uri - Ignored; BrightChain uses environment-based configuration.
|
|
72
71
|
* @throws Error if brightchainDatabaseInit() returns a failure result.
|
|
@@ -78,15 +77,15 @@ class BrightChainDatabasePlugin {
|
|
|
78
77
|
}
|
|
79
78
|
const { blockStore, db, memberStore, energyStore } = initResult.backend;
|
|
80
79
|
this._blockStore = blockStore;
|
|
81
|
-
this.
|
|
80
|
+
this._brightChainDb = db;
|
|
82
81
|
this._memberStore = memberStore;
|
|
83
82
|
this._energyStore = energyStore;
|
|
84
|
-
// BrightChainDb is the underlying database behind the documentStore adapter.
|
|
85
|
-
// brightchainDatabaseInit() creates BrightChainDb and wraps it in
|
|
86
|
-
// BrightChainDbDocumentStoreAdapter. We extract the raw BrightChainDb
|
|
87
|
-
// for the IDatabasePlugin.database property (IDatabase contract).
|
|
88
|
-
this._brightChainDb = this.extractBrightChainDb(db);
|
|
89
83
|
this._connected = true;
|
|
84
|
+
// Seed system/admin/member users into the database.
|
|
85
|
+
// Runs for both dev and production modes; idempotent if called again
|
|
86
|
+
// via initializeDevStore().
|
|
87
|
+
const config = this.buildMemberInitConfig();
|
|
88
|
+
await this.seedMembers(config);
|
|
90
89
|
}
|
|
91
90
|
/**
|
|
92
91
|
* Disconnect and release all backend references.
|
|
@@ -96,12 +95,8 @@ class BrightChainDatabasePlugin {
|
|
|
96
95
|
if (!this._connected) {
|
|
97
96
|
return;
|
|
98
97
|
}
|
|
99
|
-
if (this._brightChainDb?.isConnected()) {
|
|
100
|
-
await this._brightChainDb.disconnect();
|
|
101
|
-
}
|
|
102
98
|
this._blockStore = null;
|
|
103
99
|
this._brightChainDb = null;
|
|
104
|
-
this._documentStore = null;
|
|
105
100
|
this._memberStore = null;
|
|
106
101
|
this._energyStore = null;
|
|
107
102
|
this._authProvider = null;
|
|
@@ -130,14 +125,6 @@ class BrightChainDatabasePlugin {
|
|
|
130
125
|
await this.disconnect();
|
|
131
126
|
}
|
|
132
127
|
// ── Dev store lifecycle hooks ─────────────────────────────────────
|
|
133
|
-
// These are the BrightChain equivalents of the Mongo plugin's
|
|
134
|
-
// MongoMemoryReplSet provisioning. When environment.devDatabase is
|
|
135
|
-
// truthy, the upstream Application.start() calls setupDevStore()
|
|
136
|
-
// before connect() and initializeDevStore() after init().
|
|
137
|
-
//
|
|
138
|
-
// For BrightChain, "dev store" means using a MemoryBlockStore with
|
|
139
|
-
// an InMemoryHeadRegistry — brightchainDatabaseInit() already handles
|
|
140
|
-
// this when environment.blockStorePath is not set.
|
|
141
128
|
/**
|
|
142
129
|
* Provision an ephemeral dev/test block store.
|
|
143
130
|
*
|
|
@@ -165,11 +152,12 @@ class BrightChainDatabasePlugin {
|
|
|
165
152
|
* Seed the dev database after connection.
|
|
166
153
|
*
|
|
167
154
|
* Called by Application.start() after connect() and init() when
|
|
168
|
-
* environment.devDatabase is truthy.
|
|
169
|
-
*
|
|
155
|
+
* environment.devDatabase is truthy. Invokes BrightChainMemberInitService
|
|
156
|
+
* to persist system/admin/member seed users into the in-memory database.
|
|
170
157
|
*/
|
|
171
158
|
async initializeDevStore() {
|
|
172
|
-
|
|
159
|
+
const config = this.buildMemberInitConfig();
|
|
160
|
+
return this.seedMembers(config);
|
|
173
161
|
}
|
|
174
162
|
// ── Typed accessors ───────────────────────────────────────────────
|
|
175
163
|
/**
|
|
@@ -192,16 +180,6 @@ class BrightChainDatabasePlugin {
|
|
|
192
180
|
}
|
|
193
181
|
return this._brightChainDb;
|
|
194
182
|
}
|
|
195
|
-
/**
|
|
196
|
-
* The document store (BrightChainDbDocumentStoreAdapter wrapping BrightChainDb).
|
|
197
|
-
* @throws Error if the plugin is not connected.
|
|
198
|
-
*/
|
|
199
|
-
get documentStore() {
|
|
200
|
-
if (!this._documentStore) {
|
|
201
|
-
throw new Error('BrightChainDatabasePlugin: cannot access "documentStore" — plugin is not connected. Call connect() first.');
|
|
202
|
-
}
|
|
203
|
-
return this._documentStore;
|
|
204
|
-
}
|
|
205
183
|
/**
|
|
206
184
|
* The member store for user/member operations.
|
|
207
185
|
* @throws Error if the plugin is not connected.
|
|
@@ -224,28 +202,100 @@ class BrightChainDatabasePlugin {
|
|
|
224
202
|
}
|
|
225
203
|
// ── Private helpers ───────────────────────────────────────────────
|
|
226
204
|
/**
|
|
227
|
-
*
|
|
205
|
+
* Build an IBrightChainMemberInitConfig from the environment.
|
|
228
206
|
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* for the IDatabasePlugin.database property (IDatabase contract).
|
|
207
|
+
* Derives `useMemoryStore` from `!!environment.devDatabasePoolName` by default.
|
|
208
|
+
* When a dev pool name is set the store is in-memory; otherwise disk-backed.
|
|
232
209
|
*
|
|
233
|
-
*
|
|
234
|
-
* `db` property (TypeScript `private` is compile-time only).
|
|
210
|
+
* @param useMemoryStore - Optional override. Defaults to `!!environment.devDatabasePoolName`.
|
|
235
211
|
*/
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
212
|
+
buildMemberInitConfig(useMemoryStore = !!this._environment.devDatabasePoolName) {
|
|
213
|
+
const env = this._environment;
|
|
214
|
+
return {
|
|
215
|
+
memberPoolName: useMemoryStore
|
|
216
|
+
? (env.devDatabasePoolName ?? env.memberPoolName)
|
|
217
|
+
: env.memberPoolName,
|
|
218
|
+
blockStorePath: env.blockStorePath,
|
|
219
|
+
useMemoryStore,
|
|
220
|
+
blockSize: env.blockStoreBlockSize,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Build an IBrightChainMemberInitInput from the environment's
|
|
225
|
+
* system/admin/member IDs and their associated member types.
|
|
226
|
+
*
|
|
227
|
+
* @throws Error if any of the required IDs are not set in the environment.
|
|
228
|
+
*/
|
|
229
|
+
buildMemberInitInput() {
|
|
230
|
+
const env = this._environment;
|
|
231
|
+
if (!env.systemId || !env.adminId || !env.memberId) {
|
|
232
|
+
throw new Error('BrightChainDatabasePlugin: cannot seed members — one or more user IDs ' +
|
|
233
|
+
'(systemId, adminId, memberId) are not set in the environment.');
|
|
239
234
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
235
|
+
return {
|
|
236
|
+
systemUser: { id: env.systemId, type: ecies_lib_1.MemberType.System },
|
|
237
|
+
adminUser: { id: env.adminId, type: ecies_lib_1.MemberType.User },
|
|
238
|
+
memberUser: { id: env.memberId, type: ecies_lib_1.MemberType.User },
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Seed system/admin/member users into the database using
|
|
243
|
+
* BrightChainMemberInitService.
|
|
244
|
+
*
|
|
245
|
+
* Reusable by both dev mode (initializeDevStore) and production mode paths.
|
|
246
|
+
*
|
|
247
|
+
* @param config - The member init configuration.
|
|
248
|
+
* @returns The init result from BrightChainMemberInitService.
|
|
249
|
+
*/
|
|
250
|
+
async seedMembers(config) {
|
|
251
|
+
const input = this.buildMemberInitInput();
|
|
252
|
+
const db = this.brightChainDb;
|
|
253
|
+
// Build candidate member index documents
|
|
254
|
+
const now = new Date().toISOString();
|
|
255
|
+
const candidates = [
|
|
256
|
+
input.systemUser,
|
|
257
|
+
input.adminUser,
|
|
258
|
+
input.memberUser,
|
|
259
|
+
].map((user) => ({
|
|
260
|
+
id: user.id.toString('hex'),
|
|
261
|
+
publicCBL: '0'.repeat(64),
|
|
262
|
+
privateCBL: '0'.repeat(64),
|
|
263
|
+
poolId: config.memberPoolName,
|
|
264
|
+
type: user.type,
|
|
265
|
+
status: brightchain_lib_1.MemberStatusType.Active,
|
|
266
|
+
lastUpdate: now,
|
|
267
|
+
reputation: 0,
|
|
268
|
+
}));
|
|
269
|
+
// Idempotency check
|
|
270
|
+
const collection = db.collection('member_index');
|
|
271
|
+
const existing = await collection.find({}).toArray();
|
|
272
|
+
const existingIds = new Set(existing.map((e) => e.id));
|
|
273
|
+
const toInsert = candidates.filter((c) => !existingIds.has(c.id));
|
|
274
|
+
const skippedCount = candidates.length - toInsert.length;
|
|
275
|
+
if (toInsert.length === 0) {
|
|
276
|
+
console.log(`[BrightChain] Member seeding: already initialized (${skippedCount} skipped).`);
|
|
277
|
+
return {
|
|
278
|
+
input,
|
|
279
|
+
alreadyInitialized: true,
|
|
280
|
+
insertedCount: 0,
|
|
281
|
+
skippedCount,
|
|
282
|
+
db,
|
|
283
|
+
};
|
|
247
284
|
}
|
|
248
|
-
|
|
285
|
+
// Insert missing entries
|
|
286
|
+
await db.withTransaction(async (session) => {
|
|
287
|
+
for (const entry of toInsert) {
|
|
288
|
+
await collection.insertOne(entry, { session });
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
console.log(`[BrightChain] Member seeding: ${toInsert.length} inserted, ${skippedCount} skipped.`);
|
|
292
|
+
return {
|
|
293
|
+
input,
|
|
294
|
+
alreadyInitialized: false,
|
|
295
|
+
insertedCount: toInsert.length,
|
|
296
|
+
skippedCount,
|
|
297
|
+
db,
|
|
298
|
+
};
|
|
249
299
|
}
|
|
250
300
|
}
|
|
251
301
|
exports.BrightChainDatabasePlugin = BrightChainDatabasePlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brightchain-database-plugin.js","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/plugins/brightchain-database-plugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;
|
|
1
|
+
{"version":3,"file":"brightchain-database-plugin.js","sourceRoot":"","sources":["../../../../../brightchain-api-l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AC;YACjD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CACT,iCAAiC,QAAQ,CAAC,MAAM,cAAc,YAAY,WAAW,CACtF,CAAC;QAEF,OAAO;YACL,KAAK;YACL,kBAAkB,EAAE,KAAK;YACzB,aAAa,EAAE,QAAQ,CAAC,MAAM;YAC9B,YAAY;YACZ,EAAE;SACH,CAAC;IACJ,CAAC;CACF;AA9UD,8DA8UC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure-brightchain-app.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/plugins/configure-brightchain-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"configure-brightchain-app.d.ts","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/plugins/configure-brightchain-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAKlE,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACX,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E;;;GAGG;AACH,MAAM,WAAW,0BAA0B,CAAC,GAAG,SAAS,UAAU;IAChE,MAAM,EAAE,yBAAyB,CAAC,GAAG,CAAC,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,SAAS,UAAU,EAC5D,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,EACtB,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC,EAC7B,SAAS,GAAE,UAAyB,GACnC,0BAA0B,CAAC,GAAG,CAAC,CA6CjC"}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.configureBrightChainApp = configureBrightChainApp;
|
|
14
|
+
const brightchain_lib_1 = require("@brightchain/brightchain-lib");
|
|
14
15
|
const node_ecies_lib_1 = require("@digitaldefiance/node-ecies-lib");
|
|
15
16
|
const appConstants_1 = require("../appConstants");
|
|
16
17
|
const brightchain_database_plugin_1 = require("./brightchain-database-plugin");
|
|
@@ -53,6 +54,10 @@ function configureBrightChainApp(app, environment, constants = appConstants_1.Ap
|
|
|
53
54
|
}
|
|
54
55
|
// 2. Register node runtime configuration
|
|
55
56
|
(0, node_ecies_lib_1.registerNodeRuntimeConfiguration)('guid-config', constants);
|
|
57
|
+
// 2b. Initialize BrightChain library (registers BRIGHTCHAIN_CONFIG_KEY
|
|
58
|
+
// config with GuidV4Provider and creates the ServiceProvider singleton
|
|
59
|
+
// so that getGlobalServiceProvider() works during seedMembers).
|
|
60
|
+
(0, brightchain_lib_1.initializeBrightChain)();
|
|
56
61
|
// 3. Create and register database plugin
|
|
57
62
|
const plugin = new brightchain_database_plugin_1.BrightChainDatabasePlugin(environment);
|
|
58
63
|
// Application (HTTP) exposes useDatabasePlugin() which stores the plugin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure-brightchain-app.js","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/plugins/configure-brightchain-app.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;
|
|
1
|
+
{"version":3,"file":"configure-brightchain-app.js","sourceRoot":"","sources":["../../../../../brightchain-api-lib/src/lib/plugins/configure-brightchain-app.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AA0CH,0DAiDC;AAzFD,kEAAqE;AAErE,oEAGyC;AAKzC,kDAA+C;AAE/C,+EAA0E;AAU1E;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,uBAAuB,CACrC,GAAsB,EACtB,WAA6B,EAC7B,YAAwB,2BAAY;IAEpC,4DAA4D;IAC5D,MAAM,YAAY,GAAG,IAAI,+BAAc,EAAE,CAAC;IAC1C,SAAS,CAAC,UAAU,GAAG,YAAY,CAAC;IACpC,SAAS,CAAC,gBAAgB,GAAG,YAAY,CAAC,UAAU,CAAC;IACrD,SAAS,CAAC,KAAK,GAAG;QAChB,GAAG,SAAS,CAAC,KAAK;QAClB,QAAQ,EAAE;YACR,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ;YAC3B,iBAAiB,EAAE,YAAY,CAAC,UAAU;SAC3C;KACF,CAAC;IAEF,sDAAsD;IACtD,IAAI,YAAY,IAAI,SAAS,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;QACtD,SAAS,CAAC,UAAU,GAAG;YACrB,GAAG,SAAS,CAAC,UAAU;YACvB,iBAAiB,EAAE,YAAY,CAAC,UAAU;SAC3C,CAAC;IACJ,CAAC;IAED,yCAAyC;IACzC,IAAA,iDAAgC,EAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAE3D,uEAAuE;IACvE,2EAA2E;IAC3E,oEAAoE;IACpE,IAAA,uCAAqB,GAAE,CAAC;IAExB,yCAAyC;IACzC,MAAM,MAAM,GAAG,IAAI,uDAAyB,CAAM,WAAW,CAAC,CAAC;IAE/D,yEAAyE;IACzE,2EAA2E;IAC3E,kEAAkE;IAClE,IACE,mBAAmB,IAAI,GAAG;QAC1B,OAAO,GAAG,CAAC,iBAAiB,KAAK,UAAU,EAC3C,CAAC;QACD,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnergyAccountStore, MemberStore } from '@brightchain/brightchain-lib';
|
|
1
|
+
import { EnergyAccountStore, IRecoveryResponse, MemberStore } from '@brightchain/brightchain-lib';
|
|
2
2
|
import { MemberType, SecureString } from '@digitaldefiance/ecies-lib';
|
|
3
3
|
import { PlatformID } from '@digitaldefiance/node-ecies-lib';
|
|
4
4
|
import { IBrightChainApplication } from '../interfaces/application';
|
|
@@ -7,19 +7,23 @@ import { IAuthToken } from '../interfaces/auth-token';
|
|
|
7
7
|
import { ITokenPayload } from '../interfaces/token-payload';
|
|
8
8
|
import { DefaultBackendIdType } from '../shared-types';
|
|
9
9
|
import { BaseService } from './base';
|
|
10
|
+
import { BrightChainAuthenticationProvider } from './brightchain-authentication-provider';
|
|
10
11
|
import { EmailService } from './email';
|
|
11
12
|
export declare class AuthService<TID extends PlatformID = DefaultBackendIdType> extends BaseService<TID> {
|
|
12
13
|
private memberStore;
|
|
13
14
|
private energyStore;
|
|
14
15
|
private emailService;
|
|
15
16
|
private jwtSecret;
|
|
16
|
-
|
|
17
|
+
private authProvider?;
|
|
18
|
+
constructor(application: IBrightChainApplication<TID>, memberStore: MemberStore, energyStore: EnergyAccountStore, emailService: EmailService<TID>, jwtSecret: string, authProvider?: BrightChainAuthenticationProvider<TID>);
|
|
17
19
|
register(username: string, email: string, password: SecureString, _mnemonic?: SecureString): Promise<IAuthToken>;
|
|
18
20
|
login(credentials: IAuthCredentials): Promise<IAuthToken>;
|
|
19
21
|
signToken(memberId: string, username: string, type: MemberType): string;
|
|
20
22
|
verifyToken(token: string): Promise<ITokenPayload>;
|
|
21
23
|
storePasswordHash(memberId: Uint8Array, hash: string): Promise<void>;
|
|
22
24
|
getPasswordHash(memberId: Uint8Array): Promise<string>;
|
|
25
|
+
changePassword(memberId: Uint8Array, currentPassword: string, newPassword: string): Promise<void>;
|
|
26
|
+
recoverWithMnemonic(email: string, mnemonic: SecureString, newPassword?: string): Promise<IRecoveryResponse<string>>;
|
|
23
27
|
private sendWelcomeEmail;
|
|
24
28
|
}
|
|
25
29
|
//# sourceMappingURL=auth.d.ts.map
|