@hipnation-truth/sdk 0.25.3 → 0.26.1

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
@@ -1383,8 +1383,9 @@ interface Attachment {
1383
1383
  declare class AttachmentsResource {
1384
1384
  private readonly baseUrl;
1385
1385
  private readonly apiKey;
1386
+ private readonly auth;
1386
1387
  private readonly convex;
1387
- constructor(apiBaseUrl: string, apiKey: string, convexClient: ConvexHttpClient);
1388
+ constructor(apiBaseUrl: string, apiKey: string, convexClient: ConvexHttpClient, getAuthToken?: AuthTokenFetcher);
1388
1389
  private post;
1389
1390
  createUploadUrl(input: CreateUploadUrlInput): Promise<CreateUploadUrlResult>;
1390
1391
  getDownloadUrl(s3Key: string, expiresIn?: number): Promise<GetDownloadUrlResult>;
@@ -1420,19 +1421,6 @@ declare class AttachmentsResource {
1420
1421
  }>;
1421
1422
  }
1422
1423
 
1423
- /**
1424
- * ConversationsResource — write methods that hang off a specific
1425
- * conversation: notes, tasks, outbound messages.
1426
- *
1427
- * Replaces CommHub's `truthConversationApi.ts` raw-fetch wrappers so
1428
- * the frontend goes through a typed SDK surface instead of building
1429
- * URLs by hand.
1430
- *
1431
- * All methods proxy the matching oRPC procedures (`/conversations/*`)
1432
- * via Truth's application-key auth. Errors surface as
1433
- * `ConversationsError` with a status code so callers can distinguish
1434
- * transport failures (status=0) from API rejections (status>=400).
1435
- */
1436
1424
  /** Address a conversation by either Convex `_id` or the phonePair. */
1437
1425
  interface ConversationAddress {
1438
1426
  conversationId?: string;
@@ -1560,8 +1548,9 @@ declare class ConversationsResource {
1560
1548
  private static readonly REQUEST_TIMEOUT_MS;
1561
1549
  private readonly baseUrl;
1562
1550
  private readonly apiKey;
1551
+ private readonly auth;
1563
1552
  private readonly convex;
1564
- constructor(apiBaseUrl: string, apiKey: string, convex?: convex_browser.ConvexHttpClient);
1553
+ constructor(apiBaseUrl: string, apiKey: string, convex?: convex_browser.ConvexHttpClient, getAuthToken?: AuthTokenFetcher);
1565
1554
  /**
1566
1555
  * Mark a conversation read for the calling user (zeroes unreadCount,
1567
1556
  * stamps `lastReadAt`). Calls the public Convex `markRead` mutation
@@ -1613,6 +1602,7 @@ declare class ConversationsResource {
1613
1602
  * const url = await truth.messages.dialpad.authenticateVoicemail(voicemailLink);
1614
1603
  * ```
1615
1604
  */
1605
+
1616
1606
  interface SendSmsParams {
1617
1607
  from_number: string;
1618
1608
  to_number: string;
@@ -1647,7 +1637,8 @@ interface DialpadNumberInfo {
1647
1637
  declare class DialpadResource {
1648
1638
  private readonly baseUrl;
1649
1639
  private readonly apiKey;
1650
- constructor(apiBaseUrl: string, apiKey: string);
1640
+ private readonly auth;
1641
+ constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
1651
1642
  /**
1652
1643
  * Send an SMS or MMS message via Dialpad.
1653
1644
  */
@@ -1712,7 +1703,8 @@ declare class MessagesResource {
1712
1703
  readonly dialpad: DialpadResource;
1713
1704
  private readonly baseUrl;
1714
1705
  private readonly apiKey;
1715
- constructor(apiBaseUrl: string, apiKey: string);
1706
+ private readonly auth;
1707
+ constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
1716
1708
  /**
1717
1709
  * Get an authenticated URL for a Dialpad voicemail recording.
1718
1710
  *
@@ -1758,12 +1750,12 @@ declare class MessagesResource {
1758
1750
  * const hintPatient = await truth.ehr.hint.get('/provider/patients/456');
1759
1751
  * ```
1760
1752
  */
1753
+
1761
1754
  declare class EhrProviderProxy {
1762
1755
  private readonly baseUrl;
1763
1756
  private readonly provider;
1764
- private readonly apiKey;
1765
- constructor(apiBaseUrl: string, provider: string, apiKey: string);
1766
- private headers;
1757
+ private readonly auth;
1758
+ constructor(apiBaseUrl: string, provider: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
1767
1759
  private request;
1768
1760
  /**
1769
1761
  * GET request to the EHR proxy.
@@ -1785,7 +1777,7 @@ declare class EhrResource {
1785
1777
  readonly elation: EhrProviderProxy;
1786
1778
  /** Hint Health proxy */
1787
1779
  readonly hint: EhrProviderProxy;
1788
- constructor(apiBaseUrl: string, apiKey: string);
1780
+ constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
1789
1781
  }
1790
1782
 
1791
1783
  /**
@@ -1795,6 +1787,7 @@ declare class EhrResource {
1795
1787
  * OAuth token and the HTTP call so applications can drop Elation
1796
1788
  * credentials from their own config.
1797
1789
  */
1790
+
1798
1791
  interface NonVisitNoteBullet {
1799
1792
  text: string;
1800
1793
  category?: string;
@@ -1839,7 +1832,8 @@ interface PushConversationToElationResult {
1839
1832
  declare class NotesResource {
1840
1833
  private readonly baseUrl;
1841
1834
  private readonly apiKey;
1842
- constructor(apiBaseUrl: string, apiKey: string);
1835
+ private readonly auth;
1836
+ constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
1843
1837
  /** 30s upstream timeout — Elation API has occasional slow hops; we
1844
1838
  * don't want a pending mutation to hold the UI thread indefinitely. */
1845
1839
  private static readonly REQUEST_TIMEOUT_MS;
@@ -1869,6 +1863,7 @@ declare class NotesResource {
1869
1863
  * Client-side React usage lives in `@hipnation-truth/sdk/react` via
1870
1864
  * the `useNotifications` hook which mirrors `expo-notifications`.
1871
1865
  */
1866
+
1872
1867
  type NotificationPlatform = "ios" | "android" | "web";
1873
1868
  interface RegisterDeviceInput {
1874
1869
  userId: string;
@@ -1979,7 +1974,8 @@ interface PushEventPayload {
1979
1974
  declare class NotificationsResource {
1980
1975
  private readonly baseUrl;
1981
1976
  private readonly apiKey;
1982
- constructor(apiBaseUrl: string, apiKey: string);
1977
+ private readonly auth;
1978
+ constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
1983
1979
  private post;
1984
1980
  private get;
1985
1981
  private delete;
@@ -2037,6 +2033,7 @@ declare class NotificationsResource {
2037
2033
  * X-API-Key. Replaces CommHub's getPatientDetails / getPatientBasicDetails
2038
2034
  * / getPatientMedicalDetails actions.
2039
2035
  */
2036
+
2040
2037
  interface PatientDetailsInput {
2041
2038
  hintId?: string;
2042
2039
  elationId?: string;
@@ -2059,7 +2056,8 @@ interface PatientMedicalDetailsResult {
2059
2056
  declare class PatientDetailsResource {
2060
2057
  private readonly baseUrl;
2061
2058
  private readonly apiKey;
2062
- constructor(apiBaseUrl: string, apiKey: string);
2059
+ private readonly auth;
2060
+ constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
2063
2061
  private post;
2064
2062
  get(input: PatientDetailsInput): Promise<PatientDetailsResult>;
2065
2063
  getBasic(input: PatientDetailsInput): Promise<PatientBasicDetailsResult>;
@@ -2309,7 +2307,8 @@ interface TranslateBatchInput {
2309
2307
  declare class TranslationResource {
2310
2308
  private readonly baseUrl;
2311
2309
  private readonly apiKey;
2312
- constructor(apiBaseUrl: string, apiKey: string);
2310
+ private readonly auth;
2311
+ constructor(apiBaseUrl: string, apiKey: string, getAuthToken?: AuthTokenFetcher);
2313
2312
  private post;
2314
2313
  translate(input: TranslateTextInput): Promise<TranslationResult>;
2315
2314
  translateBatch(input: TranslateBatchInput): Promise<TranslationResult[]>;
package/dist/react.js CHANGED
@@ -471,6 +471,31 @@ var AppointmentResource = class {
471
471
  }
472
472
  };
473
473
 
474
+ // src/resources/rest-auth.ts
475
+ function buildAuthHeaders(auth, options) {
476
+ return __async(this, null, function* () {
477
+ const headers = {
478
+ "X-API-Key": auth.apiKey
479
+ };
480
+ if ((options == null ? void 0 : options.accept) !== false) {
481
+ headers.Accept = "application/json";
482
+ }
483
+ if (options == null ? void 0 : options.json) {
484
+ headers["Content-Type"] = "application/json";
485
+ }
486
+ if (auth.getAuthToken) {
487
+ try {
488
+ const token = yield auth.getAuthToken();
489
+ if (token) {
490
+ headers.Authorization = `Bearer ${token}`;
491
+ }
492
+ } catch (e) {
493
+ }
494
+ }
495
+ return headers;
496
+ });
497
+ }
498
+
474
499
  // src/resources/attachments.ts
475
500
  var AttachmentsError = class extends Error {
476
501
  constructor(operation, status, message) {
@@ -480,20 +505,17 @@ var AttachmentsError = class extends Error {
480
505
  }
481
506
  };
482
507
  var AttachmentsResource = class {
483
- constructor(apiBaseUrl, apiKey, convexClient) {
508
+ constructor(apiBaseUrl, apiKey, convexClient, getAuthToken) {
484
509
  this.baseUrl = apiBaseUrl;
485
510
  this.apiKey = apiKey;
511
+ this.auth = { apiKey, getAuthToken };
486
512
  this.convex = convexClient;
487
513
  }
488
514
  post(path, body) {
489
515
  return __async(this, null, function* () {
490
516
  const res = yield fetch(`${this.baseUrl}/api${path}`, {
491
517
  method: "POST",
492
- headers: {
493
- "Content-Type": "application/json",
494
- Accept: "application/json",
495
- "X-API-Key": this.apiKey
496
- },
518
+ headers: yield buildAuthHeaders(this.auth, { json: true }),
497
519
  body: JSON.stringify(body)
498
520
  });
499
521
  if (!res.ok) {
@@ -736,9 +758,10 @@ var ConversationMessagesSubresource = class {
736
758
  }
737
759
  };
738
760
  var _ConversationsResource = class _ConversationsResource {
739
- constructor(apiBaseUrl, apiKey, convex) {
761
+ constructor(apiBaseUrl, apiKey, convex, getAuthToken) {
740
762
  this.baseUrl = apiBaseUrl;
741
763
  this.apiKey = apiKey;
764
+ this.auth = { apiKey, getAuthToken };
742
765
  this.convex = convex != null ? convex : null;
743
766
  const post = (path, body) => this.postRequest(path, body);
744
767
  const patch = (path, body) => this.patchRequest(path, body);
@@ -821,11 +844,7 @@ var _ConversationsResource = class _ConversationsResource {
821
844
  try {
822
845
  res = yield fetch(`${this.baseUrl}/api${path}`, {
823
846
  method: "POST",
824
- headers: {
825
- "Content-Type": "application/json",
826
- Accept: "application/json",
827
- "X-API-Key": this.apiKey
828
- },
847
+ headers: yield buildAuthHeaders(this.auth, { json: true }),
829
848
  body: JSON.stringify(body),
830
849
  signal: controller.signal
831
850
  });
@@ -867,11 +886,7 @@ var _ConversationsResource = class _ConversationsResource {
867
886
  try {
868
887
  res = yield fetch(`${this.baseUrl}/api${path}`, {
869
888
  method: "PATCH",
870
- headers: {
871
- "Content-Type": "application/json",
872
- Accept: "application/json",
873
- "X-API-Key": this.apiKey
874
- },
889
+ headers: yield buildAuthHeaders(this.auth, { json: true }),
875
890
  body: JSON.stringify(body),
876
891
  signal: controller.signal
877
892
  });
@@ -900,9 +915,10 @@ var ConversationsResource = _ConversationsResource;
900
915
 
901
916
  // src/resources/dialpad.ts
902
917
  var DialpadResource = class {
903
- constructor(apiBaseUrl, apiKey) {
918
+ constructor(apiBaseUrl, apiKey, getAuthToken) {
904
919
  this.baseUrl = apiBaseUrl;
905
920
  this.apiKey = apiKey;
921
+ this.auth = { apiKey, getAuthToken };
906
922
  }
907
923
  /**
908
924
  * Send an SMS or MMS message via Dialpad.
@@ -1043,10 +1059,7 @@ var DialpadResource = class {
1043
1059
  const url = `${this.baseUrl}/api/messages/dialpad/voicemail/authenticate`;
1044
1060
  const response = yield fetch(url, {
1045
1061
  method: "POST",
1046
- headers: {
1047
- "Content-Type": "application/json",
1048
- "X-API-Key": this.apiKey
1049
- },
1062
+ headers: yield buildAuthHeaders(this.auth, { json: true, accept: false }),
1050
1063
  body: JSON.stringify({ voicemail_link: voicemailLink })
1051
1064
  });
1052
1065
  const result = yield response.json();
@@ -1071,10 +1084,7 @@ var DialpadResource = class {
1071
1084
  }
1072
1085
  const response = yield fetch(url.toString(), {
1073
1086
  method: "GET",
1074
- headers: {
1075
- Accept: "application/json",
1076
- "X-API-Key": this.apiKey
1077
- }
1087
+ headers: yield buildAuthHeaders(this.auth)
1078
1088
  });
1079
1089
  if (!response.ok) {
1080
1090
  throw new DialpadProxyError("GET", path, response.status);
@@ -1087,11 +1097,7 @@ var DialpadResource = class {
1087
1097
  const url = `${this.baseUrl}/api/messages/dialpad${path}`;
1088
1098
  const response = yield fetch(url, {
1089
1099
  method: "POST",
1090
- headers: {
1091
- "Content-Type": "application/json",
1092
- Accept: "application/json",
1093
- "X-API-Key": this.apiKey
1094
- },
1100
+ headers: yield buildAuthHeaders(this.auth, { json: true }),
1095
1101
  body: body !== void 0 ? JSON.stringify(body) : void 0
1096
1102
  });
1097
1103
  if (!response.ok) {
@@ -1106,11 +1112,7 @@ var DialpadResource = class {
1106
1112
  const url = `${this.baseUrl}/api/messages/dialpad${path}`;
1107
1113
  const response = yield fetch(url, {
1108
1114
  method: "PUT",
1109
- headers: {
1110
- "Content-Type": "application/json",
1111
- Accept: "application/json",
1112
- "X-API-Key": this.apiKey
1113
- },
1115
+ headers: yield buildAuthHeaders(this.auth, { json: true }),
1114
1116
  body: body !== void 0 ? JSON.stringify(body) : void 0
1115
1117
  });
1116
1118
  if (!response.ok) {
@@ -1124,10 +1126,11 @@ var DialpadResource = class {
1124
1126
  }
1125
1127
  };
1126
1128
  var MessagesResource = class {
1127
- constructor(apiBaseUrl, apiKey) {
1128
- this.dialpad = new DialpadResource(apiBaseUrl, apiKey);
1129
+ constructor(apiBaseUrl, apiKey, getAuthToken) {
1130
+ this.dialpad = new DialpadResource(apiBaseUrl, apiKey, getAuthToken);
1129
1131
  this.baseUrl = apiBaseUrl;
1130
1132
  this.apiKey = apiKey;
1133
+ this.auth = { apiKey, getAuthToken };
1131
1134
  }
1132
1135
  /**
1133
1136
  * Get an authenticated URL for a Dialpad voicemail recording.
@@ -1146,11 +1149,7 @@ var MessagesResource = class {
1146
1149
  return __async(this, null, function* () {
1147
1150
  const res = yield fetch(`${this.baseUrl}/api/conversations/voicemail/url`, {
1148
1151
  method: "POST",
1149
- headers: {
1150
- "Content-Type": "application/json",
1151
- Accept: "application/json",
1152
- "X-API-Key": this.apiKey
1153
- },
1152
+ headers: yield buildAuthHeaders(this.auth, { json: true }),
1154
1153
  body: JSON.stringify({ voicemailLink })
1155
1154
  });
1156
1155
  if (!res.ok) {
@@ -1174,11 +1173,7 @@ var MessagesResource = class {
1174
1173
  return __async(this, null, function* () {
1175
1174
  const res = yield fetch(`${this.baseUrl}/api/conversations/calls/end`, {
1176
1175
  method: "POST",
1177
- headers: {
1178
- "Content-Type": "application/json",
1179
- Accept: "application/json",
1180
- "X-API-Key": this.apiKey
1181
- },
1176
+ headers: yield buildAuthHeaders(this.auth, { json: true }),
1182
1177
  body: JSON.stringify({ callId })
1183
1178
  });
1184
1179
  if (!res.ok) {
@@ -1205,20 +1200,10 @@ var DialpadProxyError = class extends Error {
1205
1200
 
1206
1201
  // src/resources/ehr.ts
1207
1202
  var EhrProviderProxy = class {
1208
- constructor(apiBaseUrl, provider, apiKey) {
1203
+ constructor(apiBaseUrl, provider, apiKey, getAuthToken) {
1209
1204
  this.baseUrl = apiBaseUrl;
1210
1205
  this.provider = provider;
1211
- this.apiKey = apiKey;
1212
- }
1213
- headers(withBody) {
1214
- const headers = {
1215
- Accept: "application/json",
1216
- "X-API-Key": this.apiKey
1217
- };
1218
- if (withBody) {
1219
- headers["Content-Type"] = "application/json";
1220
- }
1221
- return headers;
1206
+ this.auth = { apiKey, getAuthToken };
1222
1207
  }
1223
1208
  request(method, path, body, params) {
1224
1209
  return __async(this, null, function* () {
@@ -1232,7 +1217,7 @@ var EhrProviderProxy = class {
1232
1217
  }
1233
1218
  const response = yield fetch(url.toString(), {
1234
1219
  method,
1235
- headers: this.headers(body !== void 0),
1220
+ headers: yield buildAuthHeaders(this.auth, { json: body !== void 0 }),
1236
1221
  body: body !== void 0 ? JSON.stringify(body) : void 0
1237
1222
  });
1238
1223
  if (!response.ok) {
@@ -1277,9 +1262,14 @@ var EhrProviderProxy = class {
1277
1262
  }
1278
1263
  };
1279
1264
  var EhrResource = class {
1280
- constructor(apiBaseUrl, apiKey) {
1281
- this.elation = new EhrProviderProxy(apiBaseUrl, "elation", apiKey);
1282
- this.hint = new EhrProviderProxy(apiBaseUrl, "hint", apiKey);
1265
+ constructor(apiBaseUrl, apiKey, getAuthToken) {
1266
+ this.elation = new EhrProviderProxy(
1267
+ apiBaseUrl,
1268
+ "elation",
1269
+ apiKey,
1270
+ getAuthToken
1271
+ );
1272
+ this.hint = new EhrProviderProxy(apiBaseUrl, "hint", apiKey, getAuthToken);
1283
1273
  }
1284
1274
  };
1285
1275
  var EhrProxyError = class extends Error {
@@ -1304,9 +1294,10 @@ var NotesError = class extends Error {
1304
1294
  }
1305
1295
  };
1306
1296
  var _NotesResource = class _NotesResource {
1307
- constructor(apiBaseUrl, apiKey) {
1297
+ constructor(apiBaseUrl, apiKey, getAuthToken) {
1308
1298
  this.baseUrl = apiBaseUrl;
1309
1299
  this.apiKey = apiKey;
1300
+ this.auth = { apiKey, getAuthToken };
1310
1301
  }
1311
1302
  post(path, body) {
1312
1303
  return __async(this, null, function* () {
@@ -1319,11 +1310,7 @@ var _NotesResource = class _NotesResource {
1319
1310
  try {
1320
1311
  res = yield fetch(`${this.baseUrl}/api${path}`, {
1321
1312
  method: "POST",
1322
- headers: {
1323
- "Content-Type": "application/json",
1324
- Accept: "application/json",
1325
- "X-API-Key": this.apiKey
1326
- },
1313
+ headers: yield buildAuthHeaders(this.auth, { json: true }),
1327
1314
  body: JSON.stringify(body),
1328
1315
  signal: controller.signal
1329
1316
  });
@@ -1384,19 +1371,16 @@ var NotificationsError = class extends Error {
1384
1371
  }
1385
1372
  };
1386
1373
  var NotificationsResource = class {
1387
- constructor(apiBaseUrl, apiKey) {
1374
+ constructor(apiBaseUrl, apiKey, getAuthToken) {
1388
1375
  this.baseUrl = apiBaseUrl;
1389
1376
  this.apiKey = apiKey;
1377
+ this.auth = { apiKey, getAuthToken };
1390
1378
  }
1391
1379
  post(path, body) {
1392
1380
  return __async(this, null, function* () {
1393
1381
  const res = yield fetch(`${this.baseUrl}/api${path}`, {
1394
1382
  method: "POST",
1395
- headers: {
1396
- "Content-Type": "application/json",
1397
- Accept: "application/json",
1398
- "X-API-Key": this.apiKey
1399
- },
1383
+ headers: yield buildAuthHeaders(this.auth, { json: true }),
1400
1384
  body: JSON.stringify(body)
1401
1385
  });
1402
1386
  if (!res.ok) {
@@ -1414,10 +1398,7 @@ var NotificationsResource = class {
1414
1398
  }
1415
1399
  const res = yield fetch(url.toString(), {
1416
1400
  method: "GET",
1417
- headers: {
1418
- Accept: "application/json",
1419
- "X-API-Key": this.apiKey
1420
- }
1401
+ headers: yield buildAuthHeaders(this.auth)
1421
1402
  });
1422
1403
  if (!res.ok) {
1423
1404
  const text = yield res.text().catch(() => "");
@@ -1430,10 +1411,7 @@ var NotificationsResource = class {
1430
1411
  return __async(this, null, function* () {
1431
1412
  const res = yield fetch(`${this.baseUrl}/api${path}`, {
1432
1413
  method: "DELETE",
1433
- headers: {
1434
- Accept: "application/json",
1435
- "X-API-Key": this.apiKey
1436
- }
1414
+ headers: yield buildAuthHeaders(this.auth)
1437
1415
  });
1438
1416
  if (!res.ok) {
1439
1417
  const text = yield res.text().catch(() => "");
@@ -1566,19 +1544,16 @@ var PatientDetailsError = class extends Error {
1566
1544
  }
1567
1545
  };
1568
1546
  var PatientDetailsResource = class {
1569
- constructor(apiBaseUrl, apiKey) {
1547
+ constructor(apiBaseUrl, apiKey, getAuthToken) {
1570
1548
  this.baseUrl = apiBaseUrl;
1571
1549
  this.apiKey = apiKey;
1550
+ this.auth = { apiKey, getAuthToken };
1572
1551
  }
1573
1552
  post(path, body) {
1574
1553
  return __async(this, null, function* () {
1575
1554
  const res = yield fetch(`${this.baseUrl}/api${path}`, {
1576
1555
  method: "POST",
1577
- headers: {
1578
- "Content-Type": "application/json",
1579
- Accept: "application/json",
1580
- "X-API-Key": this.apiKey
1581
- },
1556
+ headers: yield buildAuthHeaders(this.auth, { json: true }),
1582
1557
  body: JSON.stringify(body)
1583
1558
  });
1584
1559
  if (!res.ok) {
@@ -1900,20 +1875,17 @@ var TranslationError = class extends Error {
1900
1875
  }
1901
1876
  };
1902
1877
  var TranslationResource = class {
1903
- constructor(apiBaseUrl, apiKey) {
1878
+ constructor(apiBaseUrl, apiKey, getAuthToken) {
1904
1879
  this.baseUrl = apiBaseUrl;
1905
1880
  this.apiKey = apiKey;
1881
+ this.auth = { apiKey, getAuthToken };
1906
1882
  }
1907
1883
  post(path, body) {
1908
1884
  return __async(this, null, function* () {
1909
1885
  const url = `${this.baseUrl}/api${path}`;
1910
1886
  const res = yield fetch(url, {
1911
1887
  method: "POST",
1912
- headers: {
1913
- "Content-Type": "application/json",
1914
- Accept: "application/json",
1915
- "X-API-Key": this.apiKey
1916
- },
1888
+ headers: yield buildAuthHeaders(this.auth, { json: true }),
1917
1889
  body: JSON.stringify(body)
1918
1890
  });
1919
1891
  if (!res.ok) {
@@ -2230,24 +2202,42 @@ var TruthClient = class {
2230
2202
  const apiUrl = this.tracker.apiUrl;
2231
2203
  this.patients = new PatientResource(this.convex);
2232
2204
  this.appointments = new AppointmentResource(this.convex);
2233
- this.ehr = new EhrResource(apiUrl, config.apiKey);
2234
- this.messages = new MessagesResource(apiUrl, config.apiKey);
2205
+ this.ehr = new EhrResource(apiUrl, config.apiKey, config.getAuthToken);
2206
+ this.messages = new MessagesResource(
2207
+ apiUrl,
2208
+ config.apiKey,
2209
+ config.getAuthToken
2210
+ );
2235
2211
  this.reminders = new RemindersResource(this.convex);
2236
- this.translation = new TranslationResource(apiUrl, config.apiKey);
2212
+ this.translation = new TranslationResource(
2213
+ apiUrl,
2214
+ config.apiKey,
2215
+ config.getAuthToken
2216
+ );
2237
2217
  this.tasks = new TasksResource(this.convex);
2238
- this.patientDetails = new PatientDetailsResource(apiUrl, config.apiKey);
2218
+ this.patientDetails = new PatientDetailsResource(
2219
+ apiUrl,
2220
+ config.apiKey,
2221
+ config.getAuthToken
2222
+ );
2239
2223
  this.attachments = new AttachmentsResource(
2240
2224
  apiUrl,
2241
2225
  config.apiKey,
2242
- this.convex
2226
+ this.convex,
2227
+ config.getAuthToken
2243
2228
  );
2244
- this.notes = new NotesResource(apiUrl, config.apiKey);
2229
+ this.notes = new NotesResource(apiUrl, config.apiKey, config.getAuthToken);
2245
2230
  this.physicians = new PhysiciansResource(this.convex);
2246
- this.notifications = new NotificationsResource(apiUrl, config.apiKey);
2231
+ this.notifications = new NotificationsResource(
2232
+ apiUrl,
2233
+ config.apiKey,
2234
+ config.getAuthToken
2235
+ );
2247
2236
  this.conversations = new ConversationsResource(
2248
2237
  apiUrl,
2249
2238
  config.apiKey,
2250
- this.convex
2239
+ this.convex,
2240
+ config.getAuthToken
2251
2241
  );
2252
2242
  this.userSettings = new UserSettingsResource(this.convex);
2253
2243
  this._serviceWorkerPath = (_h = config.serviceWorkerPath) != null ? _h : "/truth-sw.js";