@bopen-io/messagebox-server 1.2.2 → 1.2.3
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/out/knexfile.js +25 -0
- package/out/knexfile.js.map +1 -0
- package/out/src/__tests/compose.test.js +25 -0
- package/out/src/__tests/compose.test.js.map +1 -0
- package/out/src/app.js +162 -0
- package/out/src/app.js.map +1 -0
- package/out/src/compose.js +239 -0
- package/out/src/compose.js.map +1 -0
- package/out/src/config/firebase.js +150 -0
- package/out/src/config/firebase.js.map +1 -0
- package/out/src/context.js +23 -0
- package/out/src/context.js.map +1 -0
- package/out/src/index.js +311 -0
- package/out/src/index.js.map +1 -0
- package/out/src/migrations/2022-12-28-001-initial-migration.js +28 -0
- package/out/src/migrations/2022-12-28-001-initial-migration.js.map +1 -0
- package/out/src/migrations/2023-01-17-messages-update.js +11 -0
- package/out/src/migrations/2023-01-17-messages-update.js.map +1 -0
- package/out/src/migrations/2024-03-05-001-messageID-upgrade.js +21 -0
- package/out/src/migrations/2024-03-05-001-messageID-upgrade.js.map +1 -0
- package/out/src/migrations/2025-01-31-001-notification-permissions.js +59 -0
- package/out/src/migrations/2025-01-31-001-notification-permissions.js.map +1 -0
- package/out/src/migrations/2025-01-31-002-device-registrations.js +24 -0
- package/out/src/migrations/2025-01-31-002-device-registrations.js.map +1 -0
- package/out/src/routes/__tests/acknowledgeMessage.test.js +135 -0
- package/out/src/routes/__tests/acknowledgeMessage.test.js.map +1 -0
- package/out/src/routes/__tests/listMessages.test.js +217 -0
- package/out/src/routes/__tests/listMessages.test.js.map +1 -0
- package/out/src/routes/__tests/sendMessage.test.js +313 -0
- package/out/src/routes/__tests/sendMessage.test.js.map +1 -0
- package/out/src/routes/acknowledgeMessage.js +133 -0
- package/out/src/routes/acknowledgeMessage.js.map +1 -0
- package/out/src/routes/index.js +17 -0
- package/out/src/routes/index.js.map +1 -0
- package/out/src/routes/listDevices.js +63 -0
- package/out/src/routes/listDevices.js.map +1 -0
- package/out/src/routes/listMessages.js +176 -0
- package/out/src/routes/listMessages.js.map +1 -0
- package/out/src/routes/permissions/getPermission.js +138 -0
- package/out/src/routes/permissions/getPermission.js.map +1 -0
- package/out/src/routes/permissions/getQuote.js +165 -0
- package/out/src/routes/permissions/getQuote.js.map +1 -0
- package/out/src/routes/permissions/index.js +12 -0
- package/out/src/routes/permissions/index.js.map +1 -0
- package/out/src/routes/permissions/listPermissions.js +179 -0
- package/out/src/routes/permissions/listPermissions.js.map +1 -0
- package/out/src/routes/permissions/setPermission.js +137 -0
- package/out/src/routes/permissions/setPermission.js.map +1 -0
- package/out/src/routes/registerDevice.js +139 -0
- package/out/src/routes/registerDevice.js.map +1 -0
- package/out/src/routes/sendMessage.js +438 -0
- package/out/src/routes/sendMessage.js.map +1 -0
- package/out/src/runtimeDeps.js +15 -0
- package/out/src/runtimeDeps.js.map +1 -0
- package/out/src/swagger.js +48 -0
- package/out/src/swagger.js.map +1 -0
- package/out/src/telemetry.js +134 -0
- package/out/src/telemetry.js.map +1 -0
- package/out/src/types/messagePermissions.js +2 -0
- package/out/src/types/messagePermissions.js.map +1 -0
- package/out/src/types/notifications.js +2 -0
- package/out/src/types/notifications.js.map +1 -0
- package/out/src/utils/logger.js +85 -0
- package/out/src/utils/logger.js.map +1 -0
- package/out/src/utils/messagePermissions.js +115 -0
- package/out/src/utils/messagePermissions.js.map +1 -0
- package/out/src/utils/sendFCMNotification.js +110 -0
- package/out/src/utils/sendFCMNotification.js.map +1 -0
- package/out/tsconfig.tsbuildinfo +1 -0
- package/out/types/jest.config.d.ts +4 -0
- package/out/types/jest.config.d.ts.map +1 -0
- package/out/types/jest.config.integration.d.ts +5 -0
- package/out/types/jest.config.integration.d.ts.map +1 -0
- package/out/types/knexfile.d.ts +6 -0
- package/out/types/knexfile.d.ts.map +1 -0
- package/out/types/src/__tests/compose.test.d.ts +2 -0
- package/out/types/src/__tests/compose.test.d.ts.map +1 -0
- package/out/types/src/app.d.ts +63 -0
- package/out/types/src/app.d.ts.map +1 -0
- package/out/types/src/compose.d.ts +22 -0
- package/out/types/src/compose.d.ts.map +1 -0
- package/out/types/src/config/firebase.d.ts +34 -0
- package/out/types/src/config/firebase.d.ts.map +1 -0
- package/out/types/src/context.d.ts +23 -0
- package/out/types/src/context.d.ts.map +1 -0
- package/out/types/src/index.d.ts +43 -0
- package/out/types/src/index.d.ts.map +1 -0
- package/out/types/src/migrations/2022-12-28-001-initial-migration.d.ts +4 -0
- package/out/types/src/migrations/2022-12-28-001-initial-migration.d.ts.map +1 -0
- package/out/types/src/migrations/2023-01-17-messages-update.d.ts +4 -0
- package/out/types/src/migrations/2023-01-17-messages-update.d.ts.map +1 -0
- package/out/types/src/migrations/2024-03-05-001-messageID-upgrade.d.ts +4 -0
- package/out/types/src/migrations/2024-03-05-001-messageID-upgrade.d.ts.map +1 -0
- package/out/types/src/migrations/2025-01-31-001-notification-permissions.d.ts +4 -0
- package/out/types/src/migrations/2025-01-31-001-notification-permissions.d.ts.map +1 -0
- package/out/types/src/migrations/2025-01-31-002-device-registrations.d.ts +4 -0
- package/out/types/src/migrations/2025-01-31-002-device-registrations.d.ts.map +1 -0
- package/out/types/src/routes/__tests/acknowledgeMessage.test.d.ts +2 -0
- package/out/types/src/routes/__tests/acknowledgeMessage.test.d.ts.map +1 -0
- package/out/types/src/routes/__tests/listMessages.test.d.ts +2 -0
- package/out/types/src/routes/__tests/listMessages.test.d.ts.map +1 -0
- package/out/types/src/routes/__tests/sendMessage.test.d.ts +2 -0
- package/out/types/src/routes/__tests/sendMessage.test.d.ts.map +1 -0
- package/out/types/src/routes/acknowledgeMessage.d.ts +100 -0
- package/out/types/src/routes/acknowledgeMessage.d.ts.map +1 -0
- package/out/types/src/routes/index.d.ts +11 -0
- package/out/types/src/routes/index.d.ts.map +1 -0
- package/out/types/src/routes/listDevices.d.ts +19 -0
- package/out/types/src/routes/listDevices.d.ts.map +1 -0
- package/out/types/src/routes/listMessages.d.ts +124 -0
- package/out/types/src/routes/listMessages.d.ts.map +1 -0
- package/out/types/src/routes/permissions/getPermission.d.ts +46 -0
- package/out/types/src/routes/permissions/getPermission.d.ts.map +1 -0
- package/out/types/src/routes/permissions/getQuote.d.ts +50 -0
- package/out/types/src/routes/permissions/getQuote.d.ts.map +1 -0
- package/out/types/src/routes/permissions/index.d.ts +18 -0
- package/out/types/src/routes/permissions/index.d.ts.map +1 -0
- package/out/types/src/routes/permissions/listPermissions.d.ts +106 -0
- package/out/types/src/routes/permissions/listPermissions.d.ts.map +1 -0
- package/out/types/src/routes/permissions/setPermission.d.ts +53 -0
- package/out/types/src/routes/permissions/setPermission.d.ts.map +1 -0
- package/out/types/src/routes/registerDevice.d.ts +67 -0
- package/out/types/src/routes/registerDevice.d.ts.map +1 -0
- package/out/types/src/routes/sendMessage.d.ts +140 -0
- package/out/types/src/routes/sendMessage.d.ts.map +1 -0
- package/out/types/src/runtimeDeps.d.ts +17 -0
- package/out/types/src/runtimeDeps.d.ts.map +1 -0
- package/out/types/src/swagger.d.ts +3 -0
- package/out/types/src/swagger.d.ts.map +1 -0
- package/out/types/src/telemetry.d.ts +2 -0
- package/out/types/src/telemetry.d.ts.map +1 -0
- package/out/types/src/types/messagePermissions.d.ts +15 -0
- package/out/types/src/types/messagePermissions.d.ts.map +1 -0
- package/out/types/src/types/notifications.d.ts +20 -0
- package/out/types/src/types/notifications.d.ts.map +1 -0
- package/out/types/src/utils/logger.d.ts +17 -0
- package/out/types/src/utils/logger.d.ts.map +1 -0
- package/out/types/src/utils/messagePermissions.d.ts +29 -0
- package/out/types/src/utils/messagePermissions.d.ts.map +1 -0
- package/out/types/src/utils/sendFCMNotification.d.ts +22 -0
- package/out/types/src/utils/sendFCMNotification.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.config.d.ts","sourceRoot":"","sources":["../../jest.config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEnD,QAAA,MAAM,MAAM,EAAE,oBA6Bb,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.config.integration.d.ts","sourceRoot":"","sources":["../../jest.config.integration.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEnD,QAAA,MAAM,MAAM,EAAE,oBAoBb,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knexfile.d.ts","sourceRoot":"","sources":["../../knexfile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAqBhC,QAAA,MAAM,QAAQ,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;CAI3C,CAAA;AAED,eAAe,QAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests/compose.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file app.ts
|
|
3
|
+
* @description
|
|
4
|
+
* Initializes the MessageBoxServer Express app.
|
|
5
|
+
*
|
|
6
|
+
* Responsibilities:
|
|
7
|
+
* - Parses environment variables and loads config
|
|
8
|
+
* - Sets up Knex for DB access
|
|
9
|
+
* - Initializes WalletClient from the BSV SDK
|
|
10
|
+
* - Mounts Express routes (pre-auth and post-auth)
|
|
11
|
+
* - Applies auth middleware using wallet identity
|
|
12
|
+
*
|
|
13
|
+
* This file exports:
|
|
14
|
+
* - `app`: the configured Express instance
|
|
15
|
+
* - `walletReady`: a promise that resolves once the wallet is ready
|
|
16
|
+
* - `getWallet()`: async accessor for the WalletClient
|
|
17
|
+
* - `useRoutes()`: middleware + route initialization
|
|
18
|
+
* - `appReady`: promise that completes once all setup is done
|
|
19
|
+
*/
|
|
20
|
+
import { Express } from 'express';
|
|
21
|
+
import { Knex } from 'knex';
|
|
22
|
+
import type { WalletInterface } from '@bsv/sdk';
|
|
23
|
+
export declare const app: Express;
|
|
24
|
+
/**
|
|
25
|
+
* Knex instance connected based on environment (development, production, or staging).
|
|
26
|
+
*/
|
|
27
|
+
export declare const knex: Knex;
|
|
28
|
+
export declare const walletReady: Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* @function initializeWallet
|
|
31
|
+
* @description Initializes the WalletClient with a root identity key and storage backend.
|
|
32
|
+
*
|
|
33
|
+
* Loads configuration from the environment and connects to the wallet service.
|
|
34
|
+
*
|
|
35
|
+
* @returns {Promise<void>} Resolves when the wallet is initialized.
|
|
36
|
+
* @throws If SERVER_PRIVATE_KEY is missing or invalid.
|
|
37
|
+
*/
|
|
38
|
+
export declare function initializeWallet(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* @function getWallet
|
|
41
|
+
* @description Waits for the WalletClient to be ready and returns the instance.
|
|
42
|
+
*
|
|
43
|
+
* @returns {Promise<WalletInterface>} The initialized wallet client
|
|
44
|
+
* @throws {Error} If called before the wallet is initialized
|
|
45
|
+
*/
|
|
46
|
+
export declare function getWallet(): Promise<WalletInterface>;
|
|
47
|
+
export declare const appReady: Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* @function useRoutes
|
|
50
|
+
* @description Registers all routes and middleware on the Express app instance.
|
|
51
|
+
*
|
|
52
|
+
* Steps:
|
|
53
|
+
* - Applies JSON body parser
|
|
54
|
+
* - Enables CORS headers for all routes
|
|
55
|
+
* - Waits for WalletClient to initialize
|
|
56
|
+
* - Adds authentication middleware
|
|
57
|
+
* - Mounts pre-auth and post-auth route handlers
|
|
58
|
+
*
|
|
59
|
+
* @returns {Promise<void>} Once all middleware and routes are mounted
|
|
60
|
+
* @throws If wallet is not available when needed
|
|
61
|
+
*/
|
|
62
|
+
export declare function useRoutes(): Promise<void>;
|
|
63
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAgB,EACd,OAAO,EAKR,MAAM,SAAS,CAAA;AAMhB,OAAgB,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAW/C,eAAO,MAAM,GAAG,EAAE,OAAmB,CAAA;AAgBrC;;GAEG;AACH,eAAO,MAAM,IAAI,EAAE,IAQlB,CAAA;AAKD,eAAO,MAAM,WAAW,eAEtB,CAAA;AAEF;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,IAAK,OAAO,CAAC,IAAI,CAAC,CAavD;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,IAAK,OAAO,CAAC,eAAe,CAAC,CAM3D;AAGD,eAAO,MAAM,QAAQ,eAGjB,CAAA;AAEJ;;;;;;;;;;;;;GAaG;AACH,wBAAsB,SAAS,IAAK,OAAO,CAAC,IAAI,CAAC,CAoEhD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composable entrypoints for embedding messagebox in a parent app.
|
|
3
|
+
* Standalone binary continues to use index.ts → app.ts as before.
|
|
4
|
+
*/
|
|
5
|
+
import { type Express } from 'express';
|
|
6
|
+
import type { Server as HttpServer } from 'node:http';
|
|
7
|
+
import { AuthSocketServer } from '@bsv/authsocket';
|
|
8
|
+
import type { MessageBoxContext } from './context.js';
|
|
9
|
+
export { createMessageBoxContext } from './context.js';
|
|
10
|
+
export type { MessageBoxContext, CreateMessageBoxContextOptions } from './context.js';
|
|
11
|
+
export declare function createMessageBoxApp(): Express;
|
|
12
|
+
/**
|
|
13
|
+
* Mount messagebox HTTP routes on an Express app.
|
|
14
|
+
* Auth/payment middleware apply only to this router (not the parent app).
|
|
15
|
+
*/
|
|
16
|
+
export declare function mountMessageBoxRoutes(app: Express, ctx: MessageBoxContext): void;
|
|
17
|
+
/**
|
|
18
|
+
* Attach authenticated WebSocket handlers. Mirrors standalone index.ts behavior
|
|
19
|
+
* with injected wallet/knex instead of module singletons.
|
|
20
|
+
*/
|
|
21
|
+
export declare function attachMessageBoxWebSockets(httpServer: HttpServer, ctx: MessageBoxContext): AuthSocketServer | null;
|
|
22
|
+
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../../src/compose.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAgB,EACd,KAAK,OAAO,EAMb,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAA;AAIrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAMlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAErD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,YAAY,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAA;AAKrF,wBAAgB,mBAAmB,IAAK,OAAO,CAE9C;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB,GAAG,IAAI,CAuDjF;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,iBAAiB,GACrB,gBAAgB,GAAG,IAAI,CAsLzB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type App } from 'firebase-admin/app';
|
|
2
|
+
import { type Messaging } from 'firebase-admin/messaging';
|
|
3
|
+
import { type Firestore } from 'firebase-admin/firestore';
|
|
4
|
+
/**
|
|
5
|
+
* Initialize Firebase Admin SDK.
|
|
6
|
+
* Returns null (and logs a warning) when ENABLE_FIREBASE is not 'true',
|
|
7
|
+
* or when FIREBASE_PROJECT_ID is absent, so the server can run without Firebase.
|
|
8
|
+
*/
|
|
9
|
+
export declare function initializeFirebase(): App | null;
|
|
10
|
+
/**
|
|
11
|
+
* Get Firebase Messaging instance, or null if Firebase is not initialized.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getFirebaseMessaging(): Messaging | null;
|
|
14
|
+
/**
|
|
15
|
+
* Get Firestore instance
|
|
16
|
+
*/
|
|
17
|
+
export declare function getFirebaseFirestore(): Firestore;
|
|
18
|
+
interface FCMPayload {
|
|
19
|
+
title: string;
|
|
20
|
+
body: string;
|
|
21
|
+
icon?: string;
|
|
22
|
+
badge?: number;
|
|
23
|
+
data?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
interface SendNotificationResult {
|
|
26
|
+
success: boolean;
|
|
27
|
+
messageId: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Send a push notification via FCM
|
|
31
|
+
*/
|
|
32
|
+
export declare function sendNotification(fcmToken: string, payload: FCMPayload): Promise<SendNotificationResult>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=firebase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase.d.ts","sourceRoot":"","sources":["../../../../src/config/firebase.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4D,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAA;AACvG,OAAO,EAAgB,KAAK,SAAS,EAAgB,MAAM,0BAA0B,CAAA;AACrF,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAA;AASvE;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,GAAG,GAAG,IAAI,CA4E/C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,SAAS,GAAG,IAAI,CAKvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,SAAS,CAOhD;AAED,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,UAAU,sBAAsB;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,sBAAsB,CAAC,CA+CjC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Knex } from 'knex';
|
|
2
|
+
import type { WalletInterface } from '@bsv/sdk';
|
|
3
|
+
import type { Request } from 'express';
|
|
4
|
+
export interface MessageBoxContext {
|
|
5
|
+
wallet: WalletInterface;
|
|
6
|
+
knex: Knex;
|
|
7
|
+
routingPrefix: string;
|
|
8
|
+
enableWebSockets: boolean;
|
|
9
|
+
enableSwagger: boolean;
|
|
10
|
+
calculateRequestPrice: (req: Request) => Promise<number> | number;
|
|
11
|
+
logger: Console;
|
|
12
|
+
}
|
|
13
|
+
export interface CreateMessageBoxContextOptions {
|
|
14
|
+
wallet: WalletInterface;
|
|
15
|
+
knex: Knex;
|
|
16
|
+
routingPrefix?: string;
|
|
17
|
+
enableWebSockets?: boolean;
|
|
18
|
+
enableSwagger?: boolean;
|
|
19
|
+
calculateRequestPrice?: (req: Request) => Promise<number> | number;
|
|
20
|
+
logger?: Console;
|
|
21
|
+
}
|
|
22
|
+
export declare function createMessageBoxContext(deps: CreateMessageBoxContextOptions): MessageBoxContext;
|
|
23
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAChC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,IAAI,CAAA;IACV,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,EAAE,OAAO,CAAA;IACzB,aAAa,EAAE,OAAO,CAAA;IACtB,qBAAqB,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;IACjE,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,IAAI,CAAA;IACV,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,qBAAqB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;IAClE,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,8BAA8B,GACnC,iBAAiB,CAsBnB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file index.ts
|
|
3
|
+
* @description
|
|
4
|
+
* Main entry point for the MessageBox Server.
|
|
5
|
+
*
|
|
6
|
+
* Responsibilities:
|
|
7
|
+
* - Initializes environment variables and config
|
|
8
|
+
* - Creates HTTP and WebSocket servers
|
|
9
|
+
* - Boots authentication and route handlers
|
|
10
|
+
* - Sets up database migrations after a short delay
|
|
11
|
+
* - Emits and handles real-time message events over WebSocket
|
|
12
|
+
*
|
|
13
|
+
* Exports:
|
|
14
|
+
* - `start()` for programmatic bootstrapping
|
|
15
|
+
* - `http` and `io` server instances
|
|
16
|
+
* - `HTTP_PORT` and `ROUTING_PREFIX` for external reference
|
|
17
|
+
*/
|
|
18
|
+
import { AuthSocketServer } from '@bsv/authsocket';
|
|
19
|
+
declare const ROUTING_PREFIX: string;
|
|
20
|
+
declare const HTTP_PORT: number;
|
|
21
|
+
declare const http: import("node:http").Server<typeof import("node:http").IncomingMessage, typeof import("node:http").ServerResponse>;
|
|
22
|
+
declare const ioRef: {
|
|
23
|
+
current: AuthSocketServer | null;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @function start
|
|
27
|
+
* @description
|
|
28
|
+
* Initializes the WebSocket server with identity-key-based authentication
|
|
29
|
+
* and attaches all supported event handlers for:
|
|
30
|
+
* - `sendMessage`
|
|
31
|
+
* - `joinRoom`
|
|
32
|
+
* - `leaveRoom`
|
|
33
|
+
* - `disconnect`
|
|
34
|
+
*
|
|
35
|
+
* Only runs if `ENABLE_WEBSOCKETS` is set to `true` in the environment.
|
|
36
|
+
*
|
|
37
|
+
* @returns {Promise<void>} Resolves once WebSocket listeners are fully attached.
|
|
38
|
+
*/
|
|
39
|
+
export declare const start: () => Promise<void>;
|
|
40
|
+
export { ioRef as io, http, HTTP_PORT, ROUTING_PREFIX };
|
|
41
|
+
export { createMessageBoxContext, createMessageBoxApp, mountMessageBoxRoutes, attachMessageBoxWebSockets } from './compose.js';
|
|
42
|
+
export type { MessageBoxContext, CreateMessageBoxContextOptions } from './context.js';
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAQlD,QAAA,MAKE,cAAc,QACD,CAAA;AAUf,QAAA,MAAM,SAAS,EAAE,MAML,CAAA;AAYZ,QAAA,MAAM,IAAI,mHAAoB,CAAA;AAI9B,QAAA,MAAM,KAAK,EAAE;IAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAAsB,CAAA;AAErE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK,QAAa,OAAO,CAAC,IAAI,CAsP1C,CAAA;AAID,OAAO,EAAE,KAAK,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,CAAA;AA+BvD,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2022-12-28-001-initial-migration.d.ts","sourceRoot":"","sources":["../../../../src/migrations/2022-12-28-001-initial-migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,wBAAsB,EAAE,CAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBnD;AAED,wBAAsB,IAAI,CAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAGrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2023-01-17-messages-update.d.ts","sourceRoot":"","sources":["../../../../src/migrations/2023-01-17-messages-update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,wBAAsB,EAAE,CAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAInD;AAED,wBAAsB,IAAI,CAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAIrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2024-03-05-001-messageID-upgrade.d.ts","sourceRoot":"","sources":["../../../../src/migrations/2024-03-05-001-messageID-upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,wBAAsB,EAAE,CAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAUnD;AAED,wBAAsB,IAAI,CAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAUrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2025-01-31-001-notification-permissions.d.ts","sourceRoot":"","sources":["../../../../src/migrations/2025-01-31-001-notification-permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,wBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA4DlD;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAGpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2025-01-31-002-device-registrations.d.ts","sourceRoot":"","sources":["../../../../src/migrations/2025-01-31-002-device-registrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,wBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBlD;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acknowledgeMessage.test.d.ts","sourceRoot":"","sources":["../../../../../src/routes/__tests/acknowledgeMessage.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listMessages.test.d.ts","sourceRoot":"","sources":["../../../../../src/routes/__tests/listMessages.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendMessage.test.d.ts","sourceRoot":"","sources":["../../../../../src/routes/__tests/sendMessage.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file acknowledgeMessage.ts
|
|
3
|
+
* @description
|
|
4
|
+
* Express route to allow a client to acknowledge receipt of one or more messages.
|
|
5
|
+
* Acknowledged messages are permanently removed from the database for the
|
|
6
|
+
* authenticated identity key (recipient).
|
|
7
|
+
*
|
|
8
|
+
* This is used in the MessageBox system to clear delivered messages once received
|
|
9
|
+
* and handled on the client side (e.g., after syncing or displaying them).
|
|
10
|
+
*/
|
|
11
|
+
import { Request, Response } from 'express';
|
|
12
|
+
/**
|
|
13
|
+
* @interface AcknowledgeRequest
|
|
14
|
+
* @extends Request
|
|
15
|
+
* @description Represents an authenticated request body for acknowledging messages.
|
|
16
|
+
*/
|
|
17
|
+
export interface AcknowledgeRequest extends Request {
|
|
18
|
+
auth: {
|
|
19
|
+
identityKey: string;
|
|
20
|
+
};
|
|
21
|
+
body: {
|
|
22
|
+
messageIds?: string[];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @openapi
|
|
27
|
+
* /acknowledgeMessage:
|
|
28
|
+
* post:
|
|
29
|
+
* summary: Acknowledge receipt of one or more messages
|
|
30
|
+
* description: |
|
|
31
|
+
* Removes acknowledged messages from the database for the authenticated identity key.
|
|
32
|
+
* This is used after a client has received and handled messages.
|
|
33
|
+
* tags:
|
|
34
|
+
* - Message
|
|
35
|
+
* requestBody:
|
|
36
|
+
* required: true
|
|
37
|
+
* content:
|
|
38
|
+
* application/json:
|
|
39
|
+
* schema:
|
|
40
|
+
* type: object
|
|
41
|
+
* properties:
|
|
42
|
+
* messageIds:
|
|
43
|
+
* type: array
|
|
44
|
+
* items:
|
|
45
|
+
* type: string
|
|
46
|
+
* description: Array of message IDs to acknowledge
|
|
47
|
+
* responses:
|
|
48
|
+
* 200:
|
|
49
|
+
* description: Successfully acknowledged messages
|
|
50
|
+
* content:
|
|
51
|
+
* application/json:
|
|
52
|
+
* schema:
|
|
53
|
+
* type: object
|
|
54
|
+
* properties:
|
|
55
|
+
* status:
|
|
56
|
+
* type: string
|
|
57
|
+
* example: success
|
|
58
|
+
* 400:
|
|
59
|
+
* description: Invalid input or message not found
|
|
60
|
+
* 500:
|
|
61
|
+
* description: Internal server error
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* @exports
|
|
65
|
+
* Route definition for acknowledging MessageBox messages.
|
|
66
|
+
* This object is consumed by the Express route loader to register the endpoint.
|
|
67
|
+
*/
|
|
68
|
+
declare const _default: {
|
|
69
|
+
type: string;
|
|
70
|
+
path: string;
|
|
71
|
+
readonly knex: import("knex").Knex<any, any[]>;
|
|
72
|
+
summary: string;
|
|
73
|
+
parameters: {
|
|
74
|
+
messageIds: string[];
|
|
75
|
+
};
|
|
76
|
+
exampleResponse: {
|
|
77
|
+
status: string;
|
|
78
|
+
};
|
|
79
|
+
errors: never[];
|
|
80
|
+
/**
|
|
81
|
+
* @function func
|
|
82
|
+
* @description
|
|
83
|
+
* Express route handler that processes a POST request to acknowledge messages.
|
|
84
|
+
* Deletes messages from the database where:
|
|
85
|
+
* - recipient matches the authenticated identity key
|
|
86
|
+
* - messageId matches one or more of the provided IDs
|
|
87
|
+
*
|
|
88
|
+
* Returns:
|
|
89
|
+
* - 200 success if deletion occurs
|
|
90
|
+
* - 400 if no messages were found or input is invalid
|
|
91
|
+
* - 500 on internal error
|
|
92
|
+
*
|
|
93
|
+
* @param {AcknowledgeRequest} req - Express request object containing auth and message IDs
|
|
94
|
+
* @param {Response} res - Express response object
|
|
95
|
+
* @returns {Promise<Response>} JSON response with status and optional error codes
|
|
96
|
+
*/
|
|
97
|
+
func: (req: AcknowledgeRequest, res: Response) => Promise<Response>;
|
|
98
|
+
};
|
|
99
|
+
export default _default;
|
|
100
|
+
//# sourceMappingURL=acknowledgeMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acknowledgeMessage.d.ts","sourceRoot":"","sources":["../../../../src/routes/acknowledgeMessage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAI3C;;;;GAIG;AACH,MAAM,WAAW,kBAAmB,SAAQ,OAAO;IACjD,IAAI,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAA;IAC7B,IAAI,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;GAIG;;;;;;;;;;;;;IAcD;;;;;;;;;;;;;;;;OAgBG;gBACe,kBAAkB,OAAO,QAAQ,KAAG,OAAO,CAAC,QAAQ,CAAC;;AA9BzE,wBAmFC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/routes/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAM,CAAA;AAChF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAO1E,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Response } from 'express';
|
|
2
|
+
import { AuthRequest } from '@bsv/auth-express-middleware';
|
|
3
|
+
export interface RegisteredDevice {
|
|
4
|
+
id: number;
|
|
5
|
+
deviceId: string | null;
|
|
6
|
+
platform: string | null;
|
|
7
|
+
fcmToken: string;
|
|
8
|
+
active: boolean;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
updatedAt: string;
|
|
11
|
+
lastUsed: string;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: {
|
|
14
|
+
type: string;
|
|
15
|
+
path: string;
|
|
16
|
+
func: (req: AuthRequest, res: Response) => Promise<Response>;
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=listDevices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listDevices.d.ts","sourceRoot":"","sources":["../../../../src/routes/listDevices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAG1D,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB;;;;gBAKmB,WAAW,OAAO,QAAQ,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAHlE,wBA+DC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file listMessages.ts
|
|
3
|
+
* @description
|
|
4
|
+
* This route allows an authenticated user to retrieve messages from a specific named messageBox.
|
|
5
|
+
*
|
|
6
|
+
* Messages are only returned if the authenticated identity has access to the specified messageBox.
|
|
7
|
+
* If the messageBox does not exist, an empty message list is returned.
|
|
8
|
+
*
|
|
9
|
+
* Typical usage: Inbox or queue retrieval for real-time or deferred message delivery.
|
|
10
|
+
*/
|
|
11
|
+
import { Response } from 'express';
|
|
12
|
+
import { AuthRequest } from '@bsv/auth-express-middleware';
|
|
13
|
+
/**
|
|
14
|
+
* @interface ListMessagesRequest
|
|
15
|
+
* @extends Request
|
|
16
|
+
* @description Extends Express Request to include `auth` identity and expected `messageBox` body property.
|
|
17
|
+
*/
|
|
18
|
+
interface ListMessagesRequest extends AuthRequest {
|
|
19
|
+
body: {
|
|
20
|
+
messageBox?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @openapi
|
|
25
|
+
* /listMessages:
|
|
26
|
+
* post:
|
|
27
|
+
* summary: Retrieve messages from a specific messageBox
|
|
28
|
+
* description: |
|
|
29
|
+
* Returns all stored messages for the specified messageBox that belong to the authenticated identity.
|
|
30
|
+
* If the box does not exist or has no messages, an empty array is returned.
|
|
31
|
+
* tags:
|
|
32
|
+
* - Message
|
|
33
|
+
* requestBody:
|
|
34
|
+
* required: true
|
|
35
|
+
* content:
|
|
36
|
+
* application/json:
|
|
37
|
+
* schema:
|
|
38
|
+
* type: object
|
|
39
|
+
* properties:
|
|
40
|
+
* messageBox:
|
|
41
|
+
* type: string
|
|
42
|
+
* description: The name of the messageBox to retrieve messages from
|
|
43
|
+
* responses:
|
|
44
|
+
* 200:
|
|
45
|
+
* description: Successfully retrieved messages (can be empty)
|
|
46
|
+
* content:
|
|
47
|
+
* application/json:
|
|
48
|
+
* schema:
|
|
49
|
+
* type: object
|
|
50
|
+
* properties:
|
|
51
|
+
* status:
|
|
52
|
+
* type: string
|
|
53
|
+
* example: success
|
|
54
|
+
* messages:
|
|
55
|
+
* type: array
|
|
56
|
+
* items:
|
|
57
|
+
* type: object
|
|
58
|
+
* properties:
|
|
59
|
+
* messageId:
|
|
60
|
+
* type: string
|
|
61
|
+
* body:
|
|
62
|
+
* type: string
|
|
63
|
+
* sender:
|
|
64
|
+
* type: string
|
|
65
|
+
* createdAt:
|
|
66
|
+
* type: string
|
|
67
|
+
* format: date-time
|
|
68
|
+
* updatedAt:
|
|
69
|
+
* type: string
|
|
70
|
+
* format: date-time
|
|
71
|
+
* 400:
|
|
72
|
+
* description: Invalid or missing messageBox name
|
|
73
|
+
* 500:
|
|
74
|
+
* description: Internal server/database error
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* @exports
|
|
78
|
+
* Route definition used by the Express router to expose the `/listMessages` POST endpoint.
|
|
79
|
+
* Responsible for querying stored messages from a messageBox owned by the authenticated user.
|
|
80
|
+
*/
|
|
81
|
+
declare const _default: {
|
|
82
|
+
type: string;
|
|
83
|
+
path: string;
|
|
84
|
+
readonly knex: import("knex").Knex<any, any[]>;
|
|
85
|
+
summary: string;
|
|
86
|
+
parameters: {
|
|
87
|
+
messageBox: string;
|
|
88
|
+
};
|
|
89
|
+
exampleResponse: {
|
|
90
|
+
status: string;
|
|
91
|
+
messages: {
|
|
92
|
+
messageId: string;
|
|
93
|
+
body: string;
|
|
94
|
+
sender: string;
|
|
95
|
+
}[];
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* @function func
|
|
99
|
+
* @description
|
|
100
|
+
* Express handler for listing stored messages in a specified messageBox.
|
|
101
|
+
*
|
|
102
|
+
* Input:
|
|
103
|
+
* - `req.body.messageBox`: Name of the messageBox to retrieve messages from.
|
|
104
|
+
* - `req.auth.identityKey`: Authenticated user’s public identity key.
|
|
105
|
+
*
|
|
106
|
+
* Behavior:
|
|
107
|
+
* - Checks if the specified messageBox exists for the identity.
|
|
108
|
+
* - If found, returns all messages in that messageBox.
|
|
109
|
+
* - If not found, returns an empty array.
|
|
110
|
+
* - Normalizes all message bodies to strings for consistent output.
|
|
111
|
+
*
|
|
112
|
+
* Output:
|
|
113
|
+
* - 200 with `{ status: 'success', messages: [...] }`
|
|
114
|
+
* - 400 if input is missing or malformed.
|
|
115
|
+
* - 500 on internal server/database errors.
|
|
116
|
+
*
|
|
117
|
+
* @param {ListMessagesRequest} req - Authenticated request containing the messageBox name
|
|
118
|
+
* @param {Response} res - Express response object
|
|
119
|
+
* @returns {Promise<Response>} JSON response containing message records or an error
|
|
120
|
+
*/
|
|
121
|
+
func: (req: ListMessagesRequest, res: Response) => Promise<Response>;
|
|
122
|
+
};
|
|
123
|
+
export default _default;
|
|
124
|
+
//# sourceMappingURL=listMessages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listMessages.d.ts","sourceRoot":"","sources":["../../../../src/routes/listMessages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAI1D;;;;GAIG;AACH,UAAU,mBAAoB,SAAQ,WAAW;IAC/C,IAAI,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH;;;;GAIG;;;;;;;;;;;;;;;;;IAmBD;;;;;;;;;;;;;;;;;;;;;;;KAuBC;gBACiB,mBAAmB,OAAO,QAAQ,KAAG,OAAO,CAAC,QAAQ,CAAC;;AA1C1E,wBA8GC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Response } from 'express';
|
|
2
|
+
import { AuthRequest } from '@bsv/auth-express-middleware';
|
|
3
|
+
export interface GetPermissionRequest extends AuthRequest {
|
|
4
|
+
query: {
|
|
5
|
+
sender?: string;
|
|
6
|
+
messageBox?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @swagger
|
|
11
|
+
* /permissions/get:
|
|
12
|
+
* get:
|
|
13
|
+
* summary: Get message permission for a sender/box combination
|
|
14
|
+
* description: Retrieve the permission setting for a specific sender and message box combination
|
|
15
|
+
* tags:
|
|
16
|
+
* - Permissions
|
|
17
|
+
* parameters:
|
|
18
|
+
* - in: query
|
|
19
|
+
* name: sender
|
|
20
|
+
* required: false
|
|
21
|
+
* schema:
|
|
22
|
+
* type: string
|
|
23
|
+
* description: identityKey of the sender to check (omit for box-wide default)
|
|
24
|
+
* - in: query
|
|
25
|
+
* name: messageBox
|
|
26
|
+
* required: true
|
|
27
|
+
* schema:
|
|
28
|
+
* type: string
|
|
29
|
+
* description: messageBox type to check
|
|
30
|
+
* responses:
|
|
31
|
+
* 200:
|
|
32
|
+
* description: Permission setting retrieved successfully (or undefined if not set)
|
|
33
|
+
* 400:
|
|
34
|
+
* description: Invalid request parameters
|
|
35
|
+
* 401:
|
|
36
|
+
* description: Authentication required
|
|
37
|
+
* 500:
|
|
38
|
+
* description: Internal server error
|
|
39
|
+
*/
|
|
40
|
+
declare const _default: {
|
|
41
|
+
type: string;
|
|
42
|
+
path: string;
|
|
43
|
+
func: (req: GetPermissionRequest, res: Response) => Promise<Response>;
|
|
44
|
+
};
|
|
45
|
+
export default _default;
|
|
46
|
+
//# sourceMappingURL=getPermission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPermission.d.ts","sourceRoot":"","sources":["../../../../../src/routes/permissions/getPermission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAG1D,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,KAAK,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,UAAU,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;;gBAIiB,oBAAoB,OAAO,QAAQ,KAAG,OAAO,CAAC,QAAQ,CAAC;;AAH3E,wBA2GC"}
|