@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,176 @@
|
|
|
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 { log } from '../utils/logger.js';
|
|
12
|
+
import { runtimeDeps } from '../runtimeDeps.js';
|
|
13
|
+
/**
|
|
14
|
+
* @openapi
|
|
15
|
+
* /listMessages:
|
|
16
|
+
* post:
|
|
17
|
+
* summary: Retrieve messages from a specific messageBox
|
|
18
|
+
* description: |
|
|
19
|
+
* Returns all stored messages for the specified messageBox that belong to the authenticated identity.
|
|
20
|
+
* If the box does not exist or has no messages, an empty array is returned.
|
|
21
|
+
* tags:
|
|
22
|
+
* - Message
|
|
23
|
+
* requestBody:
|
|
24
|
+
* required: true
|
|
25
|
+
* content:
|
|
26
|
+
* application/json:
|
|
27
|
+
* schema:
|
|
28
|
+
* type: object
|
|
29
|
+
* properties:
|
|
30
|
+
* messageBox:
|
|
31
|
+
* type: string
|
|
32
|
+
* description: The name of the messageBox to retrieve messages from
|
|
33
|
+
* responses:
|
|
34
|
+
* 200:
|
|
35
|
+
* description: Successfully retrieved messages (can be empty)
|
|
36
|
+
* content:
|
|
37
|
+
* application/json:
|
|
38
|
+
* schema:
|
|
39
|
+
* type: object
|
|
40
|
+
* properties:
|
|
41
|
+
* status:
|
|
42
|
+
* type: string
|
|
43
|
+
* example: success
|
|
44
|
+
* messages:
|
|
45
|
+
* type: array
|
|
46
|
+
* items:
|
|
47
|
+
* type: object
|
|
48
|
+
* properties:
|
|
49
|
+
* messageId:
|
|
50
|
+
* type: string
|
|
51
|
+
* body:
|
|
52
|
+
* type: string
|
|
53
|
+
* sender:
|
|
54
|
+
* type: string
|
|
55
|
+
* createdAt:
|
|
56
|
+
* type: string
|
|
57
|
+
* format: date-time
|
|
58
|
+
* updatedAt:
|
|
59
|
+
* type: string
|
|
60
|
+
* format: date-time
|
|
61
|
+
* 400:
|
|
62
|
+
* description: Invalid or missing messageBox name
|
|
63
|
+
* 500:
|
|
64
|
+
* description: Internal server/database error
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* @exports
|
|
68
|
+
* Route definition used by the Express router to expose the `/listMessages` POST endpoint.
|
|
69
|
+
* Responsible for querying stored messages from a messageBox owned by the authenticated user.
|
|
70
|
+
*/
|
|
71
|
+
export default {
|
|
72
|
+
type: 'post',
|
|
73
|
+
path: '/listMessages',
|
|
74
|
+
get knex() { return runtimeDeps.knex; },
|
|
75
|
+
summary: 'Use this route to list messages from your messageBox.',
|
|
76
|
+
parameters: {
|
|
77
|
+
messageBox: 'The name of the messageBox you would like to list messages from.'
|
|
78
|
+
},
|
|
79
|
+
exampleResponse: {
|
|
80
|
+
status: 'success',
|
|
81
|
+
messages: [
|
|
82
|
+
{
|
|
83
|
+
messageId: '3301',
|
|
84
|
+
body: '{}',
|
|
85
|
+
sender: '028d37b941208cd6b8a4c28288eda5f2f16c2b3ab0fcb6d13c18b47fe37b971fc1'
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* @function func
|
|
91
|
+
* @description
|
|
92
|
+
* Express handler for listing stored messages in a specified messageBox.
|
|
93
|
+
*
|
|
94
|
+
* Input:
|
|
95
|
+
* - `req.body.messageBox`: Name of the messageBox to retrieve messages from.
|
|
96
|
+
* - `req.auth.identityKey`: Authenticated user’s public identity key.
|
|
97
|
+
*
|
|
98
|
+
* Behavior:
|
|
99
|
+
* - Checks if the specified messageBox exists for the identity.
|
|
100
|
+
* - If found, returns all messages in that messageBox.
|
|
101
|
+
* - If not found, returns an empty array.
|
|
102
|
+
* - Normalizes all message bodies to strings for consistent output.
|
|
103
|
+
*
|
|
104
|
+
* Output:
|
|
105
|
+
* - 200 with `{ status: 'success', messages: [...] }`
|
|
106
|
+
* - 400 if input is missing or malformed.
|
|
107
|
+
* - 500 on internal server/database errors.
|
|
108
|
+
*
|
|
109
|
+
* @param {ListMessagesRequest} req - Authenticated request containing the messageBox name
|
|
110
|
+
* @param {Response} res - Express response object
|
|
111
|
+
* @returns {Promise<Response>} JSON response containing message records or an error
|
|
112
|
+
*/
|
|
113
|
+
func: async (req, res) => {
|
|
114
|
+
try {
|
|
115
|
+
const { messageBox } = req.body;
|
|
116
|
+
// Validate a messageBox is provided and is a string
|
|
117
|
+
if (messageBox == null || messageBox === '') {
|
|
118
|
+
return res.status(400).json({
|
|
119
|
+
status: 'error',
|
|
120
|
+
code: 'ERR_MESSAGEBOX_REQUIRED',
|
|
121
|
+
description: 'Please provide the name of a valid MessageBox!'
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (typeof messageBox !== 'string') {
|
|
125
|
+
return res.status(400).json({
|
|
126
|
+
status: 'error',
|
|
127
|
+
code: 'ERR_INVALID_MESSAGEBOX',
|
|
128
|
+
description: 'MessageBox name must be a string!'
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// Find the messageBox ID for this user
|
|
132
|
+
const [messageBoxRecord] = await runtimeDeps.knex('messageBox')
|
|
133
|
+
.where({
|
|
134
|
+
identityKey: req.auth?.identityKey,
|
|
135
|
+
type: messageBox
|
|
136
|
+
})
|
|
137
|
+
.select('messageBoxId');
|
|
138
|
+
// Return empty array if no messageBox was found
|
|
139
|
+
if (messageBoxRecord === undefined) {
|
|
140
|
+
return res.status(200).json({
|
|
141
|
+
status: 'success',
|
|
142
|
+
messages: []
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
// Retrieve all messages associated with the messageBox
|
|
146
|
+
const messages = await runtimeDeps.knex('messages')
|
|
147
|
+
.where({
|
|
148
|
+
recipient: req.auth?.identityKey,
|
|
149
|
+
messageBoxId: messageBoxRecord.messageBoxId
|
|
150
|
+
})
|
|
151
|
+
.select('messageId', 'body', 'sender', 'created_at', 'updated_at');
|
|
152
|
+
// Normalize all message bodies to strings and convert to camelCase
|
|
153
|
+
const formattedMessages = messages.map(message => ({
|
|
154
|
+
messageId: message.messageId,
|
|
155
|
+
body: typeof message.body === 'string' ? message.body : JSON.stringify(message.body),
|
|
156
|
+
sender: message.sender,
|
|
157
|
+
createdAt: message.created_at,
|
|
158
|
+
updatedAt: message.updated_at
|
|
159
|
+
}));
|
|
160
|
+
// Return a list of matching messages
|
|
161
|
+
return res.status(200).json({
|
|
162
|
+
status: 'success',
|
|
163
|
+
messages: formattedMessages
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
log.error({ operation: 'messages.list', outcome: 'error', err: e }, 'Failed to list messages');
|
|
168
|
+
return res.status(500).json({
|
|
169
|
+
status: 'error',
|
|
170
|
+
code: 'ERR_INTERNAL_ERROR',
|
|
171
|
+
description: 'An internal error has occurred while listing messages.'
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
//# sourceMappingURL=listMessages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listMessages.js","sourceRoot":"","sources":["../../../src/routes/listMessages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAW/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH;;;;GAIG;AACH,eAAe;IACb,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,eAAe;IACrB,IAAI,IAAI,KAAM,OAAO,WAAW,CAAC,IAAI,CAAA,CAAC,CAAC;IACvC,OAAO,EAAE,uDAAuD;IAChE,UAAU,EAAE;QACV,UAAU,EAAE,kEAAkE;KAC/E;IACD,eAAe,EAAE;QACf,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE;YACR;gBACE,SAAS,EAAE,MAAM;gBACjB,IAAI,EAAE,IAAI;gBACV,MAA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';
|
|
2
|
+
import { Logger } from '../../utils/logger.js';
|
|
3
|
+
import { runtimeDeps } from '../../runtimeDeps.js';
|
|
4
|
+
/**
|
|
5
|
+
* @swagger
|
|
6
|
+
* /permissions/get:
|
|
7
|
+
* get:
|
|
8
|
+
* summary: Get message permission for a sender/box combination
|
|
9
|
+
* description: Retrieve the permission setting for a specific sender and message box combination
|
|
10
|
+
* tags:
|
|
11
|
+
* - Permissions
|
|
12
|
+
* parameters:
|
|
13
|
+
* - in: query
|
|
14
|
+
* name: sender
|
|
15
|
+
* required: false
|
|
16
|
+
* schema:
|
|
17
|
+
* type: string
|
|
18
|
+
* description: identityKey of the sender to check (omit for box-wide default)
|
|
19
|
+
* - in: query
|
|
20
|
+
* name: messageBox
|
|
21
|
+
* required: true
|
|
22
|
+
* schema:
|
|
23
|
+
* type: string
|
|
24
|
+
* description: messageBox type to check
|
|
25
|
+
* responses:
|
|
26
|
+
* 200:
|
|
27
|
+
* description: Permission setting retrieved successfully (or undefined if not set)
|
|
28
|
+
* 400:
|
|
29
|
+
* description: Invalid request parameters
|
|
30
|
+
* 401:
|
|
31
|
+
* description: Authentication required
|
|
32
|
+
* 500:
|
|
33
|
+
* description: Internal server error
|
|
34
|
+
*/
|
|
35
|
+
export default {
|
|
36
|
+
type: 'get',
|
|
37
|
+
path: '/permissions/get',
|
|
38
|
+
func: async (req, res) => {
|
|
39
|
+
try {
|
|
40
|
+
Logger.log('[DEBUG] Processing get message permission request');
|
|
41
|
+
// Validate authentication
|
|
42
|
+
if (req.auth?.identityKey == null) {
|
|
43
|
+
Logger.log('[DEBUG] Authentication required for get permission');
|
|
44
|
+
return res.status(401).json({
|
|
45
|
+
status: 'error',
|
|
46
|
+
code: 'ERR_AUTHENTICATION_REQUIRED',
|
|
47
|
+
description: 'Authentication required.'
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const { sender, messageBox } = req.query;
|
|
51
|
+
// Validate required parameters
|
|
52
|
+
if (messageBox == null) {
|
|
53
|
+
Logger.log('[DEBUG] Missing required parameters for get permission');
|
|
54
|
+
return res.status(400).json({
|
|
55
|
+
status: 'error',
|
|
56
|
+
code: 'ERR_MISSING_PARAMETERS',
|
|
57
|
+
description: 'messageBox parameter is required.'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Validate sender public key format if provided
|
|
61
|
+
if (sender != null) {
|
|
62
|
+
try {
|
|
63
|
+
PublicKey.fromString(sender);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
Logger.log('[DEBUG] Invalid sender public key format');
|
|
67
|
+
return res.status(400).json({
|
|
68
|
+
status: 'error',
|
|
69
|
+
code: 'ERR_INVALID_PUBLIC_KEY',
|
|
70
|
+
description: 'Invalid sender public key format.'
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const recipient = req.auth.identityKey;
|
|
75
|
+
// Get message permission directly from database
|
|
76
|
+
const whereClause = {
|
|
77
|
+
recipient,
|
|
78
|
+
message_box: messageBox
|
|
79
|
+
};
|
|
80
|
+
// Add sender condition (null for box-wide, specific sender for sender-specific)
|
|
81
|
+
if (sender != null) {
|
|
82
|
+
whereClause.sender = sender;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
whereClause.sender = null;
|
|
86
|
+
}
|
|
87
|
+
const permission = await runtimeDeps.knex('message_permissions')
|
|
88
|
+
.where(whereClause)
|
|
89
|
+
.select('recipient_fee', 'created_at', 'updated_at')
|
|
90
|
+
.first();
|
|
91
|
+
Logger.log(`[DEBUG] Permission record for ${sender ?? 'box-wide'} -> ${recipient} (${messageBox}): ${JSON.stringify(permission)}`);
|
|
92
|
+
if (permission != null) {
|
|
93
|
+
// Helper function to determine status from recipient fee
|
|
94
|
+
const getStatusFromFee = (fee) => {
|
|
95
|
+
if (fee === -1)
|
|
96
|
+
return 'blocked';
|
|
97
|
+
if (fee === 0)
|
|
98
|
+
return 'always_allow';
|
|
99
|
+
return 'payment_required';
|
|
100
|
+
};
|
|
101
|
+
// Permission is set, return it
|
|
102
|
+
return res.status(200).json({
|
|
103
|
+
status: 'success',
|
|
104
|
+
description: sender != null
|
|
105
|
+
? `Permission setting found for sender ${sender} to ${messageBox}.`
|
|
106
|
+
: `Box-wide permission setting found for ${messageBox}.`,
|
|
107
|
+
permission: {
|
|
108
|
+
sender: sender ?? null,
|
|
109
|
+
messageBox,
|
|
110
|
+
recipientFee: permission.recipient_fee,
|
|
111
|
+
status: getStatusFromFee(permission.recipient_fee),
|
|
112
|
+
createdAt: permission.created_at.toISOString(),
|
|
113
|
+
updatedAt: permission.updated_at.toISOString()
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// No permission set, return undefined
|
|
119
|
+
return res.status(200).json({
|
|
120
|
+
status: 'success',
|
|
121
|
+
description: sender != null
|
|
122
|
+
? `No permission setting found for sender ${sender} to ${messageBox}.`
|
|
123
|
+
: `No box-wide permission setting found for ${messageBox}.`,
|
|
124
|
+
permission: undefined
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
Logger.error('[ERROR] Internal Server Error in get permission:', error);
|
|
130
|
+
return res.status(500).json({
|
|
131
|
+
status: 'error',
|
|
132
|
+
code: 'ERR_INTERNAL',
|
|
133
|
+
description: 'An internal error has occurred.'
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=getPermission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPermission.js","sourceRoot":"","sources":["../../../../src/routes/permissions/getPermission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AASlD;;;;;;;;;;;;;;;;;;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;oBAC1D,UAAU,EAAE;wBACV,MAAM,EAAE,MAAM,IAAI,IAAI;wBACtB,UAAU;wBACV,YAAY,EAAE,UAAU,CAAC,aAAa;wBACtC,MAAM,EAAE,gBAAgB,CAAC,UAAU,CAAC,aAAa,CAAC;wBAClD,SAAS,EAAE,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE;wBAC9C,SAAS,EAAE,UAAU,CAAC,UAAU,CAAC,WAAW,EAAE;qBAC/C;iBACF,CAAC,CAAA;YACJ,CAAC;iBAAM,CAAC;gBACN,sCAAsC;gBACtC,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;oBAC1B,MAAM,EAAE,SAAS;oBACjB,WAAW,EAAE,MAAM,IAAI,IAAI;wBACzB,CAAC,CAAC,0CAA0C,MAAM,OAAO,UAAU,GAAG;wBACtE,CAAC,CAAC,4CAA4C,UAAU,GAAG;oBAC7D,UAAU,EAAE,SAAS;iBACtB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,kDAAkD,EAAE,KAAK,CAAC,CAAA;YACvE,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBAC1B,MAAM,EAAE,OAAO;gBACf,IAAI,EAAE,cAAc;gBACpB,WAAW,EAAE,iCAAiC;aAC/C,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { PublicKey } from '@bsv/sdk';
|
|
2
|
+
import { Logger, log } from '../../utils/logger.js';
|
|
3
|
+
import { getRecipientFee, getServerDeliveryFee } from '../../utils/messagePermissions.js';
|
|
4
|
+
/**
|
|
5
|
+
* @swagger
|
|
6
|
+
* /permissions/quote:
|
|
7
|
+
* get:
|
|
8
|
+
* summary: Get message delivery quote(s)
|
|
9
|
+
* description: Get pricing information for sending messages to one or many recipients' message boxes
|
|
10
|
+
* tags:
|
|
11
|
+
* - Permissions
|
|
12
|
+
* parameters:
|
|
13
|
+
* - in: query
|
|
14
|
+
* name: recipient
|
|
15
|
+
* required: true
|
|
16
|
+
* schema:
|
|
17
|
+
* oneOf:
|
|
18
|
+
* - type: string
|
|
19
|
+
* - type: array
|
|
20
|
+
* items:
|
|
21
|
+
* type: string
|
|
22
|
+
* description: identityKey of the recipient, or multiple recipients by repeating the parameter (?recipient=A&recipient=B)
|
|
23
|
+
* - in: query
|
|
24
|
+
* name: messageBox
|
|
25
|
+
* required: true
|
|
26
|
+
* schema:
|
|
27
|
+
* type: string
|
|
28
|
+
* description: messageBox type
|
|
29
|
+
* responses:
|
|
30
|
+
* 200:
|
|
31
|
+
* description: Quote(s) retrieved successfully
|
|
32
|
+
* 400:
|
|
33
|
+
* description: Invalid request parameters
|
|
34
|
+
* 401:
|
|
35
|
+
* description: Authentication required
|
|
36
|
+
* 500:
|
|
37
|
+
* description: Internal server error
|
|
38
|
+
*/
|
|
39
|
+
export default {
|
|
40
|
+
type: 'get',
|
|
41
|
+
path: '/permissions/quote',
|
|
42
|
+
func: async (req, res) => {
|
|
43
|
+
try {
|
|
44
|
+
Logger.log('[DEBUG] Processing message quote request');
|
|
45
|
+
log.debug({ operation: 'permissions.quote' }, 'Processing message quote request');
|
|
46
|
+
// Validate authentication (the caller is the SENDER)
|
|
47
|
+
const sender = req.auth?.identityKey;
|
|
48
|
+
if (sender == null) {
|
|
49
|
+
Logger.log('[DEBUG] Authentication required for message quote');
|
|
50
|
+
return res.status(401).json({
|
|
51
|
+
status: 'error',
|
|
52
|
+
code: 'ERR_AUTHENTICATION_REQUIRED',
|
|
53
|
+
description: 'Authentication required.'
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const { recipient, messageBox } = req.query;
|
|
57
|
+
// Required params
|
|
58
|
+
if (recipient == null || messageBox == null) {
|
|
59
|
+
Logger.log('[DEBUG] Missing required parameters for message quote');
|
|
60
|
+
return res.status(400).json({
|
|
61
|
+
status: 'error',
|
|
62
|
+
code: 'ERR_MISSING_PARAMETERS',
|
|
63
|
+
description: 'recipient and messageBox parameters are required.'
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// Normalize recipients to array (preserve order)
|
|
67
|
+
const recipients = Array.isArray(recipient) ? recipient : [recipient];
|
|
68
|
+
if (recipients.length === 0) {
|
|
69
|
+
return res.status(400).json({
|
|
70
|
+
status: 'error',
|
|
71
|
+
code: 'ERR_MISSING_PARAMETERS',
|
|
72
|
+
description: 'At least one recipient is required.'
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// Validate each recipient public key
|
|
76
|
+
const invalidIdx = [];
|
|
77
|
+
for (let i = 0; i < recipients.length; i++) {
|
|
78
|
+
try {
|
|
79
|
+
PublicKey.fromString(recipients[i]);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
invalidIdx.push(i);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (invalidIdx.length > 0) {
|
|
86
|
+
Logger.log('[DEBUG] Invalid recipient public key format in array');
|
|
87
|
+
return res.status(400).json({
|
|
88
|
+
status: 'error',
|
|
89
|
+
code: 'ERR_INVALID_PUBLIC_KEY',
|
|
90
|
+
description: `Invalid recipient public key at index(es): ${invalidIdx.join(', ')}.`
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
// Delivery fee for this messageBox (applies per message/recipient)
|
|
94
|
+
const perMessageDeliveryFee = await getServerDeliveryFee(messageBox);
|
|
95
|
+
// Single-recipient path → keep legacy response shape for compatibility
|
|
96
|
+
if (recipients.length === 1) {
|
|
97
|
+
const recipientKey = recipients[0];
|
|
98
|
+
const recipientFee = await getRecipientFee(recipientKey, sender, messageBox);
|
|
99
|
+
return res.status(200).json({
|
|
100
|
+
status: 'success',
|
|
101
|
+
description: 'Message delivery quote generated.',
|
|
102
|
+
quote: {
|
|
103
|
+
deliveryFee: perMessageDeliveryFee,
|
|
104
|
+
recipientFee
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
// Multi-recipient path → compute per-recipient, plus aggregates
|
|
109
|
+
const quotesByRecipient = [];
|
|
110
|
+
const blockedRecipients = [];
|
|
111
|
+
let totalRecipientFees = 0;
|
|
112
|
+
let totalDeliveryFees = 0;
|
|
113
|
+
// Helper to map fee -> status
|
|
114
|
+
const feeToStatus = (fee) => {
|
|
115
|
+
if (fee === -1)
|
|
116
|
+
return 'blocked';
|
|
117
|
+
if (fee === 0)
|
|
118
|
+
return 'always_allow';
|
|
119
|
+
return 'payment_required';
|
|
120
|
+
};
|
|
121
|
+
for (const r of recipients) {
|
|
122
|
+
const recipientFee = await getRecipientFee(r, sender, messageBox);
|
|
123
|
+
const status = feeToStatus(recipientFee);
|
|
124
|
+
quotesByRecipient.push({
|
|
125
|
+
recipient: r,
|
|
126
|
+
messageBox,
|
|
127
|
+
deliveryFee: perMessageDeliveryFee,
|
|
128
|
+
recipientFee,
|
|
129
|
+
status
|
|
130
|
+
});
|
|
131
|
+
// Aggregate: count deliveryFee per intended message, and recipientFee if not blocked
|
|
132
|
+
totalDeliveryFees += perMessageDeliveryFee;
|
|
133
|
+
if (recipientFee === -1) {
|
|
134
|
+
blockedRecipients.push(r);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
totalRecipientFees += recipientFee;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const totals = {
|
|
141
|
+
deliveryFees: totalDeliveryFees,
|
|
142
|
+
recipientFees: totalRecipientFees,
|
|
143
|
+
// If any are blocked, caller may want to handle those separately.
|
|
144
|
+
// We still provide a full monetary total for non-blocked recipients:
|
|
145
|
+
totalForPayableRecipients: totalDeliveryFees + totalRecipientFees
|
|
146
|
+
};
|
|
147
|
+
return res.status(200).json({
|
|
148
|
+
status: 'success',
|
|
149
|
+
description: `Message delivery quotes generated for ${recipients.length} recipients.`,
|
|
150
|
+
quotesByRecipient,
|
|
151
|
+
totals,
|
|
152
|
+
blockedRecipients
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
Logger.error('[ERROR] Internal Server Error in message quote:', error);
|
|
157
|
+
return res.status(500).json({
|
|
158
|
+
status: 'error',
|
|
159
|
+
code: 'ERR_INTERNAL',
|
|
160
|
+
description: 'An internal error has occurred.'
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=getQuote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getQuote.js","sourceRoot":"","sources":["../../../../src/routes/permissions/getQuote.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AASzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAe;IACb,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,KAAK,EAAE,GAAoB,EAAE,GAAa,EAAqB,EAAE;QACrE,IAAI,CAAC;YACH,MAAM,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAA;YACtD,GAAG,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,EAAE,kCAAkC,CAAC,CAAA;YAEjF,qDAAqD;YACrD,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,WAAW,CAAA;YACpC,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;gBACnB,MAAM,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAA;gBAC/D,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;oBAC1B,MAAM,EAAE,OAAO;oBACf,IAAI,EAAE,6BAA6B;oBACnC,WAAW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
+
import setPermission from './setPermission.js';
|
|
3
|
+
import getPermission from './getPermission.js';
|
|
4
|
+
import getQuote from './getQuote.js';
|
|
5
|
+
import listPermissions from './listPermissions.js';
|
|
6
|
+
export const permissionRoutes = [
|
|
7
|
+
setPermission,
|
|
8
|
+
getPermission,
|
|
9
|
+
getQuote,
|
|
10
|
+
listPermissions
|
|
11
|
+
];
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/routes/permissions/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,aAAa,MAAM,oBAAoB,CAAA;AAC9C,OAAO,aAAa,MAAM,oBAAoB,CAAA;AAC9C,OAAO,QAAQ,MAAM,eAAe,CAAA;AACpC,OAAO,eAAe,MAAM,sBAAsB,CAAA;AAElD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,aAAa;IACb,aAAa;IACb,QAAQ;IACR,eAAe;CAChB,CAAA"}
|