@hipnation-truth/sdk 0.23.2 → 0.25.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/index.d.mts CHANGED
@@ -72,12 +72,26 @@ declare const ENVIRONMENTS: {
72
72
  readonly production: "production";
73
73
  };
74
74
  type Environment = (typeof ENVIRONMENTS)[keyof typeof ENVIRONMENTS];
75
+ /**
76
+ * Fetches a user-identity JWT for Convex calls. Return the token from
77
+ * your identity provider's Clerk JWT template named "convex"
78
+ * (e.g. `getToken({ template: "convex" })` from `@clerk/expo`), or
79
+ * `null` when no user is signed in.
80
+ */
81
+ type AuthTokenFetcher = () => Promise<string | null | undefined>;
75
82
  /**
76
83
  * Configuration for initializing a TruthClient.
77
84
  */
78
85
  interface TruthClientConfig {
79
86
  /** API key for authenticating with the Truth platform (e.g. "hn_live_...") */
80
87
  apiKey: string;
88
+ /**
89
+ * Per-call Clerk JWT fetcher for Convex data access. When provided,
90
+ * every Convex query/mutation/action carries the caller's identity;
91
+ * Convex deployments with `CLERK_AUTH_REQUIRED` enabled reject calls
92
+ * without it. Omit for service contexts that don't act as a user.
93
+ */
94
+ getAuthToken?: AuthTokenFetcher;
81
95
  /** Target environment */
82
96
  environment: Environment;
83
97
  /** Override the default Convex URL for data access */
@@ -1772,4 +1786,4 @@ declare function subscriptionToJSON(sub: PushSubscription): {
1772
1786
  };
1773
1787
  declare function onServiceWorkerMessage(type: string, callback: (payload: unknown) => void): () => void;
1774
1788
 
1775
- export { AUTH_EVENTS, type ActorContext, type Appointment, type AppointmentListOptions, AppointmentResource, type Attachment, AttachmentsError, AttachmentsResource, type AuthEventType, type AuthLoginFailedPayload, type AuthLoginSucceededPayload, CALL_EVENTS, CONVERSATION_EVENTS, type CallConnectedPayload, type CallEndedPayload, type CallEventType, type CallInitiatedPayload, type CallMissedPayload, type CallStatusResponse, type CancelScheduledNotificationResult, type ConversationAddress, type ConversationAttachmentDownloadedPayload, type ConversationAttachmentUploadedPayload, type ConversationCreatedPayload, type ConversationEventType, type ConversationMarkedReadPayload, type ConversationMessageReceivedPayload, type ConversationMessageSentPayload, type ConversationTaskPriority, type ConversationTaskStatus, ConversationsError, ConversationsResource, type CreateConversationNoteInput, type CreateConversationTaskInput, type CreateTaskInput, type CreateUploadUrlInput, type CreateUploadUrlResult, type DetectionResult, type DialpadNumberInfo, DialpadProxyError, DialpadResource, type DialpadUser, ENVIRONMENTS, EVENT_TYPES, EhrProviderProxy, EhrProxyError, EhrResource, type Environment, type EventActor, type EventCompliance, type EventEnvelope, type EventPayloadMap, type EventSubject, type EventType, type GetDownloadUrlResult, type InitiateCallResponse, MessagesResource, NOTIFICATION_EVENTS, type NonVisitNoteBullet, NotesError, NotesResource, type NotificationDeliveredPayload, type NotificationEventType, type NotificationOpenedPayload, type NotificationPlatform, type NotificationPreferences, type NotificationSentPayload, NotificationsError, NotificationsResource, PROVIDER_EVENTS, type PaginatedResult, type Patient, type PatientBasicDetailsResult, PatientDetailsError, type PatientDetailsInput, PatientDetailsResource, type PatientDetailsResult, type PatientListOptions, type PatientMedicalDetailsResult, PatientResource, type Physician, PhysiciansResource, type ProviderEventType, type ProviderSyncFailedPayload, type ProviderSyncStartedPayload, type ProviderSyncSucceededPayload, type PushEventPayload, type PushNoteToElationInput, type PushNoteToElationResult, REMINDER_EVENTS, type RecordAttachmentInput, type RegisterDeviceInput, type RegisterDeviceResult, type Reminder, type ReminderEventType, type ReminderScheduledPayload, type ReminderStatus, type ReminderTriggeredPayload, RemindersResource, SECURITY_EVENTS, type ScheduleNotificationInput, type ScheduleNotificationResult, type ScheduleReminderInput, type ScheduleReminderResult, type ScheduledJobStatus, type ScheduledNotification, type SecurityAccessDeniedPayload, type SecurityEventType, type SendConversationMessageInput, type SendConversationMessageResult, type SendNotificationInput, type SendNotificationResult, type SendSmsParams, type SendSmsResponse, type SetConversationTaskStatusInput, TASK_EVENTS, TRANSLATION_EVENTS, type Task, type TaskAssignedPayload, type TaskCreatedPayload, type TaskEventType, type TaskStatus, type TaskStatusChangedPayload, TasksResource, type TrackOptions, Tracker, type TranslateBatchInput, type TranslateTextInput, type TranslationCompletedPayload, TranslationError, type TranslationEventType, type TranslationRequestedPayload, TranslationResource, type TranslationResult, TruthClient, type TruthClientConfig, type UnregisterDeviceInput, type UpdateNotificationsInput, type UpdateNotificationsResult, type UpdatePreferencesInput, type UpdateTaskStatusInput, type UserSettings, UserSettingsResource, type VoicemailAuthResponse, type WebPushConfig, generateUuidV7, isWebPushSupported, onServiceWorkerMessage, registerServiceWorker, subscribeToPush, subscriptionToJSON };
1789
+ export { AUTH_EVENTS, type ActorContext, type Appointment, type AppointmentListOptions, AppointmentResource, type Attachment, AttachmentsError, AttachmentsResource, type AuthEventType, type AuthLoginFailedPayload, type AuthLoginSucceededPayload, type AuthTokenFetcher, CALL_EVENTS, CONVERSATION_EVENTS, type CallConnectedPayload, type CallEndedPayload, type CallEventType, type CallInitiatedPayload, type CallMissedPayload, type CallStatusResponse, type CancelScheduledNotificationResult, type ConversationAddress, type ConversationAttachmentDownloadedPayload, type ConversationAttachmentUploadedPayload, type ConversationCreatedPayload, type ConversationEventType, type ConversationMarkedReadPayload, type ConversationMessageReceivedPayload, type ConversationMessageSentPayload, type ConversationTaskPriority, type ConversationTaskStatus, ConversationsError, ConversationsResource, type CreateConversationNoteInput, type CreateConversationTaskInput, type CreateTaskInput, type CreateUploadUrlInput, type CreateUploadUrlResult, type DetectionResult, type DialpadNumberInfo, DialpadProxyError, DialpadResource, type DialpadUser, ENVIRONMENTS, EVENT_TYPES, EhrProviderProxy, EhrProxyError, EhrResource, type Environment, type EventActor, type EventCompliance, type EventEnvelope, type EventPayloadMap, type EventSubject, type EventType, type GetDownloadUrlResult, type InitiateCallResponse, MessagesResource, NOTIFICATION_EVENTS, type NonVisitNoteBullet, NotesError, NotesResource, type NotificationDeliveredPayload, type NotificationEventType, type NotificationOpenedPayload, type NotificationPlatform, type NotificationPreferences, type NotificationSentPayload, NotificationsError, NotificationsResource, PROVIDER_EVENTS, type PaginatedResult, type Patient, type PatientBasicDetailsResult, PatientDetailsError, type PatientDetailsInput, PatientDetailsResource, type PatientDetailsResult, type PatientListOptions, type PatientMedicalDetailsResult, PatientResource, type Physician, PhysiciansResource, type ProviderEventType, type ProviderSyncFailedPayload, type ProviderSyncStartedPayload, type ProviderSyncSucceededPayload, type PushEventPayload, type PushNoteToElationInput, type PushNoteToElationResult, REMINDER_EVENTS, type RecordAttachmentInput, type RegisterDeviceInput, type RegisterDeviceResult, type Reminder, type ReminderEventType, type ReminderScheduledPayload, type ReminderStatus, type ReminderTriggeredPayload, RemindersResource, SECURITY_EVENTS, type ScheduleNotificationInput, type ScheduleNotificationResult, type ScheduleReminderInput, type ScheduleReminderResult, type ScheduledJobStatus, type ScheduledNotification, type SecurityAccessDeniedPayload, type SecurityEventType, type SendConversationMessageInput, type SendConversationMessageResult, type SendNotificationInput, type SendNotificationResult, type SendSmsParams, type SendSmsResponse, type SetConversationTaskStatusInput, TASK_EVENTS, TRANSLATION_EVENTS, type Task, type TaskAssignedPayload, type TaskCreatedPayload, type TaskEventType, type TaskStatus, type TaskStatusChangedPayload, TasksResource, type TrackOptions, Tracker, type TranslateBatchInput, type TranslateTextInput, type TranslationCompletedPayload, TranslationError, type TranslationEventType, type TranslationRequestedPayload, TranslationResource, type TranslationResult, TruthClient, type TruthClientConfig, type UnregisterDeviceInput, type UpdateNotificationsInput, type UpdateNotificationsResult, type UpdatePreferencesInput, type UpdateTaskStatusInput, type UserSettings, UserSettingsResource, type VoicemailAuthResponse, type WebPushConfig, generateUuidV7, isWebPushSupported, onServiceWorkerMessage, registerServiceWorker, subscribeToPush, subscriptionToJSON };
package/dist/index.d.ts CHANGED
@@ -72,12 +72,26 @@ declare const ENVIRONMENTS: {
72
72
  readonly production: "production";
73
73
  };
74
74
  type Environment = (typeof ENVIRONMENTS)[keyof typeof ENVIRONMENTS];
75
+ /**
76
+ * Fetches a user-identity JWT for Convex calls. Return the token from
77
+ * your identity provider's Clerk JWT template named "convex"
78
+ * (e.g. `getToken({ template: "convex" })` from `@clerk/expo`), or
79
+ * `null` when no user is signed in.
80
+ */
81
+ type AuthTokenFetcher = () => Promise<string | null | undefined>;
75
82
  /**
76
83
  * Configuration for initializing a TruthClient.
77
84
  */
78
85
  interface TruthClientConfig {
79
86
  /** API key for authenticating with the Truth platform (e.g. "hn_live_...") */
80
87
  apiKey: string;
88
+ /**
89
+ * Per-call Clerk JWT fetcher for Convex data access. When provided,
90
+ * every Convex query/mutation/action carries the caller's identity;
91
+ * Convex deployments with `CLERK_AUTH_REQUIRED` enabled reject calls
92
+ * without it. Omit for service contexts that don't act as a user.
93
+ */
94
+ getAuthToken?: AuthTokenFetcher;
81
95
  /** Target environment */
82
96
  environment: Environment;
83
97
  /** Override the default Convex URL for data access */
@@ -1772,4 +1786,4 @@ declare function subscriptionToJSON(sub: PushSubscription): {
1772
1786
  };
1773
1787
  declare function onServiceWorkerMessage(type: string, callback: (payload: unknown) => void): () => void;
1774
1788
 
1775
- export { AUTH_EVENTS, type ActorContext, type Appointment, type AppointmentListOptions, AppointmentResource, type Attachment, AttachmentsError, AttachmentsResource, type AuthEventType, type AuthLoginFailedPayload, type AuthLoginSucceededPayload, CALL_EVENTS, CONVERSATION_EVENTS, type CallConnectedPayload, type CallEndedPayload, type CallEventType, type CallInitiatedPayload, type CallMissedPayload, type CallStatusResponse, type CancelScheduledNotificationResult, type ConversationAddress, type ConversationAttachmentDownloadedPayload, type ConversationAttachmentUploadedPayload, type ConversationCreatedPayload, type ConversationEventType, type ConversationMarkedReadPayload, type ConversationMessageReceivedPayload, type ConversationMessageSentPayload, type ConversationTaskPriority, type ConversationTaskStatus, ConversationsError, ConversationsResource, type CreateConversationNoteInput, type CreateConversationTaskInput, type CreateTaskInput, type CreateUploadUrlInput, type CreateUploadUrlResult, type DetectionResult, type DialpadNumberInfo, DialpadProxyError, DialpadResource, type DialpadUser, ENVIRONMENTS, EVENT_TYPES, EhrProviderProxy, EhrProxyError, EhrResource, type Environment, type EventActor, type EventCompliance, type EventEnvelope, type EventPayloadMap, type EventSubject, type EventType, type GetDownloadUrlResult, type InitiateCallResponse, MessagesResource, NOTIFICATION_EVENTS, type NonVisitNoteBullet, NotesError, NotesResource, type NotificationDeliveredPayload, type NotificationEventType, type NotificationOpenedPayload, type NotificationPlatform, type NotificationPreferences, type NotificationSentPayload, NotificationsError, NotificationsResource, PROVIDER_EVENTS, type PaginatedResult, type Patient, type PatientBasicDetailsResult, PatientDetailsError, type PatientDetailsInput, PatientDetailsResource, type PatientDetailsResult, type PatientListOptions, type PatientMedicalDetailsResult, PatientResource, type Physician, PhysiciansResource, type ProviderEventType, type ProviderSyncFailedPayload, type ProviderSyncStartedPayload, type ProviderSyncSucceededPayload, type PushEventPayload, type PushNoteToElationInput, type PushNoteToElationResult, REMINDER_EVENTS, type RecordAttachmentInput, type RegisterDeviceInput, type RegisterDeviceResult, type Reminder, type ReminderEventType, type ReminderScheduledPayload, type ReminderStatus, type ReminderTriggeredPayload, RemindersResource, SECURITY_EVENTS, type ScheduleNotificationInput, type ScheduleNotificationResult, type ScheduleReminderInput, type ScheduleReminderResult, type ScheduledJobStatus, type ScheduledNotification, type SecurityAccessDeniedPayload, type SecurityEventType, type SendConversationMessageInput, type SendConversationMessageResult, type SendNotificationInput, type SendNotificationResult, type SendSmsParams, type SendSmsResponse, type SetConversationTaskStatusInput, TASK_EVENTS, TRANSLATION_EVENTS, type Task, type TaskAssignedPayload, type TaskCreatedPayload, type TaskEventType, type TaskStatus, type TaskStatusChangedPayload, TasksResource, type TrackOptions, Tracker, type TranslateBatchInput, type TranslateTextInput, type TranslationCompletedPayload, TranslationError, type TranslationEventType, type TranslationRequestedPayload, TranslationResource, type TranslationResult, TruthClient, type TruthClientConfig, type UnregisterDeviceInput, type UpdateNotificationsInput, type UpdateNotificationsResult, type UpdatePreferencesInput, type UpdateTaskStatusInput, type UserSettings, UserSettingsResource, type VoicemailAuthResponse, type WebPushConfig, generateUuidV7, isWebPushSupported, onServiceWorkerMessage, registerServiceWorker, subscribeToPush, subscriptionToJSON };
1789
+ export { AUTH_EVENTS, type ActorContext, type Appointment, type AppointmentListOptions, AppointmentResource, type Attachment, AttachmentsError, AttachmentsResource, type AuthEventType, type AuthLoginFailedPayload, type AuthLoginSucceededPayload, type AuthTokenFetcher, CALL_EVENTS, CONVERSATION_EVENTS, type CallConnectedPayload, type CallEndedPayload, type CallEventType, type CallInitiatedPayload, type CallMissedPayload, type CallStatusResponse, type CancelScheduledNotificationResult, type ConversationAddress, type ConversationAttachmentDownloadedPayload, type ConversationAttachmentUploadedPayload, type ConversationCreatedPayload, type ConversationEventType, type ConversationMarkedReadPayload, type ConversationMessageReceivedPayload, type ConversationMessageSentPayload, type ConversationTaskPriority, type ConversationTaskStatus, ConversationsError, ConversationsResource, type CreateConversationNoteInput, type CreateConversationTaskInput, type CreateTaskInput, type CreateUploadUrlInput, type CreateUploadUrlResult, type DetectionResult, type DialpadNumberInfo, DialpadProxyError, DialpadResource, type DialpadUser, ENVIRONMENTS, EVENT_TYPES, EhrProviderProxy, EhrProxyError, EhrResource, type Environment, type EventActor, type EventCompliance, type EventEnvelope, type EventPayloadMap, type EventSubject, type EventType, type GetDownloadUrlResult, type InitiateCallResponse, MessagesResource, NOTIFICATION_EVENTS, type NonVisitNoteBullet, NotesError, NotesResource, type NotificationDeliveredPayload, type NotificationEventType, type NotificationOpenedPayload, type NotificationPlatform, type NotificationPreferences, type NotificationSentPayload, NotificationsError, NotificationsResource, PROVIDER_EVENTS, type PaginatedResult, type Patient, type PatientBasicDetailsResult, PatientDetailsError, type PatientDetailsInput, PatientDetailsResource, type PatientDetailsResult, type PatientListOptions, type PatientMedicalDetailsResult, PatientResource, type Physician, PhysiciansResource, type ProviderEventType, type ProviderSyncFailedPayload, type ProviderSyncStartedPayload, type ProviderSyncSucceededPayload, type PushEventPayload, type PushNoteToElationInput, type PushNoteToElationResult, REMINDER_EVENTS, type RecordAttachmentInput, type RegisterDeviceInput, type RegisterDeviceResult, type Reminder, type ReminderEventType, type ReminderScheduledPayload, type ReminderStatus, type ReminderTriggeredPayload, RemindersResource, SECURITY_EVENTS, type ScheduleNotificationInput, type ScheduleNotificationResult, type ScheduleReminderInput, type ScheduleReminderResult, type ScheduledJobStatus, type ScheduledNotification, type SecurityAccessDeniedPayload, type SecurityEventType, type SendConversationMessageInput, type SendConversationMessageResult, type SendNotificationInput, type SendNotificationResult, type SendSmsParams, type SendSmsResponse, type SetConversationTaskStatusInput, TASK_EVENTS, TRANSLATION_EVENTS, type Task, type TaskAssignedPayload, type TaskCreatedPayload, type TaskEventType, type TaskStatus, type TaskStatusChangedPayload, TasksResource, type TrackOptions, Tracker, type TranslateBatchInput, type TranslateTextInput, type TranslationCompletedPayload, TranslationError, type TranslationEventType, type TranslationRequestedPayload, TranslationResource, type TranslationResult, TruthClient, type TruthClientConfig, type UnregisterDeviceInput, type UpdateNotificationsInput, type UpdateNotificationsResult, type UpdatePreferencesInput, type UpdateTaskStatusInput, type UserSettings, UserSettingsResource, type VoicemailAuthResponse, type WebPushConfig, generateUuidV7, isWebPushSupported, onServiceWorkerMessage, registerServiceWorker, subscribeToPush, subscriptionToJSON };
package/dist/index.js CHANGED
@@ -3,8 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __getProtoOf = Object.getPrototypeOf;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __reflectGet = Reflect.get;
8
10
  var __pow = Math.pow;
9
11
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
12
  var __spreadValues = (a, b) => {
@@ -31,6 +33,7 @@ var __copyProps = (to, from, except, desc) => {
31
33
  return to;
32
34
  };
33
35
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+ var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
34
37
  var __async = (__this, __arguments, generator) => {
35
38
  return new Promise((resolve, reject) => {
36
39
  var fulfilled = (value) => {
@@ -101,8 +104,53 @@ __export(src_exports, {
101
104
  });
102
105
  module.exports = __toCommonJS(src_exports);
103
106
 
104
- // src/client.ts
107
+ // src/auth-convex-client.ts
105
108
  var import_browser = require("convex/browser");
109
+ var AuthAwareConvexHttpClient = class _AuthAwareConvexHttpClient extends import_browser.ConvexHttpClient {
110
+ constructor(address, getAuthToken) {
111
+ super(address);
112
+ this.getAuthToken = getAuthToken;
113
+ }
114
+ /**
115
+ * Pull a fresh token from the fetcher and apply it. A fetcher error
116
+ * keeps the previously-applied token rather than dropping auth
117
+ * mid-session.
118
+ */
119
+ syncAuth() {
120
+ return __async(this, null, function* () {
121
+ if (!this.getAuthToken) {
122
+ return;
123
+ }
124
+ try {
125
+ const token = yield this.getAuthToken();
126
+ if (token) {
127
+ this.setAuth(token);
128
+ } else {
129
+ this.clearAuth();
130
+ }
131
+ } catch (e) {
132
+ }
133
+ });
134
+ }
135
+ query(query, ...args) {
136
+ return __async(this, null, function* () {
137
+ yield this.syncAuth();
138
+ return __superGet(_AuthAwareConvexHttpClient.prototype, this, "query").call(this, query, ...args);
139
+ });
140
+ }
141
+ mutation(mutation, ...args) {
142
+ return __async(this, null, function* () {
143
+ yield this.syncAuth();
144
+ return __superGet(_AuthAwareConvexHttpClient.prototype, this, "mutation").call(this, mutation, ...args);
145
+ });
146
+ }
147
+ action(action, ...args) {
148
+ return __async(this, null, function* () {
149
+ yield this.syncAuth();
150
+ return __superGet(_AuthAwareConvexHttpClient.prototype, this, "action").call(this, action, ...args);
151
+ });
152
+ }
153
+ };
106
154
 
107
155
  // src/resources/appointments.ts
108
156
  var AppointmentResource = class {
@@ -1933,7 +1981,7 @@ var TruthClient = class {
1933
1981
  this._webPushReady = null;
1934
1982
  var _a, _b, _c, _d, _e, _f, _g, _h;
1935
1983
  const convexUrl = (_b = (_a = config.convexUrl) != null ? _a : CONVEX_URLS[config.environment]) != null ? _b : CONVEX_URLS.local;
1936
- this.convex = new import_browser.ConvexHttpClient(convexUrl);
1984
+ this.convex = new AuthAwareConvexHttpClient(convexUrl, config.getAuthToken);
1937
1985
  this.tracker = new Tracker({
1938
1986
  apiKey: config.apiKey,
1939
1987
  environment: config.environment,