@dataemergencia/emergency 0.2.1 → 0.4.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/README.md CHANGED
@@ -86,6 +86,7 @@ cancels in-flight requests, disconnects Pusher and clears the store.
86
86
  code: 'DABC12',
87
87
  trigger: '#sos',
88
88
  fallback: { phone: '+57 300 123 4567', label: 'Línea de emergencia' },
89
+ realtime: { key: 'your-public-pusher-key', cluster: 'us2' },
89
90
  });
90
91
  </script>
91
92
  ```
@@ -111,8 +112,14 @@ against the mock BFF: see
111
112
  | `locale` | `string` | Defaults to `es`; used for time formatting. |
112
113
  | `geolocationTimeoutMs` | `number` | Defaults to `8000`. |
113
114
  | `requestTimeoutMs` | `number` | Defaults to `15000`. |
115
+ | `realtime` | `{ key, cluster, channelPattern? }` | Public Pusher settings supplied by the host. |
114
116
  | `onEvent` | `(name, payload) => void` | Typed lifecycle events. |
115
117
 
118
+ Realtime is optional. Pass the public Pusher `key` and `cluster` (plus an
119
+ optional `channelPattern`, defaulting to `whatsapp.{phone}`) to subscribe
120
+ directly to the API's channels; omit the block to stay in pull mode. The API
121
+ publishes the events, and the BFF never holds Pusher credentials.
122
+
116
123
  Invalid roots or codes do not throw into the host page. `mount()` reports a
117
124
  `configuration` error through `onEvent('emergency:failed', …)`, logs it, and
118
125
  returns an inert client.
@@ -159,15 +166,15 @@ client's own emitter, not DOM custom events.
159
166
  The client expects the emergency BFF documented in
160
167
  `packages/emergency-bff`:
161
168
 
162
- | Method | Route | Purpose |
163
- | -------- | --------------- | ---------------------------------------------- |
164
- | `GET` | `/config` | Initial CSRF token and public realtime config. |
165
- | `POST` | `/session` | `{ code }` → session + rotated CSRF token. |
166
- | `GET` | `/current` | Active emergency for the session, if any. |
167
- | `POST` | `/activate` | `{ geolocation: { latitude, longitude } }`. |
168
- | `POST` | `/simulacrum` | Test message, no emergency created. |
169
- | `POST` | `/{id}/refresh` | Reconcile snapshot and responder statuses. |
170
- | `DELETE` | `/{id}` | Abort and notify contacts. |
169
+ | Method | Route | Purpose |
170
+ | -------- | --------------- | ------------------------------------------- |
171
+ | `GET` | `/config` | Initial CSRF token. |
172
+ | `POST` | `/session` | `{ code }` → session + rotated CSRF token. |
173
+ | `GET` | `/current` | Active emergency for the session, if any. |
174
+ | `POST` | `/activate` | `{ geolocation: { latitude, longitude } }`. |
175
+ | `POST` | `/simulacrum` | Test message, no emergency created. |
176
+ | `POST` | `/{id}/refresh` | Reconcile snapshot and responder statuses. |
177
+ | `DELETE` | `/{id}` | Abort and notify contacts. |
171
178
 
172
179
  Every mutating request sends the CSRF token in `X-CSRF-Token`. The default
173
180
  strategy keeps the token in memory and updates it from `/config` and `/session`.