@brightchain/brightchain-api-lib 0.14.0 → 0.16.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 +5 -5
- package/src/browser.d.ts +13 -0
- package/src/browser.d.ts.map +1 -0
- package/src/browser.js +16 -0
- package/src/browser.js.map +1 -0
- package/src/index.d.ts +4 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +6 -1
- package/src/index.js.map +1 -1
- package/src/lib/application-base.d.ts +8 -37
- package/src/lib/application-base.d.ts.map +1 -1
- package/src/lib/application-base.js +8 -80
- package/src/lib/application-base.js.map +1 -1
- package/src/lib/application.d.ts +37 -7
- package/src/lib/application.d.ts.map +1 -1
- package/src/lib/application.js +130 -118
- package/src/lib/application.js.map +1 -1
- package/src/lib/auth/aclEnforcedAvailability.d.ts +57 -0
- package/src/lib/auth/aclEnforcedAvailability.d.ts.map +1 -0
- package/src/lib/auth/aclEnforcedAvailability.js +87 -0
- package/src/lib/auth/aclEnforcedAvailability.js.map +1 -0
- package/src/lib/auth/aclEnforcedBlockStore.d.ts +66 -0
- package/src/lib/auth/aclEnforcedBlockStore.d.ts.map +1 -0
- package/src/lib/auth/aclEnforcedBlockStore.js +83 -0
- package/src/lib/auth/aclEnforcedBlockStore.js.map +1 -0
- package/src/lib/auth/ecdsaNodeAuthenticator.d.ts +46 -0
- package/src/lib/auth/ecdsaNodeAuthenticator.d.ts.map +1 -0
- package/src/lib/auth/ecdsaNodeAuthenticator.js +110 -0
- package/src/lib/auth/ecdsaNodeAuthenticator.js.map +1 -0
- package/src/lib/auth/index.d.ts +7 -0
- package/src/lib/auth/index.d.ts.map +1 -0
- package/src/lib/auth/index.js +13 -0
- package/src/lib/auth/index.js.map +1 -0
- package/src/lib/auth/poolAclBootstrap.d.ts +36 -0
- package/src/lib/auth/poolAclBootstrap.d.ts.map +1 -0
- package/src/lib/auth/poolAclBootstrap.js +64 -0
- package/src/lib/auth/poolAclBootstrap.js.map +1 -0
- package/src/lib/auth/poolAclStore.d.ts +77 -0
- package/src/lib/auth/poolAclStore.d.ts.map +1 -0
- package/src/lib/auth/poolAclStore.js +189 -0
- package/src/lib/auth/poolAclStore.js.map +1 -0
- package/src/lib/auth/poolAclUpdater.d.ts +79 -0
- package/src/lib/auth/poolAclUpdater.d.ts.map +1 -0
- package/src/lib/auth/poolAclUpdater.js +144 -0
- package/src/lib/auth/poolAclUpdater.js.map +1 -0
- package/src/lib/availability/availabilityService.d.ts +2 -2
- package/src/lib/availability/availabilityService.d.ts.map +1 -1
- package/src/lib/availability/availabilityService.js +12 -5
- package/src/lib/availability/availabilityService.js.map +1 -1
- package/src/lib/availability/blockRegistry.d.ts +45 -3
- package/src/lib/availability/blockRegistry.d.ts.map +1 -1
- package/src/lib/availability/blockRegistry.js +123 -5
- package/src/lib/availability/blockRegistry.js.map +1 -1
- package/src/lib/availability/discoveryProtocol.d.ts +30 -1
- package/src/lib/availability/discoveryProtocol.d.ts.map +1 -1
- package/src/lib/availability/discoveryProtocol.js +76 -0
- package/src/lib/availability/discoveryProtocol.js.map +1 -1
- package/src/lib/availability/gossipService.d.ts +45 -6
- package/src/lib/availability/gossipService.d.ts.map +1 -1
- package/src/lib/availability/gossipService.js +177 -5
- package/src/lib/availability/gossipService.js.map +1 -1
- package/src/lib/availability/reconciliationService.d.ts +88 -1
- package/src/lib/availability/reconciliationService.d.ts.map +1 -1
- package/src/lib/availability/reconciliationService.js +246 -48
- package/src/lib/availability/reconciliationService.js.map +1 -1
- package/src/lib/blockFetch/blockFetcher.d.ts +100 -0
- package/src/lib/blockFetch/blockFetcher.d.ts.map +1 -0
- package/src/lib/blockFetch/blockFetcher.js +279 -0
- package/src/lib/blockFetch/blockFetcher.js.map +1 -0
- package/src/lib/blockFetch/fetchQueue.d.ts +88 -0
- package/src/lib/blockFetch/fetchQueue.d.ts.map +1 -0
- package/src/lib/blockFetch/fetchQueue.js +204 -0
- package/src/lib/blockFetch/fetchQueue.js.map +1 -0
- package/src/lib/blockFetch/httpBlockFetchTransport.d.ts +65 -0
- package/src/lib/blockFetch/httpBlockFetchTransport.d.ts.map +1 -0
- package/src/lib/blockFetch/httpBlockFetchTransport.js +104 -0
- package/src/lib/blockFetch/httpBlockFetchTransport.js.map +1 -0
- package/src/lib/blockFetch/index.d.ts +10 -0
- package/src/lib/blockFetch/index.d.ts.map +1 -0
- package/src/lib/blockFetch/index.js +13 -0
- package/src/lib/blockFetch/index.js.map +1 -0
- package/src/lib/constants.js +2 -2
- package/src/lib/constants.js.map +1 -1
- package/src/lib/controllers/api/blocks.d.ts.map +1 -1
- package/src/lib/controllers/api/blocks.js +290 -290
- package/src/lib/controllers/api/blocks.js.map +1 -1
- package/src/lib/controllers/api/brightpass.d.ts +72 -0
- package/src/lib/controllers/api/brightpass.d.ts.map +1 -0
- package/src/lib/controllers/api/brightpass.js +577 -0
- package/src/lib/controllers/api/brightpass.js.map +1 -0
- package/src/lib/controllers/api/channels.d.ts +122 -0
- package/src/lib/controllers/api/channels.d.ts.map +1 -0
- package/src/lib/controllers/api/channels.js +701 -0
- package/src/lib/controllers/api/channels.js.map +1 -0
- package/src/lib/controllers/api/conversations.d.ts +89 -0
- package/src/lib/controllers/api/conversations.d.ts.map +1 -0
- package/src/lib/controllers/api/conversations.js +259 -0
- package/src/lib/controllers/api/conversations.js.map +1 -0
- package/src/lib/controllers/api/emails.d.ts +122 -0
- package/src/lib/controllers/api/emails.d.ts.map +1 -0
- package/src/lib/controllers/api/emails.js +494 -0
- package/src/lib/controllers/api/emails.js.map +1 -0
- package/src/lib/controllers/api/energy.d.ts.map +1 -1
- package/src/lib/controllers/api/energy.js +93 -93
- package/src/lib/controllers/api/energy.js.map +1 -1
- package/src/lib/controllers/api/explodingMessages.d.ts +79 -0
- package/src/lib/controllers/api/explodingMessages.d.ts.map +1 -0
- package/src/lib/controllers/api/explodingMessages.js +378 -0
- package/src/lib/controllers/api/explodingMessages.js.map +1 -0
- package/src/lib/controllers/api/groups.d.ts +94 -0
- package/src/lib/controllers/api/groups.d.ts.map +1 -0
- package/src/lib/controllers/api/groups.js +484 -0
- package/src/lib/controllers/api/groups.js.map +1 -0
- package/src/lib/controllers/api/i18n.d.ts.map +1 -1
- package/src/lib/controllers/api/i18n.js +8 -8
- package/src/lib/controllers/api/i18n.js.map +1 -1
- package/src/lib/controllers/api/index.d.ts +6 -0
- package/src/lib/controllers/api/index.d.ts.map +1 -1
- package/src/lib/controllers/api/index.js +6 -0
- package/src/lib/controllers/api/index.js.map +1 -1
- package/src/lib/controllers/api/messages.d.ts.map +1 -1
- package/src/lib/controllers/api/messages.js +2 -1
- package/src/lib/controllers/api/messages.js.map +1 -1
- package/src/lib/controllers/api/quorum.d.ts.map +1 -1
- package/src/lib/controllers/api/quorum.js +483 -483
- package/src/lib/controllers/api/quorum.js.map +1 -1
- package/src/lib/controllers/api/sessions.d.ts.map +1 -1
- package/src/lib/controllers/api/sessions.js +8 -8
- package/src/lib/controllers/api/sessions.js.map +1 -1
- package/src/lib/controllers/api/sync.d.ts +38 -2
- package/src/lib/controllers/api/sync.d.ts.map +1 -1
- package/src/lib/controllers/api/sync.js +89 -0
- package/src/lib/controllers/api/sync.js.map +1 -1
- package/src/lib/controllers/api/user.d.ts.map +1 -1
- package/src/lib/controllers/api/user.js +180 -180
- package/src/lib/controllers/api/user.js.map +1 -1
- package/src/lib/controllers/crypto/gitController.d.ts +70 -0
- package/src/lib/controllers/crypto/gitController.d.ts.map +1 -0
- package/src/lib/controllers/crypto/gitController.js +306 -0
- package/src/lib/controllers/crypto/gitController.js.map +1 -0
- package/src/lib/controllers/crypto/index.d.ts +3 -0
- package/src/lib/controllers/crypto/index.d.ts.map +1 -0
- package/src/lib/controllers/crypto/index.js +6 -0
- package/src/lib/controllers/crypto/index.js.map +1 -0
- package/src/lib/controllers/crypto/walletController.d.ts +64 -0
- package/src/lib/controllers/crypto/walletController.d.ts.map +1 -0
- package/src/lib/controllers/crypto/walletController.js +260 -0
- package/src/lib/controllers/crypto/walletController.js.map +1 -0
- package/src/lib/controllers/identity/deviceController.d.ts +96 -0
- package/src/lib/controllers/identity/deviceController.d.ts.map +1 -0
- package/src/lib/controllers/identity/deviceController.js +355 -0
- package/src/lib/controllers/identity/deviceController.js.map +1 -0
- package/src/lib/controllers/identity/directoryController.d.ts +75 -0
- package/src/lib/controllers/identity/directoryController.d.ts.map +1 -0
- package/src/lib/controllers/identity/directoryController.js +288 -0
- package/src/lib/controllers/identity/directoryController.js.map +1 -0
- package/src/lib/controllers/identity/identityProofController.d.ts +94 -0
- package/src/lib/controllers/identity/identityProofController.d.ts.map +1 -0
- package/src/lib/controllers/identity/identityProofController.js +454 -0
- package/src/lib/controllers/identity/identityProofController.js.map +1 -0
- package/src/lib/controllers/identity/index.d.ts +4 -0
- package/src/lib/controllers/identity/index.d.ts.map +1 -0
- package/src/lib/controllers/identity/index.js +7 -0
- package/src/lib/controllers/identity/index.js.map +1 -0
- package/src/lib/controllers/index.d.ts +2 -0
- package/src/lib/controllers/index.d.ts.map +1 -1
- package/src/lib/controllers/index.js +2 -0
- package/src/lib/controllers/index.js.map +1 -1
- package/src/lib/encryption/encryptedMetadataService.d.ts +87 -0
- package/src/lib/encryption/encryptedMetadataService.d.ts.map +1 -0
- package/src/lib/encryption/encryptedMetadataService.js +224 -0
- package/src/lib/encryption/encryptedMetadataService.js.map +1 -0
- package/src/lib/encryption/encryptionAwareReplication.d.ts +76 -0
- package/src/lib/encryption/encryptionAwareReplication.d.ts.map +1 -0
- package/src/lib/encryption/encryptionAwareReplication.js +116 -0
- package/src/lib/encryption/encryptionAwareReplication.js.map +1 -0
- package/src/lib/encryption/errors.d.ts +49 -0
- package/src/lib/encryption/errors.d.ts.map +1 -0
- package/src/lib/encryption/errors.js +80 -0
- package/src/lib/encryption/errors.js.map +1 -0
- package/src/lib/encryption/index.d.ts +6 -0
- package/src/lib/encryption/index.d.ts.map +1 -0
- package/src/lib/encryption/index.js +9 -0
- package/src/lib/encryption/index.js.map +1 -0
- package/src/lib/encryption/poolEncryptionService.d.ts +94 -0
- package/src/lib/encryption/poolEncryptionService.d.ts.map +1 -0
- package/src/lib/encryption/poolEncryptionService.js +252 -0
- package/src/lib/encryption/poolEncryptionService.js.map +1 -0
- package/src/lib/encryption/poolKeyManager.d.ts +82 -0
- package/src/lib/encryption/poolKeyManager.d.ts.map +1 -0
- package/src/lib/encryption/poolKeyManager.js +156 -0
- package/src/lib/encryption/poolKeyManager.js.map +1 -0
- package/src/lib/environment.d.ts +3 -0
- package/src/lib/environment.d.ts.map +1 -1
- package/src/lib/environment.js +5 -0
- package/src/lib/environment.js.map +1 -1
- package/src/lib/interfaces/application.d.ts +7 -1
- package/src/lib/interfaces/application.d.ts.map +1 -1
- package/src/lib/interfaces/brightchain-init-result.d.ts +17 -0
- package/src/lib/interfaces/brightchain-init-result.d.ts.map +1 -0
- package/src/lib/interfaces/brightchain-init-result.js +9 -0
- package/src/lib/interfaces/brightchain-init-result.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/index.d.ts +1 -1
- package/src/lib/interfaces/index.d.ts.map +1 -1
- package/src/lib/interfaces/requests/getBlockDataRequest.d.ts +12 -0
- package/src/lib/interfaces/requests/getBlockDataRequest.d.ts.map +1 -0
- package/src/lib/interfaces/{blockStore.js → requests/getBlockDataRequest.js} +1 -1
- package/src/lib/interfaces/requests/getBlockDataRequest.js.map +1 -0
- package/src/lib/interfaces/requests/index.d.ts +1 -0
- package/src/lib/interfaces/requests/index.d.ts.map +1 -1
- package/src/lib/routers/api.d.ts +54 -1
- package/src/lib/routers/api.d.ts.map +1 -1
- package/src/lib/routers/api.js +77 -0
- package/src/lib/routers/api.js.map +1 -1
- package/src/lib/routers/app.d.ts +22 -14
- package/src/lib/routers/app.d.ts.map +1 -1
- package/src/lib/routers/app.js +28 -116
- package/src/lib/routers/app.js.map +1 -1
- package/src/lib/services/blockStore.d.ts +5 -2
- package/src/lib/services/blockStore.d.ts.map +1 -1
- package/src/lib/services/blockStore.js +4 -0
- package/src/lib/services/blockStore.js.map +1 -1
- package/src/lib/services/brightpass/auditLogger.d.ts +77 -0
- package/src/lib/services/brightpass/auditLogger.d.ts.map +1 -0
- package/src/lib/services/brightpass/auditLogger.js +184 -0
- package/src/lib/services/brightpass/auditLogger.js.map +1 -0
- package/src/lib/services/brightpass/vaultEncryption.d.ts +82 -0
- package/src/lib/services/brightpass/vaultEncryption.d.ts.map +1 -0
- package/src/lib/services/brightpass/vaultEncryption.js +144 -0
- package/src/lib/services/brightpass/vaultEncryption.js.map +1 -0
- package/src/lib/services/brightpass.d.ts +294 -0
- package/src/lib/services/brightpass.d.ts.map +1 -0
- package/src/lib/services/brightpass.js +1260 -0
- package/src/lib/services/brightpass.js.map +1 -0
- package/src/lib/services/brightpass.property.helpers.d.ts +23 -0
- package/src/lib/services/brightpass.property.helpers.d.ts.map +1 -0
- package/src/lib/services/brightpass.property.helpers.js +113 -0
- package/src/lib/services/brightpass.property.helpers.js.map +1 -0
- package/src/lib/services/eventNotificationSystem.d.ts +69 -3
- package/src/lib/services/eventNotificationSystem.d.ts.map +1 -1
- package/src/lib/services/eventNotificationSystem.js +200 -0
- package/src/lib/services/eventNotificationSystem.js.map +1 -1
- package/src/lib/services/expirationScheduler.d.ts +90 -0
- package/src/lib/services/expirationScheduler.d.ts.map +1 -0
- package/src/lib/services/expirationScheduler.js +131 -0
- package/src/lib/services/expirationScheduler.js.map +1 -0
- package/src/lib/services/fecUsageExample.d.ts +2 -2
- package/src/lib/services/index.d.ts +2 -0
- package/src/lib/services/index.d.ts.map +1 -1
- package/src/lib/services/index.js +2 -0
- package/src/lib/services/index.js.map +1 -1
- package/src/lib/services/paginationService.d.ts +18 -0
- package/src/lib/services/paginationService.d.ts.map +1 -0
- package/src/lib/services/paginationService.js +32 -0
- package/src/lib/services/paginationService.js.map +1 -0
- package/src/lib/services/presenceService.d.ts +76 -0
- package/src/lib/services/presenceService.d.ts.map +1 -0
- package/src/lib/services/presenceService.js +143 -0
- package/src/lib/services/presenceService.js.map +1 -0
- package/src/lib/services/wireConversationPromotion.d.ts +23 -0
- package/src/lib/services/wireConversationPromotion.d.ts.map +1 -0
- package/src/lib/services/wireConversationPromotion.js +26 -0
- package/src/lib/services/wireConversationPromotion.js.map +1 -0
- package/src/lib/stores/availabilityAwareBlockStore.d.ts +115 -10
- package/src/lib/stores/availabilityAwareBlockStore.d.ts.map +1 -1
- package/src/lib/stores/availabilityAwareBlockStore.js +267 -23
- package/src/lib/stores/availabilityAwareBlockStore.js.map +1 -1
- package/src/lib/stores/diskBlockAsyncStore.d.ts +81 -2
- package/src/lib/stores/diskBlockAsyncStore.d.ts.map +1 -1
- package/src/lib/stores/diskBlockAsyncStore.js +297 -10
- package/src/lib/stores/diskBlockAsyncStore.js.map +1 -1
- package/src/lib/upstream-stubs.d.ts +36 -0
- package/src/lib/upstream-stubs.d.ts.map +1 -0
- package/src/lib/upstream-stubs.js +43 -0
- package/src/lib/upstream-stubs.js.map +1 -0
- package/src/lib/utils/communicationValidation.d.ts +44 -0
- package/src/lib/utils/communicationValidation.d.ts.map +1 -0
- package/src/lib/utils/communicationValidation.js +291 -0
- package/src/lib/utils/communicationValidation.js.map +1 -0
- package/src/lib/utils/emailValidation.d.ts +19 -0
- package/src/lib/utils/emailValidation.d.ts.map +1 -0
- package/src/lib/utils/emailValidation.js +232 -0
- package/src/lib/utils/emailValidation.js.map +1 -0
- package/src/lib/interfaces/blockStore.d.ts +0 -7
- package/src/lib/interfaces/blockStore.d.ts.map +0 -1
- package/src/lib/interfaces/blockStore.js.map +0 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { CoreLanguageCode } from '@digitaldefiance/i18n-lib';
|
|
2
|
+
import { PlatformID } from '@digitaldefiance/node-ecies-lib';
|
|
3
|
+
import { ApiErrorResponse, ApiRequestHandler, TypedHandlers } from '@digitaldefiance/node-express-suite';
|
|
4
|
+
import { IBrightChainApplication } from '../../interfaces/application';
|
|
5
|
+
import { DefaultBackendIdType } from '../../shared-types';
|
|
6
|
+
import { BaseController } from '../base';
|
|
7
|
+
interface IBrightPassDataResponse {
|
|
8
|
+
success: true;
|
|
9
|
+
data: Record<string, unknown>;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
type BrightPassApiResponse = IBrightPassDataResponse | ApiErrorResponse;
|
|
13
|
+
interface BrightPassHandlers extends TypedHandlers {
|
|
14
|
+
createVault: ApiRequestHandler<BrightPassApiResponse>;
|
|
15
|
+
listVaults: ApiRequestHandler<BrightPassApiResponse>;
|
|
16
|
+
openVault: ApiRequestHandler<BrightPassApiResponse>;
|
|
17
|
+
deleteVault: ApiRequestHandler<BrightPassApiResponse>;
|
|
18
|
+
createEntry: ApiRequestHandler<BrightPassApiResponse>;
|
|
19
|
+
getEntry: ApiRequestHandler<BrightPassApiResponse>;
|
|
20
|
+
updateEntry: ApiRequestHandler<BrightPassApiResponse>;
|
|
21
|
+
deleteEntry: ApiRequestHandler<BrightPassApiResponse>;
|
|
22
|
+
searchEntries: ApiRequestHandler<BrightPassApiResponse>;
|
|
23
|
+
generatePassword: ApiRequestHandler<BrightPassApiResponse>;
|
|
24
|
+
generateTotp: ApiRequestHandler<BrightPassApiResponse>;
|
|
25
|
+
validateTotp: ApiRequestHandler<BrightPassApiResponse>;
|
|
26
|
+
breachCheck: ApiRequestHandler<BrightPassApiResponse>;
|
|
27
|
+
autofill: ApiRequestHandler<BrightPassApiResponse>;
|
|
28
|
+
getAuditLog: ApiRequestHandler<BrightPassApiResponse>;
|
|
29
|
+
shareVault: ApiRequestHandler<BrightPassApiResponse>;
|
|
30
|
+
revokeShare: ApiRequestHandler<BrightPassApiResponse>;
|
|
31
|
+
configureEmergencyAccess: ApiRequestHandler<BrightPassApiResponse>;
|
|
32
|
+
recoverWithShares: ApiRequestHandler<BrightPassApiResponse>;
|
|
33
|
+
importEntries: ApiRequestHandler<BrightPassApiResponse>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* BrightPassController — REST API for the BrightPass password manager.
|
|
37
|
+
*
|
|
38
|
+
* Provides endpoints for vault CRUD, entry CRUD, search, password generation,
|
|
39
|
+
* TOTP, breach detection, autofill, audit log, sharing, emergency access, and import.
|
|
40
|
+
*
|
|
41
|
+
* All routes require JWT authentication.
|
|
42
|
+
*
|
|
43
|
+
* @requirements 5.1–5.11
|
|
44
|
+
*/
|
|
45
|
+
export declare class BrightPassController<TID extends PlatformID = DefaultBackendIdType> extends BaseController<TID, BrightPassApiResponse, BrightPassHandlers, CoreLanguageCode> {
|
|
46
|
+
private brightPassService;
|
|
47
|
+
constructor(application: IBrightChainApplication<TID>);
|
|
48
|
+
private getAuthMemberId;
|
|
49
|
+
protected initRouteDefinitions(): void;
|
|
50
|
+
private handleCreateVault;
|
|
51
|
+
private handleListVaults;
|
|
52
|
+
private handleOpenVault;
|
|
53
|
+
private handleDeleteVault;
|
|
54
|
+
private handleCreateEntry;
|
|
55
|
+
private handleGetEntry;
|
|
56
|
+
private handleUpdateEntry;
|
|
57
|
+
private handleDeleteEntry;
|
|
58
|
+
private handleSearchEntries;
|
|
59
|
+
private handleGeneratePassword;
|
|
60
|
+
private handleGenerateTotp;
|
|
61
|
+
private handleValidateTotp;
|
|
62
|
+
private handleBreachCheck;
|
|
63
|
+
private handleAutofill;
|
|
64
|
+
private handleGetAuditLog;
|
|
65
|
+
private handleShareVault;
|
|
66
|
+
private handleRevokeShare;
|
|
67
|
+
private handleConfigureEmergencyAccess;
|
|
68
|
+
private handleRecoverWithShares;
|
|
69
|
+
private handleImportEntries;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=brightpass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brightpass.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/controllers/api/brightpass.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EAEjB,aAAa,EAEd,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAQvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAO1D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAKzC,UAAU,uBAAuB;IAC/B,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,KAAK,qBAAqB,GAAG,uBAAuB,GAAG,gBAAgB,CAAC;AAIxE,UAAU,kBAAmB,SAAQ,aAAa;IAChD,WAAW,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACtD,UAAU,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACrD,SAAS,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACpD,WAAW,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACtD,WAAW,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACtD,QAAQ,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACnD,WAAW,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACtD,WAAW,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACtD,aAAa,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACxD,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IAC3D,YAAY,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACvD,YAAY,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACvD,WAAW,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACtD,QAAQ,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACnD,WAAW,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACtD,UAAU,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACrD,WAAW,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACtD,wBAAwB,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IACnE,iBAAiB,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IAC5D,aAAa,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;CACzD;AA6DD;;;;;;;;;GASG;AACH,qBAAa,oBAAoB,CAC/B,GAAG,SAAS,UAAU,GAAG,oBAAoB,CAC7C,SAAQ,cAAc,CACtB,GAAG,EACH,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,CACjB;IACC,OAAO,CAAC,iBAAiB,CAAoB;gBAEjC,WAAW,EAAE,uBAAuB,CAAC,GAAG,CAAC;IAKrD,OAAO,CAAC,eAAe;IAgBvB,SAAS,CAAC,oBAAoB,IAAI,IAAI;YAmPxB,iBAAiB;YAsBjB,gBAAgB;YAYhB,eAAe;YAsBf,iBAAiB;YAwBjB,iBAAiB;YAgBjB,cAAc;YAad,iBAAiB;YAkBjB,iBAAiB;YAajB,mBAAmB;YAmBnB,sBAAsB;YActB,kBAAkB;YAelB,kBAAkB;YAmBlB,iBAAiB;YAgBjB,cAAc;YAoBd,iBAAiB;YAcjB,gBAAgB;YAoBhB,iBAAiB;YAmBjB,8BAA8B;YA2B9B,uBAAuB;YAwBvB,mBAAmB;CAyBlC"}
|
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrightPassController = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
+
const brightchain_lib_1 = require("@brightchain/brightchain-lib");
|
|
6
|
+
const node_express_suite_1 = require("@digitaldefiance/node-express-suite");
|
|
7
|
+
const brightpass_1 = require("../../services/brightpass");
|
|
8
|
+
const errorResponse_1 = require("../../utils/errorResponse");
|
|
9
|
+
const base_1 = require("../base");
|
|
10
|
+
// ─── Helper ─────────────────────────────────────────────────────
|
|
11
|
+
class AuthenticationRequiredError extends Error {
|
|
12
|
+
constructor() {
|
|
13
|
+
super('Authentication required');
|
|
14
|
+
this.name = 'AuthenticationRequiredError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function mapBrightPassError(error) {
|
|
18
|
+
if (error instanceof AuthenticationRequiredError) {
|
|
19
|
+
return (0, errorResponse_1.unauthorizedError)();
|
|
20
|
+
}
|
|
21
|
+
if (error instanceof brightpass_1.VaultNotFoundError) {
|
|
22
|
+
return (0, errorResponse_1.notFoundError)('Vault', 'unknown');
|
|
23
|
+
}
|
|
24
|
+
if (error instanceof brightpass_1.VaultAuthenticationError) {
|
|
25
|
+
return (0, errorResponse_1.unauthorizedError)(error.message);
|
|
26
|
+
}
|
|
27
|
+
if (error instanceof brightpass_1.EntryNotFoundError) {
|
|
28
|
+
return (0, errorResponse_1.notFoundError)('Entry', 'unknown');
|
|
29
|
+
}
|
|
30
|
+
if (error instanceof brightpass_1.EmergencyAccessError) {
|
|
31
|
+
return (0, errorResponse_1.validationError)(error.message);
|
|
32
|
+
}
|
|
33
|
+
return (0, errorResponse_1.handleError)(error);
|
|
34
|
+
}
|
|
35
|
+
function ok(data) {
|
|
36
|
+
return { statusCode: 200, response: { success: true, data } };
|
|
37
|
+
}
|
|
38
|
+
// ─── Controller ─────────────────────────────────────────────────
|
|
39
|
+
/**
|
|
40
|
+
* BrightPassController — REST API for the BrightPass password manager.
|
|
41
|
+
*
|
|
42
|
+
* Provides endpoints for vault CRUD, entry CRUD, search, password generation,
|
|
43
|
+
* TOTP, breach detection, autofill, audit log, sharing, emergency access, and import.
|
|
44
|
+
*
|
|
45
|
+
* All routes require JWT authentication.
|
|
46
|
+
*
|
|
47
|
+
* @requirements 5.1–5.11
|
|
48
|
+
*/
|
|
49
|
+
class BrightPassController extends base_1.BaseController {
|
|
50
|
+
constructor(application) {
|
|
51
|
+
super(application);
|
|
52
|
+
this.brightPassService = new brightpass_1.BrightPassService();
|
|
53
|
+
}
|
|
54
|
+
getAuthMemberId(req) {
|
|
55
|
+
const sessionsController = this.application.getController('sessions');
|
|
56
|
+
try {
|
|
57
|
+
const member = sessionsController.getMemberFromSession(req.headers.authorization);
|
|
58
|
+
if (!member) {
|
|
59
|
+
throw new Error('No member found');
|
|
60
|
+
}
|
|
61
|
+
return member.id.toString();
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
throw new AuthenticationRequiredError();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
initRouteDefinitions() {
|
|
68
|
+
this.routeDefinitions = [
|
|
69
|
+
// Vault CRUD
|
|
70
|
+
(0, node_express_suite_1.routeConfig)('post', '/vaults', {
|
|
71
|
+
useAuthentication: true,
|
|
72
|
+
useCryptoAuthentication: false,
|
|
73
|
+
handlerKey: 'createVault',
|
|
74
|
+
openapi: {
|
|
75
|
+
summary: 'Create a vault',
|
|
76
|
+
tags: ['BrightPass'],
|
|
77
|
+
requestBody: { schema: 'CreateVaultRequest' },
|
|
78
|
+
responses: { 200: { description: 'Vault created' } },
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
(0, node_express_suite_1.routeConfig)('get', '/vaults', {
|
|
82
|
+
useAuthentication: true,
|
|
83
|
+
useCryptoAuthentication: false,
|
|
84
|
+
handlerKey: 'listVaults',
|
|
85
|
+
openapi: {
|
|
86
|
+
summary: 'List vaults',
|
|
87
|
+
tags: ['BrightPass'],
|
|
88
|
+
responses: { 200: { description: 'Vault list' } },
|
|
89
|
+
},
|
|
90
|
+
}),
|
|
91
|
+
(0, node_express_suite_1.routeConfig)('post', '/vaults/:vaultId/open', {
|
|
92
|
+
useAuthentication: true,
|
|
93
|
+
useCryptoAuthentication: false,
|
|
94
|
+
handlerKey: 'openVault',
|
|
95
|
+
openapi: {
|
|
96
|
+
summary: 'Open a vault',
|
|
97
|
+
tags: ['BrightPass'],
|
|
98
|
+
responses: { 200: { description: 'Vault opened' } },
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
(0, node_express_suite_1.routeConfig)('delete', '/vaults/:vaultId', {
|
|
102
|
+
useAuthentication: true,
|
|
103
|
+
useCryptoAuthentication: false,
|
|
104
|
+
handlerKey: 'deleteVault',
|
|
105
|
+
openapi: {
|
|
106
|
+
summary: 'Delete a vault',
|
|
107
|
+
tags: ['BrightPass'],
|
|
108
|
+
responses: { 200: { description: 'Vault deleted' } },
|
|
109
|
+
},
|
|
110
|
+
}),
|
|
111
|
+
// Entry CRUD
|
|
112
|
+
(0, node_express_suite_1.routeConfig)('post', '/vaults/:vaultId/entries', {
|
|
113
|
+
useAuthentication: true,
|
|
114
|
+
useCryptoAuthentication: false,
|
|
115
|
+
handlerKey: 'createEntry',
|
|
116
|
+
openapi: {
|
|
117
|
+
summary: 'Add entry to vault',
|
|
118
|
+
tags: ['BrightPass'],
|
|
119
|
+
responses: { 200: { description: 'Entry created' } },
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
(0, node_express_suite_1.routeConfig)('get', '/vaults/:vaultId/entries/:entryId', {
|
|
123
|
+
useAuthentication: true,
|
|
124
|
+
useCryptoAuthentication: false,
|
|
125
|
+
handlerKey: 'getEntry',
|
|
126
|
+
openapi: {
|
|
127
|
+
summary: 'Get entry by ID',
|
|
128
|
+
tags: ['BrightPass'],
|
|
129
|
+
responses: { 200: { description: 'Entry retrieved' } },
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
132
|
+
(0, node_express_suite_1.routeConfig)('put', '/vaults/:vaultId/entries/:entryId', {
|
|
133
|
+
useAuthentication: true,
|
|
134
|
+
useCryptoAuthentication: false,
|
|
135
|
+
handlerKey: 'updateEntry',
|
|
136
|
+
openapi: {
|
|
137
|
+
summary: 'Update entry',
|
|
138
|
+
tags: ['BrightPass'],
|
|
139
|
+
responses: { 200: { description: 'Entry updated' } },
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
(0, node_express_suite_1.routeConfig)('delete', '/vaults/:vaultId/entries/:entryId', {
|
|
143
|
+
useAuthentication: true,
|
|
144
|
+
useCryptoAuthentication: false,
|
|
145
|
+
handlerKey: 'deleteEntry',
|
|
146
|
+
openapi: {
|
|
147
|
+
summary: 'Delete entry',
|
|
148
|
+
tags: ['BrightPass'],
|
|
149
|
+
responses: { 200: { description: 'Entry deleted' } },
|
|
150
|
+
},
|
|
151
|
+
}),
|
|
152
|
+
(0, node_express_suite_1.routeConfig)('post', '/vaults/:vaultId/search', {
|
|
153
|
+
useAuthentication: true,
|
|
154
|
+
useCryptoAuthentication: false,
|
|
155
|
+
handlerKey: 'searchEntries',
|
|
156
|
+
openapi: {
|
|
157
|
+
summary: 'Search entries',
|
|
158
|
+
tags: ['BrightPass'],
|
|
159
|
+
responses: { 200: { description: 'Search results' } },
|
|
160
|
+
},
|
|
161
|
+
}),
|
|
162
|
+
// Utilities
|
|
163
|
+
(0, node_express_suite_1.routeConfig)('post', '/generate-password', {
|
|
164
|
+
useAuthentication: true,
|
|
165
|
+
useCryptoAuthentication: false,
|
|
166
|
+
handlerKey: 'generatePassword',
|
|
167
|
+
openapi: {
|
|
168
|
+
summary: 'Generate password',
|
|
169
|
+
tags: ['BrightPass'],
|
|
170
|
+
responses: { 200: { description: 'Password generated' } },
|
|
171
|
+
},
|
|
172
|
+
}),
|
|
173
|
+
(0, node_express_suite_1.routeConfig)('post', '/totp/generate', {
|
|
174
|
+
useAuthentication: true,
|
|
175
|
+
useCryptoAuthentication: false,
|
|
176
|
+
handlerKey: 'generateTotp',
|
|
177
|
+
openapi: {
|
|
178
|
+
summary: 'Generate TOTP code',
|
|
179
|
+
tags: ['BrightPass'],
|
|
180
|
+
responses: { 200: { description: 'TOTP code' } },
|
|
181
|
+
},
|
|
182
|
+
}),
|
|
183
|
+
(0, node_express_suite_1.routeConfig)('post', '/totp/validate', {
|
|
184
|
+
useAuthentication: true,
|
|
185
|
+
useCryptoAuthentication: false,
|
|
186
|
+
handlerKey: 'validateTotp',
|
|
187
|
+
openapi: {
|
|
188
|
+
summary: 'Validate TOTP code',
|
|
189
|
+
tags: ['BrightPass'],
|
|
190
|
+
responses: { 200: { description: 'Validation result' } },
|
|
191
|
+
},
|
|
192
|
+
}),
|
|
193
|
+
(0, node_express_suite_1.routeConfig)('post', '/breach-check', {
|
|
194
|
+
useAuthentication: true,
|
|
195
|
+
useCryptoAuthentication: false,
|
|
196
|
+
handlerKey: 'breachCheck',
|
|
197
|
+
openapi: {
|
|
198
|
+
summary: 'Check password breach status',
|
|
199
|
+
tags: ['BrightPass'],
|
|
200
|
+
responses: { 200: { description: 'Breach check result' } },
|
|
201
|
+
},
|
|
202
|
+
}),
|
|
203
|
+
(0, node_express_suite_1.routeConfig)('post', '/vaults/:vaultId/autofill', {
|
|
204
|
+
useAuthentication: true,
|
|
205
|
+
useCryptoAuthentication: false,
|
|
206
|
+
handlerKey: 'autofill',
|
|
207
|
+
openapi: {
|
|
208
|
+
summary: 'Get autofill payload',
|
|
209
|
+
tags: ['BrightPass'],
|
|
210
|
+
responses: { 200: { description: 'Autofill payload' } },
|
|
211
|
+
},
|
|
212
|
+
}),
|
|
213
|
+
(0, node_express_suite_1.routeConfig)('get', '/vaults/:vaultId/audit-log', {
|
|
214
|
+
useAuthentication: true,
|
|
215
|
+
useCryptoAuthentication: false,
|
|
216
|
+
handlerKey: 'getAuditLog',
|
|
217
|
+
openapi: {
|
|
218
|
+
summary: 'Get vault audit log',
|
|
219
|
+
tags: ['BrightPass'],
|
|
220
|
+
responses: { 200: { description: 'Audit log entries' } },
|
|
221
|
+
},
|
|
222
|
+
}),
|
|
223
|
+
// Sharing
|
|
224
|
+
(0, node_express_suite_1.routeConfig)('post', '/vaults/:vaultId/share', {
|
|
225
|
+
useAuthentication: true,
|
|
226
|
+
useCryptoAuthentication: false,
|
|
227
|
+
handlerKey: 'shareVault',
|
|
228
|
+
openapi: {
|
|
229
|
+
summary: 'Share vault',
|
|
230
|
+
tags: ['BrightPass'],
|
|
231
|
+
responses: { 200: { description: 'Vault shared' } },
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
(0, node_express_suite_1.routeConfig)('post', '/vaults/:vaultId/revoke-share', {
|
|
235
|
+
useAuthentication: true,
|
|
236
|
+
useCryptoAuthentication: false,
|
|
237
|
+
handlerKey: 'revokeShare',
|
|
238
|
+
openapi: {
|
|
239
|
+
summary: 'Revoke vault share',
|
|
240
|
+
tags: ['BrightPass'],
|
|
241
|
+
responses: { 200: { description: 'Share revoked' } },
|
|
242
|
+
},
|
|
243
|
+
}),
|
|
244
|
+
// Emergency access
|
|
245
|
+
(0, node_express_suite_1.routeConfig)('post', '/vaults/:vaultId/emergency-access', {
|
|
246
|
+
useAuthentication: true,
|
|
247
|
+
useCryptoAuthentication: false,
|
|
248
|
+
handlerKey: 'configureEmergencyAccess',
|
|
249
|
+
openapi: {
|
|
250
|
+
summary: 'Configure emergency access',
|
|
251
|
+
tags: ['BrightPass'],
|
|
252
|
+
responses: { 200: { description: 'Emergency access configured' } },
|
|
253
|
+
},
|
|
254
|
+
}),
|
|
255
|
+
(0, node_express_suite_1.routeConfig)('post', '/vaults/:vaultId/emergency-recover', {
|
|
256
|
+
useAuthentication: true,
|
|
257
|
+
useCryptoAuthentication: false,
|
|
258
|
+
handlerKey: 'recoverWithShares',
|
|
259
|
+
openapi: {
|
|
260
|
+
summary: 'Recover vault with emergency shares',
|
|
261
|
+
tags: ['BrightPass'],
|
|
262
|
+
responses: { 200: { description: 'Vault recovered' } },
|
|
263
|
+
},
|
|
264
|
+
}),
|
|
265
|
+
// Import
|
|
266
|
+
(0, node_express_suite_1.routeConfig)('post', '/vaults/:vaultId/import', {
|
|
267
|
+
useAuthentication: true,
|
|
268
|
+
useCryptoAuthentication: false,
|
|
269
|
+
handlerKey: 'importEntries',
|
|
270
|
+
openapi: {
|
|
271
|
+
summary: 'Import entries from file',
|
|
272
|
+
tags: ['BrightPass'],
|
|
273
|
+
responses: { 200: { description: 'Import result' } },
|
|
274
|
+
},
|
|
275
|
+
}),
|
|
276
|
+
];
|
|
277
|
+
node_express_suite_1.ControllerRegistry.register('/brightpass', 'BrightPassController', this.routeDefinitions);
|
|
278
|
+
this.handlers = {
|
|
279
|
+
createVault: this.handleCreateVault.bind(this),
|
|
280
|
+
listVaults: this.handleListVaults.bind(this),
|
|
281
|
+
openVault: this.handleOpenVault.bind(this),
|
|
282
|
+
deleteVault: this.handleDeleteVault.bind(this),
|
|
283
|
+
createEntry: this.handleCreateEntry.bind(this),
|
|
284
|
+
getEntry: this.handleGetEntry.bind(this),
|
|
285
|
+
updateEntry: this.handleUpdateEntry.bind(this),
|
|
286
|
+
deleteEntry: this.handleDeleteEntry.bind(this),
|
|
287
|
+
searchEntries: this.handleSearchEntries.bind(this),
|
|
288
|
+
generatePassword: this.handleGeneratePassword.bind(this),
|
|
289
|
+
generateTotp: this.handleGenerateTotp.bind(this),
|
|
290
|
+
validateTotp: this.handleValidateTotp.bind(this),
|
|
291
|
+
breachCheck: this.handleBreachCheck.bind(this),
|
|
292
|
+
autofill: this.handleAutofill.bind(this),
|
|
293
|
+
getAuditLog: this.handleGetAuditLog.bind(this),
|
|
294
|
+
shareVault: this.handleShareVault.bind(this),
|
|
295
|
+
revokeShare: this.handleRevokeShare.bind(this),
|
|
296
|
+
configureEmergencyAccess: this.handleConfigureEmergencyAccess.bind(this),
|
|
297
|
+
recoverWithShares: this.handleRecoverWithShares.bind(this),
|
|
298
|
+
importEntries: this.handleImportEntries.bind(this),
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
// ─── Vault CRUD Handlers ──────────────────────────────────────
|
|
302
|
+
async handleCreateVault(req) {
|
|
303
|
+
try {
|
|
304
|
+
const memberId = this.getAuthMemberId(req);
|
|
305
|
+
const { name, masterPassword } = req.body;
|
|
306
|
+
if (!name || !masterPassword) {
|
|
307
|
+
return (0, errorResponse_1.validationError)('Missing required fields: name, masterPassword');
|
|
308
|
+
}
|
|
309
|
+
const metadata = await this.brightPassService.createVault(memberId, name, masterPassword);
|
|
310
|
+
return ok({ vault: metadata });
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
return mapBrightPassError(error);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
async handleListVaults(req) {
|
|
317
|
+
try {
|
|
318
|
+
const memberId = this.getAuthMemberId(req);
|
|
319
|
+
const vaults = await this.brightPassService.listVaults(memberId);
|
|
320
|
+
return ok({ vaults: vaults });
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
return mapBrightPassError(error);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
async handleOpenVault(req) {
|
|
327
|
+
try {
|
|
328
|
+
const memberId = this.getAuthMemberId(req);
|
|
329
|
+
const { vaultId } = req.params;
|
|
330
|
+
const { masterPassword } = req
|
|
331
|
+
.body;
|
|
332
|
+
if (!masterPassword) {
|
|
333
|
+
return (0, errorResponse_1.validationError)('Missing required field: masterPassword');
|
|
334
|
+
}
|
|
335
|
+
const vault = await this.brightPassService.openVault(memberId, vaultId, masterPassword);
|
|
336
|
+
return ok({ vault: vault });
|
|
337
|
+
}
|
|
338
|
+
catch (error) {
|
|
339
|
+
return mapBrightPassError(error);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
async handleDeleteVault(req) {
|
|
343
|
+
try {
|
|
344
|
+
const memberId = this.getAuthMemberId(req);
|
|
345
|
+
const { vaultId } = req.params;
|
|
346
|
+
const { masterPassword } = req
|
|
347
|
+
.body;
|
|
348
|
+
if (!masterPassword) {
|
|
349
|
+
return (0, errorResponse_1.validationError)('Missing required field: masterPassword');
|
|
350
|
+
}
|
|
351
|
+
await this.brightPassService.deleteVault(memberId, vaultId, masterPassword);
|
|
352
|
+
return ok({ deleted: true });
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
return mapBrightPassError(error);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// ─── Entry CRUD Handlers ──────────────────────────────────────
|
|
359
|
+
async handleCreateEntry(req) {
|
|
360
|
+
try {
|
|
361
|
+
const { vaultId } = req.params;
|
|
362
|
+
const entry = req.body;
|
|
363
|
+
if (!entry || !entry.type || !entry.title) {
|
|
364
|
+
return (0, errorResponse_1.validationError)('Missing required fields: type, title');
|
|
365
|
+
}
|
|
366
|
+
const created = await this.brightPassService.addEntry(vaultId, entry);
|
|
367
|
+
return ok({ entry: created });
|
|
368
|
+
}
|
|
369
|
+
catch (error) {
|
|
370
|
+
return mapBrightPassError(error);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
async handleGetEntry(req) {
|
|
374
|
+
try {
|
|
375
|
+
const { vaultId, entryId } = req
|
|
376
|
+
.params;
|
|
377
|
+
const entry = await this.brightPassService.getEntry(vaultId, entryId);
|
|
378
|
+
return ok({ entry: entry });
|
|
379
|
+
}
|
|
380
|
+
catch (error) {
|
|
381
|
+
return mapBrightPassError(error);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
async handleUpdateEntry(req) {
|
|
385
|
+
try {
|
|
386
|
+
const { vaultId, entryId } = req
|
|
387
|
+
.params;
|
|
388
|
+
const updates = req.body;
|
|
389
|
+
const updated = await this.brightPassService.updateEntry(vaultId, entryId, updates);
|
|
390
|
+
return ok({ entry: updated });
|
|
391
|
+
}
|
|
392
|
+
catch (error) {
|
|
393
|
+
return mapBrightPassError(error);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
async handleDeleteEntry(req) {
|
|
397
|
+
try {
|
|
398
|
+
const { vaultId, entryId } = req
|
|
399
|
+
.params;
|
|
400
|
+
await this.brightPassService.deleteEntry(vaultId, entryId);
|
|
401
|
+
return ok({ deleted: true });
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
return mapBrightPassError(error);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
async handleSearchEntries(req) {
|
|
408
|
+
try {
|
|
409
|
+
const { vaultId } = req
|
|
410
|
+
.params;
|
|
411
|
+
const query = req.body;
|
|
412
|
+
const results = await this.brightPassService.searchEntries(vaultId, query);
|
|
413
|
+
return ok({ results: results });
|
|
414
|
+
}
|
|
415
|
+
catch (error) {
|
|
416
|
+
return mapBrightPassError(error);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
// ─── Utility Handlers ─────────────────────────────────────────
|
|
420
|
+
async handleGeneratePassword(req) {
|
|
421
|
+
try {
|
|
422
|
+
const options = req.body;
|
|
423
|
+
// validate throws on invalid options
|
|
424
|
+
brightchain_lib_1.PasswordGenerator.validate(options);
|
|
425
|
+
const password = brightchain_lib_1.PasswordGenerator.generate(options);
|
|
426
|
+
return ok({ password });
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
return mapBrightPassError(error);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
async handleGenerateTotp(req) {
|
|
433
|
+
try {
|
|
434
|
+
const { secret } = req.body;
|
|
435
|
+
if (!secret) {
|
|
436
|
+
return (0, errorResponse_1.validationError)('Missing required field: secret');
|
|
437
|
+
}
|
|
438
|
+
const code = brightchain_lib_1.TOTPEngine.generate(secret);
|
|
439
|
+
return ok({ code });
|
|
440
|
+
}
|
|
441
|
+
catch (error) {
|
|
442
|
+
return mapBrightPassError(error);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
async handleValidateTotp(req) {
|
|
446
|
+
try {
|
|
447
|
+
const { code, secret, window } = req.body;
|
|
448
|
+
if (!code || !secret) {
|
|
449
|
+
return (0, errorResponse_1.validationError)('Missing required fields: code, secret');
|
|
450
|
+
}
|
|
451
|
+
const valid = brightchain_lib_1.TOTPEngine.validate(code, secret, window);
|
|
452
|
+
return ok({ valid });
|
|
453
|
+
}
|
|
454
|
+
catch (error) {
|
|
455
|
+
return mapBrightPassError(error);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
async handleBreachCheck(req) {
|
|
459
|
+
try {
|
|
460
|
+
const { password } = req
|
|
461
|
+
.body;
|
|
462
|
+
if (!password) {
|
|
463
|
+
return (0, errorResponse_1.validationError)('Missing required field: password');
|
|
464
|
+
}
|
|
465
|
+
const result = await brightchain_lib_1.BreachDetector.check(password);
|
|
466
|
+
return ok(result);
|
|
467
|
+
}
|
|
468
|
+
catch (error) {
|
|
469
|
+
return mapBrightPassError(error);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
async handleAutofill(req) {
|
|
473
|
+
try {
|
|
474
|
+
const { vaultId } = req.params;
|
|
475
|
+
const { siteUrl } = req
|
|
476
|
+
.body;
|
|
477
|
+
if (!siteUrl) {
|
|
478
|
+
return (0, errorResponse_1.validationError)('Missing required field: siteUrl');
|
|
479
|
+
}
|
|
480
|
+
const payload = await this.brightPassService.getAutofillPayload(vaultId, siteUrl);
|
|
481
|
+
return ok(payload);
|
|
482
|
+
}
|
|
483
|
+
catch (error) {
|
|
484
|
+
return mapBrightPassError(error);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
async handleGetAuditLog(req) {
|
|
488
|
+
try {
|
|
489
|
+
const { vaultId } = req.params;
|
|
490
|
+
const entries = await this.brightPassService.getAuditLog(vaultId);
|
|
491
|
+
return ok({ entries: entries });
|
|
492
|
+
}
|
|
493
|
+
catch (error) {
|
|
494
|
+
return mapBrightPassError(error);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
// ─── Sharing Handlers ─────────────────────────────────────────
|
|
498
|
+
async handleShareVault(req) {
|
|
499
|
+
try {
|
|
500
|
+
const { vaultId } = req.params;
|
|
501
|
+
const { recipientMemberIds } = req.body;
|
|
502
|
+
if (!recipientMemberIds || !Array.isArray(recipientMemberIds)) {
|
|
503
|
+
return (0, errorResponse_1.validationError)('Missing required field: recipientMemberIds (array)');
|
|
504
|
+
}
|
|
505
|
+
await this.brightPassService.shareVault(vaultId, recipientMemberIds);
|
|
506
|
+
return ok({ shared: true });
|
|
507
|
+
}
|
|
508
|
+
catch (error) {
|
|
509
|
+
return mapBrightPassError(error);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
async handleRevokeShare(req) {
|
|
513
|
+
try {
|
|
514
|
+
const { vaultId } = req.params;
|
|
515
|
+
const { memberId } = req
|
|
516
|
+
.body;
|
|
517
|
+
if (!memberId) {
|
|
518
|
+
return (0, errorResponse_1.validationError)('Missing required field: memberId');
|
|
519
|
+
}
|
|
520
|
+
await this.brightPassService.revokeShare(vaultId, memberId);
|
|
521
|
+
return ok({ revoked: true });
|
|
522
|
+
}
|
|
523
|
+
catch (error) {
|
|
524
|
+
return mapBrightPassError(error);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
// ─── Emergency Access Handlers ────────────────────────────────
|
|
528
|
+
async handleConfigureEmergencyAccess(req) {
|
|
529
|
+
try {
|
|
530
|
+
const { vaultId } = req
|
|
531
|
+
.params;
|
|
532
|
+
const { threshold, trustees } = req.body;
|
|
533
|
+
if (!threshold || !trustees || !Array.isArray(trustees)) {
|
|
534
|
+
return (0, errorResponse_1.validationError)('Missing required fields: threshold, trustees (array)');
|
|
535
|
+
}
|
|
536
|
+
const config = await this.brightPassService.configureEmergencyAccess(vaultId, threshold, trustees);
|
|
537
|
+
return ok(config);
|
|
538
|
+
}
|
|
539
|
+
catch (error) {
|
|
540
|
+
return mapBrightPassError(error);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
async handleRecoverWithShares(req) {
|
|
544
|
+
try {
|
|
545
|
+
const { vaultId } = req
|
|
546
|
+
.params;
|
|
547
|
+
const { shares } = req.body;
|
|
548
|
+
if (!shares || !Array.isArray(shares)) {
|
|
549
|
+
return (0, errorResponse_1.validationError)('Missing required field: shares (array)');
|
|
550
|
+
}
|
|
551
|
+
const vault = await this.brightPassService.recoverWithShares(vaultId, shares);
|
|
552
|
+
return ok({ vault: vault });
|
|
553
|
+
}
|
|
554
|
+
catch (error) {
|
|
555
|
+
return mapBrightPassError(error);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
// ─── Import Handler ───────────────────────────────────────────
|
|
559
|
+
async handleImportEntries(req) {
|
|
560
|
+
try {
|
|
561
|
+
const { vaultId } = req
|
|
562
|
+
.params;
|
|
563
|
+
const { format, fileContent } = req.body;
|
|
564
|
+
if (!format || !fileContent) {
|
|
565
|
+
return (0, errorResponse_1.validationError)('Missing required fields: format, fileContent');
|
|
566
|
+
}
|
|
567
|
+
const buf = Buffer.from(fileContent, 'base64');
|
|
568
|
+
const result = await this.brightPassService.importFromFile(vaultId, format, buf);
|
|
569
|
+
return ok(result);
|
|
570
|
+
}
|
|
571
|
+
catch (error) {
|
|
572
|
+
return mapBrightPassError(error);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
exports.BrightPassController = BrightPassController;
|
|
577
|
+
//# sourceMappingURL=brightpass.js.map
|