@arkstack/notifications 0.17.14 → 0.17.15
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/dist/index.d.ts +5 -2
- package/dist/index.js +12 -7
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -431,15 +431,18 @@ declare class PusherRealtimeDriver implements RealtimeDriver {
|
|
|
431
431
|
*
|
|
432
432
|
* @param authEndpoint
|
|
433
433
|
* @param middleware
|
|
434
|
+
* @param config
|
|
435
|
+
* @param channelPrefix
|
|
434
436
|
*/
|
|
435
|
-
static registerAuthRoute(authEndpoint?: string, middleware?: unknown | unknown[], config?: PusherTransportConfig): Promise<void>;
|
|
437
|
+
static registerAuthRoute(authEndpoint?: string, middleware?: unknown | unknown[], channelPrefix?: string, config?: PusherTransportConfig): Promise<void>;
|
|
436
438
|
/**
|
|
437
439
|
* Register a realtime autorization route
|
|
438
440
|
*
|
|
439
441
|
* @param authEndpoint
|
|
440
442
|
* @param middleware
|
|
443
|
+
* @param channelPrefix
|
|
441
444
|
*/
|
|
442
|
-
registerAuthRoute(authEndpoint?: string, middleware?: unknown | unknown[]): Promise<void>;
|
|
445
|
+
registerAuthRoute(authEndpoint?: string, middleware?: unknown | unknown[], channelPrefix?: string): Promise<void>;
|
|
443
446
|
}
|
|
444
447
|
//#endregion
|
|
445
448
|
//#region src/Contracts/RealtimeDriver.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { config, env, getModel } from "@arkstack/common";
|
|
1
|
+
import { RequestException, config as config$1, env, getModel } from "@arkstack/common";
|
|
2
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
3
|
import path, { join } from "node:path";
|
|
4
4
|
import nodemailer from "nodemailer";
|
|
@@ -192,7 +192,7 @@ var DbNotification = class extends NotificationContract {
|
|
|
192
192
|
//#region src/config.ts
|
|
193
193
|
const configure = (key, defaultValue) => {
|
|
194
194
|
try {
|
|
195
|
-
return config(`notifications.${key}`, defaultValue);
|
|
195
|
+
return config$1(`notifications.${key}`, defaultValue);
|
|
196
196
|
} catch {
|
|
197
197
|
return defaultValue;
|
|
198
198
|
}
|
|
@@ -366,7 +366,7 @@ var MailNotification = class extends NotificationContract {
|
|
|
366
366
|
*/
|
|
367
367
|
async send(message, subject, recipient, data) {
|
|
368
368
|
const mergedData = {
|
|
369
|
-
app_name: config("app.name", "Arkstack"),
|
|
369
|
+
app_name: config$1("app.name", "Arkstack"),
|
|
370
370
|
...this.mergeData(data)
|
|
371
371
|
};
|
|
372
372
|
const resolvedSubject = interpolate(subject ?? this.subjectLine ?? "", mergedData);
|
|
@@ -575,17 +575,20 @@ var PusherRealtimeDriver = class PusherRealtimeDriver {
|
|
|
575
575
|
*
|
|
576
576
|
* @param authEndpoint
|
|
577
577
|
* @param middleware
|
|
578
|
+
* @param config
|
|
579
|
+
* @param channelPrefix
|
|
578
580
|
*/
|
|
579
|
-
static async registerAuthRoute(authEndpoint = "/realtime/auth", middleware, config = {}) {
|
|
580
|
-
return new PusherRealtimeDriver(config).registerAuthRoute(authEndpoint, middleware);
|
|
581
|
+
static async registerAuthRoute(authEndpoint = "/realtime/auth", middleware, channelPrefix, config = {}) {
|
|
582
|
+
return new PusherRealtimeDriver(config).registerAuthRoute(authEndpoint, middleware, channelPrefix);
|
|
581
583
|
}
|
|
582
584
|
/**
|
|
583
585
|
* Register a realtime autorization route
|
|
584
586
|
*
|
|
585
587
|
* @param authEndpoint
|
|
586
588
|
* @param middleware
|
|
589
|
+
* @param channelPrefix
|
|
587
590
|
*/
|
|
588
|
-
async registerAuthRoute(authEndpoint = "/realtime/auth", middleware) {
|
|
591
|
+
async registerAuthRoute(authEndpoint = "/realtime/auth", middleware, channelPrefix) {
|
|
589
592
|
const client = await this.client();
|
|
590
593
|
for (const [name, path] of Object.entries({
|
|
591
594
|
express: "@arkstack/driver-express",
|
|
@@ -596,9 +599,11 @@ var PusherRealtimeDriver = class PusherRealtimeDriver {
|
|
|
596
599
|
const { Router } = await import(path);
|
|
597
600
|
const { auth } = await import(midsPath);
|
|
598
601
|
const middlewares = new Set(Array.isArray(middleware) ? middleware.concat(auth) : [middleware, auth]);
|
|
599
|
-
Router.post(authEndpoint, ({ clearRequest }) => {
|
|
602
|
+
Router.post(authEndpoint, ({ clearRequest, req }) => {
|
|
600
603
|
const channel = clearRequest.input("channel_name");
|
|
601
604
|
const socketId = clearRequest.input("socket_id");
|
|
605
|
+
const expected = channelPrefix ?? `${config("notifications.drivers.realtime.channel_prefix", "user.")}${req.user?.id ?? clearRequest.user?.id}`;
|
|
606
|
+
RequestException.abortIf(channel !== expected, "Channel access denied", 403);
|
|
602
607
|
return client.authorizeChannel(socketId, channel);
|
|
603
608
|
}).middleware(Array.from(middlewares));
|
|
604
609
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/notifications",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Framework-agnostic notification module for Arkstack and Nodejs, providing support for multi-channel notification delivery.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net/guide/notifications",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"africastalking": "^0.8.0",
|
|
35
35
|
"nodemailer": "^9.0.3",
|
|
36
36
|
"twilio": "^6.0.2",
|
|
37
|
-
"@arkstack/common": "^0.17.
|
|
37
|
+
"@arkstack/common": "^0.17.15"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@kanun-hq/plugin-phone": "^0.1.8",
|
|
41
41
|
"firebase-admin": "^13.0.0",
|
|
42
42
|
"pusher": "^5.2.0",
|
|
43
|
-
"@arkstack/contract": "^0.17.
|
|
44
|
-
"@arkstack/database": "^0.17.
|
|
45
|
-
"@arkstack/driver-
|
|
46
|
-
"@arkstack/driver-
|
|
43
|
+
"@arkstack/contract": "^0.17.15",
|
|
44
|
+
"@arkstack/database": "^0.17.15",
|
|
45
|
+
"@arkstack/driver-express": "^0.17.15",
|
|
46
|
+
"@arkstack/driver-h3": "^0.17.15"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"@arkstack/driver-express": {
|