@venturekit/notify 0.0.47 → 0.0.48
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/README.md +37 -15
- package/dist/devices/devices.d.ts +10 -9
- package/dist/devices/devices.d.ts.map +1 -1
- package/dist/devices/devices.js +8 -7
- package/dist/devices/devices.js.map +1 -1
- package/dist/devices/index.d.ts +2 -2
- package/dist/devices/index.d.ts.map +1 -1
- package/dist/devices/index.js +1 -1
- package/dist/devices/index.js.map +1 -1
- package/dist/devices/push.d.ts +91 -21
- package/dist/devices/push.d.ts.map +1 -1
- package/dist/devices/push.js +119 -34
- package/dist/devices/push.js.map +1 -1
- package/dist/providers/index.d.ts +3 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +2 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/push-apns.d.ts +117 -0
- package/dist/providers/push-apns.d.ts.map +1 -0
- package/dist/providers/push-apns.js +279 -0
- package/dist/providers/push-apns.js.map +1 -0
- package/dist/providers/push-fcm.d.ts +92 -0
- package/dist/providers/push-fcm.d.ts.map +1 -0
- package/dist/providers/push-fcm.js +299 -0
- package/dist/providers/push-fcm.js.map +1 -0
- package/dist/providers/types.d.ts +49 -1
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/providers/types.js +2 -1
- package/dist/providers/types.js.map +1 -1
- package/package.json +14 -6
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @venturekit/notify — Firebase Cloud Messaging push provider (HTTP v1).
|
|
3
|
+
*
|
|
4
|
+
* Android's push is FCM whatever sits in front of it; this talks to it directly, with the
|
|
5
|
+
* Firebase project's **service account** (Project settings › Service accounts › Generate new
|
|
6
|
+
* private key): no Expo project, no relay, one HTTPS request per device token.
|
|
7
|
+
*
|
|
8
|
+
* ### Authorisation
|
|
9
|
+
*
|
|
10
|
+
* HTTP v1 takes an OAuth 2.0 access token, minted here from the service account by the
|
|
11
|
+
* JWT-bearer grant (an RS256 assertion signed with `node:crypto`, no Google SDK) and cached
|
|
12
|
+
* per service account until a minute before it expires — so a warm Lambda asks Google once
|
|
13
|
+
* an hour, not once a send.
|
|
14
|
+
*
|
|
15
|
+
* ### One request per token, and what the answer means
|
|
16
|
+
*
|
|
17
|
+
* HTTP v1 has no multicast: every token is its own request, sent {@link FcmPushConfig.concurrency}
|
|
18
|
+
* at a time. Each answer is final — there is no receipt to ask for later, unlike Expo — and
|
|
19
|
+
* becomes a {@link PushSendOutcome}:
|
|
20
|
+
*
|
|
21
|
+
* - `UNREGISTERED` (404), or `INVALID_ARGUMENT` about the registration token: the token is
|
|
22
|
+
* dead — `gone`, revoke it. Any other `INVALID_ARGUMENT` is the message's fault and says
|
|
23
|
+
* nothing about the device.
|
|
24
|
+
* - 429, 5xx, a network failure: `retryable`.
|
|
25
|
+
* - `SENDER_ID_MISMATCH`: the token belongs to another Firebase project — a configuration
|
|
26
|
+
* mistake (the app's `google-services.json` and this service account disagree), so it is
|
|
27
|
+
* reported, never revoked.
|
|
28
|
+
*
|
|
29
|
+
* A service account that cannot be read, or that Google refuses, throws before anything is
|
|
30
|
+
* sent ({@link prepareFcmPush}).
|
|
31
|
+
*/
|
|
32
|
+
import { createSign } from 'node:crypto';
|
|
33
|
+
import { ProviderHardError, ProviderSendError, PushDeviceGoneError, } from './types.js';
|
|
34
|
+
const DEFAULT_TOKEN_URI = 'https://oauth2.googleapis.com/token';
|
|
35
|
+
const SCOPE = 'https://www.googleapis.com/auth/firebase.messaging';
|
|
36
|
+
/** Seconds an access token is asked for (Google's maximum). */
|
|
37
|
+
const TOKEN_LIFETIME = 3600;
|
|
38
|
+
/** Renew this long before Google's expiry, so a send never carries a token about to lapse. */
|
|
39
|
+
const RENEW_MARGIN_MS = 60_000;
|
|
40
|
+
const DEFAULT_CONCURRENCY = 8;
|
|
41
|
+
/** Read a service-account key, refusing one that lacks what the send needs. */
|
|
42
|
+
export function parseFcmServiceAccount(input) {
|
|
43
|
+
let raw;
|
|
44
|
+
if (typeof input === 'string') {
|
|
45
|
+
try {
|
|
46
|
+
raw = JSON.parse(input);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
throw new ProviderHardError('[notify:push-fcm] the service account is not JSON — paste the whole key file Firebase downloaded');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
raw = input;
|
|
54
|
+
}
|
|
55
|
+
const pick = (...keys) => {
|
|
56
|
+
for (const key of keys) {
|
|
57
|
+
const value = raw[key];
|
|
58
|
+
if (typeof value === 'string' && value.trim())
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
return '';
|
|
62
|
+
};
|
|
63
|
+
const account = {
|
|
64
|
+
projectId: pick('projectId', 'project_id'),
|
|
65
|
+
clientEmail: pick('clientEmail', 'client_email'),
|
|
66
|
+
privateKey: pick('privateKey', 'private_key'),
|
|
67
|
+
tokenUri: pick('tokenUri', 'token_uri') || DEFAULT_TOKEN_URI,
|
|
68
|
+
};
|
|
69
|
+
const missing = ['projectId', 'clientEmail', 'privateKey'].filter((k) => !account[k]);
|
|
70
|
+
if (missing.length > 0) {
|
|
71
|
+
throw new ProviderHardError(`[notify:push-fcm] the service account has no ${missing.join(', ')} — use the key from Project settings › Service accounts`);
|
|
72
|
+
}
|
|
73
|
+
return account;
|
|
74
|
+
}
|
|
75
|
+
const base64url = (input) => Buffer.from(input).toString('base64url');
|
|
76
|
+
/** Access tokens per service account (and the request minting one), process-wide. */
|
|
77
|
+
const tokens = new Map();
|
|
78
|
+
const minting = new Map();
|
|
79
|
+
/** Forget every cached access token. For tests. */
|
|
80
|
+
export function __resetFcmTokensForTests() {
|
|
81
|
+
tokens.clear();
|
|
82
|
+
minting.clear();
|
|
83
|
+
}
|
|
84
|
+
function cacheKey(account) {
|
|
85
|
+
return `${account.clientEmail}|${account.tokenUri}`;
|
|
86
|
+
}
|
|
87
|
+
async function mintAccessToken(account, doFetch, now) {
|
|
88
|
+
const iat = Math.floor(now() / 1000);
|
|
89
|
+
const header = base64url(JSON.stringify({ alg: 'RS256', typ: 'JWT' }));
|
|
90
|
+
const claims = base64url(JSON.stringify({ iss: account.clientEmail, scope: SCOPE, aud: account.tokenUri, iat, exp: iat + TOKEN_LIFETIME }));
|
|
91
|
+
let signature;
|
|
92
|
+
try {
|
|
93
|
+
signature = createSign('RSA-SHA256').update(`${header}.${claims}`).sign(account.privateKey, 'base64url');
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
throw new ProviderHardError('[notify:push-fcm] the service account\'s private key cannot sign — paste the key file unmodified', err);
|
|
97
|
+
}
|
|
98
|
+
let response;
|
|
99
|
+
try {
|
|
100
|
+
response = await doFetch(account.tokenUri, {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: { 'content-type': 'application/x-www-form-urlencoded', accept: 'application/json' },
|
|
103
|
+
body: `grant_type=${encodeURIComponent('urn:ietf:params:oauth:grant-type:jwt-bearer')}&assertion=${header}.${claims}.${signature}`,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
throw new ProviderSendError('[notify:push-fcm] the access-token request failed', err);
|
|
108
|
+
}
|
|
109
|
+
const json = (await response.json().catch(() => ({})));
|
|
110
|
+
if (!response.ok || !json.access_token) {
|
|
111
|
+
const reason = json.error_description ?? json.error ?? `HTTP ${response.status}`;
|
|
112
|
+
const message = `[notify:push-fcm] Google refused the service account: ${reason}`;
|
|
113
|
+
/* a revoked or deleted key, a wrong client: the same request fails again */
|
|
114
|
+
if (response.status >= 400 && response.status < 500 && response.status !== 429)
|
|
115
|
+
throw new ProviderHardError(message);
|
|
116
|
+
throw new ProviderSendError(message);
|
|
117
|
+
}
|
|
118
|
+
const lifetime = typeof json.expires_in === 'number' && json.expires_in > 0 ? json.expires_in : TOKEN_LIFETIME;
|
|
119
|
+
tokens.set(cacheKey(account), { token: json.access_token, expiresAtMs: now() + lifetime * 1000 });
|
|
120
|
+
return json.access_token;
|
|
121
|
+
}
|
|
122
|
+
/** An access token for this service account: the cached one while it has more than a minute left. */
|
|
123
|
+
export async function fcmAccessToken(account, options = {}) {
|
|
124
|
+
const now = options.now ?? Date.now;
|
|
125
|
+
const key = cacheKey(account);
|
|
126
|
+
const cached = tokens.get(key);
|
|
127
|
+
if (cached && cached.expiresAtMs - RENEW_MARGIN_MS > now())
|
|
128
|
+
return cached.token;
|
|
129
|
+
const doFetch = options.fetchImpl ?? globalThis.fetch;
|
|
130
|
+
if (!doFetch)
|
|
131
|
+
throw new ProviderHardError('[notify:push-fcm] no fetch available — pass `fetchImpl` on Node without a global fetch');
|
|
132
|
+
/* concurrent sends share one request rather than minting a token each */
|
|
133
|
+
let pending = minting.get(key);
|
|
134
|
+
if (!pending) {
|
|
135
|
+
pending = mintAccessToken(account, doFetch, now).finally(() => minting.delete(key));
|
|
136
|
+
minting.set(key, pending);
|
|
137
|
+
}
|
|
138
|
+
return pending;
|
|
139
|
+
}
|
|
140
|
+
/** FCM `data` carries strings only: a non-string value travels as its JSON. */
|
|
141
|
+
function stringData(data) {
|
|
142
|
+
const out = {};
|
|
143
|
+
for (const [key, value] of Object.entries(data ?? {})) {
|
|
144
|
+
if (value === undefined)
|
|
145
|
+
continue;
|
|
146
|
+
out[key] = typeof value === 'string' ? value : JSON.stringify(value);
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
/** The HTTP v1 request body for one message (`{ message: … }`), in the app's payload layout. */
|
|
151
|
+
export function fcmRequestBody(message, format = 'standard') {
|
|
152
|
+
const android = {
|
|
153
|
+
/* `default` is FCM's normal priority, as on Expo: a phone in Doze gets it at its next window */
|
|
154
|
+
priority: message.priority === 'high' ? 'HIGH' : 'NORMAL',
|
|
155
|
+
...(message.ttl !== undefined ? { ttl: `${Math.max(0, Math.floor(message.ttl))}s` } : {}),
|
|
156
|
+
};
|
|
157
|
+
if (format === 'expo-notifications') {
|
|
158
|
+
/* A data-only message, which `expo-notifications` presents itself (FirebaseMessagingDelegate)
|
|
159
|
+
with the channel named here, and whose `body` becomes `content.data`. No `sound` key: the
|
|
160
|
+
library plays the channel's default sound when none is named. */
|
|
161
|
+
return {
|
|
162
|
+
message: {
|
|
163
|
+
token: message.to,
|
|
164
|
+
data: {
|
|
165
|
+
...(message.title ? { title: message.title } : {}),
|
|
166
|
+
...(message.body ? { message: message.body } : {}),
|
|
167
|
+
body: JSON.stringify(message.data ?? {}),
|
|
168
|
+
...(message.channelId ? { channelId: message.channelId } : {}),
|
|
169
|
+
...(message.badge !== undefined ? { badge: String(message.badge) } : {}),
|
|
170
|
+
},
|
|
171
|
+
android,
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const notification = {
|
|
176
|
+
...(message.channelId ? { channel_id: message.channelId } : {}),
|
|
177
|
+
...(message.sound === 'default' ? { sound: 'default' } : {}),
|
|
178
|
+
...(message.badge !== undefined ? { notification_count: message.badge } : {}),
|
|
179
|
+
};
|
|
180
|
+
const aps = {
|
|
181
|
+
...(message.sound === 'default' ? { sound: 'default' } : {}),
|
|
182
|
+
...(message.badge !== undefined ? { badge: message.badge } : {}),
|
|
183
|
+
};
|
|
184
|
+
return {
|
|
185
|
+
message: {
|
|
186
|
+
token: message.to,
|
|
187
|
+
...(message.title || message.body ? { notification: { ...(message.title ? { title: message.title } : {}), ...(message.body ? { body: message.body } : {}) } } : {}),
|
|
188
|
+
...(message.data && Object.keys(message.data).length > 0 ? { data: stringData(message.data) } : {}),
|
|
189
|
+
android: { ...android, ...(Object.keys(notification).length > 0 ? { notification } : {}) },
|
|
190
|
+
apns: {
|
|
191
|
+
headers: { 'apns-priority': message.priority === 'normal' ? '5' : '10' },
|
|
192
|
+
...(Object.keys(aps).length > 0 ? { payload: { aps } } : {}),
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/** What one HTTP v1 answer means for the token it was about. */
|
|
198
|
+
export function fcmOutcome(to, status, json) {
|
|
199
|
+
if (status >= 200 && status < 300) {
|
|
200
|
+
const name = json?.name;
|
|
201
|
+
return { to, messageId: typeof name === 'string' ? name : `fcm:${Date.now()}`, error: null, gone: false, retryable: false };
|
|
202
|
+
}
|
|
203
|
+
const error = json?.error;
|
|
204
|
+
const code = error?.details?.find((d) => typeof d.errorCode === 'string')?.errorCode ?? error?.status ?? `HTTP ${status}`;
|
|
205
|
+
const message = error?.message ?? '';
|
|
206
|
+
const gone = code === 'UNREGISTERED' || (code === 'INVALID_ARGUMENT' && /registration token/i.test(message));
|
|
207
|
+
const retryable = !gone && (status === 429 || status >= 500 || status === 401 || code === 'UNAVAILABLE' || code === 'INTERNAL' || code === 'QUOTA_EXCEEDED');
|
|
208
|
+
return { to, messageId: null, error: code, gone, retryable };
|
|
209
|
+
}
|
|
210
|
+
async function pool(items, size, work) {
|
|
211
|
+
const out = new Array(items.length);
|
|
212
|
+
let next = 0;
|
|
213
|
+
const lanes = Array.from({ length: Math.max(1, Math.min(size, items.length)) }, async () => {
|
|
214
|
+
while (next < items.length) {
|
|
215
|
+
const i = next++;
|
|
216
|
+
out[i] = await work(items[i]);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
await Promise.all(lanes);
|
|
220
|
+
return out;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Read the service account and fetch its access token — everything that can fail for the
|
|
224
|
+
* whole send — and return the sender. Throws {@link ProviderHardError} for a key that cannot
|
|
225
|
+
* be used and {@link ProviderSendError} when Google could not be reached; having returned,
|
|
226
|
+
* the sender never throws: each token's fate is in its {@link PushSendOutcome}.
|
|
227
|
+
*/
|
|
228
|
+
export async function prepareFcmPush(config) {
|
|
229
|
+
const account = parseFcmServiceAccount(config.serviceAccount);
|
|
230
|
+
const now = config.now ?? Date.now;
|
|
231
|
+
const doFetch = config.fetchImpl ?? globalThis.fetch;
|
|
232
|
+
const accessToken = await fcmAccessToken(account, { fetchImpl: doFetch, now });
|
|
233
|
+
const url = `https://fcm.googleapis.com/v1/projects/${encodeURIComponent(account.projectId)}/messages:send`;
|
|
234
|
+
const format = config.format ?? 'standard';
|
|
235
|
+
return (messages) => pool(messages, config.concurrency ?? DEFAULT_CONCURRENCY, async (message) => {
|
|
236
|
+
let response;
|
|
237
|
+
try {
|
|
238
|
+
response = await doFetch(url, {
|
|
239
|
+
method: 'POST',
|
|
240
|
+
headers: { authorization: `Bearer ${accessToken}`, 'content-type': 'application/json', accept: 'application/json' },
|
|
241
|
+
body: JSON.stringify(fcmRequestBody(message, format)),
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
return { to: message.to, messageId: null, error: 'network', gone: false, retryable: true };
|
|
246
|
+
}
|
|
247
|
+
const json = await response.json().catch(() => null);
|
|
248
|
+
const outcome = fcmOutcome(message.to, response.status, json);
|
|
249
|
+
/* the token lapsed under us: the next send mints a fresh one */
|
|
250
|
+
if (response.status === 401)
|
|
251
|
+
tokens.delete(cacheKey(account));
|
|
252
|
+
return outcome;
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Send to many FCM registration tokens, one outcome per token, in order. Throws only what
|
|
257
|
+
* {@link prepareFcmPush} throws — before anything is sent.
|
|
258
|
+
*/
|
|
259
|
+
export async function sendFcmPush(messages, config) {
|
|
260
|
+
if (messages.length === 0)
|
|
261
|
+
return [];
|
|
262
|
+
const send = await prepareFcmPush(config);
|
|
263
|
+
return send(messages);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* A `NotifyProvider` for the `push` channel, where `to` is one FCM registration token — for the
|
|
267
|
+
* outbox and its dispatcher. A dead token is a {@link PushDeviceGoneError} (the dispatcher
|
|
268
|
+
* revokes it), a retryable refusal a {@link ProviderSendError}, anything else a
|
|
269
|
+
* {@link ProviderHardError}.
|
|
270
|
+
*/
|
|
271
|
+
export function createFcmPushProvider(config) {
|
|
272
|
+
const channel = 'push';
|
|
273
|
+
return {
|
|
274
|
+
channel,
|
|
275
|
+
name: 'fcm-push',
|
|
276
|
+
async send(request) {
|
|
277
|
+
const [outcome] = await sendFcmPush([
|
|
278
|
+
{
|
|
279
|
+
to: request.to,
|
|
280
|
+
...(request.message.subject ? { title: request.message.subject } : {}),
|
|
281
|
+
body: request.message.text,
|
|
282
|
+
data: { notificationId: request.notificationId },
|
|
283
|
+
sound: 'default',
|
|
284
|
+
...(config.defaultChannelId ? { channelId: config.defaultChannelId } : {}),
|
|
285
|
+
},
|
|
286
|
+
], config);
|
|
287
|
+
if (!outcome || !outcome.messageId) {
|
|
288
|
+
if (outcome?.gone)
|
|
289
|
+
throw new PushDeviceGoneError(request.to, `[notify:push-fcm] device not registered: ${request.to}`);
|
|
290
|
+
const message = `[notify:push-fcm] rejected: ${outcome?.error ?? 'unknown error'}`;
|
|
291
|
+
if (outcome?.retryable)
|
|
292
|
+
throw new ProviderSendError(message);
|
|
293
|
+
throw new ProviderHardError(message);
|
|
294
|
+
}
|
|
295
|
+
return { providerMessageId: outcome.messageId, acceptedAtMs: Date.now(), channel };
|
|
296
|
+
},
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=push-fcm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push-fcm.js","sourceRoot":"","sources":["../../src/providers/push-fcm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GAOpB,MAAM,YAAY,CAAC;AAEpB,MAAM,iBAAiB,GAAG,qCAAqC,CAAC;AAChE,MAAM,KAAK,GAAG,oDAAoD,CAAC;AACnE,+DAA+D;AAC/D,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,8FAA8F;AAC9F,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,mBAAmB,GAAG,C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,SAAS,EAAE,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC;QACrF,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -98,9 +98,57 @@ export declare class ProviderHardError extends Error {
|
|
|
98
98
|
cause?: unknown;
|
|
99
99
|
constructor(message: string, cause?: unknown);
|
|
100
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* One push to one device token, as every push provider takes it (Expo, FCM, APNs): the
|
|
103
|
+
* fields a phone shows, and the payload the app reads when it is tapped.
|
|
104
|
+
*/
|
|
105
|
+
export interface PushSendMessage {
|
|
106
|
+
/** The provider's device token. */
|
|
107
|
+
to: string;
|
|
108
|
+
title?: string;
|
|
109
|
+
body?: string;
|
|
110
|
+
/** Arbitrary JSON the app receives; typically what the notification opens. */
|
|
111
|
+
data?: Record<string, unknown>;
|
|
112
|
+
sound?: 'default' | null;
|
|
113
|
+
/** `high` asks the OS not to batch it. Reserve it for time-critical messages. */
|
|
114
|
+
priority?: 'default' | 'normal' | 'high';
|
|
115
|
+
/** Android notification channel id. */
|
|
116
|
+
channelId?: string;
|
|
117
|
+
badge?: number;
|
|
118
|
+
/** Seconds the provider may keep trying. */
|
|
119
|
+
ttl?: number;
|
|
120
|
+
}
|
|
121
|
+
/** What a provider that answers per device (FCM, APNs) said about one token. */
|
|
122
|
+
export interface PushSendOutcome {
|
|
123
|
+
/** The token it concerns. */
|
|
124
|
+
to: string;
|
|
125
|
+
/** The provider's id for the accepted message (FCM's message name, APNs' `apns-id`); `null` when refused. */
|
|
126
|
+
messageId: string | null;
|
|
127
|
+
/** The provider's reason, when it refused. */
|
|
128
|
+
error: string | null;
|
|
129
|
+
/** The token is dead at the provider — revoke it. */
|
|
130
|
+
gone: boolean;
|
|
131
|
+
/** A refusal another attempt may get through: a rate limit, the provider's outage, the network. */
|
|
132
|
+
retryable: boolean;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* How a native push (FCM, APNs) lays out its payload, which depends on the library that
|
|
136
|
+
* receives it in the app:
|
|
137
|
+
*
|
|
138
|
+
* - `standard` — the platform's own notification fields, the `data` keys beside them
|
|
139
|
+
* (FCM `notification` + string `data`; APNs `aps` + top-level keys). What a native app or
|
|
140
|
+
* `@react-native-firebase/messaging` expects.
|
|
141
|
+
* - `expo-notifications` — what `expo-notifications` reads when the app takes native tokens
|
|
142
|
+
* (`getDevicePushTokenAsync`) instead of Expo's push service: on Android a data-only FCM
|
|
143
|
+
* message (`title`, `message`, `channelId`, and the payload as JSON in `body`), which the
|
|
144
|
+
* library presents itself; on iOS the payload under the `body` key next to `aps`. Either
|
|
145
|
+
* way the app finds it in `notification.request.content.data`.
|
|
146
|
+
*/
|
|
147
|
+
export type PushPayloadFormat = 'standard' | 'expo-notifications';
|
|
101
148
|
/**
|
|
102
149
|
* Permanent, and about the ADDRESS rather than the message: the push token is dead at the
|
|
103
|
-
* provider (Expo's `DeviceNotRegistered`
|
|
150
|
+
* provider (Expo's `DeviceNotRegistered`, FCM's `UNREGISTERED`, APNs' `Unregistered` — the
|
|
151
|
+
* app uninstalled, the token rotated). The
|
|
104
152
|
* dispatcher fails the row like any {@link ProviderHardError} and, with a
|
|
105
153
|
* `PushDeviceDirectory` configured, revokes the token so no later row is addressed to it.
|
|
106
154
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAElE,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB;IAClC,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,OAAO,EAAE,eAAe,CAAC;IACzB;;;;;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AM,CAAC;IACf,4CAA4C;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,gFAAgF;AAChF,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,6GAA6G;IAC7G,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,8CAA8C;IAC9C,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,qDAAqD;IACrD,IAAI,EAAE,OAAO,CAAC;IACd,mGAAmG;IACnG,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,oBAAoB,CAAC;AAElE;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,iBAAiB;IACxD,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBACX,KAAK,EAAE,MAAM,EAAE,OAAO,SAAoC;CAKvE"}
|
package/dist/providers/types.js
CHANGED
|
@@ -39,7 +39,8 @@ export class ProviderHardError extends Error {
|
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Permanent, and about the ADDRESS rather than the message: the push token is dead at the
|
|
42
|
-
* provider (Expo's `DeviceNotRegistered`
|
|
42
|
+
* provider (Expo's `DeviceNotRegistered`, FCM's `UNREGISTERED`, APNs' `Unregistered` — the
|
|
43
|
+
* app uninstalled, the token rotated). The
|
|
43
44
|
* dispatcher fails the row like any {@link ProviderHardError} and, with a
|
|
44
45
|
* `PushDeviceDirectory` configured, revokes the token so no later row is addressed to it.
|
|
45
46
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA2EH;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,KAAK,CAAW;IAChB,YAAY,OAAe,EAAE,KAAe;QAC1C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C;IACrB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venturekit/notify",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48",
|
|
4
4
|
"description": "Transactional notifications for VentureKit — email (SES), WhatsApp (Meta Cloud), with a Postgres outbox + cron dispatcher.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,6 +52,14 @@
|
|
|
52
52
|
"types": "./dist/providers/push-expo.d.ts",
|
|
53
53
|
"import": "./dist/providers/push-expo.js"
|
|
54
54
|
},
|
|
55
|
+
"./providers/push-fcm": {
|
|
56
|
+
"types": "./dist/providers/push-fcm.d.ts",
|
|
57
|
+
"import": "./dist/providers/push-fcm.js"
|
|
58
|
+
},
|
|
59
|
+
"./providers/push-apns": {
|
|
60
|
+
"types": "./dist/providers/push-apns.d.ts",
|
|
61
|
+
"import": "./dist/providers/push-apns.js"
|
|
62
|
+
},
|
|
55
63
|
"./providers/whatsapp-meta": {
|
|
56
64
|
"types": "./dist/providers/whatsapp-meta.d.ts",
|
|
57
65
|
"import": "./dist/providers/whatsapp-meta.js"
|
|
@@ -108,11 +116,11 @@
|
|
|
108
116
|
"outbox"
|
|
109
117
|
],
|
|
110
118
|
"dependencies": {
|
|
111
|
-
"@venturekit/core": "0.0.
|
|
119
|
+
"@venturekit/core": "0.0.48"
|
|
112
120
|
},
|
|
113
121
|
"peerDependencies": {
|
|
114
|
-
"@venturekit/data": "0.0.
|
|
115
|
-
"@venturekit/runtime": "0.0.
|
|
122
|
+
"@venturekit/data": "0.0.48",
|
|
123
|
+
"@venturekit/runtime": "0.0.48",
|
|
116
124
|
"@aws-sdk/client-sesv2": "^3.1126.0",
|
|
117
125
|
"@aws-sdk/client-secrets-manager": "^3.1126.0"
|
|
118
126
|
},
|
|
@@ -131,8 +139,8 @@
|
|
|
131
139
|
}
|
|
132
140
|
},
|
|
133
141
|
"devDependencies": {
|
|
134
|
-
"@venturekit/data": "0.0.
|
|
135
|
-
"@venturekit/runtime": "0.0.
|
|
142
|
+
"@venturekit/data": "0.0.48",
|
|
143
|
+
"@venturekit/runtime": "0.0.48",
|
|
136
144
|
"@aws-sdk/client-sesv2": "^3.1126.0",
|
|
137
145
|
"@aws-sdk/client-secrets-manager": "^3.1126.0",
|
|
138
146
|
"@types/aws-lambda": "^8.10.163",
|