@hipnation-truth/sdk 0.26.16 → 0.26.17

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/react.d.ts CHANGED
@@ -745,6 +745,15 @@ declare function useConversationMessages(input: {
745
745
  * - addReceivedListener / addResponseListener — re-exports of expo's
746
746
  * - getBadgeCount / setBadgeCount — re-exports of expo's
747
747
  *
748
+ * Fresh-install registration (FIX #2): the hook installs a native
749
+ * `Notifications.addPushTokenListener` so a device token that arrives AFTER
750
+ * the initial mount (the OS registers for APNs/FCM asynchronously on a first
751
+ * install) still triggers registration — no app relaunch required. It also
752
+ * re-registers when `userId` transitions from null/undefined → a value, so a
753
+ * login right after install attributes the device to the user. The public hook
754
+ * API is unchanged — mounting the hook (with `autoRegister` left at its default
755
+ * `true`) is all the client needs; there is no new method to call.
756
+ *
748
757
  * Web push (VAPID subscription) lands in Phase 3.
749
758
  */
750
759
  type PermissionStatus = "granted" | "denied" | "undetermined" | "unknown";
@@ -2171,7 +2180,21 @@ interface ScheduleReminderInput {
2171
2180
  conversationId: string;
2172
2181
  remindAt: string | Date;
2173
2182
  note?: string;
2183
+ /**
2184
+ * Who scheduled the reminder. May be the end user's email — the backend
2185
+ * translates it to a Clerk id for push targeting. Prefer also passing
2186
+ * `createdByClerkId` when known so the reminder push lands on the right
2187
+ * device-bearing identity.
2188
+ */
2174
2189
  createdBy: string;
2190
+ /**
2191
+ * Optional pre-resolved Clerk id of the creator. Push devices + the push
2192
+ * tenancy gate are keyed by Clerk id, so passing it lets the reminder push
2193
+ * (and its conversation deep-link) target the right identity directly
2194
+ * instead of relying on an email→user lookup at fire time. When omitted the
2195
+ * backend resolves it from `createdBy`.
2196
+ */
2197
+ createdByClerkId?: string;
2175
2198
  }
2176
2199
  interface ScheduleReminderResult {
2177
2200
  reminderId: string;
@@ -2252,8 +2275,11 @@ interface ConversationTaskMarkSeenInput {
2252
2275
  * TasksResource — create, update status, list, get tasks.
2253
2276
  *
2254
2277
  * Backed by Convex. Replaces CommHub's createTaskWithNotification +
2255
- * updateTaskStatusWithNotification actions. Push notification side-effect
2256
- * is emitted downstream via Kinesis.
2278
+ * updateTaskStatusWithNotification actions. The push notification side-effect
2279
+ * is NOT emitted via Kinesis: the Convex task mutation enqueues a
2280
+ * `notificationJobs` row and schedules `notificationScheduler.runJob`, which
2281
+ * HTTP-fetches the Truth Lambda push endpoint (Truth API → Convex scheduler →
2282
+ * push). See apps/web/convex/lib/taskPush.ts.
2257
2283
  */
2258
2284
 
2259
2285
  declare class TasksResource {
package/dist/react.js CHANGED
@@ -314,7 +314,14 @@ var AttachmentsResource = class {
314
314
  return __async(this, null, function* () {
315
315
  const res = yield fetch(`${this.baseUrl}/api${path}`, {
316
316
  method: "POST",
317
- headers: yield buildAuthHeaders(this.auth, { json: true }),
317
+ // PHI (patient photos / MMS media) — REQUIRE the user JWT. The server
318
+ // hardens these routes to `verifiedUserProcedure`, so degrading to
319
+ // key-only would 401. `requireUserToken` retries across the Clerk-
320
+ // hydration gap and throws rather than silently sending key-only.
321
+ headers: yield buildAuthHeaders(this.auth, {
322
+ json: true,
323
+ requireUserToken: true
324
+ }),
318
325
  body: JSON.stringify(body)
319
326
  });
320
327
  if (!res.ok) {
@@ -1030,7 +1037,13 @@ var EhrProviderProxy = class {
1030
1037
  }
1031
1038
  const response = yield fetch(url.toString(), {
1032
1039
  method,
1033
- headers: yield buildAuthHeaders(this.auth, { json: body !== void 0 }),
1040
+ // PHI (EHR/Elation proxy) — REQUIRE the user JWT. The server hardens the
1041
+ // EHR proxy routes to `verifiedUserProcedure`, so degrading to key-only
1042
+ // would 401.
1043
+ headers: yield buildAuthHeaders(this.auth, {
1044
+ json: body !== void 0,
1045
+ requireUserToken: true
1046
+ }),
1034
1047
  body: body !== void 0 ? JSON.stringify(body) : void 0
1035
1048
  });
1036
1049
  if (!response.ok) {
@@ -1123,7 +1136,12 @@ var _NotesResource = class _NotesResource {
1123
1136
  try {
1124
1137
  res = yield fetch(`${this.baseUrl}/api${path}`, {
1125
1138
  method: "POST",
1126
- headers: yield buildAuthHeaders(this.auth, { json: true }),
1139
+ // PHI (clinical notes) — REQUIRE the user JWT. The server hardens these
1140
+ // routes to `verifiedUserProcedure`, so degrading to key-only would 401.
1141
+ headers: yield buildAuthHeaders(this.auth, {
1142
+ json: true,
1143
+ requireUserToken: true
1144
+ }),
1127
1145
  body: JSON.stringify(body),
1128
1146
  signal: controller.signal
1129
1147
  });
@@ -1366,7 +1384,15 @@ var PatientDetailsResource = class {
1366
1384
  return __async(this, null, function* () {
1367
1385
  const res = yield fetch(`${this.baseUrl}/api${path}`, {
1368
1386
  method: "POST",
1369
- headers: yield buildAuthHeaders(this.auth, { json: true }),
1387
+ // PHI (patient chart) — REQUIRE the user JWT. The server hardens these
1388
+ // routes to `verifiedUserProcedure`, so degrading to key-only would 401.
1389
+ // `requireUserToken` retries token resolution across the Clerk-hydration
1390
+ // gap and throws a clear auth error if none is obtainable, rather than
1391
+ // silently sending key-only.
1392
+ headers: yield buildAuthHeaders(this.auth, {
1393
+ json: true,
1394
+ requireUserToken: true
1395
+ }),
1370
1396
  body: JSON.stringify(body)
1371
1397
  });
1372
1398
  if (!res.ok) {
@@ -1603,7 +1629,8 @@ var RemindersResource = class {
1603
1629
  conversationId: input.conversationId,
1604
1630
  remindAt,
1605
1631
  note: input.note,
1606
- createdBy: input.createdBy
1632
+ createdBy: input.createdBy,
1633
+ createdByClerkId: input.createdByClerkId
1607
1634
  }
1608
1635
  );
1609
1636
  return result;
@@ -3110,6 +3137,7 @@ function useNotifications(options) {
3110
3137
  const expoRef = (0, import_react6.useRef)(null);
3111
3138
  const isWebRef = (0, import_react6.useRef)(false);
3112
3139
  const vapidKeyRef = (0, import_react6.useRef)((_e = options.vapidPublicKey) != null ? _e : null);
3140
+ const prevUserIdRef = (0, import_react6.useRef)(void 0);
3113
3141
  (0, import_react6.useEffect)(() => {
3114
3142
  let mounted = true;
3115
3143
  void (() => __async(null, null, function* () {
@@ -3368,6 +3396,56 @@ function useNotifications(options) {
3368
3396
  yield expo.setBadgeCountAsync(count);
3369
3397
  }), []);
3370
3398
  const autoRegister = options.autoRegister !== false;
3399
+ (0, import_react6.useEffect)(() => {
3400
+ if (!autoRegister) {
3401
+ return;
3402
+ }
3403
+ if (isWebRef.current) {
3404
+ return;
3405
+ }
3406
+ let cancelled = false;
3407
+ let remove;
3408
+ void (() => __async(null, null, function* () {
3409
+ var _a2;
3410
+ const expo = (_a2 = expoRef.current) != null ? _a2 : yield loadExpo();
3411
+ expoRef.current = expo;
3412
+ if (cancelled || !(expo == null ? void 0 : expo.addPushTokenListener)) {
3413
+ return;
3414
+ }
3415
+ const sub = expo.addPushTokenListener((devicePushTokenEvent) => {
3416
+ if (cancelled) {
3417
+ return;
3418
+ }
3419
+ const data = devicePushTokenEvent == null ? void 0 : devicePushTokenEvent.data;
3420
+ if (typeof data !== "string" || !data) {
3421
+ return;
3422
+ }
3423
+ setDevicePushToken(data);
3424
+ if (options.userId) {
3425
+ void register();
3426
+ }
3427
+ });
3428
+ remove = () => {
3429
+ var _a3;
3430
+ return (_a3 = sub == null ? void 0 : sub.remove) == null ? void 0 : _a3.call(sub);
3431
+ };
3432
+ }))();
3433
+ return () => {
3434
+ cancelled = true;
3435
+ remove == null ? void 0 : remove();
3436
+ };
3437
+ }, [autoRegister, options.userId, register]);
3438
+ (0, import_react6.useEffect)(() => {
3439
+ const prev = prevUserIdRef.current;
3440
+ prevUserIdRef.current = options.userId;
3441
+ if (!autoRegister) {
3442
+ return;
3443
+ }
3444
+ if (!options.userId || prev) {
3445
+ return;
3446
+ }
3447
+ void register();
3448
+ }, [options.userId, autoRegister, register]);
3371
3449
  (0, import_react6.useEffect)(() => {
3372
3450
  if (!autoRegister) {
3373
3451
  return;