@visulima/notification 1.0.16 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +75 -15
- package/dist/channels/inapp/index.d.ts +4 -2
- package/dist/channels/inapp/index.js +1 -1
- package/dist/inbound/index.d.ts +97 -0
- package/dist/inbound/index.js +1 -0
- package/dist/packem_shared/chatReply-HANpcetF.js +1 -0
- package/dist/packem_shared/createDiscordReceiver-ErG7MJ_N.js +1 -0
- package/dist/packem_shared/createInboundRouter-DWk4xvCj.js +1 -0
- package/dist/packem_shared/createMessageBirdReceiver-DNPoScxB.js +1 -0
- package/dist/packem_shared/createMsTeamsReceiver-CKZsylzU.js +1 -0
- package/dist/packem_shared/createSlackReceiver-BHY2tumz.js +1 -0
- package/dist/packem_shared/{snsProvider-BtlNUN7u.js → createSnsProvider-Df9fqQ2A.js} +1 -1
- package/dist/packem_shared/createTelegramReceiver-BjZa0eVx.js +1 -0
- package/dist/packem_shared/createTelnyxReceiver-Ev-ThOtu.js +1 -0
- package/dist/packem_shared/createTwilioReceiver-CQmdSCMX.js +1 -0
- package/dist/packem_shared/createVonageReceiver-BWVR3E7q.js +1 -0
- package/dist/packem_shared/{webPushProvider-CUDMDRKw.js → createWebPushProvider-BNu3bPeV.js} +1 -1
- package/dist/packem_shared/hmacBase64-ocSXhrdQ.js +1 -0
- package/dist/packem_shared/isJwtTimeValid-CdCG24pW.js +1 -0
- package/dist/packem_shared/{slackWebhook-CGbFBgpo.js → slackWebhook-DILLGl3P.js} +1 -1
- package/dist/packem_shared/snsWebhook-DTBQW5U5.js +3 -0
- package/dist/packem_shared/{standardWebhook-DV_fVNtX.js → standardWebhook-CPjtIEKe.js} +1 -1
- package/dist/packem_shared/{twilioWebhook-DScQeZta.js → twilioWebhook-BjM8B0sB.js} +1 -1
- package/dist/packem_shared/types.d-4T7bNo4x.d.ts +182 -0
- package/dist/packem_shared/types.d-BXfGenMH.d.ts +34 -0
- package/dist/packem_shared/utils-DuaeYOiD.js +1 -0
- package/dist/packem_shared/verifyEd25519-lmU3nhP0.js +1 -0
- package/dist/packem_shared/{webcrypto-Cz40u9vp.js → webcrypto-BPm3NDEm.js} +1 -1
- package/dist/providers/chat/discord/index.d.ts +40 -3
- package/dist/providers/chat/discord/index.js +1 -1
- package/dist/providers/chat/msteams/index.d.ts +31 -3
- package/dist/providers/chat/msteams/index.js +1 -1
- package/dist/providers/chat/slack/index.d.ts +31 -3
- package/dist/providers/chat/slack/index.js +1 -1
- package/dist/providers/chat/telegram/index.d.ts +32 -3
- package/dist/providers/chat/telegram/index.js +1 -1
- package/dist/providers/failover/index.d.ts +4 -2
- package/dist/providers/failover/index.js +1 -1
- package/dist/providers/mock/index.d.ts +4 -2
- package/dist/providers/mock/index.js +1 -1
- package/dist/providers/opentelemetry/index.d.ts +4 -2
- package/dist/providers/opentelemetry/index.js +1 -1
- package/dist/providers/push/apns/index.d.ts +4 -2
- package/dist/providers/push/apns/index.js +1 -1
- package/dist/providers/push/expo/index.d.ts +4 -2
- package/dist/providers/push/expo/index.js +1 -1
- package/dist/providers/push/fcm/index.d.ts +4 -2
- package/dist/providers/push/fcm/index.js +1 -1
- package/dist/providers/push/web-push/index.d.ts +4 -2
- package/dist/providers/push/web-push/index.js +1 -1
- package/dist/providers/roundrobin/index.d.ts +4 -2
- package/dist/providers/roundrobin/index.js +1 -1
- package/dist/providers/sms/messagebird/index.d.ts +33 -3
- package/dist/providers/sms/messagebird/index.js +1 -1
- package/dist/providers/sms/plivo/index.d.ts +4 -2
- package/dist/providers/sms/plivo/index.js +1 -1
- package/dist/providers/sms/sns/index.d.ts +4 -2
- package/dist/providers/sms/sns/index.js +1 -1
- package/dist/providers/sms/telnyx/index.d.ts +28 -3
- package/dist/providers/sms/telnyx/index.js +1 -1
- package/dist/providers/sms/twilio/index.d.ts +36 -3
- package/dist/providers/sms/twilio/index.js +1 -1
- package/dist/providers/sms/vonage/index.d.ts +27 -3
- package/dist/providers/sms/vonage/index.js +1 -1
- package/dist/providers/webhook/index.d.ts +4 -2
- package/dist/providers/webhook/index.js +1 -1
- package/dist/webhooks/index.d.ts +35 -47
- package/dist/webhooks/index.js +1 -1
- package/package.json +10 -2
- package/dist/packem_shared/hmacBase64-Dtvoq4Ry.js +0 -1
- package/dist/packem_shared/snsWebhook-eOX1eh23.js +0 -1
- /package/dist/packem_shared/{apnsProvider-Dfgwt-6Z.js → createApnsProvider-Dfgwt-6Z.js} +0 -0
- /package/dist/packem_shared/{discordProvider-B9rc2nrV.js → createDiscordProvider-B9rc2nrV.js} +0 -0
- /package/dist/packem_shared/{expoProvider-DofT1sEf.js → createExpoProvider-DofT1sEf.js} +0 -0
- /package/dist/packem_shared/{failoverProvider-CyYOOitI.js → createFailoverProvider-CyYOOitI.js} +0 -0
- /package/dist/packem_shared/{fcmProvider-86S6m7zk.js → createFcmProvider-86S6m7zk.js} +0 -0
- /package/dist/packem_shared/{inAppProvider-DWO4D6VN.js → createInAppProvider-DWO4D6VN.js} +0 -0
- /package/dist/packem_shared/{messageBirdProvider-CnsBOuY6.js → createMessageBirdProvider-CnsBOuY6.js} +0 -0
- /package/dist/packem_shared/{mockProvider-OaWdPlKU.js → createMockProvider-OaWdPlKU.js} +0 -0
- /package/dist/packem_shared/{msTeamsProvider-BAgW_ba5.js → createMsTeamsProvider-BAgW_ba5.js} +0 -0
- /package/dist/packem_shared/{otelProvider-DdnT7q6B.js → createOtelProvider-DdnT7q6B.js} +0 -0
- /package/dist/packem_shared/{plivoProvider-C27zpwI3.js → createPlivoProvider-C27zpwI3.js} +0 -0
- /package/dist/packem_shared/{roundRobinProvider-BrujhDY6.js → createRoundRobinProvider-BrujhDY6.js} +0 -0
- /package/dist/packem_shared/{slackProvider-CP35fu9-.js → createSlackProvider-CP35fu9-.js} +0 -0
- /package/dist/packem_shared/{telegramProvider-CyaUiWkh.js → createTelegramProvider-CyaUiWkh.js} +0 -0
- /package/dist/packem_shared/{telnyxProvider-M23jXIyu.js → createTelnyxProvider-M23jXIyu.js} +0 -0
- /package/dist/packem_shared/{twilioProvider-CaoTEqz-.js → createTwilioProvider-CaoTEqz-.js} +0 -0
- /package/dist/packem_shared/{vonageProvider-CYNivc-x.js → createVonageProvider-CYNivc-x.js} +0 -0
- /package/dist/packem_shared/{webhookProvider-C13EqjLL.js → createWebhookProvider-C13EqjLL.js} +0 -0
|
@@ -14,5 +14,7 @@ interface WebhookConfig extends BaseConfig {
|
|
|
14
14
|
* @param config Optional config.
|
|
15
15
|
* @returns A webhook-channel provider.
|
|
16
16
|
*/
|
|
17
|
-
declare const webhookProvider: (config?: WebhookConfig) => Provider<WebhookConfig, WebhookPayload>;
|
|
18
|
-
|
|
17
|
+
declare const webhookProvider$1: (config?: WebhookConfig) => Provider<WebhookConfig, WebhookPayload>;
|
|
18
|
+
/** @deprecated Renamed to `createWebhookProvider`; removed in the next major. */
|
|
19
|
+
declare const webhookProvider: typeof webhookProvider$1;
|
|
20
|
+
export { type WebhookConfig, webhookProvider$1 as createWebhookProvider, webhookProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{webhookProvider as
|
|
1
|
+
import{webhookProvider as o}from"../../packem_shared/createWebhookProvider-C13EqjLL.js";const e=o;export{o as createWebhookProvider,e as webhookProvider};
|
package/dist/webhooks/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as WebhookVerifier } from "../packem_shared/types.d-BXfGenMH.js";
|
|
2
|
+
export { type W as WebhookHeaders, g as getHeader } from "../packem_shared/types.d-BXfGenMH.js";
|
|
3
|
+
import "../packem_shared/types.d-C7l7qdMG.js";
|
|
2
4
|
/**
|
|
3
5
|
* Computes an HMAC over `message` and returns the lowercase hex digest.
|
|
4
6
|
* @param key The shared secret (UTF-8 string) or raw key bytes.
|
|
@@ -25,38 +27,6 @@ declare const hmacBase64: (key: string | Uint8Array, message: string, hash: "SHA
|
|
|
25
27
|
* @returns `true` when the strings are equal.
|
|
26
28
|
*/
|
|
27
29
|
declare const timingSafeEqual: (a: string, b: string) => boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Case-insensitive map of inbound request headers. Values may be a single string or
|
|
30
|
-
* an array (mirroring `node:http` and `Headers`); verifiers normalise both forms.
|
|
31
|
-
*/
|
|
32
|
-
type WebhookHeaders = Record<string, string | string[] | undefined>;
|
|
33
|
-
/**
|
|
34
|
-
* A provider inbound-webhook verifier: validates the request signature and normalises
|
|
35
|
-
* the body into a {@link NotificationEvent}.
|
|
36
|
-
*/
|
|
37
|
-
interface WebhookVerifier {
|
|
38
|
-
/**
|
|
39
|
-
* Normalises a verified webhook body into a {@link NotificationEvent}.
|
|
40
|
-
* @param body The raw request body (string).
|
|
41
|
-
* @returns The normalised event, or `undefined` when the body is not a delivery event.
|
|
42
|
-
*/
|
|
43
|
-
parse: (body: string) => NotificationEvent | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* Verifies the request signature against the shared secret.
|
|
46
|
-
* @param payload The raw request body (string).
|
|
47
|
-
* @param headers The inbound request headers.
|
|
48
|
-
* @param secret The provider signing secret / auth token.
|
|
49
|
-
* @returns `true` when the signature is valid.
|
|
50
|
-
*/
|
|
51
|
-
verify: (payload: string, headers: WebhookHeaders, secret: string) => Promise<boolean>;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Reads a header value case-insensitively, coercing array values to their first entry.
|
|
55
|
-
* @param headers The inbound headers.
|
|
56
|
-
* @param name The header name to read.
|
|
57
|
-
* @returns The header value, or `undefined` when absent.
|
|
58
|
-
*/
|
|
59
|
-
declare const getHeader: (headers: WebhookHeaders, name: string) => string | undefined;
|
|
60
30
|
/**
|
|
61
31
|
* Verifier + parser for Slack event/interaction webhooks.
|
|
62
32
|
*
|
|
@@ -66,22 +36,40 @@ declare const getHeader: (headers: WebhookHeaders, name: string) => string | und
|
|
|
66
36
|
* Web Crypto only.
|
|
67
37
|
*/
|
|
68
38
|
declare const slackWebhook: WebhookVerifier;
|
|
39
|
+
/**
|
|
40
|
+
* SNS message envelope (the relevant subset). SNS delivers every field as a string.
|
|
41
|
+
*/
|
|
42
|
+
interface SnsMessage {
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
Message?: string;
|
|
45
|
+
MessageId?: string;
|
|
46
|
+
Signature?: string;
|
|
47
|
+
SignatureVersion?: string;
|
|
48
|
+
SigningCertURL?: string;
|
|
49
|
+
SubscribeURL?: string;
|
|
50
|
+
Timestamp?: string;
|
|
51
|
+
TopicArn?: string;
|
|
52
|
+
Type?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Verifies an AWS SNS message signature (SignatureVersion 1 = RSA-SHA1, 2 = RSA-SHA256) against
|
|
56
|
+
* the certificate at its `SigningCertURL`. Validates the certificate host, rebuilds the
|
|
57
|
+
* canonical string-to-sign, fetches (and caches) the signing certificate, and checks the RSA
|
|
58
|
+
* signature with Web Crypto. Returns `false` on any malformed input, disallowed host, stale
|
|
59
|
+
* `Timestamp`, fetch failure or signature mismatch. Edge-safe — `fetch` + Web Crypto only.
|
|
60
|
+
* @param message The parsed SNS envelope.
|
|
61
|
+
* @returns `true` when the signature is valid.
|
|
62
|
+
*/
|
|
63
|
+
declare const verifySnsMessage: (message: SnsMessage) => Promise<boolean>;
|
|
69
64
|
/**
|
|
70
65
|
* Verifier + parser for AWS SNS HTTP/S subscription deliveries.
|
|
71
66
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* since both are attacker-controllable. `parse` remains available for callers that have
|
|
79
|
-
* verified the message out-of-band. Callers handling `SubscriptionConfirmation` should
|
|
80
|
-
* confirm the subscription by requesting the `SubscribeURL` from the parsed metadata.
|
|
81
|
-
* Edge-safe — performs no `node:*` work.
|
|
82
|
-
*
|
|
83
|
-
* TODO: implement RSA-SHA1/RSA-SHA256 verification of the canonical string-to-sign
|
|
84
|
-
* against the fetched signing certificate (SignatureVersion 1 and 2).
|
|
67
|
+
* `verify` implements SNS SignatureVersion 1 (RSA-SHA1) and 2 (RSA-SHA256): it validates the
|
|
68
|
+
* `SigningCertURL` host, rebuilds the canonical string-to-sign, fetches and caches the signing
|
|
69
|
+
* certificate, extracts its RSA public key and checks the signature — all with `fetch` + Web
|
|
70
|
+
* Crypto, so it runs on edge runtimes. `headers` and `secret` are unused (SNS is asymmetric).
|
|
71
|
+
* Callers handling `SubscriptionConfirmation` should confirm by requesting the `SubscribeURL`
|
|
72
|
+
* from the parsed metadata.
|
|
85
73
|
*/
|
|
86
74
|
declare const snsWebhook: WebhookVerifier;
|
|
87
75
|
/**
|
|
@@ -107,4 +95,4 @@ declare const standardWebhook: WebhookVerifier;
|
|
|
107
95
|
* Edge-safe — uses Web Crypto only.
|
|
108
96
|
*/
|
|
109
97
|
declare const twilioWebhook: WebhookVerifier;
|
|
110
|
-
export { type
|
|
98
|
+
export { type WebhookVerifier, hmacBase64, hmacHex, slackWebhook, snsWebhook, standardWebhook, timingSafeEqual, twilioWebhook, verifySnsMessage };
|
package/dist/webhooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hmacBase64 as r,hmacHex as
|
|
1
|
+
import{hmacBase64 as r,hmacHex as a,timingSafeEqual as t}from"../packem_shared/hmacBase64-ocSXhrdQ.js";import{slackWebhook as f}from"../packem_shared/slackWebhook-DILLGl3P.js";import{snsWebhook as x,verifySnsMessage as h}from"../packem_shared/snsWebhook-DTBQW5U5.js";import{standardWebhook as i}from"../packem_shared/standardWebhook-CPjtIEKe.js";import{twilioWebhook as b}from"../packem_shared/twilioWebhook-BjM8B0sB.js";import{getHeader as W}from"../packem_shared/getHeader-BF9s-Tgp.js";export{W as getHeader,r as hmacBase64,a as hmacHex,f as slackWebhook,x as snsWebhook,i as standardWebhook,t as timingSafeEqual,b as twilioWebhook,h as verifySnsMessage};
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/notification",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A reusable, ESM-only, edge-ready multi-channel notification library with SMS, push, chat, in-app and webhook providers",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"agent",
|
|
7
|
+
"ai",
|
|
6
8
|
"apns",
|
|
7
9
|
"aws-sns",
|
|
10
|
+
"chatbot",
|
|
11
|
+
"inbound",
|
|
8
12
|
"chat",
|
|
9
13
|
"discord",
|
|
10
14
|
"expo",
|
|
@@ -188,6 +192,10 @@
|
|
|
188
192
|
"types": "./dist/webhooks/index.d.ts",
|
|
189
193
|
"default": "./dist/webhooks/index.js"
|
|
190
194
|
},
|
|
195
|
+
"./inbound": {
|
|
196
|
+
"types": "./dist/inbound/index.d.ts",
|
|
197
|
+
"default": "./dist/inbound/index.js"
|
|
198
|
+
},
|
|
191
199
|
"./template/string": {
|
|
192
200
|
"types": "./dist/template-engines/string.d.ts",
|
|
193
201
|
"default": "./dist/template-engines/string.js"
|
|
@@ -230,7 +238,7 @@
|
|
|
230
238
|
"peerDependencies": {
|
|
231
239
|
"@aws-sdk/client-sqs": "^3.0.0",
|
|
232
240
|
"@opentelemetry/api": "^1.0.0 || ^2.0.0",
|
|
233
|
-
"@visulima/email": "3.0.
|
|
241
|
+
"@visulima/email": "3.0.4",
|
|
234
242
|
"@visulima/workflow": "3.0.0",
|
|
235
243
|
"bullmq": "^5.0.0",
|
|
236
244
|
"croner": "^10.0.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as s,h as o,a as i}from"./webcrypto-Cz40u9vp.js";const r=300,h=async(t,n,e)=>i(await o(t,n,e)),l=async(t,n,e)=>s(await o(t,n,e)),f=(t,n)=>{if(t.length!==n.length)return!1;let e=0;for(let a=0;a<t.length;a+=1)e|=(t.codePointAt(a)??0)^(n.codePointAt(a)??0);return e===0},m=(t,n)=>{if(t===void 0)return!1;const e=Number.parseInt(t,10);if(Number.isNaN(e))return!1;const a=Math.floor(Date.now()/1e3);return Math.abs(a-e)<=n};export{r as REPLAY_WINDOW_SECONDS,l as hmacBase64,h as hmacHex,m as isWithinReplayWindow,f as timingSafeEqual};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{tryParseObject as r}from"./getHeader-BF9s-Tgp.js";const o=s=>r(s),a={parse:s=>{const e=o(s);if(e?.Type===void 0)return;const i={type:e.Type};return e.Type==="SubscriptionConfirmation"||e.Type==="UnsubscribeConfirmation"?i.subscribeUrl=e.SubscribeURL:e.Message!==void 0&&(i.message=e.Message),{messageId:e.MessageId??"",metadata:i,provider:"sns",timestamp:e.Timestamp===void 0?new Date:new Date(e.Timestamp),type:"delivered"}},verify:()=>Promise.resolve(!1)};export{a as snsWebhook};
|
|
File without changes
|
/package/dist/packem_shared/{discordProvider-B9rc2nrV.js → createDiscordProvider-B9rc2nrV.js}
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/packem_shared/{failoverProvider-CyYOOitI.js → createFailoverProvider-CyYOOitI.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/packem_shared/{msTeamsProvider-BAgW_ba5.js → createMsTeamsProvider-BAgW_ba5.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/packem_shared/{roundRobinProvider-BrujhDY6.js → createRoundRobinProvider-BrujhDY6.js}
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/packem_shared/{telegramProvider-CyaUiWkh.js → createTelegramProvider-CyaUiWkh.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/packem_shared/{webhookProvider-C13EqjLL.js → createWebhookProvider-C13EqjLL.js}
RENAMED
|
File without changes
|