@freecorps/ember-push 0.1.0 → 0.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/dist/types.d.ts CHANGED
@@ -1,7 +1,30 @@
1
1
  /**
2
- * Provider-neutral push types. Expo Push is the first provider (PLAN §10, CLOUDFLARE.md §8); direct APNs (ES256 JWT
3
- * over HTTP/2) and FCM v1 (service-account OAuth) can implement `PushProvider` later without changing callers.
2
+ * Provider-neutral push types. Two transports implement them: Expo Push (`expo.ts`, zero setup) and direct APNs (ES256
3
+ * provider token over HTTP/2, `apns.ts`) + FCM HTTP v1 (service-account OAuth, `fcm.ts`). Callers do not change.
4
4
  */
5
+ import type { PushEnvelope } from "./envelope.ts";
6
+ /**
7
+ * How urgent a push is. Direct transports map it to the APNs priority, the FCM Android priority, the TTL default and
8
+ * the iOS interruption level (Brigade's `low`/`high`/`page`, see `delivery.ts`):
9
+ *
10
+ * | urgency | APNs priority | FCM priority | TTL default | interruption level |
11
+ * |----------|---------------|--------------|-------------|--------------------|
12
+ * | `low` | 5 | NORMAL | 4 h | active |
13
+ * | `normal` | 10 | HIGH | 1 h | active |
14
+ * | `high` | 10 | HIGH | 15 min | time-sensitive |
15
+ */
16
+ export type PushUrgency = "low" | "normal" | "high";
17
+ /** iOS 15+ interruption levels. `time-sensitive` needs the entitlement; `critical` needs Apple's approval. */
18
+ export type PushInterruptionLevel = "passive" | "active" | "time-sensitive" | "critical";
19
+ /** APNs environment of an iOS device token: Xcode/development-signed builds get sandbox tokens, ad hoc/TestFlight/App Store ones production. */
20
+ export type ApnsEnvironment = "sandbox" | "production";
21
+ /**
22
+ * End-to-end encryption of a push (direct transport only):
23
+ * - `off`: content in clear;
24
+ * - `auto` (default): sealed for devices that registered a public key, in clear for the others;
25
+ * - `required`: sealed; a device without a key (or an Expo token) gets only the fallback text.
26
+ */
27
+ export type PushEncryption = "off" | "auto" | "required";
5
28
  /** What a notification says. Fields a provider does not support are ignored by it. */
6
29
  export interface PushMessage {
7
30
  title?: string;
@@ -24,18 +47,51 @@ export interface PushMessage {
24
47
  categoryId?: string;
25
48
  /** iOS Notification Service Extension may modify the content. */
26
49
  mutableContent?: boolean;
50
+ /** Direct transports: see `PushUrgency`. Without it, `priority: "normal"` means `low`, anything else `normal`. */
51
+ urgency?: PushUrgency;
52
+ /** Replaces an earlier notification with the same id (APNs `apns-collapse-id`, ≤ 64 bytes; FCM `collapse_key` + tag; Expo `collapseId` + `tag`). */
53
+ collapseId?: string;
54
+ /** iOS notification grouping (`thread-id`). */
55
+ threadId?: string;
56
+ /** iOS interruption level; default from `urgency` (`high` → `time-sensitive`). */
57
+ interruptionLevel?: PushInterruptionLevel;
58
+ /** Direct transports: overrides the install's encryption setting for this message (see `PushEncryption`). */
59
+ encryption?: PushEncryption;
60
+ /**
61
+ * iOS: send as a PushKit VoIP push to the device's `voipToken` (topic `<bundle id>.voip`, push type `voip`). The app
62
+ * must report a call to CallKit for every one, or iOS stops delivering them. Devices without a VoIP token are skipped.
63
+ */
64
+ voip?: boolean;
27
65
  }
28
66
  /** A message for one device token. */
29
67
  export interface AddressedPushMessage extends PushMessage {
30
68
  to: string;
69
+ /** APNs environment of `to` (iOS). Unknown: the transport's default, then the other host if APNs says `BadDeviceToken`. */
70
+ environment?: ApnsEnvironment;
71
+ /**
72
+ * Set by `sendToDevices` when the content is sealed for this device: the transport sends this envelope and the
73
+ * fallback text instead of title/subtitle/body/data.
74
+ */
75
+ sealed?: PushEnvelope;
76
+ }
77
+ /** What a device shows when an encrypted push cannot be opened (or, with `encryption: "required"`, has no key). */
78
+ export interface PushFallback {
79
+ title?: string;
80
+ body?: string;
81
+ /** iOS: localization keys from the app's `Localizable.strings`, preferred over the plain text when set. */
82
+ titleLocKey?: string;
83
+ locKey?: string;
31
84
  }
32
85
  /** Well-known per-message errors (Expo names; APNs/FCM providers map theirs onto these). */
33
86
  export type PushErrorCode = "DeviceNotRegistered" | "MessageTooBig" | "MessageRateExceeded" | "MismatchSenderId" | "InvalidCredentials" | "InvalidToken" | "RequestFailed" | (string & {});
34
87
  /** The push service's answer at send time. `ok` means accepted, not delivered: check receipts later. */
35
- export type PushTicket = {
88
+ export type PushTicket =
89
+ /** `environment`: set when a direct send found the device's APNs environment by trying the other host. */
90
+ {
36
91
  token: string;
37
92
  status: "ok";
38
93
  id: string;
94
+ environment?: ApnsEnvironment;
39
95
  } | {
40
96
  token: string;
41
97
  status: "error";
package/dist/types.js CHANGED
@@ -1,5 +1 @@
1
- /**
2
- * Provider-neutral push types. Expo Push is the first provider (PLAN §10, CLOUDFLARE.md §8); direct APNs (ES256 JWT
3
- * over HTTP/2) and FCM v1 (service-account OAuth) can implement `PushProvider` later without changing callers.
4
- */
5
1
  export {};
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@freecorps/ember-push",
3
- "version": "0.1.0",
4
- "description": "Push notifications for Ember actions: device table helpers and an Expo Push sender.",
3
+ "version": "0.2.0",
4
+ "description": "Push notifications for Ember: device registry, Expo Push, direct APNs + FCM, end-to-end encrypted payloads (HPKE), and a push component.",
5
5
  "keywords": [
6
- "ember",
7
- "convex",
6
+ "apns",
8
7
  "cloudflare",
9
- "workers",
10
- "push",
8
+ "convex",
9
+ "e2ee",
10
+ "ember",
11
11
  "expo",
12
- "notifications"
12
+ "fcm",
13
+ "hpke",
14
+ "notifications",
15
+ "push",
16
+ "workers"
13
17
  ],
14
18
  "homepage": "https://github.com/freecorps/ember/tree/main/packages/push#readme",
15
19
  "bugs": {
@@ -41,7 +45,7 @@
41
45
  "access": "public"
42
46
  },
43
47
  "dependencies": {
44
- "@freecorps/ember-server": "0.1.0",
45
- "@freecorps/ember-values": "0.1.0"
48
+ "@freecorps/ember-server": "0.2.0",
49
+ "@freecorps/ember-values": "0.2.0"
46
50
  }
47
51
  }