@findatruck/shared-schemas 0.4.0 → 0.6.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/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,15 +17,31 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
21
31
  var index_exports = {};
22
32
  __export(index_exports, {
33
+ ConvexUpdate: () => ConvexUpdate,
34
+ ConvexUpdateNested: () => ConvexUpdateNested,
35
+ DriverLocation: () => DriverLocation,
36
+ DriverLogin: () => DriverLogin,
37
+ DriverStatus: () => DriverStatus,
38
+ HoursOfService: () => HoursOfService,
23
39
  NewLoginRequest: () => NewLoginRequest,
24
40
  NewLoginResponse: () => NewLoginResponse,
25
41
  NewLoginResponseFailure: () => NewLoginResponseFailure,
26
- NewLoginResponseSuccess: () => NewLoginResponseSuccess
42
+ NewLoginResponseSuccess: () => NewLoginResponseSuccess,
43
+ decryptRsaOaepSha256B64: () => decryptRsaOaepSha256B64,
44
+ encryptRsaOaepSha256ToB64: () => encryptRsaOaepSha256ToB64
27
45
  });
28
46
  module.exports = __toCommonJS(index_exports);
29
47
 
@@ -66,10 +84,98 @@ var NewLoginResponseFailure = import_zod.z.object({
66
84
  error: import_zod.z.string()
67
85
  });
68
86
  var NewLoginResponse = import_zod.z.union([NewLoginResponseSuccess, NewLoginResponseFailure]);
87
+
88
+ // src/schemas/convex-update.ts
89
+ var import_zod2 = __toESM(require("zod"), 1);
90
+ var UrlSchema2 = import_zod2.default.string().refine(
91
+ (val) => {
92
+ try {
93
+ new URL(val);
94
+ return true;
95
+ } catch {
96
+ return false;
97
+ }
98
+ },
99
+ { message: "Invalid URL" }
100
+ );
101
+ var ConvexUpdate = import_zod2.default.object({
102
+ providerUrl: UrlSchema2.describe("The URL of the ELD provider"),
103
+ username: import_zod2.default.string().describe("The driver's login username"),
104
+ password: import_zod2.default.string().describe("The driver's login password"),
105
+ driver_id: import_zod2.default.string().optional().describe("The ELD's internal driver ID"),
106
+ driver_status: import_zod2.default.string().describe("The driver's duty status (direct from ELD)"),
107
+ time_remaining_in_shift: import_zod2.default.number().describe("Seconds remaining in current shift"),
108
+ time_remaining_till_break: import_zod2.default.number().describe("Seconds remaining until next required break"),
109
+ time_remaining_in_week: import_zod2.default.number().describe("Seconds remaining in current cycle/week"),
110
+ time_remaining_in_drive: import_zod2.default.number().describe("Seconds remaining in current drive period"),
111
+ driver_current_location_latitude: import_zod2.default.number().describe("Driver's current latitude"),
112
+ driver_current_location_longitude: import_zod2.default.number().describe("Driver's current longitude"),
113
+ driver_current_location_address: import_zod2.default.string().describe("Driver's current address")
114
+ }).describe("Schema for updating driver ELD status information");
115
+ var HoursOfService = import_zod2.default.object({
116
+ timeRemainingInShift: import_zod2.default.number().describe("Seconds remaining in current shift"),
117
+ timeRemainingTillBreak: import_zod2.default.number().describe("Seconds remaining until next required break"),
118
+ timeRemainingInWeek: import_zod2.default.number().describe("Seconds remaining in current cycle/week"),
119
+ timeRemainingInDrive: import_zod2.default.number().describe("Seconds remaining in current drive period")
120
+ }).describe("Schema for driver's hours of service information");
121
+ var DriverLocation = import_zod2.default.object({
122
+ latitude: import_zod2.default.number().describe("Driver's current latitude"),
123
+ longitude: import_zod2.default.number().describe("Driver's current longitude"),
124
+ address: import_zod2.default.string().describe("Driver's current address")
125
+ }).describe("Schema for driver's current location information");
126
+ var DriverStatus = import_zod2.default.object({
127
+ status: import_zod2.default.string().describe("The driver's duty status (direct from ELD)")
128
+ }).describe("Schema for driver's current duty status information");
129
+ var DriverLogin = import_zod2.default.object({
130
+ providerUrl: UrlSchema2.describe("The URL of the ELD provider"),
131
+ username: import_zod2.default.string().describe("The driver's login username"),
132
+ password: import_zod2.default.string().describe("The driver's login password")
133
+ }).describe("Schema for driver login information");
134
+ var ConvexUpdateNested = import_zod2.default.object({
135
+ driverId: import_zod2.default.string().describe("The ELD's internal driver ID"),
136
+ hoursOfService: HoursOfService,
137
+ driverLocation: DriverLocation,
138
+ driverStatus: DriverStatus,
139
+ driverLogin: DriverLogin
140
+ }).describe("Nested schema for updating driver ELD status information");
141
+
142
+ // src/security/transit-crypto.ts
143
+ var import_node_crypto = require("crypto");
144
+ function encryptRsaOaepSha256ToB64(plaintext, publicKeyPem) {
145
+ const ciphertext = (0, import_node_crypto.publicEncrypt)(
146
+ {
147
+ key: publicKeyPem,
148
+ padding: import_node_crypto.constants.RSA_PKCS1_OAEP_PADDING,
149
+ oaepHash: "sha256"
150
+ },
151
+ Buffer.from(plaintext, "utf8")
152
+ );
153
+ return ciphertext.toString("base64");
154
+ }
155
+ function decryptRsaOaepSha256B64(ciphertextB64, privateKeyPem, passphrase) {
156
+ const plaintext = (0, import_node_crypto.privateDecrypt)(
157
+ {
158
+ key: privateKeyPem,
159
+ passphrase,
160
+ padding: import_node_crypto.constants.RSA_PKCS1_OAEP_PADDING,
161
+ oaepHash: "sha256"
162
+ },
163
+ Buffer.from(ciphertextB64, "base64")
164
+ );
165
+ return plaintext.toString("utf8");
166
+ }
69
167
  // Annotate the CommonJS export names for ESM import in node:
