@visulima/notification 1.1.22 → 1.2.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 +18 -0
- package/dist/channels/email/index.d.ts +2 -2
- package/dist/channels/inapp/index.d.ts +2 -2
- package/dist/events/index.d.ts +1 -1
- package/dist/inbound/index.d.ts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/middleware/index.d.ts +3 -3
- package/dist/packem_shared/createApnsProvider-DLdfR4Vx.js +1 -0
- package/dist/packem_shared/createExpoProvider-DtCfr1WA.js +1 -0
- package/dist/packem_shared/createFcmProvider-Ds2cUAnA.js +1 -0
- package/dist/packem_shared/createWebPushProvider-Cpu1Whj-.js +1 -0
- package/dist/packem_shared/{notification.d-D0ado_cy.d.ts → notification.d-eA68bykk.d.ts} +3 -3
- package/dist/packem_shared/{provider.d-Dh32nRm9.d.ts → provider.d-D5HGHu5g.d.ts} +1 -1
- package/dist/packem_shared/push-BWm6ghav.js +1 -0
- package/dist/packem_shared/{types.d-BXfGenMH.d.ts → types.d-BulLsx7s.d.ts} +1 -1
- package/dist/packem_shared/{types.d-r8K0ICyx.d.ts → types.d-Bvs6BFvT.d.ts} +1 -1
- package/dist/packem_shared/{types.d-C7l7qdMG.d.ts → types.d-COwyORBZ.d.ts} +17 -1
- package/dist/packem_shared/{types.d-4T7bNo4x.d.ts → types.d-CsjVAmeG.d.ts} +2 -2
- package/dist/packem_shared/{types.d-CRs03TYV.d.ts → types.d-YJ8U7pag.d.ts} +1 -1
- package/dist/preferences/index.d.ts +4 -4
- package/dist/providers/chat/discord/index.d.ts +4 -4
- package/dist/providers/chat/msteams/index.d.ts +4 -4
- package/dist/providers/chat/slack/index.d.ts +4 -4
- package/dist/providers/chat/telegram/index.d.ts +4 -4
- package/dist/providers/failover/index.d.ts +2 -2
- package/dist/providers/mock/index.d.ts +2 -2
- package/dist/providers/opentelemetry/index.d.ts +2 -2
- package/dist/providers/push/apns/index.d.ts +2 -2
- package/dist/providers/push/apns/index.js +1 -1
- package/dist/providers/push/expo/index.d.ts +2 -2
- package/dist/providers/push/expo/index.js +1 -1
- package/dist/providers/push/fcm/index.d.ts +2 -2
- package/dist/providers/push/fcm/index.js +1 -1
- package/dist/providers/push/web-push/index.d.ts +5 -5
- package/dist/providers/push/web-push/index.js +1 -1
- package/dist/providers/roundrobin/index.d.ts +2 -2
- package/dist/providers/sms/messagebird/index.d.ts +4 -4
- package/dist/providers/sms/plivo/index.d.ts +2 -2
- package/dist/providers/sms/sns/index.d.ts +2 -2
- package/dist/providers/sms/telnyx/index.d.ts +4 -4
- package/dist/providers/sms/twilio/index.d.ts +4 -4
- package/dist/providers/sms/vonage/index.d.ts +4 -4
- package/dist/providers/webhook/index.d.ts +2 -2
- package/dist/queue/bullmq-queue.d.ts +5 -5
- package/dist/queue/index.d.ts +5 -5
- package/dist/queue/pg-boss-queue.d.ts +5 -5
- package/dist/queue/sqs-queue.d.ts +5 -5
- package/dist/queue/unstorage-queue.d.ts +5 -5
- package/dist/routing/index.d.ts +4 -4
- package/dist/utils/result.d.ts +1 -1
- package/dist/webhooks/index.d.ts +3 -3
- package/dist/workflow/index.d.ts +4 -4
- package/package.json +2 -2
- package/dist/packem_shared/createApnsProvider-Dfgwt-6Z.js +0 -1
- package/dist/packem_shared/createExpoProvider-DofT1sEf.js +0 -1
- package/dist/packem_shared/createFcmProvider-86S6m7zk.js +0 -1
- package/dist/packem_shared/createWebPushProvider-BNu3bPeV.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## @visulima/notification [1.2.0](https://github.com/visulima/visulima/compare/@visulima/notification@1.1.23...@visulima/notification@1.2.0) (2026-10-08)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **notification:** per-message ttl and urgency for push ([#936](https://github.com/visulima/visulima/issues/936)) ([0452040](https://github.com/visulima/visulima/commit/04520405eab63a5eadf6d7af1931cc3813686a01))
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Dependencies
|
|
9
|
+
|
|
10
|
+
* **@visulima/email:** upgraded to 3.0.28
|
|
11
|
+
|
|
12
|
+
## @visulima/notification [1.1.23](https://github.com/visulima/visulima/compare/@visulima/notification@1.1.22...@visulima/notification@1.1.23) (2026-10-05)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Dependencies
|
|
16
|
+
|
|
17
|
+
* **@visulima/email:** upgraded to 3.0.27
|
|
18
|
+
|
|
1
19
|
## @visulima/notification [1.1.22](https://github.com/visulima/visulima/compare/@visulima/notification@1.1.21...@visulima/notification@1.1.22) (2026-10-04)
|
|
2
20
|
|
|
3
21
|
|
package/README.md
CHANGED
|
@@ -137,6 +137,24 @@ Providers are imported from `@visulima/notification/providers/<name>` so unused
|
|
|
137
137
|
> pieces are **APNs** (`node:http2`) and the **bullmq / pg-boss / sqs** queue adapters — import those from a Node runtime.
|
|
138
138
|
> See the [runtime matrix](https://visulima.com/docs/packages/notification/installation#runtime-support).
|
|
139
139
|
|
|
140
|
+
### Push delivery hints
|
|
141
|
+
|
|
142
|
+
A push payload can carry per-message `ttl` (seconds, non-negative integer) and `urgency`
|
|
143
|
+
(`"very-low" | "low" | "normal" | "high"`), overriding the provider's configured defaults:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
await notify.send({ push: { to: subscription, title: "Approval needed", body: "…", urgency: "high", ttl: 3600 } });
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
| Provider | `ttl` | `urgency` |
|
|
150
|
+
| ---------- | ----------------- | ------------------------------------------------------ |
|
|
151
|
+
| `web-push` | `TTL` header | `Urgency` header (falls back to config, then `normal`) |
|
|
152
|
+
| `fcm` | `android.ttl` | `android.priority` (`high` → high, else normal) |
|
|
153
|
+
| `apns` | `apns-expiration` | `apns-priority` (`high` → 10, `low`/`very-low` → 5) |
|
|
154
|
+
| `expo` | `ttl` | `priority` (`high` → high, `low`/`very-low` → normal) |
|
|
155
|
+
|
|
156
|
+
An invalid `ttl` fails the send with a `NotificationError` before any request is made.
|
|
157
|
+
|
|
140
158
|
## Writing a provider
|
|
141
159
|
|
|
142
160
|
Every provider implements the same contract; author one with `defineProvider`:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Provider } from "../../packem_shared/provider.d-
|
|
2
|
-
import { E as EmailChannelPayload } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as Provider } from "../../packem_shared/provider.d-D5HGHu5g.js";
|
|
2
|
+
import { E as EmailChannelPayload } from "../../packem_shared/types.d-COwyORBZ.js";
|
|
3
3
|
/**
|
|
4
4
|
* The result shape returned by `@visulima/email`'s `Mail.send`.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Provider } from "../../packem_shared/provider.d-
|
|
2
|
-
import { I as InAppPayload } from "../../packem_shared/types.d-
|
|
1
|
+
import { P as Provider } from "../../packem_shared/provider.d-D5HGHu5g.js";
|
|
2
|
+
import { I as InAppPayload } from "../../packem_shared/types.d-COwyORBZ.js";
|
|
3
3
|
import { S as Storage } from "../../packem_shared/unstorage.DqlWKU2I.d-CogP3Etw.js";
|
|
4
4
|
/**
|
|
5
5
|
* A persisted in-app notification.
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as NotificationEvent, e as NotificationEventType } from "../packem_shared/types.d-
|
|
1
|
+
import { N as NotificationEvent, e as NotificationEventType } from "../packem_shared/types.d-COwyORBZ.js";
|
|
2
2
|
/**
|
|
3
3
|
* An append-only timeline store for notification events.
|
|
4
4
|
*/
|
package/dist/inbound/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as Provider } from "../packem_shared/provider.d-
|
|
2
|
-
import { b as ChatPayload, S as SmsPayload } from "../packem_shared/types.d-
|
|
3
|
-
import { I as InboundMessage, a as InboundReplyFunction, b as InboundReplyInput, c as InboundReply, R as Receiver } from "../packem_shared/types.d-
|
|
4
|
-
export type { d as InboundAttachment, e as InboundChannel, f as InboundContext, g as InboundErrorReason, h as InboundHandler, i as InboundMessageType, j as InboundParticipant, k as InboundResponse, l as ReceiverOptions } from "../packem_shared/types.d-
|
|
5
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { P as Provider } from "../packem_shared/provider.d-D5HGHu5g.js";
|
|
2
|
+
import { b as ChatPayload, S as SmsPayload } from "../packem_shared/types.d-COwyORBZ.js";
|
|
3
|
+
import { I as InboundMessage, a as InboundReplyFunction, b as InboundReplyInput, c as InboundReply, R as Receiver } from "../packem_shared/types.d-CsjVAmeG.js";
|
|
4
|
+
export type { d as InboundAttachment, e as InboundChannel, f as InboundContext, g as InboundErrorReason, h as InboundHandler, i as InboundMessageType, j as InboundParticipant, k as InboundResponse, l as ReceiverOptions } from "../packem_shared/types.d-CsjVAmeG.js";
|
|
5
|
+
import "../packem_shared/types.d-BulLsx7s.js";
|
|
6
6
|
/**
|
|
7
7
|
* Verifies an Ed25519 signature over `timestamp + body`, Discord's interaction signing
|
|
8
8
|
* scheme. Edge-safe — uses Web Crypto's Ed25519 primitive only (available on Node 22+ and
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { type M as Middleware, type S as SendContext, type a as SendFunction, c as composeMiddleware } from "./packem_shared/types.d-
|
|
2
|
-
import { C as ChannelPayloadMap, a as NotificationMessage } from "./packem_shared/notification.d-
|
|
3
|
-
export { N as Notification, type b as NotificationProviders, type S as SendManyOptions, c as createNotification, s as send } from "./packem_shared/notification.d-
|
|
4
|
-
export { type P as Provider, type a as ProviderFactory, d as defineProvider } from "./packem_shared/provider.d-
|
|
5
|
-
export type { d as BaseConfig, B as BaseNotificationPayload, C as ChannelType, b as ChatPayload,
|
|
1
|
+
export { type M as Middleware, type S as SendContext, type a as SendFunction, c as composeMiddleware } from "./packem_shared/types.d-YJ8U7pag.js";
|
|
2
|
+
import { C as ChannelPayloadMap, a as NotificationMessage } from "./packem_shared/notification.d-eA68bykk.js";
|
|
3
|
+
export { N as Notification, type b as NotificationProviders, type S as SendManyOptions, c as createNotification, s as send } from "./packem_shared/notification.d-eA68bykk.js";
|
|
4
|
+
export { type P as Provider, type a as ProviderFactory, d as defineProvider } from "./packem_shared/provider.d-D5HGHu5g.js";
|
|
5
|
+
export type { d as BaseConfig, B as BaseNotificationPayload, C as ChannelType, b as ChatPayload, g as EmailAddressLike, E as EmailChannelPayload, h as FailureReceipt, F as FeatureFlags, I as InAppPayload, M as MaybePromise, N as NotificationEvent, e as NotificationEventType, i as NotificationPayload, a as NotificationResult, P as PushPayload, f as PushUrgency, c as Receipt, j as RecipientResult, R as Result, S as SmsPayload, k as SuccessReceipt, W as WebhookPayload } from "./packem_shared/types.d-COwyORBZ.js";
|
|
6
6
|
interface ErrorProperties {
|
|
7
7
|
cause?: unknown;
|
|
8
8
|
hint?: ErrorHint;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { M as Middleware, S as SendContext } from "../packem_shared/types.d-
|
|
2
|
-
export { type a as SendFunction, c as composeMiddleware } from "../packem_shared/types.d-
|
|
3
|
-
import { C as ChannelType, B as BaseNotificationPayload } from "../packem_shared/types.d-
|
|
1
|
+
import { M as Middleware, S as SendContext } from "../packem_shared/types.d-YJ8U7pag.js";
|
|
2
|
+
export { type a as SendFunction, c as composeMiddleware } from "../packem_shared/types.d-YJ8U7pag.js";
|
|
3
|
+
import { C as ChannelType, B as BaseNotificationPayload } from "../packem_shared/types.d-COwyORBZ.js";
|
|
4
4
|
import { A as Attributes, C as Context, T as Tracer } from "../packem_shared/tracer.d-BPznIQx9.js";
|
|
5
5
|
interface CircuitBreakerMiddlewareOptions {
|
|
6
6
|
/** Time in ms the circuit stays open before a trial request (default 30000). */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as v}from"node:module";import m from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as R}from"./defineProvider-C9q-7iwt.js";import{t as $}from"./credentials-D9KXFoo0.js";import{v as j}from"./push-BWm6ghav.js";import{a as k}from"./sms-CT04IxF8.js";let O;const I=r=>(O??=v(import.meta.url))(r),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=r=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[t,a]=f.versions.node.split(".").map(Number);if(t>22||t===22&&a>=3||t===20&&a>=16)return f.getBuiltinModule(r)}return I(r)},{sign:P,createPrivateKey:K}=b("node:crypto"),{connect:N}=b("node:http2"),q="https://api.push.apple.com",B="https://api.sandbox.push.apple.com",E=3e3*1e3,H=200,T=r=>Buffer.from(r,"utf8").toString("base64url"),J=(r,t,a)=>{const g=T(JSON.stringify({alg:"ES256",kid:r.keyId,typ:"JWT"})),u=T(JSON.stringify({iat:a,iss:r.teamId})),d=`${g}.${u}`,s=P("sha256",Buffer.from(d,"utf8"),{dsaEncoding:"ieee-p1363",key:t}).toString("base64url");return`${d}.${s}`},U=R(r=>{const t=r??{};if(!t.teamId)throw new m("apns","teamId");if(!t.keyId)throw new m("apns","keyId");if(!t.signingKey)throw new m("apns","signingKey");if(!t.bundleId)throw new m("apns","bundleId");const a=t.production?q:B;let g,u,d=0,s;const _=()=>(g??=K({format:"pem",key:t.signingKey}),g),y=()=>{const e=Date.now();return(!u||e-d>E)&&(u=J(t,_(),Math.floor(e/1e3)),d=e),u},w=()=>((!s||s.closed||s.destroyed)&&(s=N(a),s.on("error",e=>{t.logger?.warn(`[@visulima/notification] [apns] HTTP/2 session error: ${e.message}`)})),s),S=async(e,l,h)=>new Promise(i=>{const o=w().request({":method":"POST",":path":`/3/device/${e}`,"apns-topic":t.bundleId,authorization:`bearer ${y()}`,"content-type":"application/json",...h});let p=0,c="";o.setEncoding("utf8"),o.on("response",n=>{p=n[":status"]??0}),o.on("data",n=>{c+=n}),o.on("error",n=>{i({error:n.message,id:e,status:"failed"})}),o.on("end",()=>{if(p===H){i({id:e,messageId:e,status:"sent"});return}let n=`HTTP ${String(p)}`;if(c)try{n=JSON.parse(c).reason??n}catch{n=c}i({error:n,id:e,status:"failed"})}),o.end(l)});return{channel:"push",endpoint:a,features:{batchSending:!1,media:!0,richContent:!0},id:"apns",initialize:()=>{},isAvailable:()=>!0,options:t,send:async e=>{const l=j("apns",e.ttl);if(l)return{error:l,success:!1};const h=$(e.to),i={};e.ttl!==void 0&&(i["apns-expiration"]=e.ttl===0?"0":String(Math.floor(Date.now()/1e3)+e.ttl)),e.urgency==="high"?i["apns-priority"]="10":(e.urgency==="low"||e.urgency==="very-low")&&(i["apns-priority"]="5");const o={alert:{body:e.body,title:e.title}};e.sound!==void 0&&(o.sound=e.sound),e.badge!==void 0&&(o.badge=e.badge);const p=JSON.stringify({...e.data,aps:o}),c=[];for(const n of h)c.push(await S(n,p,i));return k("push","apns",c)},shutdown:()=>{s&&!s.closed&&s.close(),s=void 0}}});export{U as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import u from"./NotificationError-tZsXfB7V.js";import{defineProvider as w}from"./defineProvider-C9q-7iwt.js";import{t as k}from"./credentials-D9KXFoo0.js";import{r as A}from"./http-YFt2eXXy.js";import{g as P}from"./id-FYdbBSpb.js";import{v as y}from"./push-BWm6ghav.js";const E="https://exp.host",O=w(g=>{const r=g??{},d=r.endpoint??E,h=r.retries??3,x=r.timeout??3e4,T=`${d}/--/api/v2/push/send`;return{channel:"push",endpoint:d,features:{batchSending:!0,media:!0,richContent:!0},id:"expo",initialize:()=>{},isAvailable:()=>!0,options:r,send:async e=>{const f=y("expo",e.ttl);if(f)return{error:f,success:!1};const l=k(e.to);let o;e.urgency==="high"?o="high":(e.urgency==="low"||e.urgency==="very-low")&&(o="normal");const b=l.map(s=>({badge:e.badge,body:e.body,data:e.data,priority:o,sound:e.sound??"default",title:e.title,to:s,ttl:e.ttl})),m={"Content-Type":"application/json"};r.accessToken&&(m.Authorization=`Bearer ${r.accessToken}`);const t=await A(T,{body:JSON.stringify(b),headers:m,method:"POST",timeout:x},h);if(!t.success||!t.data)return{error:new u("expo",t.error instanceof Error?t.error.message:"Request failed"),success:!1};if(t.data.status>=400)return{error:new u("expo",`HTTP ${String(t.data.status)}`),success:!1};const i=t.data.body.data;let a;Array.isArray(i)?a=i:a=i?[i]:[];const c=l.map((s,v)=>{const n=a[v];return n?.status==="error"?{error:n.details?.error??n.message??"error",id:s,status:"failed"}:{id:s,messageId:n?.id,status:"sent"}}),p=c.filter(s=>s.status==="sent");return p.length===0?{error:new u("expo",c[0]?.error??"All tokens failed"),success:!1}:{data:{channel:"push",messageId:p[0]?.messageId??P("expo"),provider:"expo",recipients:c,sent:!0,timestamp:new Date},success:!0}}}});export{O as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import l from"./NotificationError-tZsXfB7V.js";import a from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as p}from"./defineProvider-C9q-7iwt.js";import{t as T}from"./credentials-D9KXFoo0.js";import{r as b}from"./http-YFt2eXXy.js";import{v as k}from"./push-BWm6ghav.js";import{a as v}from"./sms-CT04IxF8.js";const E=p(f=>{const e=f??{};if(!e.projectId)throw new a("fcm","projectId");if(!e.accessToken&&!e.getAccessToken)throw new a("fcm",["accessToken","getAccessToken"]);const c=e.endpoint??"https://fcm.googleapis.com",m=e.retries??3,u=e.timeout??3e4,d=`${c}/v1/projects/${e.projectId}/messages:send`,g=r=>{if(r)return Object.fromEntries(Object.entries(r).map(([t,o])=>[t,typeof o=="string"?o:JSON.stringify(o)]))},h=async(r,t,o)=>{const i={data:g(t.data),notification:{body:t.body,image:t.imageUrl,title:t.title},token:r};(t.ttl!==void 0||t.urgency!==void 0)&&(i.android={priority:t.urgency&&(t.urgency==="high"?"high":"normal"),ttl:t.ttl===void 0?void 0:`${String(t.ttl)}s`});const s=await b(d,{body:JSON.stringify({message:i}),headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},method:"POST",timeout:u},m);return!s.success||!s.data?{error:s.error instanceof Error?s.error.message:"Request failed",id:r,status:"failed"}:s.data.status>=400?{error:s.data.body.error?.message??`HTTP ${String(s.data.status)}`,id:r,status:"failed"}:{id:r,messageId:s.data.body.name,status:"sent"}};return{channel:"push",endpoint:c,features:{batchSending:!1,media:!0,richContent:!0},id:"fcm",initialize:()=>{},isAvailable:()=>!!(e.projectId&&(e.accessToken??e.getAccessToken)),options:e,send:async r=>{const t=k("fcm",r.ttl);if(t)return{error:t,success:!1};let o;try{o=e.getAccessToken?await e.getAccessToken():e.accessToken}catch(n){return{error:new l("fcm","Failed to obtain access token",{cause:n}),success:!1}}const i=T(r.to),s=[];for(const n of i)s.push(await h(n,r,o));return v("push","fcm",s)}}});export{E as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import K from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import{t as E}from"./credentials-D9KXFoo0.js";import{m as T}from"./http-YFt2eXXy.js";import{g as A}from"./id-FYdbBSpb.js";import{v as k}from"./push-BWm6ghav.js";import{a as U}from"./sms-CT04IxF8.js";import{u as l,f as S,b as g,s as c,r as B,d as v,e as P,g as R}from"./webcrypto-BPm3NDEm.js";const $=2419200,j=i=>{let t=i;if(typeof i=="string")try{t=JSON.parse(i)}catch{return}const e=t;if(!(!e||typeof e.endpoint!="string"||typeof e.keys?.p256dh!="string"||typeof e.keys.auth!="string"))return e},x=async(i,t)=>{const e=S(t),d=g(e.slice(1,33)),s=g(e.slice(33,65));return c().importKey("jwk",{crv:"P-256",d:i,ext:!0,key_ops:["sign"],kty:"EC",x:d,y:s},{name:"ECDSA",namedCurve:"P-256"},!1,["sign"])},D=async(i,t,e)=>{const d=g(l(JSON.stringify({alg:"ES256",typ:"JWT"}))),s=g(l(JSON.stringify({aud:i,exp:Math.floor(Date.now()/1e3)+720*60,sub:t}))),u=`${d}.${s}`,n=await c().sign({hash:"SHA-256",name:"ECDSA"},e,l(u));return`${u}.${g(new Uint8Array(n))}`},O=async(i,t)=>{const e=S(i.keys.p256dh),d=S(i.keys.auth),s=B(16),u=await c().generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveBits"]),n=new Uint8Array(await c().exportKey("raw",u.publicKey)),a=await c().importKey("raw",e,{name:"ECDH",namedCurve:"P-256"},!1,[]),m=new Uint8Array(await c().deriveBits({name:"ECDH",public:a},u.privateKey,256)),o=v(l("WebPush: info\0"),e,n),p=await P(d,m,o,32),f=await P(s,p,l("Content-Encoding: aes128gcm\0"),16),b=await P(s,p,l("Content-Encoding: nonce\0"),12),h=await c().importKey("raw",f,{name:"AES-GCM"},!1,["encrypt"]),w=v(t,new Uint8Array([2])),r=new Uint8Array(await c().encrypt({iv:b,name:"AES-GCM"},h,w)),y=v(s,R(4096,4),new Uint8Array([n.length]),n);return v(y,r)},G=C(i=>{const t=i??{};if(!t.vapidPublicKey||!t.vapidPrivateKey||!t.vapidSubject)throw new K("web-push",["vapidPublicKey","vapidPrivateKey","vapidSubject"]);const e=t.ttl??$,d=t.urgency??"normal",s=t.timeout??3e4,u=async(n,a,m)=>{const o=j(n);if(!o)return{error:"Invalid push subscription (expected { endpoint, keys: { p256dh, auth } })",id:n,status:"failed"};const{origin:p}=new URL(o.endpoint),f=await D(p,t.vapidSubject,m),b=JSON.stringify({badge:a.badge,body:a.body,data:a.data,image:a.imageUrl,title:a.title}),h=await O(o,l(b)),w={Authorization:`vapid t=${f},k=${t.vapidPublicKey}`,"Content-Encoding":"aes128gcm","Content-Type":"application/octet-stream",TTL:String(a.ttl??e),Urgency:a.urgency??d},r=await T(o.endpoint,{body:h,headers:w,method:"POST",timeout:s});if(!r.success||!r.data)return{error:r.error instanceof Error?r.error.message:"Request failed",id:n,status:"failed"};const{status:y}=r.data;return y===404||y===410?{error:`Subscription gone (HTTP ${String(y)}) — remove this subscription`,id:n,status:"failed"}:y>=400?{error:`HTTP ${String(y)}: ${typeof r.data.body=="string"?r.data.body:""}`.trim(),id:n,status:"failed"}:{id:n,messageId:A("web-push"),status:"sent"}};return{channel:"push",features:{batchSending:!1,media:!1,richContent:!0},id:"web-push",initialize:()=>{},isAvailable:()=>!!(t.vapidPublicKey&&t.vapidPrivateKey&&t.vapidSubject),options:t,send:async n=>{const a=k("web-push",n.ttl??e);if(a)return{error:a,success:!1};const m=E(n.to),o=await x(t.vapidPrivateKey,t.vapidPublicKey),p=[];for(const f of m)p.push(await u(f,n,o));return U("push","web-push",p)},validateCredentials:()=>!!(t.vapidPublicKey&&t.vapidPrivateKey&&t.vapidSubject)}});export{G as default};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { M as Middleware } from "./types.d-
|
|
2
|
-
import { P as Provider } from "./provider.d-
|
|
3
|
-
import { b as ChatPayload, E as EmailChannelPayload, I as InAppPayload, P as PushPayload, S as SmsPayload, W as WebhookPayload, C as ChannelType, c as Receipt } from "./types.d-
|
|
1
|
+
import { M as Middleware } from "./types.d-YJ8U7pag.js";
|
|
2
|
+
import { P as Provider } from "./provider.d-D5HGHu5g.js";
|
|
3
|
+
import { b as ChatPayload, E as EmailChannelPayload, I as InAppPayload, P as PushPayload, S as SmsPayload, W as WebhookPayload, C as ChannelType, c as Receipt } from "./types.d-COwyORBZ.js";
|
|
4
4
|
/**
|
|
5
5
|
* Maps each channel to its payload type.
|
|
6
6
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BaseNotificationPayload, C as ChannelType, F as FeatureFlags, M as MaybePromise, N as NotificationEvent, a as NotificationResult, R as Result } from "./types.d-
|
|
1
|
+
import { B as BaseNotificationPayload, C as ChannelType, F as FeatureFlags, M as MaybePromise, N as NotificationEvent, a as NotificationResult, R as Result } from "./types.d-COwyORBZ.js";
|
|
2
2
|
/**
|
|
3
3
|
* Standard provider interface for notification channels. Every provider belongs to
|
|
4
4
|
* exactly one {@link ChannelType} and accepts a channel-specific payload.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"./NotificationError-tZsXfB7V.js";const o=(r,e)=>{if(!(e===void 0||Number.isInteger(e)&&e>=0))return new n(r,`Invalid ttl: expected a non-negative integer number of seconds, got ${String(e)}`)};export{o as v};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as NotificationEvent } from "./types.d-
|
|
1
|
+
import { N as NotificationEvent } from "./types.d-COwyORBZ.js";
|
|
2
2
|
/**
|
|
3
3
|
* Case-insensitive map of inbound request headers. Values may be a single string or
|
|
4
4
|
* an array (mirroring `node:http` and `Headers`); verifiers normalise both forms.
|
|
@@ -90,7 +90,23 @@ interface PushPayload extends BaseNotificationPayload {
|
|
|
90
90
|
title?: string;
|
|
91
91
|
/** Device token(s) / subscription target(s). */
|
|
92
92
|
to: string | string[];
|
|
93
|
+
/**
|
|
94
|
+
* Seconds the push service should keep the message for an offline device (non-negative
|
|
95
|
+
* integer; `0` = deliver now or drop). Overrides the provider's configured default.
|
|
96
|
+
* Mapped to web-push `TTL`, FCM `android.ttl`, APNs `apns-expiration` and Expo `ttl`.
|
|
97
|
+
*/
|
|
98
|
+
ttl?: number;
|
|
99
|
+
/**
|
|
100
|
+
* Delivery urgency hint. Overrides the provider's configured default. Sent verbatim as
|
|
101
|
+
* the web-push `Urgency` header; FCM, APNs and Expo map it onto their two-level priority
|
|
102
|
+
* (`high` → high, `normal` → platform default, `low` / `very-low` → low/normal).
|
|
103
|
+
*/
|
|
104
|
+
urgency?: PushUrgency;
|
|
93
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Push delivery urgency (RFC 8030 §5.3).
|
|
108
|
+
*/
|
|
109
|
+
type PushUrgency = "high" | "low" | "normal" | "very-low";
|
|
94
110
|
/**
|
|
95
111
|
* Chat payload (Slack, Discord, Teams, Telegram, ...).
|
|
96
112
|
*/
|
|
@@ -232,4 +248,4 @@ interface NotificationEvent {
|
|
|
232
248
|
timestamp: Date;
|
|
233
249
|
type: NotificationEventType;
|
|
234
250
|
}
|
|
235
|
-
export { BaseNotificationPayload as B, ChannelType as C, EmailChannelPayload as E, FeatureFlags as F, InAppPayload as I, MaybePromise as M, NotificationEvent as N, PushPayload as P, Result as R, SmsPayload as S, WebhookPayload as W, NotificationResult as a, ChatPayload as b, Receipt as c, BaseConfig as d, NotificationEventType as e,
|
|
251
|
+
export { BaseNotificationPayload as B, ChannelType as C, EmailChannelPayload as E, FeatureFlags as F, InAppPayload as I, MaybePromise as M, NotificationEvent as N, PushPayload as P, Result as R, SmsPayload as S, WebhookPayload as W, NotificationResult as a, ChatPayload as b, Receipt as c, BaseConfig as d, NotificationEventType as e, PushUrgency as f, EmailAddressLike as g, FailureReceipt as h, NotificationPayload as i, RecipientResult as j, SuccessReceipt as k };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ChannelType, a as NotificationResult, R as Result, M as MaybePromise } from "./types.d-
|
|
2
|
-
import { W as WebhookHeaders } from "./types.d-
|
|
1
|
+
import { C as ChannelType, a as NotificationResult, R as Result, M as MaybePromise } from "./types.d-COwyORBZ.js";
|
|
2
|
+
import { W as WebhookHeaders } from "./types.d-BulLsx7s.js";
|
|
3
3
|
/**
|
|
4
4
|
* The normalised kind of an inbound payload, abstracting over each provider's own taxonomy:
|
|
5
5
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ChannelType, B as BaseNotificationPayload, a as NotificationResult, R as Result } from "./types.d-
|
|
1
|
+
import { C as ChannelType, B as BaseNotificationPayload, a as NotificationResult, R as Result } from "./types.d-COwyORBZ.js";
|
|
2
2
|
/**
|
|
3
3
|
* Context passed through the middleware chain for a single send.
|
|
4
4
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ChannelGate } from "../routing/index.js";
|
|
2
|
-
import { C as ChannelType } from "../packem_shared/types.d-
|
|
3
|
-
import "../packem_shared/notification.d-
|
|
4
|
-
import "../packem_shared/types.d-
|
|
5
|
-
import "../packem_shared/provider.d-
|
|
2
|
+
import { C as ChannelType } from "../packem_shared/types.d-COwyORBZ.js";
|
|
3
|
+
import "../packem_shared/notification.d-eA68bykk.js";
|
|
4
|
+
import "../packem_shared/types.d-YJ8U7pag.js";
|
|
5
|
+
import "../packem_shared/provider.d-D5HGHu5g.js";
|
|
6
6
|
/**
|
|
7
7
|
* A subscriber's channel preferences. A channel set to `false` is opted out; channels
|
|
8
8
|
* absent default to allowed.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as BaseConfig, b as ChatPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-
|
|
3
|
-
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-
|
|
4
|
-
import "../../../packem_shared/types.d-
|
|
1
|
+
import { d as BaseConfig, b as ChatPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
|
+
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-CsjVAmeG.js";
|
|
4
|
+
import "../../../packem_shared/types.d-BulLsx7s.js";
|
|
5
5
|
interface DiscordConfig extends BaseConfig {
|
|
6
6
|
/** Override the bot username for the message. */
|
|
7
7
|
username?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as BaseConfig, b as ChatPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-
|
|
3
|
-
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-
|
|
4
|
-
import "../../../packem_shared/types.d-
|
|
1
|
+
import { d as BaseConfig, b as ChatPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
|
+
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-CsjVAmeG.js";
|
|
4
|
+
import "../../../packem_shared/types.d-BulLsx7s.js";
|
|
5
5
|
interface MsTeamsConfig extends BaseConfig {
|
|
6
6
|
/** Microsoft Teams Incoming Webhook URL. Required. */
|
|
7
7
|
webhookUrl: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as BaseConfig, b as ChatPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-
|
|
3
|
-
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-
|
|
4
|
-
import "../../../packem_shared/types.d-
|
|
1
|
+
import { d as BaseConfig, b as ChatPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
|
+
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-CsjVAmeG.js";
|
|
4
|
+
import "../../../packem_shared/types.d-BulLsx7s.js";
|
|
5
5
|
interface SlackConfig extends BaseConfig {
|
|
6
6
|
/** Default channel id/name used when the payload omits `to` (Web API mode). */
|
|
7
7
|
defaultChannel?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as BaseConfig, b as ChatPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-
|
|
3
|
-
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-
|
|
4
|
-
import "../../../packem_shared/types.d-
|
|
1
|
+
import { d as BaseConfig, b as ChatPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
|
+
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-CsjVAmeG.js";
|
|
4
|
+
import "../../../packem_shared/types.d-BulLsx7s.js";
|
|
5
5
|
interface TelegramConfig extends BaseConfig {
|
|
6
6
|
/** Telegram bot token (`123456:ABC-DEF...`). Required. */
|
|
7
7
|
botToken: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BaseNotificationPayload } from "../../packem_shared/types.d-
|
|
2
|
-
import { P as Provider } from "../../packem_shared/provider.d-
|
|
1
|
+
import { B as BaseNotificationPayload } from "../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { P as Provider } from "../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
3
|
interface FailoverConfig {
|
|
4
4
|
/** Provider id reported on results (default `"failover"`). */
|
|
5
5
|
id?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ChannelType, B as BaseNotificationPayload } from "../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory } from "../../packem_shared/provider.d-
|
|
1
|
+
import { C as ChannelType, B as BaseNotificationPayload } from "../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
3
|
interface MockSentMessage {
|
|
4
4
|
messageId: string;
|
|
5
5
|
payload: BaseNotificationPayload;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BaseNotificationPayload } from "../../packem_shared/types.d-
|
|
2
|
-
import { P as Provider } from "../../packem_shared/provider.d-
|
|
1
|
+
import { B as BaseNotificationPayload } from "../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { P as Provider } from "../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
3
|
import { T as Tracer } from "../../packem_shared/tracer.d-BPznIQx9.js";
|
|
4
4
|
interface OtelProviderConfig {
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as BaseConfig, P as PushPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory } from "../../../packem_shared/provider.d-
|
|
1
|
+
import { d as BaseConfig, P as PushPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
3
|
interface ApnsConfig extends BaseConfig {
|
|
4
4
|
/** The app bundle id, sent as the `apns-topic` header. */
|
|
5
5
|
bundleId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"../../../packem_shared/createApnsProvider-
|
|
1
|
+
import r from"../../../packem_shared/createApnsProvider-DLdfR4Vx.js";const e=r;export{e as apnsProvider,r as createApnsProvider};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as BaseConfig, P as PushPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory } from "../../../packem_shared/provider.d-
|
|
1
|
+
import { d as BaseConfig, P as PushPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
3
|
interface ExpoConfig extends BaseConfig {
|
|
4
4
|
/** Expo access token (required for projects with enhanced security). */
|
|
5
5
|
accessToken?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"../../../packem_shared/createExpoProvider-
|
|
1
|
+
import o from"../../../packem_shared/createExpoProvider-DtCfr1WA.js";const e=o;export{o as createExpoProvider,e as expoProvider};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MaybePromise, d as BaseConfig, P as PushPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory } from "../../../packem_shared/provider.d-
|
|
1
|
+
import { M as MaybePromise, d as BaseConfig, P as PushPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
3
|
interface FcmConfig extends BaseConfig {
|
|
4
4
|
/**
|
|
5
5
|
* A static OAuth2 access token. Prefer {@link FcmConfig.getAccessToken} for tokens
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"../../../packem_shared/createFcmProvider-
|
|
1
|
+
import r from"../../../packem_shared/createFcmProvider-Ds2cUAnA.js";const e=r;export{r as createFcmProvider,e as fcmProvider};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as BaseConfig, P as PushPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory } from "../../../packem_shared/provider.d-
|
|
1
|
+
import { f as PushUrgency, d as BaseConfig, P as PushPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
3
|
/**
|
|
4
4
|
* A W3C Push API subscription. The `to` field of a push payload carries one of these
|
|
5
5
|
* (as an object, or its JSON string form) when targeting the web-push provider.
|
|
@@ -14,10 +14,10 @@ interface PushSubscriptionLike {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
interface WebPushConfig extends BaseConfig {
|
|
17
|
-
/**
|
|
17
|
+
/** Default time-to-live in seconds the push service should retain the message (default 2419200). Overridden by `payload.ttl`. */
|
|
18
18
|
ttl?: number;
|
|
19
|
-
/** Default delivery urgency hint (`very-low` | `low` | `normal` | `high`). */
|
|
20
|
-
urgency?:
|
|
19
|
+
/** Default delivery urgency hint (`very-low` | `low` | `normal` | `high`). Overridden by `payload.urgency`. */
|
|
20
|
+
urgency?: PushUrgency;
|
|
21
21
|
/** Application server private VAPID key (base64url, raw P-256 scalar `d`). */
|
|
22
22
|
vapidPrivateKey: string;
|
|
23
23
|
/** Application server public VAPID key (base64url, uncompressed P-256 point). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"../../../packem_shared/createWebPushProvider-
|
|
1
|
+
import r from"../../../packem_shared/createWebPushProvider-Cpu1Whj-.js";const o=r;export{r as createWebPushProvider,o as webPushProvider};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BaseNotificationPayload } from "../../packem_shared/types.d-
|
|
2
|
-
import { P as Provider } from "../../packem_shared/provider.d-
|
|
1
|
+
import { B as BaseNotificationPayload } from "../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { P as Provider } from "../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
3
|
interface RoundRobinConfig {
|
|
4
4
|
/** When true, falls through to the next provider on failure (default true). */
|
|
5
5
|
failover?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-
|
|
3
|
-
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-
|
|
4
|
-
import "../../../packem_shared/types.d-
|
|
1
|
+
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
|
+
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-CsjVAmeG.js";
|
|
4
|
+
import "../../../packem_shared/types.d-BulLsx7s.js";
|
|
5
5
|
interface MessageBirdConfig extends BaseConfig {
|
|
6
6
|
/** MessageBird (Bird) access key. */
|
|
7
7
|
accessKey: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory } from "../../../packem_shared/provider.d-
|
|
1
|
+
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
3
|
interface PlivoConfig extends BaseConfig {
|
|
4
4
|
/** Plivo Auth ID. */
|
|
5
5
|
authId: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory } from "../../../packem_shared/provider.d-
|
|
1
|
+
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
3
|
interface SnsConfig extends BaseConfig {
|
|
4
4
|
/** AWS access key id. */
|
|
5
5
|
accessKeyId: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-
|
|
3
|
-
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-
|
|
4
|
-
import "../../../packem_shared/types.d-
|
|
1
|
+
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
|
+
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-CsjVAmeG.js";
|
|
4
|
+
import "../../../packem_shared/types.d-BulLsx7s.js";
|
|
5
5
|
interface TelnyxConfig extends BaseConfig {
|
|
6
6
|
/** Telnyx API key (v2). */
|
|
7
7
|
apiKey: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-
|
|
3
|
-
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-
|
|
4
|
-
import "../../../packem_shared/types.d-
|
|
1
|
+
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
|
+
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-CsjVAmeG.js";
|
|
4
|
+
import "../../../packem_shared/types.d-BulLsx7s.js";
|
|
5
5
|
interface TwilioConfig extends BaseConfig {
|
|
6
6
|
/** Twilio Account SID. */
|
|
7
7
|
accountSid: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-
|
|
2
|
-
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-
|
|
3
|
-
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-
|
|
4
|
-
import "../../../packem_shared/types.d-
|
|
1
|
+
import { d as BaseConfig, S as SmsPayload } from "../../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { a as ProviderFactory, P as Provider } from "../../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
|
+
import { l as ReceiverOptions, R as Receiver } from "../../../packem_shared/types.d-CsjVAmeG.js";
|
|
4
|
+
import "../../../packem_shared/types.d-BulLsx7s.js";
|
|
5
5
|
interface VonageConfig extends BaseConfig {
|
|
6
6
|
/** Vonage (Nexmo) API key. */
|
|
7
7
|
apiKey: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as BaseConfig, W as WebhookPayload } from "../../packem_shared/types.d-
|
|
2
|
-
import { P as Provider } from "../../packem_shared/provider.d-
|
|
1
|
+
import { d as BaseConfig, W as WebhookPayload } from "../../packem_shared/types.d-COwyORBZ.js";
|
|
2
|
+
import { P as Provider } from "../../packem_shared/provider.d-D5HGHu5g.js";
|
|
3
3
|
interface WebhookConfig extends BaseConfig {
|
|
4
4
|
/** Default headers merged into every request. */
|
|
5
5
|
headers?: Record<string, string>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as NotificationMessage } from "../packem_shared/notification.d-
|
|
2
|
-
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-
|
|
3
|
-
import "../packem_shared/types.d-
|
|
4
|
-
import "../packem_shared/types.d-
|
|
5
|
-
import "../packem_shared/provider.d-
|
|
1
|
+
import { a as NotificationMessage } from "../packem_shared/notification.d-eA68bykk.js";
|
|
2
|
+
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-Bvs6BFvT.js";
|
|
3
|
+
import "../packem_shared/types.d-YJ8U7pag.js";
|
|
4
|
+
import "../packem_shared/types.d-COwyORBZ.js";
|
|
5
|
+
import "../packem_shared/provider.d-D5HGHu5g.js";
|
|
6
6
|
/**
|
|
7
7
|
* A BullMQ job, narrowed to the members this adapter reads.
|
|
8
8
|
*/
|
package/dist/queue/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { BullMqQueue, createBullMqQueue } from "./bullmq-queue.js";
|
|
2
|
-
import { a as NotificationMessage, N as Notification } from "../packem_shared/notification.d-
|
|
3
|
-
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-
|
|
2
|
+
import { a as NotificationMessage, N as Notification } from "../packem_shared/notification.d-eA68bykk.js";
|
|
3
|
+
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-Bvs6BFvT.js";
|
|
4
4
|
export { PgBossQueue, type PgBossQueueOptions, createPgBossQueue } from "./pg-boss-queue.js";
|
|
5
5
|
export { SqsQueue, type SqsQueueOptions, createSqsQueue } from "./sqs-queue.js";
|
|
6
|
-
import { c as Receipt } from "../packem_shared/types.d-
|
|
7
|
-
import "../packem_shared/types.d-
|
|
8
|
-
import "../packem_shared/provider.d-
|
|
6
|
+
import { c as Receipt } from "../packem_shared/types.d-COwyORBZ.js";
|
|
7
|
+
import "../packem_shared/types.d-YJ8U7pag.js";
|
|
8
|
+
import "../packem_shared/provider.d-D5HGHu5g.js";
|
|
9
9
|
/**
|
|
10
10
|
* In-process {@link NotificationQueue}. Suitable for single-instance apps, tests and the
|
|
11
11
|
* default worker; swap for the unstorage/BullMQ adapters for durability.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as NotificationMessage } from "../packem_shared/notification.d-
|
|
2
|
-
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-
|
|
3
|
-
import "../packem_shared/types.d-
|
|
4
|
-
import "../packem_shared/types.d-
|
|
5
|
-
import "../packem_shared/provider.d-
|
|
1
|
+
import { a as NotificationMessage } from "../packem_shared/notification.d-eA68bykk.js";
|
|
2
|
+
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-Bvs6BFvT.js";
|
|
3
|
+
import "../packem_shared/types.d-YJ8U7pag.js";
|
|
4
|
+
import "../packem_shared/types.d-COwyORBZ.js";
|
|
5
|
+
import "../packem_shared/provider.d-D5HGHu5g.js";
|
|
6
6
|
/**
|
|
7
7
|
* A pg-boss job fetched with `includeMetadata`, narrowed to the members this adapter reads.
|
|
8
8
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as NotificationMessage } from "../packem_shared/notification.d-
|
|
2
|
-
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-
|
|
3
|
-
import "../packem_shared/types.d-
|
|
4
|
-
import "../packem_shared/types.d-
|
|
5
|
-
import "../packem_shared/provider.d-
|
|
1
|
+
import { a as NotificationMessage } from "../packem_shared/notification.d-eA68bykk.js";
|
|
2
|
+
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-Bvs6BFvT.js";
|
|
3
|
+
import "../packem_shared/types.d-YJ8U7pag.js";
|
|
4
|
+
import "../packem_shared/types.d-COwyORBZ.js";
|
|
5
|
+
import "../packem_shared/provider.d-D5HGHu5g.js";
|
|
6
6
|
/**
|
|
7
7
|
* A single SQS message, narrowed to the members this adapter reads.
|
|
8
8
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { S as Storage } from "../packem_shared/unstorage.DqlWKU2I.d-CogP3Etw.js";
|
|
2
|
-
import { a as NotificationMessage } from "../packem_shared/notification.d-
|
|
3
|
-
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-
|
|
4
|
-
import "../packem_shared/types.d-
|
|
5
|
-
import "../packem_shared/types.d-
|
|
6
|
-
import "../packem_shared/provider.d-
|
|
2
|
+
import { a as NotificationMessage } from "../packem_shared/notification.d-eA68bykk.js";
|
|
3
|
+
import { Q as QueueJob, N as NotificationQueue } from "../packem_shared/types.d-Bvs6BFvT.js";
|
|
4
|
+
import "../packem_shared/types.d-YJ8U7pag.js";
|
|
5
|
+
import "../packem_shared/types.d-COwyORBZ.js";
|
|
6
|
+
import "../packem_shared/provider.d-D5HGHu5g.js";
|
|
7
7
|
/**
|
|
8
8
|
* A {@link NotificationQueue} backed by an [unstorage](https://unstorage.unjs.io) driver,
|
|
9
9
|
* giving durable, multi-backend persistence (Redis, filesystem, KV, ...). `unstorage` is
|
package/dist/routing/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as ChannelPayloadMap, N as Notification, a as NotificationMessage } from "../packem_shared/notification.d-
|
|
2
|
-
import { C as ChannelType, M as MaybePromise, c as Receipt } from "../packem_shared/types.d-
|
|
3
|
-
import "../packem_shared/types.d-
|
|
4
|
-
import "../packem_shared/provider.d-
|
|
1
|
+
import { C as ChannelPayloadMap, N as Notification, a as NotificationMessage } from "../packem_shared/notification.d-eA68bykk.js";
|
|
2
|
+
import { C as ChannelType, M as MaybePromise, c as Receipt } from "../packem_shared/types.d-COwyORBZ.js";
|
|
3
|
+
import "../packem_shared/types.d-YJ8U7pag.js";
|
|
4
|
+
import "../packem_shared/provider.d-D5HGHu5g.js";
|
|
5
5
|
/**
|
|
6
6
|
* A gate decides whether a channel should be attempted for a given payload. Use it for
|
|
7
7
|
* preferences, capability checks, send-windows or arbitrary conditions.
|
package/dist/utils/result.d.ts
CHANGED
package/dist/webhooks/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as WebhookVerifier } from "../packem_shared/types.d-
|
|
2
|
-
export { type W as WebhookHeaders, g as getHeader } from "../packem_shared/types.d-
|
|
3
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { a as WebhookVerifier } from "../packem_shared/types.d-BulLsx7s.js";
|
|
2
|
+
export { type W as WebhookHeaders, g as getHeader } from "../packem_shared/types.d-BulLsx7s.js";
|
|
3
|
+
import "../packem_shared/types.d-COwyORBZ.js";
|
|
4
4
|
/**
|
|
5
5
|
* Computes an HMAC over `message` and returns the lowercase hex digest.
|
|
6
6
|
* @param key The shared secret (UTF-8 string) or raw key bytes.
|
package/dist/workflow/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { M as MaybePromise, D as Duration, W as WorkflowConfig, a as WorkflowDefinition } from "../packem_shared/types.d-CcjfiGpo.d-DuZME7ry.js";
|
|
2
|
-
import { C as ChannelPayloadMap, N as Notification } from "../packem_shared/notification.d-
|
|
3
|
-
import { C as ChannelType, c as Receipt } from "../packem_shared/types.d-
|
|
2
|
+
import { C as ChannelPayloadMap, N as Notification } from "../packem_shared/notification.d-eA68bykk.js";
|
|
3
|
+
import { C as ChannelType, c as Receipt } from "../packem_shared/types.d-COwyORBZ.js";
|
|
4
4
|
import '@standard-schema/spec';
|
|
5
|
-
import "../packem_shared/types.d-
|
|
6
|
-
import "../packem_shared/provider.d-
|
|
5
|
+
import "../packem_shared/types.d-YJ8U7pag.js";
|
|
6
|
+
import "../packem_shared/provider.d-D5HGHu5g.js";
|
|
7
7
|
/** The context handed to a step resolver / skip predicate. */
|
|
8
8
|
interface StepResolverContext<PayloadT> {
|
|
9
9
|
/** The validated trigger payload of the run. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/notification",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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
6
|
"agent",
|
|
@@ -238,7 +238,7 @@
|
|
|
238
238
|
"peerDependencies": {
|
|
239
239
|
"@aws-sdk/client-sqs": "^3.0.0",
|
|
240
240
|
"@opentelemetry/api": "^1.0.0 || ^2.0.0",
|
|
241
|
-
"@visulima/email": "3.0.
|
|
241
|
+
"@visulima/email": "3.0.28",
|
|
242
242
|
"@visulima/workflow": "3.0.0",
|
|
243
243
|
"bullmq": "^5.0.0",
|
|
244
244
|
"croner": "^10.0.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as w}from"node:module";import l from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as N}from"./defineProvider-C9q-7iwt.js";import{t as R}from"./credentials-D9KXFoo0.js";import{a as $}from"./sms-CT04IxF8.js";let O;const I=n=>(O??=w(import.meta.url))(n),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=n=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[t,i]=f.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return f.getBuiltinModule(n)}return I(n)},{sign:v,createPrivateKey:P}=b("node:crypto"),{connect:K}=b("node:http2"),j="https://api.push.apple.com",k="https://api.sandbox.push.apple.com",q=3e3*1e3,B=200,h=n=>Buffer.from(n,"utf8").toString("base64url"),E=(n,t,i)=>{const g=h(JSON.stringify({alg:"ES256",kid:n.keyId,typ:"JWT"})),u=h(JSON.stringify({iat:i,iss:n.teamId})),p=`${g}.${u}`,s=v("sha256",Buffer.from(p,"utf8"),{dsaEncoding:"ieee-p1363",key:t}).toString("base64url");return`${p}.${s}`},z=N(n=>{const t=n??{};if(!t.teamId)throw new l("apns","teamId");if(!t.keyId)throw new l("apns","keyId");if(!t.signingKey)throw new l("apns","signingKey");if(!t.bundleId)throw new l("apns","bundleId");const i=t.production?j:k;let g,u,p=0,s;const T=()=>(g??=P({format:"pem",key:t.signingKey}),g),y=()=>{const e=Date.now();return(!u||e-p>q)&&(u=E(t,T(),Math.floor(e/1e3)),p=e),u},_=()=>((!s||s.closed||s.destroyed)&&(s=K(i),s.on("error",e=>{t.logger?.warn(`[@visulima/notification] [apns] HTTP/2 session error: ${e.message}`)})),s),S=async(e,m)=>new Promise(a=>{const r=_().request({":method":"POST",":path":`/3/device/${e}`,"apns-topic":t.bundleId,authorization:`bearer ${y()}`,"content-type":"application/json"});let c=0,d="";r.setEncoding("utf8"),r.on("response",o=>{c=o[":status"]??0}),r.on("data",o=>{d+=o}),r.on("error",o=>{a({error:o.message,id:e,status:"failed"})}),r.on("end",()=>{if(c===B){a({id:e,messageId:e,status:"sent"});return}let o=`HTTP ${String(c)}`;if(d)try{o=JSON.parse(d).reason??o}catch{o=d}a({error:o,id:e,status:"failed"})}),r.end(m)});return{channel:"push",endpoint:i,features:{batchSending:!1,media:!0,richContent:!0},id:"apns",initialize:()=>{},isAvailable:()=>!0,options:t,send:async e=>{const m=R(e.to),a={alert:{body:e.body,title:e.title}};e.sound!==void 0&&(a.sound=e.sound),e.badge!==void 0&&(a.badge=e.badge);const r=JSON.stringify({...e.data,aps:a}),c=[];for(const d of m)c.push(await S(d,r));return $("push","apns",c)},shutdown:()=>{s&&!s.closed&&s.close(),s=void 0}}});export{z as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import c from"./NotificationError-tZsXfB7V.js";import{defineProvider as T}from"./defineProvider-C9q-7iwt.js";import{t as k}from"./credentials-D9KXFoo0.js";import{r as A}from"./http-YFt2eXXy.js";import{g as v}from"./id-FYdbBSpb.js";const w="https://exp.host",R=T(m=>{const t=m??{},u=t.endpoint??w,l=t.retries??3,g=t.timeout??3e4,h=`${u}/--/api/v2/push/send`;return{channel:"push",endpoint:u,features:{batchSending:!0,media:!0,richContent:!0},id:"expo",initialize:()=>{},isAvailable:()=>!0,options:t,send:async s=>{const d=k(s.to),x=d.map(r=>({badge:s.badge,body:s.body,data:s.data,sound:s.sound??"default",title:s.title,to:r})),p={"Content-Type":"application/json"};t.accessToken&&(p.Authorization=`Bearer ${t.accessToken}`);const e=await A(h,{body:JSON.stringify(x),headers:p,method:"POST",timeout:g},l);if(!e.success||!e.data)return{error:new c("expo",e.error instanceof Error?e.error.message:"Request failed"),success:!1};if(e.data.status>=400)return{error:new c("expo",`HTTP ${String(e.data.status)}`),success:!1};const i=e.data.body.data;let o;Array.isArray(i)?o=i:o=i?[i]:[];const a=d.map((r,b)=>{const n=o[b];return n?.status==="error"?{error:n.details?.error??n.message??"error",id:r,status:"failed"}:{id:r,messageId:n?.id,status:"sent"}}),f=a.filter(r=>r.status==="sent");return f.length===0?{error:new c("expo",a[0]?.error??"All tokens failed"),success:!1}:{data:{channel:"push",messageId:f[0]?.messageId??v("expo"),provider:"expo",recipients:a,sent:!0,timestamp:new Date},success:!0}}}});export{R as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import g from"./NotificationError-tZsXfB7V.js";import c from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as l}from"./defineProvider-C9q-7iwt.js";import{t as h}from"./credentials-D9KXFoo0.js";import{r as T}from"./http-YFt2eXXy.js";import{a as b}from"./sms-CT04IxF8.js";const R=l(a=>{const e=a??{};if(!e.projectId)throw new c("fcm","projectId");if(!e.accessToken&&!e.getAccessToken)throw new c("fcm",["accessToken","getAccessToken"]);const n=e.endpoint??"https://fcm.googleapis.com",f=e.retries??3,d=e.timeout??3e4,m=`${n}/v1/projects/${e.projectId}/messages:send`,u=s=>{if(s)return Object.fromEntries(Object.entries(s).map(([r,o])=>[r,typeof o=="string"?o:JSON.stringify(o)]))},p=async(s,r,o)=>{const i={data:u(r.data),notification:{body:r.body,image:r.imageUrl,title:r.title},token:s},t=await T(m,{body:JSON.stringify({message:i}),headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},method:"POST",timeout:d},f);return!t.success||!t.data?{error:t.error instanceof Error?t.error.message:"Request failed",id:s,status:"failed"}:t.data.status>=400?{error:t.data.body.error?.message??`HTTP ${String(t.data.status)}`,id:s,status:"failed"}:{id:s,messageId:t.data.body.name,status:"sent"}};return{channel:"push",endpoint:n,features:{batchSending:!1,media:!0,richContent:!0},id:"fcm",initialize:()=>{},isAvailable:()=>!!(e.projectId&&(e.accessToken??e.getAccessToken)),options:e,send:async s=>{let r;try{r=e.getAccessToken?await e.getAccessToken():e.accessToken}catch(t){return{error:new g("fcm","Failed to obtain access token",{cause:t}),success:!1}}const o=h(s.to),i=[];for(const t of o)i.push(await p(t,s,r));return b("push","fcm",i)}}});export{R as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import K from"./RequiredOptionError-CAuRlc0R.js";import{defineProvider as C}from"./defineProvider-C9q-7iwt.js";import{t as E}from"./credentials-D9KXFoo0.js";import{m as A}from"./http-YFt2eXXy.js";import{g as k}from"./id-FYdbBSpb.js";import{a as T}from"./sms-CT04IxF8.js";import{u as y,f as S,b as m,s as c,r as U,d as f,e as P,g as B}from"./webcrypto-BPm3NDEm.js";const R=2419200,$=i=>{let e=i;if(typeof i=="string")try{e=JSON.parse(i)}catch{return}const t=e;if(!(!t||typeof t.endpoint!="string"||typeof t.keys?.p256dh!="string"||typeof t.keys.auth!="string"))return t},j=async(i,e)=>{const t=S(e),d=m(t.slice(1,33)),a=m(t.slice(33,65));return c().importKey("jwk",{crv:"P-256",d:i,ext:!0,key_ops:["sign"],kty:"EC",x:d,y:a},{name:"ECDSA",namedCurve:"P-256"},!1,["sign"])},x=async(i,e,t)=>{const d=m(y(JSON.stringify({alg:"ES256",typ:"JWT"}))),a=m(y(JSON.stringify({aud:i,exp:Math.floor(Date.now()/1e3)+720*60,sub:e}))),u=`${d}.${a}`,n=await c().sign({hash:"SHA-256",name:"ECDSA"},t,y(u));return`${u}.${m(new Uint8Array(n))}`},D=async(i,e)=>{const t=S(i.keys.p256dh),d=S(i.keys.auth),a=U(16),u=await c().generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveBits"]),n=new Uint8Array(await c().exportKey("raw",u.publicKey)),s=await c().importKey("raw",t,{name:"ECDH",namedCurve:"P-256"},!1,[]),g=new Uint8Array(await c().deriveBits({name:"ECDH",public:s},u.privateKey,256)),r=f(y("WebPush: info\0"),t,n),l=await P(d,g,r,32),b=await P(a,l,y("Content-Encoding: aes128gcm\0"),16),v=await P(a,l,y("Content-Encoding: nonce\0"),12),w=await c().importKey("raw",b,{name:"AES-GCM"},!1,["encrypt"]),h=f(e,new Uint8Array([2])),o=new Uint8Array(await c().encrypt({iv:v,name:"AES-GCM"},w,h)),p=f(a,B(4096,4),new Uint8Array([n.length]),n);return f(p,o)},q=C(i=>{const e=i??{};if(!e.vapidPublicKey||!e.vapidPrivateKey||!e.vapidSubject)throw new K("web-push",["vapidPublicKey","vapidPrivateKey","vapidSubject"]);const t=e.ttl??R,d=e.urgency??"normal",a=e.timeout??3e4,u=async(n,s,g)=>{const r=$(n);if(!r)return{error:"Invalid push subscription (expected { endpoint, keys: { p256dh, auth } })",id:n,status:"failed"};const{origin:l}=new URL(r.endpoint),b=await x(l,e.vapidSubject,g),v=JSON.stringify({badge:s.badge,body:s.body,data:s.data,image:s.imageUrl,title:s.title}),w=await D(r,y(v)),h={Authorization:`vapid t=${b},k=${e.vapidPublicKey}`,"Content-Encoding":"aes128gcm","Content-Type":"application/octet-stream",TTL:String(t),Urgency:d},o=await A(r.endpoint,{body:w,headers:h,method:"POST",timeout:a});if(!o.success||!o.data)return{error:o.error instanceof Error?o.error.message:"Request failed",id:n,status:"failed"};const{status:p}=o.data;return p===404||p===410?{error:`Subscription gone (HTTP ${String(p)}) — remove this subscription`,id:n,status:"failed"}:p>=400?{error:`HTTP ${String(p)}: ${typeof o.data.body=="string"?o.data.body:""}`.trim(),id:n,status:"failed"}:{id:n,messageId:k("web-push"),status:"sent"}};return{channel:"push",features:{batchSending:!1,media:!1,richContent:!0},id:"web-push",initialize:()=>{},isAvailable:()=>!!(e.vapidPublicKey&&e.vapidPrivateKey&&e.vapidSubject),options:e,send:async n=>{const s=E(n.to),g=await j(e.vapidPrivateKey,e.vapidPublicKey),r=[];for(const l of s)r.push(await u(l,n,g));return T("push","web-push",r)},validateCredentials:()=>!!(e.vapidPublicKey&&e.vapidPrivateKey&&e.vapidSubject)}});export{q as default};
|