@bopen-io/messagebox-server 1.2.1 → 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 +3 -3
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Logger } from '../../utils/logger.js';
|
|
2
|
+
import { runtimeDeps } from '../../runtimeDeps.js';
|
|
3
|
+
/**
|
|
4
|
+
* @swagger
|
|
5
|
+
* /permissions/list:
|
|
6
|
+
* get:
|
|
7
|
+
* summary: List message permissions for the authenticated user
|
|
8
|
+
* description: Retrieve all permissions set by the authenticated user with optional filtering and pagination
|
|
9
|
+
* tags:
|
|
10
|
+
* - Permissions
|
|
11
|
+
* parameters:
|
|
12
|
+
* - in: query
|
|
13
|
+
* name: messageBox
|
|
14
|
+
* required: false
|
|
15
|
+
* schema:
|
|
16
|
+
* type: string
|
|
17
|
+
* description: Optional messageBox type filter (e.g., 'notifications', 'inbox')
|
|
18
|
+
* - in: query
|
|
19
|
+
* name: limit
|
|
20
|
+
* required: false
|
|
21
|
+
* schema:
|
|
22
|
+
* type: integer
|
|
23
|
+
* minimum: 1
|
|
24
|
+
* maximum: 1000
|
|
25
|
+
* default: 100
|
|
26
|
+
* description: Maximum number of permissions to return
|
|
27
|
+
* - in: query
|
|
28
|
+
* name: offset
|
|
29
|
+
* required: false
|
|
30
|
+
* schema:
|
|
31
|
+
* type: integer
|
|
32
|
+
* minimum: 0
|
|
33
|
+
* default: 0
|
|
34
|
+
* description: Number of permissions to skip for pagination
|
|
35
|
+
* - in: query
|
|
36
|
+
* name: createdAtOrder
|
|
37
|
+
* required: false
|
|
38
|
+
* schema:
|
|
39
|
+
* type: string
|
|
40
|
+
* enum: ['asc', 'desc']
|
|
41
|
+
* default: 'desc'
|
|
42
|
+
* description: Sort order for created_at date (asc=oldest first, desc=newest first)
|
|
43
|
+
* responses:
|
|
44
|
+
* 200:
|
|
45
|
+
* description: Permissions retrieved successfully
|
|
46
|
+
* content:
|
|
47
|
+
* application/json:
|
|
48
|
+
* schema:
|
|
49
|
+
* type: object
|
|
50
|
+
* properties:
|
|
51
|
+
* status:
|
|
52
|
+
* type: string
|
|
53
|
+
* example: 'success'
|
|
54
|
+
* permissions:
|
|
55
|
+
* type: array
|
|
56
|
+
* items:
|
|
57
|
+
* type: object
|
|
58
|
+
* properties:
|
|
59
|
+
* sender:
|
|
60
|
+
* type: string
|
|
61
|
+
* nullable: true
|
|
62
|
+
* description: Sender identity key (null for box-wide defaults)
|
|
63
|
+
* messageBox:
|
|
64
|
+
* type: string
|
|
65
|
+
* description: MessageBox type
|
|
66
|
+
* recipientFee:
|
|
67
|
+
* type: integer
|
|
68
|
+
* description: Fee setting (-1=block all, 0=always allow, >0=satoshi amount)
|
|
69
|
+
* created_at:
|
|
70
|
+
* type: string
|
|
71
|
+
* format: date-time
|
|
72
|
+
* updated_at:
|
|
73
|
+
* type: string
|
|
74
|
+
* format: date-time
|
|
75
|
+
* total_count:
|
|
76
|
+
* type: integer
|
|
77
|
+
* description: Total number of permissions (useful for pagination)
|
|
78
|
+
* 400:
|
|
79
|
+
* description: Invalid query parameters
|
|
80
|
+
* 401:
|
|
81
|
+
* description: Unauthorized - authentication required
|
|
82
|
+
* 500:
|
|
83
|
+
* description: Internal server error
|
|
84
|
+
*/
|
|
85
|
+
export default {
|
|
86
|
+
type: 'get',
|
|
87
|
+
path: '/permissions/list',
|
|
88
|
+
/**
|
|
89
|
+
* List message permissions for the authenticated user
|
|
90
|
+
*
|
|
91
|
+
* @param {ListPermissionsRequest} req - Authenticated request with query parameters
|
|
92
|
+
* @param {Response} res - Express response object
|
|
93
|
+
* @returns {Promise<Response>} JSON response with permissions list
|
|
94
|
+
*/
|
|
95
|
+
func: async (req, res) => {
|
|
96
|
+
Logger.log('[DEBUG] Processing /permissions/list request...');
|
|
97
|
+
try {
|
|
98
|
+
// Validate authentication
|
|
99
|
+
if (req.auth?.identityKey == null) {
|
|
100
|
+
return res.status(401).json({
|
|
101
|
+
status: 'error',
|
|
102
|
+
code: 'ERR_UNAUTHORIZED',
|
|
103
|
+
description: 'Authentication required'
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// Parse and validate query parameters
|
|
107
|
+
const { messageBox, limit: limitStr, offset: offsetStr, createdAtOrder } = req.query;
|
|
108
|
+
const limit = limitStr != null ? Number.parseInt(limitStr, 10) : 100;
|
|
109
|
+
const offset = offsetStr != null ? Number.parseInt(offsetStr, 10) : 0;
|
|
110
|
+
const sortOrder = createdAtOrder === 'asc' ? 'asc' : 'desc'; // Default to 'desc'
|
|
111
|
+
// Validate pagination parameters
|
|
112
|
+
if (Number.isNaN(limit) || limit < 1 || limit > 1000) {
|
|
113
|
+
return res.status(400).json({
|
|
114
|
+
status: 'error',
|
|
115
|
+
code: 'ERR_INVALID_LIMIT',
|
|
116
|
+
description: 'Limit must be a number between 1 and 1000'
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (Number.isNaN(offset) || offset < 0) {
|
|
120
|
+
return res.status(400).json({
|
|
121
|
+
status: 'error',
|
|
122
|
+
code: 'ERR_INVALID_OFFSET',
|
|
123
|
+
description: 'Offset must be a non-negative number'
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
// Validate identity key format
|
|
127
|
+
const recipientKey = req.auth.identityKey;
|
|
128
|
+
Logger.log(`[DEBUG] Listing permissions for recipient: ${recipientKey}, messageBox: ${messageBox ?? 'all'}, limit: ${limit}, offset: ${offset}, createdAtOrder: ${sortOrder}`);
|
|
129
|
+
// Build base query
|
|
130
|
+
let query = runtimeDeps.knex('message_permissions')
|
|
131
|
+
.select([
|
|
132
|
+
'sender',
|
|
133
|
+
'message_box',
|
|
134
|
+
'recipient_fee',
|
|
135
|
+
'created_at',
|
|
136
|
+
'updated_at'
|
|
137
|
+
])
|
|
138
|
+
.where('recipient', recipientKey)
|
|
139
|
+
.orderBy([
|
|
140
|
+
{ column: 'message_box', order: 'asc' },
|
|
141
|
+
{ column: 'sender', order: 'asc', nulls: 'first' }, // Box-wide (null) first
|
|
142
|
+
{ column: 'created_at', order: sortOrder }
|
|
143
|
+
]);
|
|
144
|
+
// Apply messageBox filter if provided
|
|
145
|
+
if (messageBox != null) {
|
|
146
|
+
query = query.where('message_box', messageBox);
|
|
147
|
+
}
|
|
148
|
+
// Get total count for pagination info (before applying limit/offset)
|
|
149
|
+
const countQuery = query.clone().clearSelect().clearOrder().count('* as count');
|
|
150
|
+
const [{ count: totalCount }] = await countQuery;
|
|
151
|
+
const total = Number.parseInt(String(totalCount), 10);
|
|
152
|
+
// Apply pagination
|
|
153
|
+
const permissions = await query
|
|
154
|
+
.limit(limit)
|
|
155
|
+
.offset(offset);
|
|
156
|
+
Logger.log(`[DEBUG] Found ${permissions.length} permissions (${total} total)`);
|
|
157
|
+
return res.status(200).json({
|
|
158
|
+
status: 'success',
|
|
159
|
+
permissions: permissions.map(p => ({
|
|
160
|
+
sender: p.sender, // null for box-wide defaults
|
|
161
|
+
messageBox: p.message_box,
|
|
162
|
+
recipientFee: p.recipient_fee,
|
|
163
|
+
createdAt: p.created_at,
|
|
164
|
+
updatedAt: p.updated_at
|
|
165
|
+
})),
|
|
166
|
+
totalCount: total
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
Logger.error('[ERROR] Error listing permissions:', error);
|
|
171
|
+
return res.status(500).json({
|
|
172
|
+
status: 'error',
|
|
173
|
+
code: 'ERR_LIST_PERMISSIONS_FAILED',
|
|
174
|
+
description: 'Failed to list permissions'
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=listPermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listPermissions.js","sourceRoot":"","sources":["../../../../src/routes/permissions/listPermissions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAWlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AACH,eAAe;IACb,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,mBAAmB;IACzB;;;;;;OAMG;IACH,IAAI,EAAE,KAAK,EAAE,GAA2B,EAAE,GAAa,EAAqB,EAAE;Q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,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAA;YAErD,mBAAmB;YACnB,MAAM,WAAW,GAAG,MAAM,KAAK;iBAC5B,KAAK,CAAC,KAAK,CAAC;iBACZ,MAAM,CAAC,MAAM,CAAC,CAAA;YAEjB,MAAM,CAAC,GAAG,CAAC,iBAAiB,WAAW,CAAC,MAAM,iBAAiB,KAAK,SAAS,CAAC,CAAA;YAE9E,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBAC1B,MAAM,EAAE,SAAS;gBACjB,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;oBACjC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,6BAA6B;oBAC/C,UAAU,EAAE,CAAC,CAAC,WAAW;oBACzB,YAAY,EAAE,CAAC,CAAC,aAAa;oBAC7B,SAAS,EAAE,CAAC,CAAC,UAAU;oBACvB,SAAS,EAAE,CAAC,CAAC,UAAU;iBACxB,CAAC,CAAC;gBACH,UAAU,EAAE,KAAK;aAClB,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAA;YACzD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBAC1B,MAAM,EAAE,OAAO;gBACf,IAAI,EAAE,6BAA6B;gBACnC,WAAW,EAAE,4BAA4B;aAC1C,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { PublicKey } from '@bsv/sdk';
|
|
2
|
+
import { Logger } from '../../utils/logger.js';
|
|
3
|
+
import { setMessagePermission } from '../../utils/messagePermissions.js';
|
|
4
|
+
/**
|
|
5
|
+
* @swagger
|
|
6
|
+
* /permissions/set:
|
|
7
|
+
* post:
|
|
8
|
+
* summary: Set message permission for a sender/box combination or box-wide default
|
|
9
|
+
* description: Set permission level for receiving messages. If sender is provided, sets permission for that specific sender. If sender is omitted, sets box-wide default for all senders.
|
|
10
|
+
* tags:
|
|
11
|
+
* - Permissions
|
|
12
|
+
* requestBody:
|
|
13
|
+
* required: true
|
|
14
|
+
* content:
|
|
15
|
+
* application/json:
|
|
16
|
+
* schema:
|
|
17
|
+
* type: object
|
|
18
|
+
* required:
|
|
19
|
+
* - messageBox
|
|
20
|
+
* - recipientFee
|
|
21
|
+
* properties:
|
|
22
|
+
* sender:
|
|
23
|
+
* type: string
|
|
24
|
+
* description: identityKey of the sender (optional - if omitted, sets box-wide default for all senders)
|
|
25
|
+
* messageBox:
|
|
26
|
+
* type: string
|
|
27
|
+
* description: messageBox type (e.g., 'notifications', 'inbox')
|
|
28
|
+
* recipientFee:
|
|
29
|
+
* type: integer
|
|
30
|
+
* description: Fee level (-1=blocked, 0=always allow, >0=satoshi amount required)
|
|
31
|
+
* responses:
|
|
32
|
+
* 200:
|
|
33
|
+
* description: Permission successfully set/updated
|
|
34
|
+
* 400:
|
|
35
|
+
* description: Invalid request data
|
|
36
|
+
* 401:
|
|
37
|
+
* description: Authentication required
|
|
38
|
+
* 500:
|
|
39
|
+
* description: Internal server error
|
|
40
|
+
*/
|
|
41
|
+
export default {
|
|
42
|
+
type: 'post',
|
|
43
|
+
path: '/permissions/set',
|
|
44
|
+
func: async (req, res) => {
|
|
45
|
+
try {
|
|
46
|
+
Logger.log('[DEBUG] Processing set message permission request');
|
|
47
|
+
// Validate authentication
|
|
48
|
+
const recipient = req.auth?.identityKey;
|
|
49
|
+
if (recipient == null) {
|
|
50
|
+
Logger.log('[DEBUG] Authentication required for set permission');
|
|
51
|
+
return res.status(401).json({
|
|
52
|
+
status: 'error',
|
|
53
|
+
code: 'ERR_AUTHENTICATION_REQUIRED',
|
|
54
|
+
description: 'Authentication required.'
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const { sender, messageBox, recipientFee } = req.body;
|
|
58
|
+
// Validate request body (sender is optional)
|
|
59
|
+
if (messageBox == null || typeof recipientFee !== 'number') {
|
|
60
|
+
Logger.log('[DEBUG] Invalid request body for set permission');
|
|
61
|
+
return res.status(400).json({
|
|
62
|
+
status: 'error',
|
|
63
|
+
code: 'ERR_INVALID_REQUEST',
|
|
64
|
+
description: 'messageBox (string) and recipientFee (number) are required. sender (string) is optional for box-wide settings.'
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// Validate sender public key format only if provided
|
|
68
|
+
if (sender != null) {
|
|
69
|
+
try {
|
|
70
|
+
PublicKey.fromString(sender);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
Logger.log('[DEBUG] Invalid sender public key format');
|
|
74
|
+
return res.status(400).json({
|
|
75
|
+
status: 'error',
|
|
76
|
+
code: 'ERR_INVALID_PUBLIC_KEY',
|
|
77
|
+
description: 'Invalid sender public key format.'
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Validate recipientFee value
|
|
82
|
+
if (!Number.isInteger(recipientFee)) {
|
|
83
|
+
Logger.log('[DEBUG] Invalid recipientFee value - must be integer');
|
|
84
|
+
return res.status(400).json({
|
|
85
|
+
status: 'error',
|
|
86
|
+
code: 'ERR_INVALID_FEE_VALUE',
|
|
87
|
+
description: 'recipientFee must be an integer (-1, 0, or positive number).'
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// Validate messageBox value
|
|
91
|
+
if (typeof messageBox !== 'string' || messageBox.trim() === '') {
|
|
92
|
+
Logger.log('[DEBUG] Invalid messageBox value');
|
|
93
|
+
return res.status(400).json({
|
|
94
|
+
status: 'error',
|
|
95
|
+
code: 'ERR_INVALID_MESSAGE_BOX',
|
|
96
|
+
description: 'messageBox must be a non-empty string.'
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
// Set the message permission (convert undefined sender to null for box-wide)
|
|
100
|
+
const success = await setMessagePermission(recipient, sender ?? null, messageBox, recipientFee);
|
|
101
|
+
if (success == null) {
|
|
102
|
+
return res.status(500).json({
|
|
103
|
+
status: 'error',
|
|
104
|
+
code: 'ERR_DATABASE_ERROR',
|
|
105
|
+
description: 'Failed to update message permission.'
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const isBoxWide = sender == null;
|
|
109
|
+
Logger.log(`[DEBUG] Successfully updated message permission: ${sender ?? 'BOX-WIDE'} -> ${recipient} (${messageBox}), fee: ${recipientFee}`);
|
|
110
|
+
let description;
|
|
111
|
+
const senderText = isBoxWide ? 'all senders' : sender;
|
|
112
|
+
const actionText = isBoxWide ? 'Box-wide default for' : 'Messages from';
|
|
113
|
+
if (recipientFee === -1) {
|
|
114
|
+
description = `${actionText} ${senderText} to ${messageBox} ${isBoxWide ? 'is' : 'are'} now blocked.`;
|
|
115
|
+
}
|
|
116
|
+
else if (recipientFee === 0) {
|
|
117
|
+
description = `${actionText} ${senderText} to ${messageBox} ${isBoxWide ? 'is' : 'are'} now always allowed.`;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
description = `${actionText} ${senderText} to ${messageBox} now require${isBoxWide ? 's' : ''} ${recipientFee} satoshis.`;
|
|
121
|
+
}
|
|
122
|
+
return res.status(200).json({
|
|
123
|
+
status: 'success',
|
|
124
|
+
description
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
Logger.error('[ERROR] Internal Server Error in set permission:', error);
|
|
129
|
+
return res.status(500).json({
|
|
130
|
+
status: 'error',
|
|
131
|
+
code: 'ERR_INTERNAL',
|
|
132
|
+
description: 'An internal error has occurred.'
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=setPermission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setPermission.js","sourceRoot":"","sources":["../../../../src/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DAAkD,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,139 @@
|
|
|
1
|
+
import { Logger } from '../utils/logger.js';
|
|
2
|
+
import { runtimeDeps } from '../runtimeDeps.js';
|
|
3
|
+
/**
|
|
4
|
+
* @swagger
|
|
5
|
+
* /registerDevice:
|
|
6
|
+
* post:
|
|
7
|
+
* summary: Register device for push notifications
|
|
8
|
+
* description: Register a device's FCM token for receiving push notifications
|
|
9
|
+
* tags:
|
|
10
|
+
* - Device
|
|
11
|
+
* requestBody:
|
|
12
|
+
* required: true
|
|
13
|
+
* content:
|
|
14
|
+
* application/json:
|
|
15
|
+
* schema:
|
|
16
|
+
* type: object
|
|
17
|
+
* required:
|
|
18
|
+
* - fcmToken
|
|
19
|
+
* properties:
|
|
20
|
+
* fcmToken:
|
|
21
|
+
* type: string
|
|
22
|
+
* description: Firebase Cloud Messaging token
|
|
23
|
+
* deviceId:
|
|
24
|
+
* type: string
|
|
25
|
+
* description: Optional device identifier
|
|
26
|
+
* platform:
|
|
27
|
+
* type: string
|
|
28
|
+
* description: Device platform (ios, android, web)
|
|
29
|
+
* enum: [ios, android, web]
|
|
30
|
+
* responses:
|
|
31
|
+
* 200:
|
|
32
|
+
* description: Device registered successfully
|
|
33
|
+
* content:
|
|
34
|
+
* application/json:
|
|
35
|
+
* schema:
|
|
36
|
+
* type: object
|
|
37
|
+
* properties:
|
|
38
|
+
* status:
|
|
39
|
+
* type: string
|
|
40
|
+
* example: success
|
|
41
|
+
* message:
|
|
42
|
+
* type: string
|
|
43
|
+
* example: Device registered successfully
|
|
44
|
+
* deviceId:
|
|
45
|
+
* type: integer
|
|
46
|
+
* description: Database ID of the registered device
|
|
47
|
+
* 400:
|
|
48
|
+
* description: Invalid request parameters
|
|
49
|
+
* 401:
|
|
50
|
+
* description: Authentication required
|
|
51
|
+
* 500:
|
|
52
|
+
* description: Internal server error
|
|
53
|
+
*/
|
|
54
|
+
export default {
|
|
55
|
+
type: 'post',
|
|
56
|
+
path: '/registerDevice',
|
|
57
|
+
func: async (req, res) => {
|
|
58
|
+
try {
|
|
59
|
+
Logger.log('[DEBUG] Processing device registration request');
|
|
60
|
+
// Validate authentication
|
|
61
|
+
const identityKey = req.auth?.identityKey;
|
|
62
|
+
if (identityKey == null) {
|
|
63
|
+
Logger.log('[DEBUG] Authentication required for device registration');
|
|
64
|
+
return res.status(401).json({
|
|
65
|
+
status: 'error',
|
|
66
|
+
code: 'ERR_AUTHENTICATION_REQUIRED',
|
|
67
|
+
description: 'Authentication required.'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const { fcmToken, deviceId, platform } = req.body;
|
|
71
|
+
// Validate required fields
|
|
72
|
+
if (fcmToken == null || typeof fcmToken !== 'string' || fcmToken.trim() === '') {
|
|
73
|
+
Logger.log('[DEBUG] Invalid FCM token provided');
|
|
74
|
+
return res.status(400).json({
|
|
75
|
+
status: 'error',
|
|
76
|
+
code: 'ERR_INVALID_FCM_TOKEN',
|
|
77
|
+
description: 'fcmToken is required and must be a non-empty string.'
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
// Validate platform if provided
|
|
81
|
+
const validPlatforms = ['ios', 'android', 'web'];
|
|
82
|
+
if (platform != null && !validPlatforms.includes(platform)) {
|
|
83
|
+
Logger.log('[DEBUG] Invalid platform provided');
|
|
84
|
+
return res.status(400).json({
|
|
85
|
+
status: 'error',
|
|
86
|
+
code: 'ERR_INVALID_PLATFORM',
|
|
87
|
+
description: 'platform must be one of: ios, android, web'
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
// Insert or update device registration
|
|
92
|
+
const now = new Date();
|
|
93
|
+
const [deviceRegistrationId] = await runtimeDeps.knex('device_registrations')
|
|
94
|
+
.insert({
|
|
95
|
+
identity_key: identityKey,
|
|
96
|
+
fcm_token: fcmToken.trim(),
|
|
97
|
+
device_id: deviceId?.trim() ?? null,
|
|
98
|
+
platform: platform ?? null,
|
|
99
|
+
created_at: now,
|
|
100
|
+
updated_at: now,
|
|
101
|
+
active: true,
|
|
102
|
+
last_used: now
|
|
103
|
+
})
|
|
104
|
+
.onConflict('fcm_token')
|
|
105
|
+
.merge({
|
|
106
|
+
identity_key: identityKey, // Update identity key in case token was reassigned
|
|
107
|
+
device_id: deviceId?.trim() ?? null,
|
|
108
|
+
platform: platform ?? null,
|
|
109
|
+
updated_at: now,
|
|
110
|
+
active: true,
|
|
111
|
+
last_used: now
|
|
112
|
+
});
|
|
113
|
+
Logger.log(`[DEBUG] Device registered successfully: ${identityKey} with token ending in ...${fcmToken.slice(-10)}`);
|
|
114
|
+
return res.status(200).json({
|
|
115
|
+
status: 'success',
|
|
116
|
+
message: 'Device registered successfully for push notifications',
|
|
117
|
+
deviceId: deviceRegistrationId
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
catch (dbError) {
|
|
121
|
+
Logger.error('[ERROR] Database error during device registration:', dbError);
|
|
122
|
+
return res.status(500).json({
|
|
123
|
+
status: 'error',
|
|
124
|
+
code: 'ERR_DATABASE_ERROR',
|
|
125
|
+
description: 'Failed to register device.'
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
Logger.error('[ERROR] Internal Server Error in registerDevice:', error);
|
|
131
|
+
return res.status(500).json({
|
|
132
|
+
status: 'error',
|
|
133
|
+
code: 'ERR_INTERNAL',
|
|
134
|
+
description: 'An internal error has occurred.'
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=registerDevice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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