70
168
  0 && (module.exports = {
169
+ ConvexUpdate,
170
+ ConvexUpdateNested,
171
+ DriverLocation,
172
+ DriverLogin,
173
+ DriverStatus,
174
+ HoursOfService,
71
175
  NewLoginRequest,
72
176
  NewLoginResponse,
73
177
  NewLoginResponseFailure,
74
- NewLoginResponseSuccess
178
+ NewLoginResponseSuccess,
179
+ decryptRsaOaepSha256B64,
180
+ encryptRsaOaepSha256ToB64
75
181
  });
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import z$1, { z } from 'zod';
2
2
 
3
3
  declare const NewLoginRequest: z.ZodObject<{
4
4
  providerUrl: z.ZodEffects<z.ZodString, string, string>;
@@ -145,4 +145,197 @@ declare const NewLoginResponse: z.ZodUnion<[z.ZodObject<{
145
145
  error: string;
146
146
  }>]>;
147
147
 
148
- export { NewLoginRequest, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseSuccess };
148
+ declare const ConvexUpdate: z$1.ZodObject<{
149
+ providerUrl: z$1.ZodEffects<z$1.ZodString, string, string>;
150
+ username: z$1.ZodString;
151
+ password: z$1.ZodString;
152
+ driver_id: z$1.ZodOptional<z$1.ZodString>;
153
+ driver_status: z$1.ZodString;
154
+ time_remaining_in_shift: z$1.ZodNumber;
155
+ time_remaining_till_break: z$1.ZodNumber;
156
+ time_remaining_in_week: z$1.ZodNumber;
157
+ time_remaining_in_drive: z$1.ZodNumber;
158
+ driver_current_location_latitude: z$1.ZodNumber;
159
+ driver_current_location_longitude: z$1.ZodNumber;
160
+ driver_current_location_address: z$1.ZodString;
161
+ }, "strip", z$1.ZodTypeAny, {
162
+ providerUrl: string;
163
+ username: string;
164
+ password: string;
165
+ driver_status: string;
166
+ time_remaining_in_shift: number;
167
+ time_remaining_till_break: number;
168
+ time_remaining_in_week: number;
169
+ time_remaining_in_drive: number;
170
+ driver_current_location_latitude: number;
171
+ driver_current_location_longitude: number;
172
+ driver_current_location_address: string;
173
+ driver_id?: string | undefined;
174
+ }, {
175
+ providerUrl: string;
176
+ username: string;
177
+ password: string;
178
+ driver_status: string;
179
+ time_remaining_in_shift: number;
180
+ time_remaining_till_break: number;
181
+ time_remaining_in_week: number;
182
+ time_remaining_in_drive: number;
183
+ driver_current_location_latitude: number;
184
+ driver_current_location_longitude: number;
185
+ driver_current_location_address: string;
186
+ driver_id?: string | undefined;
187
+ }>;
188
+ type ConvexUpdate = z$1.infer<typeof ConvexUpdate>;
189
+ declare const HoursOfService: z$1.ZodObject<{
190
+ timeRemainingInShift: z$1.ZodNumber;
191
+ timeRemainingTillBreak: z$1.ZodNumber;
192
+ timeRemainingInWeek: z$1.ZodNumber;
193
+ timeRemainingInDrive: z$1.ZodNumber;
194
+ }, "strip", z$1.ZodTypeAny, {
195
+ timeRemainingInShift: number;
196
+ timeRemainingTillBreak: number;
197
+ timeRemainingInWeek: number;
198
+ timeRemainingInDrive: number;
199
+ }, {
200
+ timeRemainingInShift: number;
201
+ timeRemainingTillBreak: number;
202
+ timeRemainingInWeek: number;
203
+ timeRemainingInDrive: number;
204
+ }>;
205
+ type HoursOfService = z$1.infer<typeof HoursOfService>;
206
+ declare const DriverLocation: z$1.ZodObject<{
207
+ latitude: z$1.ZodNumber;
208
+ longitude: z$1.ZodNumber;
209
+ address: z$1.ZodString;
210
+ }, "strip", z$1.ZodTypeAny, {
211
+ latitude: number;
212
+ longitude: number;
213
+ address: string;
214
+ }, {
215
+ latitude: number;
216
+ longitude: number;
217
+ address: string;
218
+ }>;
219
+ type DriverLocation = z$1.infer<typeof DriverLocation>;
220
+ declare const DriverStatus: z$1.ZodObject<{
221
+ status: z$1.ZodString;
222
+ }, "strip", z$1.ZodTypeAny, {
223
+ status: string;
224
+ }, {
225
+ status: string;
226
+ }>;
227
+ type DriverStatus = z$1.infer<typeof DriverStatus>;
228
+ declare const DriverLogin: z$1.ZodObject<{
229
+ providerUrl: z$1.ZodEffects<z$1.ZodString, string, string>;
230
+ username: z$1.ZodString;
231
+ password: z$1.ZodString;
232
+ }, "strip", z$1.ZodTypeAny, {
233
+ providerUrl: string;
234
+ username: string;
235
+ password: string;
236
+ }, {
237
+ providerUrl: string;
238
+ username: string;
239
+ password: string;
240
+ }>;
241
+ type DriverLogin = z$1.infer<typeof DriverLogin>;
242
+ declare const ConvexUpdateNested: z$1.ZodObject<{
243
+ driverId: z$1.ZodString;
244
+ hoursOfService: z$1.ZodObject<{
245
+ timeRemainingInShift: z$1.ZodNumber;
246
+ timeRemainingTillBreak: z$1.ZodNumber;
247
+ timeRemainingInWeek: z$1.ZodNumber;
248
+ timeRemainingInDrive: z$1.ZodNumber;
249
+ }, "strip", z$1.ZodTypeAny, {
250
+ timeRemainingInShift: number;
251
+ timeRemainingTillBreak: number;
252
+ timeRemainingInWeek: number;
253
+ timeRemainingInDrive: number;
254
+ }, {
255
+ timeRemainingInShift: number;
256
+ timeRemainingTillBreak: number;
257
+ timeRemainingInWeek: number;
258
+ timeRemainingInDrive: number;
259
+ }>;
260
+ driverLocation: z$1.ZodObject<{
261
+ latitude: z$1.ZodNumber;
262
+ longitude: z$1.ZodNumber;
263
+ address: z$1.ZodString;
264
+ }, "strip", z$1.ZodTypeAny, {
265
+ latitude: number;
266
+ longitude: number;
267
+ address: string;
268
+ }, {
269
+ latitude: number;
270
+ longitude: number;
271
+ address: string;
272
+ }>;
273
+ driverStatus: z$1.ZodObject<{
274
+ status: z$1.ZodString;
275
+ }, "strip", z$1.ZodTypeAny, {
276
+ status: string;
277
+ }, {
278
+ status: string;
279
+ }>;
280
+ driverLogin: z$1.ZodObject<{
281
+ providerUrl: z$1.ZodEffects<z$1.ZodString, string, string>;
282
+ username: z$1.ZodString;
283
+ password: z$1.ZodString;
284
+ }, "strip", z$1.ZodTypeAny, {
285
+ providerUrl: string;
286
+ username: string;
287
+ password: string;
288
+ }, {
289
+ providerUrl: string;
290
+ username: string;
291
+ password: string;
292
+ }>;
293
+ }, "strip", z$1.ZodTypeAny, {
294
+ driverId: string;
295
+ hoursOfService: {
296
+ timeRemainingInShift: number;
297
+ timeRemainingTillBreak: number;
298
+ timeRemainingInWeek: number;
299
+ timeRemainingInDrive: number;
300
+ };
301
+ driverLocation: {
302
+ latitude: number;
303
+ longitude: number;
304
+ address: string;
305
+ };
306
+ driverStatus: {
307
+ status: string;
308
+ };
309
+ driverLogin: {
310
+ providerUrl: string;
311
+ username: string;
312
+ password: string;
313
+ };
314
+ }, {
315
+ driverId: string;
316
+ hoursOfService: {
317
+ timeRemainingInShift: number;
318
+ timeRemainingTillBreak: number;
319
+ timeRemainingInWeek: number;
320
+ timeRemainingInDrive: number;
321
+ };
322
+ driverLocation: {
323
+ latitude: number;
324
+ longitude: number;
325
+ address: string;
326
+ };
327
+ driverStatus: {
328
+ status: string;
329
+ };
330
+ driverLogin: {
331
+ providerUrl: string;
332
+ username: string;
333
+ password: string;
334
+ };
335
+ }>;
336
+ type ConvexUpdateNested = z$1.infer<typeof ConvexUpdateNested>;
337
+
338
+ declare function encryptRsaOaepSha256ToB64(plaintext: string, publicKeyPem: string): string;
339
+ declare function decryptRsaOaepSha256B64(ciphertextB64: string, privateKeyPem: string, passphrase?: string): string;
340
+
341
+ export { ConvexUpdate, ConvexUpdateNested, DriverLocation, DriverLogin, DriverStatus, HoursOfService, NewLoginRequest, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseSuccess, decryptRsaOaepSha256B64, encryptRsaOaepSha256ToB64 };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import z$1, { z } from 'zod';
2
2
 
3
3
  declare const NewLoginRequest: z.ZodObject<{
4
4
  providerUrl: z.ZodEffects<z.ZodString, string, string>;
@@ -145,4 +145,197 @@ declare const NewLoginResponse: z.ZodUnion<[z.ZodObject<{
145
145
  error: string;
146
146
  }>]>;
147
147
 
148
- export { NewLoginRequest, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseSuccess };
148
+ declare const ConvexUpdate: z$1.ZodObject<{
149
+ providerUrl: z$1.ZodEffects<z$1.ZodString, string, string>;
150
+ username: z$1.ZodString;
151
+ password: z$1.ZodString;
152
+ driver_id: z$1.ZodOptional<z$1.ZodString>;
153
+ driver_status: z$1.ZodString;
154
+ time_remaining_in_shift: z$1.ZodNumber;
155
+ time_remaining_till_break: z$1.ZodNumber;
156
+ time_remaining_in_week: z$1.ZodNumber;
157
+ time_remaining_in_drive: z$1.ZodNumber;
158
+ driver_current_location_latitude: z$1.ZodNumber;
159
+ driver_current_location_longitude: z$1.ZodNumber;
160
+ driver_current_location_address: z$1.ZodString;
161
+ }, "strip", z$1.ZodTypeAny, {
162
+ providerUrl: string;
163
+ username: string;
164
+ password: string;
165
+ driver_status: string;
166
+ time_remaining_in_shift: number;
167
+ time_remaining_till_break: number;
168
+ time_remaining_in_week: number;
169
+ time_remaining_in_drive: number;
170
+ driver_current_location_latitude: number;
171
+ driver_current_location_longitude: number;
172
+ driver_current_location_address: string;
173
+ driver_id?: string | undefined;
174
+ }, {
175
+ providerUrl: string;
176
+ username: string;
177
+ password: string;
178
+ driver_status: string;
179
+ time_remaining_in_shift: number;
180
+ time_remaining_till_break: number;
181
+ time_remaining_in_week: number;
182
+ time_remaining_in_drive: number;
183
+ driver_current_location_latitude: number;
184
+ driver_current_location_longitude: number;
185
+ driver_current_location_address: string;
186
+ driver_id?: string | undefined;
187
+ }>;
188
+ type ConvexUpdate = z$1.infer<typeof ConvexUpdate>;
189
+ declare const HoursOfService: z$1.ZodObject<{
190
+ timeRemainingInShift: z$1.ZodNumber;
191
+ timeRemainingTillBreak: z$1.ZodNumber;
192
+ timeRemainingInWeek: z$1.ZodNumber;
193
+ timeRemainingInDrive: z$1.ZodNumber;
194
+ }, "strip", z$1.ZodTypeAny, {
195
+ timeRemainingInShift: number;
196
+ timeRemainingTillBreak: number;
197
+ timeRemainingInWeek: number;
198
+ timeRemainingInDrive: number;
199
+ }, {
200
+ timeRemainingInShift: number;
201
+ timeRemainingTillBreak: number;
202
+ timeRemainingInWeek: number;
203
+ timeRemainingInDrive: number;
204
+ }>;
205
+ type HoursOfService = z$1.infer<typeof HoursOfService>;
206
+ declare const DriverLocation: z$1.ZodObject<{
207
+ latitude: z$1.ZodNumber;
208
+ longitude: z$1.ZodNumber;
209
+ address: z$1.ZodString;
210
+ }, "strip", z$1.ZodTypeAny, {
211
+ latitude: number;
212
+ longitude: number;
213
+ address: string;
214
+ }, {
215
+ latitude: number;
216
+ longitude: number;
217
+ address: string;
218
+ }>;
219
+ type DriverLocation = z$1.infer<typeof DriverLocation>;
220
+ declare const DriverStatus: z$1.ZodObject<{
221
+ status: z$1.ZodString;
222
+ }, "strip", z$1.ZodTypeAny, {
223
+ status: string;
224
+ }, {
225
+ status: string;
226
+ }>;
227
+ type DriverStatus = z$1.infer<typeof DriverStatus>;
228
+ declare const DriverLogin: z$1.ZodObject<{
229
+ providerUrl: z$1.ZodEffects<z$1.ZodString, string, string>;
230
+ username: z$1.ZodString;
231
+ password: z$1.ZodString;
232
+ }, "strip", z$1.ZodTypeAny, {
233
+ providerUrl: string;
234
+ username: string;
235
+ password: string;
236
+ }, {
237
+ providerUrl: string;
238
+ username: string;
239
+ password: string;
240
+ }>;
241
+ type DriverLogin = z$1.infer<typeof DriverLogin>;
242
+ declare const ConvexUpdateNested: z$1.ZodObject<{
243
+ driverId: z$1.ZodString;
244
+ hoursOfService: z$1.ZodObject<{
245
+ timeRemainingInShift: z$1.ZodNumber;
246
+ timeRemainingTillBreak: z$1.ZodNumber;
247
+ timeRemainingInWeek: z$1.ZodNumber;
248
+ timeRemainingInDrive: z$1.ZodNumber;
249
+ }, "strip", z$1.ZodTypeAny, {
250
+ timeRemainingInShift: number;
251
+ timeRemainingTillBreak: number;
252
+ timeRemainingInWeek: number;
253
+ timeRemainingInDrive: number;
254
+ }, {
255
+ timeRemainingInShift: number;
256
+ timeRemainingTillBreak: number;
257
+ timeRemainingInWeek: number;
258
+ timeRemainingInDrive: number;
259
+ }>;
260
+ driverLocation: z$1.ZodObject<{
261
+ latitude: z$1.ZodNumber;
262
+ longitude: z$1.ZodNumber;
263
+ address: z$1.ZodString;
264
+ }, "strip", z$1.ZodTypeAny, {
265
+ latitude: number;
266
+ longitude: number;
267
+ address: string;
268
+ }, {
269
+ latitude: number;
270
+ longitude: number;
271
+ address: string;
272
+ }>;
273
+ driverStatus: z$1.ZodObject<{
274
+ status: z$1.ZodString;
275
+ }, "strip", z$1.ZodTypeAny, {
276
+ status: string;
277
+ }, {
278
+ status: string;
279
+ }>;
280
+ driverLogin: z$1.ZodObject<{
281
+ providerUrl: z$1.ZodEffects<z$1.ZodString, string, string>;
282
+ username: z$1.ZodString;
283
+ password: z$1.ZodString;
284
+ }, "strip", z$1.ZodTypeAny, {
285
+ providerUrl: string;
286
+ username: string;
287
+ password: string;
288
+ }, {
289
+ providerUrl: string;
290
+ username: string;
291
+ password: string;
292
+ }>;
293
+ }, "strip", z$1.ZodTypeAny, {
294
+ driverId: string;
295
+ hoursOfService: {
296
+ timeRemainingInShift: number;
297
+ timeRemainingTillBreak: number;
298
+ timeRemainingInWeek: number;
299
+ timeRemainingInDrive: number;
300
+ };
301
+ driverLocation: {
302
+ latitude: number;
303
+ longitude: number;
304
+ address: string;
305
+ };
306
+ driverStatus: {
307
+ status: string;
308
+ };
309
+ driverLogin: {
310
+ providerUrl: string;
311
+ username: string;
312
+ password: string;
313
+ };
314
+ }, {
315
+ driverId: string;
316
+ hoursOfService: {
317
+ timeRemainingInShift: number;
318
+ timeRemainingTillBreak: number;
319
+ timeRemainingInWeek: number;
320
+ timeRemainingInDrive: number;
321
+ };
322
+ driverLocation: {
323
+ latitude: number;
324
+ longitude: number;
325
+ address: string;
326
+ };
327
+ driverStatus: {
328
+ status: string;
329
+ };
330
+ driverLogin: {
331
+ providerUrl: string;
332
+ username: string;
333
+ password: string;
334
+ };
335
+ }>;
336
+ type ConvexUpdateNested = z$1.infer<typeof ConvexUpdateNested>;
337
+
338
+ declare function encryptRsaOaepSha256ToB64(plaintext: string, publicKeyPem: string): string;
339
+ declare function decryptRsaOaepSha256B64(ciphertextB64: string, privateKeyPem: string, passphrase?: string): string;
340
+
341
+ export { ConvexUpdate, ConvexUpdateNested, DriverLocation, DriverLogin, DriverStatus, HoursOfService, NewLoginRequest, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseSuccess, decryptRsaOaepSha256B64, encryptRsaOaepSha256ToB64 };
package/dist/index.js CHANGED
@@ -37,9 +37,97 @@ var NewLoginResponseFailure = z.object({
37
37
  error: z.string()
38
38
  });
39
39
  var NewLoginResponse = z.union([NewLoginResponseSuccess, NewLoginResponseFailure]);
40
+
41
+ // src/schemas/convex-update.ts
42
+ import z2 from "zod";
43
+ var UrlSchema2 = z2.string().refine(
44
+ (val) => {
45
+ try {
46
+ new URL(val);
47
+ return true;
48
+ } catch {
49
+ return false;
50
+ }
51
+ },
52
+ { message: "Invalid URL" }
53
+ );
54
+ var ConvexUpdate = z2.object({
55
+ providerUrl: UrlSchema2.describe("The URL of the ELD provider"),
56
+ username: z2.string().describe("The driver's login username"),
57
+ password: z2.string().describe("The driver's login password"),
58
+ driver_id: z2.string().optional().describe("The ELD's internal driver ID"),
59
+ driver_status: z2.string().describe("The driver's duty status (direct from ELD)"),
60
+ time_remaining_in_shift: z2.number().describe("Seconds remaining in current shift"),
61
+ time_remaining_till_break: z2.number().describe("Seconds remaining until next required break"),
62
+ time_remaining_in_week: z2.number().describe("Seconds remaining in current cycle/week"),
63
+ time_remaining_in_drive: z2.number().describe("Seconds remaining in current drive period"),
64
+ driver_current_location_latitude: z2.number().describe("Driver's current latitude"),
65
+ driver_current_location_longitude: z2.number().describe("Driver's current longitude"),
66
+ driver_current_location_address: z2.string().describe("Driver's current address")
67
+ }).describe("Schema for updating driver ELD status information");
68
+ var HoursOfService = z2.object({
69
+ timeRemainingInShift: z2.number().describe("Seconds remaining in current shift"),
70
+ timeRemainingTillBreak: z2.number().describe("Seconds remaining until next required break"),
71
+ timeRemainingInWeek: z2.number().describe("Seconds remaining in current cycle/week"),
72
+ timeRemainingInDrive: z2.number().describe("Seconds remaining in current drive period")
73
+ }).describe("Schema for driver's hours of service information");
74
+ var DriverLocation = z2.object({
75
+ latitude: z2.number().describe("Driver's current latitude"),
76
+ longitude: z2.number().describe("Driver's current longitude"),
77
+ address: z2.string().describe("Driver's current address")
78
+ }).describe("Schema for driver's current location information");
79
+ var DriverStatus = z2.object({
80
+ status: z2.string().describe("The driver's duty status (direct from ELD)")
81
+ }).describe("Schema for driver's current duty status information");
82
+ var DriverLogin = z2.object({
83
+ providerUrl: UrlSchema2.describe("The URL of the ELD provider"),
84
+ username: z2.string().describe("The driver's login username"),
85
+ password: z2.string().describe("The driver's login password")
86
+ }).describe("Schema for driver login information");
87
+ var ConvexUpdateNested = z2.object({
88
+ driverId: z2.string().describe("The ELD's internal driver ID"),
89
+ hoursOfService: HoursOfService,
90
+ driverLocation: DriverLocation,
91
+ driverStatus: DriverStatus,
92
+ driverLogin: DriverLogin
93
+ }).describe("Nested schema for updating driver ELD status information");
94
+
95
+ // src/security/transit-crypto.ts
96
+ import { publicEncrypt, privateDecrypt, constants } from "crypto";
97
+ function encryptRsaOaepSha256ToB64(plaintext, publicKeyPem) {
98
+ const ciphertext = publicEncrypt(
99
+ {
100
+ key: publicKeyPem,
101
+ padding: constants.RSA_PKCS1_OAEP_PADDING,
102
+ oaepHash: "sha256"
103
+ },
104
+ Buffer.from(plaintext, "utf8")
105
+ );
106
+ return ciphertext.toString("base64");
107
+ }
108
+ function decryptRsaOaepSha256B64(ciphertextB64, privateKeyPem, passphrase) {
109
+ const plaintext = privateDecrypt(
110
+ {
111
+ key: privateKeyPem,
112
+ passphrase,
113
+ padding: constants.RSA_PKCS1_OAEP_PADDING,
114
+ oaepHash: "sha256"
115
+ },
116
+ Buffer.from(ciphertextB64, "base64")
117
+ );
118
+ return plaintext.toString("utf8");
119
+ }
40
120
  export {
121
+ ConvexUpdate,
122
+ ConvexUpdateNested,
123
+ DriverLocation,
124
+ DriverLogin,
125
+ DriverStatus,
126
+ HoursOfService,
41
127
  NewLoginRequest,
42
128
  NewLoginResponse,
43
129
  NewLoginResponseFailure,
44
- NewLoginResponseSuccess
130
+ NewLoginResponseSuccess,
131
+ decryptRsaOaepSha256B64,
132
+ encryptRsaOaepSha256ToB64
45
133
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@findatruck/shared-schemas",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -19,15 +19,20 @@
19
19
  "scripts": {
20
20
  "build": "tsup src/index.ts --dts --format esm,cjs --out-dir dist --clean",
21
21
  "prepublishOnly": "npm run build",
22
- "prepare": "npm run build"
22
+ "prepare": "npm run build",
23
+ "test": "vitest run",
24
+ "test:watch": "vitest",
25
+ "coverage": "vitest run --coverage"
23
26
  },
24
27
  "peerDependencies": {
25
28
  "zod": "^3.23.0"
26
29
  },
27
30
  "devDependencies": {
28
31
  "@changesets/cli": "^2.29.7",
32
+ "@types/node": "^24.7.0",
29
33
  "tsup": "^8.0.0",
30
- "typescript": "^5.6.0",
34
+ "typescript": "^5.9.3",
35
+ "vitest": "^3.2.4",
31
36
  "zod": "^3.23.0"
32
37
  }
33
38
  }