@brightchain/brightchain-api-lib 0.13.0 → 0.15.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/index.d.ts +3 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +5 -0
- package/src/index.js.map +1 -1
- package/src/lib/application.d.ts +1 -0
- package/src/lib/application.d.ts.map +1 -1
- package/src/lib/application.js +23 -0
- 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/configValidation.d.ts.map +1 -1
- package/src/lib/availability/configValidation.js +20 -0
- package/src/lib/availability/configValidation.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 +193 -11
- package/src/lib/availability/gossipService.d.ts.map +1 -1
- package/src/lib/availability/gossipService.js +473 -21
- 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/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/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/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/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/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/environment.d.ts +7 -1
- package/src/lib/interfaces/environment.d.ts.map +1 -1
- package/src/lib/interfaces/index.d.ts +0 -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/interfaces/websocketMessages.d.ts +30 -1
- package/src/lib/interfaces/websocketMessages.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/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/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 +3 -0
- package/src/lib/services/index.d.ts.map +1 -1
- package/src/lib/services/index.js +3 -0
- package/src/lib/services/index.js.map +1 -1
- package/src/lib/services/messagePassingService.d.ts +95 -5
- package/src/lib/services/messagePassingService.d.ts.map +1 -1
- package/src/lib/services/messagePassingService.js +187 -28
- package/src/lib/services/messagePassingService.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/webSocketMessageServer.d.ts +18 -23
- package/src/lib/services/webSocketMessageServer.d.ts.map +1 -1
- package/src/lib/services/webSocketMessageServer.js +30 -46
- package/src/lib/services/webSocketMessageServer.js.map +1 -1
- package/src/lib/services/webSocketPeerProvider.d.ts +49 -0
- package/src/lib/services/webSocketPeerProvider.d.ts.map +1 -0
- package/src/lib/services/webSocketPeerProvider.js +133 -0
- package/src/lib/services/webSocketPeerProvider.js.map +1 -0
- package/src/lib/services/websocketHandler.d.ts +11 -8
- package/src/lib/services/websocketHandler.d.ts.map +1 -1
- package/src/lib/services/websocketHandler.js +33 -40
- package/src/lib/services/websocketHandler.js.map +1 -1
- 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/stores/diskMessageMetadataStore.d.ts +2 -2
- package/src/lib/stores/diskMessageMetadataStore.d.ts.map +1 -1
- package/src/lib/stores/diskMessageMetadataStore.js +1 -1
- package/src/lib/stores/diskMessageMetadataStore.js.map +1 -1
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAvailabilityService, IBlockLocationsResponse, IReconcileResponse, IReconciliationService, IReplicateBlockResponse, ISyncRequestResponse } from '@brightchain/brightchain-lib';
|
|
1
|
+
import { IAvailabilityService, IBlockDataResponse, IBlockLocationsResponse, IBlockStore, IReconcileResponse, IReconciliationService, IReplicateBlockResponse, ISyncRequestResponse } from '@brightchain/brightchain-lib';
|
|
2
2
|
import { CoreLanguageCode } from '@digitaldefiance/i18n-lib';
|
|
3
3
|
import { PlatformID } from '@digitaldefiance/node-ecies-lib';
|
|
4
4
|
import { ApiErrorResponse, ApiRequestHandler, TypedHandlers } from '@digitaldefiance/node-express-suite';
|
|
@@ -6,10 +6,11 @@ import { IBrightChainApplication } from '../../interfaces/application';
|
|
|
6
6
|
import { EventNotificationSystem } from '../../services/eventNotificationSystem';
|
|
7
7
|
import { DefaultBackendIdType } from '../../shared-types';
|
|
8
8
|
import { BaseController } from '../base';
|
|
9
|
-
type SyncApiResponse = IReplicateBlockResponse | IBlockLocationsResponse | ISyncRequestResponse | IReconcileResponse | ApiErrorResponse;
|
|
9
|
+
type SyncApiResponse = IReplicateBlockResponse | IBlockLocationsResponse | IBlockDataResponse | ISyncRequestResponse | IReconcileResponse | ApiErrorResponse;
|
|
10
10
|
interface SyncHandlers extends TypedHandlers {
|
|
11
11
|
replicateBlock: ApiRequestHandler<IReplicateBlockResponse | ApiErrorResponse>;
|
|
12
12
|
getBlockLocations: ApiRequestHandler<IBlockLocationsResponse | ApiErrorResponse>;
|
|
13
|
+
getBlockData: ApiRequestHandler<IBlockDataResponse | ApiErrorResponse>;
|
|
13
14
|
syncRequest: ApiRequestHandler<ISyncRequestResponse | ApiErrorResponse>;
|
|
14
15
|
reconcile: ApiRequestHandler<IReconcileResponse | ApiErrorResponse>;
|
|
15
16
|
}
|
|
@@ -45,6 +46,19 @@ interface SyncHandlers extends TypedHandlers {
|
|
|
45
46
|
* - `blockId` (string): The block ID queried
|
|
46
47
|
* - `locations` (array): Array of location records
|
|
47
48
|
*
|
|
49
|
+
* ### GET /api/sync/blocks/:blockId
|
|
50
|
+
* Get raw block data from the local store.
|
|
51
|
+
*
|
|
52
|
+
* **Parameters:**
|
|
53
|
+
* - `blockId` (string, required): Block ID to retrieve
|
|
54
|
+
*
|
|
55
|
+
* **Query Parameters:**
|
|
56
|
+
* - `poolId` (string, optional): Pool ID for pool-scoped retrieval
|
|
57
|
+
*
|
|
58
|
+
* **Response:**
|
|
59
|
+
* - `blockId` (string): The block ID retrieved
|
|
60
|
+
* - `data` (string): Base64-encoded raw block data
|
|
61
|
+
*
|
|
48
62
|
* ### POST /api/sync/request
|
|
49
63
|
* Check which blocks are available locally and which need to be fetched.
|
|
50
64
|
*
|
|
@@ -68,6 +82,7 @@ export declare class SyncController<TID extends PlatformID = DefaultBackendIdTyp
|
|
|
68
82
|
private availabilityService;
|
|
69
83
|
private reconciliationService;
|
|
70
84
|
private eventSystem;
|
|
85
|
+
private blockStore;
|
|
71
86
|
constructor(application: IBrightChainApplication<TID>);
|
|
72
87
|
/**
|
|
73
88
|
* Set the AvailabilityService instance.
|
|
@@ -85,6 +100,12 @@ export declare class SyncController<TID extends PlatformID = DefaultBackendIdTyp
|
|
|
85
100
|
* @requirements 4.5
|
|
86
101
|
*/
|
|
87
102
|
setEventSystem(eventSystem: EventNotificationSystem): void;
|
|
103
|
+
/**
|
|
104
|
+
* Set the block store for serving block data to remote nodes.
|
|
105
|
+
* This should be the local inner store (not AvailabilityAwareBlockStore).
|
|
106
|
+
* @requirements 1.1
|
|
107
|
+
*/
|
|
108
|
+
setBlockStore(store: IBlockStore): void;
|
|
88
109
|
/**
|
|
89
110
|
* Get the AvailabilityService instance.
|
|
90
111
|
* Throws if the service has not been set.
|
|
@@ -95,6 +116,11 @@ export declare class SyncController<TID extends PlatformID = DefaultBackendIdTyp
|
|
|
95
116
|
* Throws if the service has not been set.
|
|
96
117
|
*/
|
|
97
118
|
private getReconciliationService;
|
|
119
|
+
/**
|
|
120
|
+
* Get the block store instance.
|
|
121
|
+
* Throws if the store has not been set.
|
|
122
|
+
*/
|
|
123
|
+
private getBlockStore;
|
|
98
124
|
protected initRouteDefinitions(): void;
|
|
99
125
|
/**
|
|
100
126
|
* Convert ILocationRecord to response format
|
|
@@ -118,6 +144,16 @@ export declare class SyncController<TID extends PlatformID = DefaultBackendIdTyp
|
|
|
118
144
|
* @requirements 4.2
|
|
119
145
|
*/
|
|
120
146
|
private handleGetBlockLocations;
|
|
147
|
+
/**
|
|
148
|
+
* GET /api/sync/blocks/:blockId
|
|
149
|
+
* Get raw block data from the local store.
|
|
150
|
+
* Supports optional poolId query parameter for pool-scoped retrieval.
|
|
151
|
+
*
|
|
152
|
+
* @param req - Request containing the block ID parameter and optional poolId query
|
|
153
|
+
* @returns Block data as base64-encoded string, or 404 if not found
|
|
154
|
+
* @requirements 1.1
|
|
155
|
+
*/
|
|
156
|
+
private handleGetBlockData;
|
|
121
157
|
/**
|
|
122
158
|
* POST /api/sync/request
|
|
123
159
|
* Check which blocks are available locally and which need to be fetched.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/controllers/api/sync.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/controllers/api/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EACpB,kBAAkB,EAElB,uBAAuB,EACvB,WAAW,EAEX,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EAEvB,oBAAoB,EAErB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EAEd,MAAM,qCAAqC,CAAC;AAO7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAM1D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,KAAK,eAAe,GAChB,uBAAuB,GACvB,uBAAuB,GACvB,kBAAkB,GAClB,oBAAoB,GACpB,kBAAkB,GAClB,gBAAgB,CAAC;AAErB,UAAU,YAAa,SAAQ,aAAa;IAC1C,cAAc,EAAE,iBAAiB,CAAC,uBAAuB,GAAG,gBAAgB,CAAC,CAAC;IAC9E,iBAAiB,EAAE,iBAAiB,CAClC,uBAAuB,GAAG,gBAAgB,CAC3C,CAAC;IACF,YAAY,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,gBAAgB,CAAC,CAAC;IACvE,WAAW,EAAE,iBAAiB,CAAC,oBAAoB,GAAG,gBAAgB,CAAC,CAAC;IACxE,SAAS,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,gBAAgB,CAAC,CAAC;CACrE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,qBAAa,cAAc,CACzB,GAAG,SAAS,UAAU,GAAG,oBAAoB,CAC7C,SAAQ,cAAc,CAAC,GAAG,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,CAAC;IAC5E,OAAO,CAAC,mBAAmB,CAAqC;IAChE,OAAO,CAAC,qBAAqB,CAAuC;IACpE,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,UAAU,CAA4B;gBAElC,WAAW,EAAE,uBAAuB,CAAC,GAAG,CAAC;IAIrD;;;OAGG;IACI,sBAAsB,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;IAIlE;;;OAGG;IACI,wBAAwB,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI;IAItE;;;;OAIG;IACI,cAAc,CAAC,WAAW,EAAE,uBAAuB,GAAG,IAAI;IAIjE;;;;OAIG;IACI,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAI9C;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAO9B;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAOhC;;;OAGG;IACH,OAAO,CAAC,aAAa;IAOrB,SAAS,CAAC,oBAAoB,IAAI,IAAI;IAsCtC;;OAEG;IACH,OAAO,CAAC,cAAc;IAStB;;;;;;;OAOG;YACW,oBAAoB;IAiGlC;;;;;;;OAOG;YACW,uBAAuB;IA2BrC;;;;;;;;OAQG;YACW,kBAAkB;IAgDhC;;;;;;;OAOG;YACW,iBAAiB;IA8D/B;;;;;;OAMG;YACW,eAAe;CA8B9B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SyncController = void 0;
|
|
4
|
+
const brightchain_lib_1 = require("@brightchain/brightchain-lib");
|
|
4
5
|
const node_express_suite_1 = require("@digitaldefiance/node-express-suite");
|
|
5
6
|
const errorResponse_1 = require("../../utils/errorResponse");
|
|
6
7
|
const base_1 = require("../base");
|
|
@@ -36,6 +37,19 @@ const base_1 = require("../base");
|
|
|
36
37
|
* - `blockId` (string): The block ID queried
|
|
37
38
|
* - `locations` (array): Array of location records
|
|
38
39
|
*
|
|
40
|
+
* ### GET /api/sync/blocks/:blockId
|
|
41
|
+
* Get raw block data from the local store.
|
|
42
|
+
*
|
|
43
|
+
* **Parameters:**
|
|
44
|
+
* - `blockId` (string, required): Block ID to retrieve
|
|
45
|
+
*
|
|
46
|
+
* **Query Parameters:**
|
|
47
|
+
* - `poolId` (string, optional): Pool ID for pool-scoped retrieval
|
|
48
|
+
*
|
|
49
|
+
* **Response:**
|
|
50
|
+
* - `blockId` (string): The block ID retrieved
|
|
51
|
+
* - `data` (string): Base64-encoded raw block data
|
|
52
|
+
*
|
|
39
53
|
* ### POST /api/sync/request
|
|
40
54
|
* Check which blocks are available locally and which need to be fetched.
|
|
41
55
|
*
|
|
@@ -61,6 +75,7 @@ class SyncController extends base_1.BaseController {
|
|
|
61
75
|
this.availabilityService = null;
|
|
62
76
|
this.reconciliationService = null;
|
|
63
77
|
this.eventSystem = null;
|
|
78
|
+
this.blockStore = null;
|
|
64
79
|
}
|
|
65
80
|
/**
|
|
66
81
|
* Set the AvailabilityService instance.
|
|
@@ -84,6 +99,14 @@ class SyncController extends base_1.BaseController {
|
|
|
84
99
|
setEventSystem(eventSystem) {
|
|
85
100
|
this.eventSystem = eventSystem;
|
|
86
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Set the block store for serving block data to remote nodes.
|
|
104
|
+
* This should be the local inner store (not AvailabilityAwareBlockStore).
|
|
105
|
+
* @requirements 1.1
|
|
106
|
+
*/
|
|
107
|
+
setBlockStore(store) {
|
|
108
|
+
this.blockStore = store;
|
|
109
|
+
}
|
|
87
110
|
/**
|
|
88
111
|
* Get the AvailabilityService instance.
|
|
89
112
|
* Throws if the service has not been set.
|
|
@@ -104,6 +127,16 @@ class SyncController extends base_1.BaseController {
|
|
|
104
127
|
}
|
|
105
128
|
return this.reconciliationService;
|
|
106
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Get the block store instance.
|
|
132
|
+
* Throws if the store has not been set.
|
|
133
|
+
*/
|
|
134
|
+
getBlockStore() {
|
|
135
|
+
if (!this.blockStore) {
|
|
136
|
+
throw new Error('BlockStore not initialized');
|
|
137
|
+
}
|
|
138
|
+
return this.blockStore;
|
|
139
|
+
}
|
|
107
140
|
initRouteDefinitions() {
|
|
108
141
|
this.routeDefinitions = [
|
|
109
142
|
(0, node_express_suite_1.routeConfig)('post', '/blocks/:blockId/replicate', {
|
|
@@ -116,6 +149,11 @@ class SyncController extends base_1.BaseController {
|
|
|
116
149
|
useAuthentication: false,
|
|
117
150
|
useCryptoAuthentication: false,
|
|
118
151
|
}),
|
|
152
|
+
(0, node_express_suite_1.routeConfig)('get', '/blocks/:blockId', {
|
|
153
|
+
handlerKey: 'getBlockData',
|
|
154
|
+
useAuthentication: false,
|
|
155
|
+
useCryptoAuthentication: false,
|
|
156
|
+
}),
|
|
119
157
|
(0, node_express_suite_1.routeConfig)('post', '/request', {
|
|
120
158
|
handlerKey: 'syncRequest',
|
|
121
159
|
useAuthentication: false,
|
|
@@ -130,6 +168,7 @@ class SyncController extends base_1.BaseController {
|
|
|
130
168
|
this.handlers = {
|
|
131
169
|
replicateBlock: this.handleReplicateBlock.bind(this),
|
|
132
170
|
getBlockLocations: this.handleGetBlockLocations.bind(this),
|
|
171
|
+
getBlockData: this.handleGetBlockData.bind(this),
|
|
133
172
|
syncRequest: this.handleSyncRequest.bind(this),
|
|
134
173
|
reconcile: this.handleReconcile.bind(this),
|
|
135
174
|
};
|
|
@@ -256,6 +295,56 @@ class SyncController extends base_1.BaseController {
|
|
|
256
295
|
return (0, errorResponse_1.handleError)(_error);
|
|
257
296
|
}
|
|
258
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* GET /api/sync/blocks/:blockId
|
|
300
|
+
* Get raw block data from the local store.
|
|
301
|
+
* Supports optional poolId query parameter for pool-scoped retrieval.
|
|
302
|
+
*
|
|
303
|
+
* @param req - Request containing the block ID parameter and optional poolId query
|
|
304
|
+
* @returns Block data as base64-encoded string, or 404 if not found
|
|
305
|
+
* @requirements 1.1
|
|
306
|
+
*/
|
|
307
|
+
async handleGetBlockData(req) {
|
|
308
|
+
try {
|
|
309
|
+
const typedReq = req;
|
|
310
|
+
const { blockId } = typedReq.params;
|
|
311
|
+
if (!blockId) {
|
|
312
|
+
return (0, errorResponse_1.validationError)('Missing required parameter: blockId');
|
|
313
|
+
}
|
|
314
|
+
const store = this.getBlockStore();
|
|
315
|
+
const poolId = typedReq.query?.poolId;
|
|
316
|
+
let data;
|
|
317
|
+
if (poolId && (0, brightchain_lib_1.isPooledBlockStore)(store)) {
|
|
318
|
+
// Pool-scoped retrieval
|
|
319
|
+
const hasBlock = await store.hasInPool(poolId, blockId);
|
|
320
|
+
if (!hasBlock) {
|
|
321
|
+
return (0, errorResponse_1.notFoundError)('Block', blockId);
|
|
322
|
+
}
|
|
323
|
+
data = await store.getFromPool(poolId, blockId);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
// Standard retrieval from the local store
|
|
327
|
+
const hasBlock = await store.has(blockId);
|
|
328
|
+
if (!hasBlock) {
|
|
329
|
+
return (0, errorResponse_1.notFoundError)('Block', blockId);
|
|
330
|
+
}
|
|
331
|
+
const checksum = brightchain_lib_1.Checksum.fromHex(blockId);
|
|
332
|
+
const block = await store.getData(checksum);
|
|
333
|
+
data = block.data;
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
statusCode: 200,
|
|
337
|
+
response: {
|
|
338
|
+
message: 'OK',
|
|
339
|
+
blockId,
|
|
340
|
+
data: Buffer.from(data).toString('base64'),
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
catch (_error) {
|
|
345
|
+
return (0, errorResponse_1.handleError)(_error);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
259
348
|
/**
|
|
260
349
|
* POST /api/sync/request
|
|
261
350
|
* Check which blocks are available locally and which need to be fetched.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/controllers/api/sync.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/controllers/api/sync.ts"],"names":[],"mappings":";;;AAAA,kEAcsC;AAGtC,4EAK6C;AAU7C,6DAImC;AACnC,kCAAyC;AAoBzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,MAAa,cAEX,SAAQ,qBAAoE;IAM5E,YAAY,WAAyC;QACnD,KAAK,CAAC,WAAW,CAAC,CAAC;QANb,wBAAmB,GAAgC,IAAI,CAAC;QACxD,0BAAqB,GAAkC,IAAI,CAAC;QAC5D,gBAAW,GAAmC,IAAI,CAAC;QACnD,eAAU,GAAuB,IAAI,CAAC;IAI9C,CAAC;IAED;;;OAGG;IACI,sBAAsB,CAAC,OAA6B;QACzD,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC;IACrC,CAAC;IAED;;;OAGG;IACI,wBAAwB,CAAC,OAA+B;QAC7D,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,WAAoC;QACxD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,KAAkB;QACrC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACK,sBAAsB;QAC5B,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,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CAAC,OAAO,CAAC,CAAC;YAE9D,OAAO;gBACL,UAAU,EAAE,GAAG;gBACf,QAAQ,EAAE;oBACR,OAAO,EAAE,0BAA0B;oBACnC,MAAM;iBACP;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,OAAO,IAAA,2BAAW,EAAC,MAAM,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;CACF;AAjbD,wCAibC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitController — REST API for Git commit/tag signing operations.
|
|
3
|
+
*
|
|
4
|
+
* Routes:
|
|
5
|
+
* POST /sign-commit — Sign a Git commit
|
|
6
|
+
* POST /sign-tag — Sign a Git tag
|
|
7
|
+
* POST /verify — Verify a Git signature
|
|
8
|
+
* POST /export-public-key — Export the signing public key in PGP format
|
|
9
|
+
*
|
|
10
|
+
* Requirements: 7.1-7.10
|
|
11
|
+
*/
|
|
12
|
+
import type { IExportGitPublicKeyResponse, ISignCommitResponse, ISignTagResponse, IVerifyGitSignatureResponse } from '@brightchain/brightchain-lib/lib/interfaces/responses/cryptoResponses';
|
|
13
|
+
import { PlatformID } from '@digitaldefiance/ecies-lib';
|
|
14
|
+
import { CoreLanguageCode } from '@digitaldefiance/i18n-lib';
|
|
15
|
+
import { ApiErrorResponse, ApiRequestHandler, TypedHandlers } from '@digitaldefiance/node-express-suite';
|
|
16
|
+
import { IBrightChainApplication } from '../../interfaces/application';
|
|
17
|
+
import { DefaultBackendIdType } from '../../shared-types';
|
|
18
|
+
import { BaseController } from '../base';
|
|
19
|
+
type GitApiResponse = ISignCommitResponse | ISignTagResponse | IVerifyGitSignatureResponse | IExportGitPublicKeyResponse | ApiErrorResponse;
|
|
20
|
+
interface GitHandlers extends TypedHandlers {
|
|
21
|
+
signCommit: ApiRequestHandler<ISignCommitResponse | ApiErrorResponse>;
|
|
22
|
+
signTag: ApiRequestHandler<ISignTagResponse | ApiErrorResponse>;
|
|
23
|
+
verifySignature: ApiRequestHandler<IVerifyGitSignatureResponse | ApiErrorResponse>;
|
|
24
|
+
exportPublicKey: ApiRequestHandler<IExportGitPublicKeyResponse | ApiErrorResponse>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Controller for Git commit and tag signing operations.
|
|
28
|
+
*
|
|
29
|
+
* Delegates to {@link GitSigningService} in brightchain-lib for
|
|
30
|
+
* core signing logic including ECDSA signing over SHA-256 hashes
|
|
31
|
+
* wrapped in PGP-armored format.
|
|
32
|
+
*
|
|
33
|
+
* @requirements 7.1, 7.2, 7.3, 7.4, 7.5
|
|
34
|
+
*/
|
|
35
|
+
export declare class GitController<TID extends PlatformID = DefaultBackendIdType> extends BaseController<TID, GitApiResponse, GitHandlers, CoreLanguageCode> {
|
|
36
|
+
constructor(application: IBrightChainApplication<TID>);
|
|
37
|
+
protected initRouteDefinitions(): void;
|
|
38
|
+
/**
|
|
39
|
+
* POST /sign-commit — Sign a Git commit.
|
|
40
|
+
*
|
|
41
|
+
* @requirements 7.1, 7.2
|
|
42
|
+
*/
|
|
43
|
+
private handleSignCommit;
|
|
44
|
+
/**
|
|
45
|
+
* POST /sign-tag — Sign a Git tag.
|
|
46
|
+
*
|
|
47
|
+
* @requirements 7.3
|
|
48
|
+
*/
|
|
49
|
+
private handleSignTag;
|
|
50
|
+
/**
|
|
51
|
+
* POST /verify — Verify a Git signature.
|
|
52
|
+
*
|
|
53
|
+
* Supports verification by paper key or by raw public key hex.
|
|
54
|
+
*
|
|
55
|
+
* @requirements 7.4
|
|
56
|
+
*/
|
|
57
|
+
private handleVerifySignature;
|
|
58
|
+
/**
|
|
59
|
+
* POST /export-public-key — Export the Git signing public key.
|
|
60
|
+
*
|
|
61
|
+
* @requirements 7.5
|
|
62
|
+
*/
|
|
63
|
+
private handleExportPublicKey;
|
|
64
|
+
/**
|
|
65
|
+
* Map Git signing errors to appropriate HTTP responses.
|
|
66
|
+
*/
|
|
67
|
+
private mapGitError;
|
|
68
|
+
}
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=gitController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitController.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-api-lib/src/lib/controllers/crypto/gitController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,2BAA2B,EAC5B,MAAM,uEAAuE,CAAC;AAK/E,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EAEd,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAIzC,KAAK,cAAc,GACf,mBAAmB,GACnB,gBAAgB,GAChB,2BAA2B,GAC3B,2BAA2B,GAC3B,gBAAgB,CAAC;AAIrB,UAAU,WAAY,SAAQ,aAAa;IACzC,UAAU,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,gBAAgB,CAAC,CAAC;IACtE,OAAO,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,CAAC;IAChE,eAAe,EAAE,iBAAiB,CAChC,2BAA2B,GAAG,gBAAgB,CAC/C,CAAC;IACF,eAAe,EAAE,iBAAiB,CAChC,2BAA2B,GAAG,gBAAgB,CAC/C,CAAC;CACH;AAsCD;;;;;;;;GAQG;AACH,qBAAa,aAAa,CACxB,GAAG,SAAS,UAAU,GAAG,oBAAoB,CAC7C,SAAQ,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,CAAC;gBAC9D,WAAW,EAAE,uBAAuB,CAAC,GAAG,CAAC;IAMrD,SAAS,CAAC,oBAAoB,IAAI,IAAI;IAmGtC;;;;OAIG;YACW,gBAAgB;IAqC9B;;;;OAIG;YACW,aAAa;IAqC3B;;;;;;OAMG;YACW,qBAAqB;IAyEnC;;;;OAIG;YACW,qBAAqB;IAmCnC;;OAEG;IACH,OAAO,CAAC,WAAW;CAepB"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GitController — REST API for Git commit/tag signing operations.
|
|
4
|
+
*
|
|
5
|
+
* Routes:
|
|
6
|
+
* POST /sign-commit — Sign a Git commit
|
|
7
|
+
* POST /sign-tag — Sign a Git tag
|
|
8
|
+
* POST /verify — Verify a Git signature
|
|
9
|
+
* POST /export-public-key — Export the signing public key in PGP format
|
|
10
|
+
*
|
|
11
|
+
* Requirements: 7.1-7.10
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.GitController = void 0;
|
|
15
|
+
const gitSigningService_1 = require("@brightchain/brightchain-lib/lib/services/crypto/gitSigningService");
|
|
16
|
+
const node_express_suite_1 = require("@digitaldefiance/node-express-suite");
|
|
17
|
+
const errorResponse_1 = require("../../utils/errorResponse");
|
|
18
|
+
const base_1 = require("../base");
|
|
19
|
+
// ─── Controller ─────────────────────────────────────────────────────────────
|
|
20
|
+
/**
|
|
21
|
+
* Controller for Git commit and tag signing operations.
|
|
22
|
+
*
|
|
23
|
+
* Delegates to {@link GitSigningService} in brightchain-lib for
|
|
24
|
+
* core signing logic including ECDSA signing over SHA-256 hashes
|
|
25
|
+
* wrapped in PGP-armored format.
|
|
26
|
+
*
|
|
27
|
+
* @requirements 7.1, 7.2, 7.3, 7.4, 7.5
|
|
28
|
+
*/
|
|
29
|
+
class GitController extends base_1.BaseController {
|
|
30
|
+
constructor(application) {
|
|
31
|
+
super(application);
|
|
32
|
+
}
|
|
33
|
+
// ─── Route definitions ──────────────────────────────────────────────────
|
|
34
|
+
initRouteDefinitions() {
|
|
35
|
+
const noAuth = {
|
|
36
|
+
useAuthentication: false,
|
|
37
|
+
useCryptoAuthentication: false,
|
|
38
|
+
};
|
|
39
|
+
this.routeDefinitions = [
|
|
40
|
+
(0, node_express_suite_1.routeConfig)('post', '/sign-commit', {
|
|
41
|
+
...noAuth,
|
|
42
|
+
handlerKey: 'signCommit',
|
|
43
|
+
openapi: {
|
|
44
|
+
summary: 'Sign a Git commit',
|
|
45
|
+
description: 'Signs a Git commit payload using ECDSA over SHA-256, producing a PGP-armored signature.',
|
|
46
|
+
tags: ['Git'],
|
|
47
|
+
responses: {
|
|
48
|
+
200: {
|
|
49
|
+
schema: 'SignCommitResponse',
|
|
50
|
+
description: 'Commit signed successfully',
|
|
51
|
+
},
|
|
52
|
+
400: {
|
|
53
|
+
schema: 'ApiErrorResponse',
|
|
54
|
+
description: 'Invalid paper key or missing content',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
(0, node_express_suite_1.routeConfig)('post', '/sign-tag', {
|
|
60
|
+
...noAuth,
|
|
61
|
+
handlerKey: 'signTag',
|
|
62
|
+
openapi: {
|
|
63
|
+
summary: 'Sign a Git tag',
|
|
64
|
+
description: 'Signs a Git tag payload using ECDSA over SHA-256, producing a PGP-armored signature.',
|
|
65
|
+
tags: ['Git'],
|
|
66
|
+
responses: {
|
|
67
|
+
200: {
|
|
68
|
+
schema: 'SignTagResponse',
|
|
69
|
+
description: 'Tag signed successfully',
|
|
70
|
+
},
|
|
71
|
+
400: {
|
|
72
|
+
schema: 'ApiErrorResponse',
|
|
73
|
+
description: 'Invalid paper key or missing content',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
(0, node_express_suite_1.routeConfig)('post', '/verify', {
|
|
79
|
+
...noAuth,
|
|
80
|
+
handlerKey: 'verifySignature',
|
|
81
|
+
openapi: {
|
|
82
|
+
summary: 'Verify a Git signature',
|
|
83
|
+
description: 'Verifies a Git commit or tag signature using the signer public key or paper key.',
|
|
84
|
+
tags: ['Git'],
|
|
85
|
+
responses: {
|
|
86
|
+
200: {
|
|
87
|
+
schema: 'VerifyGitSignatureResponse',
|
|
88
|
+
description: 'Verification result',
|
|
89
|
+
},
|
|
90
|
+
400: {
|
|
91
|
+
schema: 'ApiErrorResponse',
|
|
92
|
+
description: 'Missing required fields',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
97
|
+
(0, node_express_suite_1.routeConfig)('post', '/export-public-key', {
|
|
98
|
+
...noAuth,
|
|
99
|
+
handlerKey: 'exportPublicKey',
|
|
100
|
+
openapi: {
|
|
101
|
+
summary: 'Export Git signing public key',
|
|
102
|
+
description: 'Exports the Git signing public key in PGP-armored format for GPG keyring import.',
|
|
103
|
+
tags: ['Git'],
|
|
104
|
+
responses: {
|
|
105
|
+
200: {
|
|
106
|
+
schema: 'ExportGitPublicKeyResponse',
|
|
107
|
+
description: 'Public key exported successfully',
|
|
108
|
+
},
|
|
109
|
+
400: {
|
|
110
|
+
schema: 'ApiErrorResponse',
|
|
111
|
+
description: 'Invalid paper key',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
];
|
|
117
|
+
this.handlers = {
|
|
118
|
+
signCommit: this.handleSignCommit.bind(this),
|
|
119
|
+
signTag: this.handleSignTag.bind(this),
|
|
120
|
+
verifySignature: this.handleVerifySignature.bind(this),
|
|
121
|
+
exportPublicKey: this.handleExportPublicKey.bind(this),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// ─── Handlers ─────────────────────────────────────────────────────────
|
|
125
|
+
/**
|
|
126
|
+
* POST /sign-commit — Sign a Git commit.
|
|
127
|
+
*
|
|
128
|
+
* @requirements 7.1, 7.2
|
|
129
|
+
*/
|
|
130
|
+
async handleSignCommit(req) {
|
|
131
|
+
try {
|
|
132
|
+
const { paperKey, commitContent } = req.body;
|
|
133
|
+
if (!paperKey || typeof paperKey !== 'string') {
|
|
134
|
+
return (0, errorResponse_1.validationError)('Missing required field: paperKey');
|
|
135
|
+
}
|
|
136
|
+
if (!commitContent || typeof commitContent !== 'string') {
|
|
137
|
+
return (0, errorResponse_1.validationError)('Missing required field: commitContent');
|
|
138
|
+
}
|
|
139
|
+
const result = gitSigningService_1.GitSigningService.signCommit(paperKey, commitContent);
|
|
140
|
+
return {
|
|
141
|
+
statusCode: 200,
|
|
142
|
+
response: {
|
|
143
|
+
status: 'success',
|
|
144
|
+
data: {
|
|
145
|
+
memberId: '',
|
|
146
|
+
objectType: 'commit',
|
|
147
|
+
contentHashHex: result.contentHashHex,
|
|
148
|
+
armoredSignature: result.armoredSignature,
|
|
149
|
+
signatureHex: result.signatureHex,
|
|
150
|
+
derivationPath: result.derivationPath,
|
|
151
|
+
signedAt: new Date(),
|
|
152
|
+
},
|
|
153
|
+
message: 'Commit signed successfully',
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
return this.mapGitError(error);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* POST /sign-tag — Sign a Git tag.
|
|
163
|
+
*
|
|
164
|
+
* @requirements 7.3
|
|
165
|
+
*/
|
|
166
|
+
async handleSignTag(req) {
|
|
167
|
+
try {
|
|
168
|
+
const { paperKey, tagContent } = req.body;
|
|
169
|
+
if (!paperKey || typeof paperKey !== 'string') {
|
|
170
|
+
return (0, errorResponse_1.validationError)('Missing required field: paperKey');
|
|
171
|
+
}
|
|
172
|
+
if (!tagContent || typeof tagContent !== 'string') {
|
|
173
|
+
return (0, errorResponse_1.validationError)('Missing required field: tagContent');
|
|
174
|
+
}
|
|
175
|
+
const result = gitSigningService_1.GitSigningService.signTag(paperKey, tagContent);
|
|
176
|
+
return {
|
|
177
|
+
statusCode: 200,
|
|
178
|
+
response: {
|
|
179
|
+
status: 'success',
|
|
180
|
+
data: {
|
|
181
|
+
memberId: '',
|
|
182
|
+
objectType: 'tag',
|
|
183
|
+
contentHashHex: result.contentHashHex,
|
|
184
|
+
armoredSignature: result.armoredSignature,
|
|
185
|
+
signatureHex: result.signatureHex,
|
|
186
|
+
derivationPath: result.derivationPath,
|
|
187
|
+
signedAt: new Date(),
|
|
188
|
+
},
|
|
189
|
+
message: 'Tag signed successfully',
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
return this.mapGitError(error);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* POST /verify — Verify a Git signature.
|
|
199
|
+
*
|
|
200
|
+
* Supports verification by paper key or by raw public key hex.
|
|
201
|
+
*
|
|
202
|
+
* @requirements 7.4
|
|
203
|
+
*/
|
|
204
|
+
async handleVerifySignature(req) {
|
|
205
|
+
try {
|
|
206
|
+
const { content, signatureHex, contentHashHex, armoredSignature, derivationPath, paperKey, publicKeyHex, } = req.body;
|
|
207
|
+
if (!content || typeof content !== 'string') {
|
|
208
|
+
return (0, errorResponse_1.validationError)('Missing required field: content');
|
|
209
|
+
}
|
|
210
|
+
if (!signatureHex || typeof signatureHex !== 'string') {
|
|
211
|
+
return (0, errorResponse_1.validationError)('Missing required field: signatureHex');
|
|
212
|
+
}
|
|
213
|
+
if (!paperKey && !publicKeyHex) {
|
|
214
|
+
return (0, errorResponse_1.validationError)('Either paperKey or publicKeyHex must be provided');
|
|
215
|
+
}
|
|
216
|
+
const sigResult = {
|
|
217
|
+
armoredSignature: armoredSignature ?? '',
|
|
218
|
+
signatureHex,
|
|
219
|
+
contentHashHex: contentHashHex ?? '',
|
|
220
|
+
derivationPath: derivationPath ?? "m/44'/60'/0'/2/0",
|
|
221
|
+
};
|
|
222
|
+
let valid;
|
|
223
|
+
let verifyPubKeyHex;
|
|
224
|
+
let fingerprint;
|
|
225
|
+
if (publicKeyHex) {
|
|
226
|
+
valid = gitSigningService_1.GitSigningService.verifyWithPublicKey(content, sigResult, publicKeyHex);
|
|
227
|
+
verifyPubKeyHex = publicKeyHex;
|
|
228
|
+
fingerprint = '';
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
valid = gitSigningService_1.GitSigningService.verify(content, sigResult, paperKey);
|
|
232
|
+
const exported = gitSigningService_1.GitSigningService.exportPublicKey(paperKey);
|
|
233
|
+
verifyPubKeyHex = exported.publicKeyHex;
|
|
234
|
+
fingerprint = exported.fingerprint;
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
statusCode: 200,
|
|
238
|
+
response: {
|
|
239
|
+
status: 'success',
|
|
240
|
+
data: {
|
|
241
|
+
valid,
|
|
242
|
+
publicKeyHex: verifyPubKeyHex,
|
|
243
|
+
fingerprint,
|
|
244
|
+
verifiedAt: new Date(),
|
|
245
|
+
},
|
|
246
|
+
message: valid
|
|
247
|
+
? 'Signature is valid'
|
|
248
|
+
: 'Signature verification failed',
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
return this.mapGitError(error);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* POST /export-public-key — Export the Git signing public key.
|
|
258
|
+
*
|
|
259
|
+
* @requirements 7.5
|
|
260
|
+
*/
|
|
261
|
+
async handleExportPublicKey(req) {
|
|
262
|
+
try {
|
|
263
|
+
const { paperKey } = req.body;
|
|
264
|
+
if (!paperKey || typeof paperKey !== 'string') {
|
|
265
|
+
return (0, errorResponse_1.validationError)('Missing required field: paperKey');
|
|
266
|
+
}
|
|
267
|
+
const result = gitSigningService_1.GitSigningService.exportPublicKey(paperKey);
|
|
268
|
+
return {
|
|
269
|
+
statusCode: 200,
|
|
270
|
+
response: {
|
|
271
|
+
status: 'success',
|
|
272
|
+
data: {
|
|
273
|
+
memberId: '',
|
|
274
|
+
armoredPublicKey: result.armoredPublicKey,
|
|
275
|
+
publicKeyHex: result.publicKeyHex,
|
|
276
|
+
fingerprint: result.fingerprint,
|
|
277
|
+
derivationPath: result.derivationPath,
|
|
278
|
+
exportedAt: new Date(),
|
|
279
|
+
},
|
|
280
|
+
message: 'Public key exported successfully',
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
return this.mapGitError(error);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
// ─── Error mapping ──────────────────────────────────────────────────
|
|
289
|
+
/**
|
|
290
|
+
* Map Git signing errors to appropriate HTTP responses.
|
|
291
|
+
*/
|
|
292
|
+
mapGitError(error) {
|
|
293
|
+
if (error instanceof gitSigningService_1.GitSigningError) {
|
|
294
|
+
return {
|
|
295
|
+
statusCode: 400,
|
|
296
|
+
response: {
|
|
297
|
+
message: error.message,
|
|
298
|
+
error: 'GIT_SIGNING_ERROR',
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
return (0, errorResponse_1.handleError)(error);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
exports.GitController = GitController;
|
|
306
|
+
//# sourceMappingURL=gitController.js.map
|