@findatruck/shared-schemas 0.5.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
@@ -39,7 +39,9 @@ __export(index_exports, {
39
39
  NewLoginRequest: () => NewLoginRequest,
40
40
  NewLoginResponse: () => NewLoginResponse,
41
41
  NewLoginResponseFailure: () => NewLoginResponseFailure,
42
- NewLoginResponseSuccess: () => NewLoginResponseSuccess
42
+ NewLoginResponseSuccess: () => NewLoginResponseSuccess,
43
+ decryptRsaOaepSha256B64: () => decryptRsaOaepSha256B64,
44
+ encryptRsaOaepSha256ToB64: () => encryptRsaOaepSha256ToB64
43
45
  });
44
46
  module.exports = __toCommonJS(index_exports);
45
47
 
@@ -136,6 +138,32 @@ var ConvexUpdateNested = import_zod2.default.object({
136
138
  driverStatus: DriverStatus,
137
139
  driverLogin: DriverLogin
138
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
+ }
139
167
  // Annotate the CommonJS export names for ESM import in node:
140
168
  0 && (module.exports = {
141
169
  ConvexUpdate,
@@ -147,5 +175,7 @@ var ConvexUpdateNested = import_zod2.default.object({
147
175
  NewLoginRequest,
148
176
  NewLoginResponse,
149
177
  NewLoginResponseFailure,
150
- NewLoginResponseSuccess
178
+ NewLoginResponseSuccess,
179
+ decryptRsaOaepSha256B64,
180
+ encryptRsaOaepSha256ToB64
151
181
  });
package/dist/index.d.cts CHANGED
@@ -335,4 +335,7 @@ declare const ConvexUpdateNested: z$1.ZodObject<{
335
335
  }>;
336
336
  type ConvexUpdateNested = z$1.infer<typeof ConvexUpdateNested>;
337
337
 
338
- export { ConvexUpdate, ConvexUpdateNested, DriverLocation, DriverLogin, DriverStatus, HoursOfService, NewLoginRequest, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseSuccess };
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
@@ -335,4 +335,7 @@ declare const ConvexUpdateNested: z$1.ZodObject<{
335
335
  }>;
336
336
  type ConvexUpdateNested = z$1.infer<typeof ConvexUpdateNested>;
337
337
 
338
- export { ConvexUpdate, ConvexUpdateNested, DriverLocation, DriverLogin, DriverStatus, HoursOfService, NewLoginRequest, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseSuccess };
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
@@ -91,6 +91,32 @@ var ConvexUpdateNested = z2.object({
91
91
  driverStatus: DriverStatus,
92
92
  driverLogin: DriverLogin
93
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
+ }
94
120
  export {
95
121
  ConvexUpdate,
96
122
  ConvexUpdateNested,
@@ -101,5 +127,7 @@ export {
101
127
  NewLoginRequest,
102
128
  NewLoginResponse,
103
129
  NewLoginResponseFailure,
104
- NewLoginResponseSuccess
130
+ NewLoginResponseSuccess,
131
+ decryptRsaOaepSha256B64,
132
+ encryptRsaOaepSha256ToB64
105
133
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@findatruck/shared-schemas",
3
- "version": "0.5.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
  }