@versini/sassysaint-common 4.2.0 → 4.2.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.ts +92 -51
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
@@ -70,16 +70,17 @@ declare const POLICY_GRANTS: {
|
|
70
70
|
REASONING: string;
|
71
71
|
};
|
72
72
|
/**
|
73
|
-
* Header string for Callisto Chat Id. Used to identify the chat in the
|
74
|
-
*
|
73
|
+
* Header string for Callisto Chat Id. Used to identify the chat in the server
|
74
|
+
* when there is a client abort.
|
75
75
|
*/
|
76
76
|
declare const CALLISTO_CHAT_ID_HEADER = "x-callisto-chat-id";
|
77
77
|
/**
|
78
|
-
* This function finds the provider associated with a given model name.
|
79
|
-
*
|
78
|
+
* This function finds the provider associated with a given model name. It
|
79
|
+
* checks the model name against a list of approximate models for each provider.
|
80
80
|
*
|
81
81
|
* @param modelName - The model name to check.
|
82
82
|
* @returns The provider associated with the model name or null if not found.
|
83
|
+
*
|
83
84
|
*/
|
84
85
|
declare const findProvider: (modelName: string) => null | typeof PROVIDER_ANTHROPIC | typeof PROVIDER_OPENAI | typeof PROVIDER_GOOGLE;
|
85
86
|
/**
|
@@ -93,76 +94,110 @@ declare const SORT_BY_TOKEN_USAGE = "tokenUsage";
|
|
93
94
|
declare const APPLICATION_NAME = "Callisto";
|
94
95
|
|
95
96
|
/**
|
96
|
-
* TypeScript interfaces for Server-Mediated Encryption
|
97
|
+
* TypeScript interfaces for Server-Mediated Encryption.
|
97
98
|
*/
|
98
99
|
/**
|
99
|
-
* RSA key pair stored in memory for the current session
|
100
|
+
* RSA key pair stored in memory for the current session.
|
100
101
|
*/
|
101
102
|
interface ClientCryptoKeyPair {
|
102
103
|
publicKey: CryptoKey;
|
103
104
|
privateKey: CryptoKey;
|
104
105
|
}
|
105
106
|
/**
|
106
|
-
* Serializable format for public key exchange with server
|
107
|
+
* Serializable format for public key exchange with server.
|
107
108
|
*/
|
108
109
|
interface SerializablePublicKey {
|
109
|
-
/**
|
110
|
+
/**
|
111
|
+
* Public key in JSON Web Key format.
|
112
|
+
*/
|
110
113
|
jwk: JsonWebKey;
|
111
|
-
/**
|
114
|
+
/**
|
115
|
+
* Key type identifier.
|
116
|
+
*/
|
112
117
|
kty: "RSA";
|
113
|
-
/**
|
118
|
+
/**
|
119
|
+
* Algorithm identifier.
|
120
|
+
*/
|
114
121
|
alg: "RSA-OAEP-256";
|
115
122
|
}
|
116
123
|
/**
|
117
|
-
* Response from server's key exchange mutation
|
124
|
+
* Response from server's key exchange mutation.
|
118
125
|
*/
|
119
126
|
interface KeyExchangeResponse {
|
120
|
-
/**
|
127
|
+
/**
|
128
|
+
* Server's public key in JWK format.
|
129
|
+
*/
|
121
130
|
serverPublicKey: string;
|
122
|
-
/**
|
131
|
+
/**
|
132
|
+
* Server's key identifier for rotation tracking.
|
133
|
+
*/
|
123
134
|
keyId: string;
|
124
|
-
/**
|
135
|
+
/**
|
136
|
+
* List of supported encryption algorithms.
|
137
|
+
*/
|
125
138
|
supportedAlgorithms: string[];
|
126
139
|
}
|
127
140
|
/**
|
128
|
-
* Client crypto session state stored in memory
|
141
|
+
* Client crypto session state stored in memory.
|
129
142
|
*/
|
130
143
|
interface CryptoSession {
|
131
|
-
/**
|
144
|
+
/**
|
145
|
+
* Client's RSA key pair.
|
146
|
+
*/
|
132
147
|
clientKeyPair: ClientCryptoKeyPair;
|
133
|
-
/**
|
148
|
+
/**
|
149
|
+
* Server's public key for encryption.
|
150
|
+
*/
|
134
151
|
serverPublicKey: CryptoKey;
|
135
|
-
/**
|
152
|
+
/**
|
153
|
+
* Unique device/session identifier.
|
154
|
+
*/
|
136
155
|
deviceId: string;
|
137
|
-
/**
|
156
|
+
/**
|
157
|
+
* Server's key identifier.
|
158
|
+
*/
|
138
159
|
serverKeyId: string;
|
139
|
-
/**
|
160
|
+
/**
|
161
|
+
* When this session was established.
|
162
|
+
*/
|
140
163
|
establishedAt: Date;
|
141
164
|
}
|
142
165
|
/**
|
143
|
-
* Encrypted message format for transport
|
166
|
+
* Encrypted message format for transport.
|
144
167
|
*/
|
145
168
|
interface EncryptedMessage {
|
146
|
-
/**
|
169
|
+
/**
|
170
|
+
* Base64-encoded encrypted data.
|
171
|
+
*/
|
147
172
|
data: string;
|
148
|
-
/**
|
173
|
+
/**
|
174
|
+
* Algorithm used for encryption.
|
175
|
+
*/
|
149
176
|
algorithm: "RSA-OAEP";
|
150
|
-
/**
|
177
|
+
/**
|
178
|
+
* Key ID used for encryption.
|
179
|
+
*/
|
151
180
|
keyId: string;
|
152
181
|
}
|
153
182
|
/**
|
154
|
-
* Parameters for RSA key generation
|
183
|
+
* Parameters for RSA key generation.
|
155
184
|
*/
|
156
185
|
interface RSAKeyGenParams {
|
157
|
-
/**
|
186
|
+
/**
|
187
|
+
* RSA modulus length in bits.
|
188
|
+
*/
|
158
189
|
modulusLength: 2048 | 4096;
|
159
|
-
/**
|
190
|
+
/**
|
191
|
+
* Public exponent.
|
192
|
+
*/
|
160
193
|
publicExponent: Uint8Array;
|
161
|
-
/**
|
194
|
+
/**
|
195
|
+
* Hash algorithm for OAEP.
|
196
|
+
*/
|
162
197
|
hash: "SHA-256";
|
163
198
|
}
|
164
199
|
/**
|
165
|
-
* Error types for crypto operations
|
200
|
+
* Error types for crypto operations.
|
166
201
|
*/
|
167
202
|
declare class CryptoError extends Error {
|
168
203
|
readonly code: "KEY_GENERATION_FAILED" | "ENCRYPTION_FAILED" | "DECRYPTION_FAILED" | "KEY_IMPORT_FAILED" | "INVALID_KEY_FORMAT";
|
@@ -170,85 +205,89 @@ declare class CryptoError extends Error {
|
|
170
205
|
constructor(message: string, code: "KEY_GENERATION_FAILED" | "ENCRYPTION_FAILED" | "DECRYPTION_FAILED" | "KEY_IMPORT_FAILED" | "INVALID_KEY_FORMAT", originalError?: Error | undefined);
|
171
206
|
}
|
172
207
|
/**
|
173
|
-
* Configuration options for crypto operations
|
208
|
+
* Configuration options for crypto operations.
|
174
209
|
*/
|
175
210
|
interface CryptoConfig {
|
176
|
-
/**
|
211
|
+
/**
|
212
|
+
* RSA key size in bits.
|
213
|
+
*/
|
177
214
|
keySize: 2048 | 4096;
|
178
|
-
/**
|
215
|
+
/**
|
216
|
+
* Enable debug logging.
|
217
|
+
*/
|
179
218
|
debug: boolean;
|
180
219
|
}
|
181
220
|
/**
|
182
|
-
* Default crypto configuration
|
221
|
+
* Default crypto configuration.
|
183
222
|
*/
|
184
223
|
declare const DEFAULT_CRYPTO_CONFIG: CryptoConfig;
|
185
224
|
|
186
225
|
/**
|
187
|
-
* Generate a new RSA key pair for the current session
|
226
|
+
* Generate a new RSA key pair for the current session.
|
188
227
|
*/
|
189
228
|
declare function generateClientKeyPair(config?: Partial<CryptoConfig>): Promise<ClientCryptoKeyPair>;
|
190
229
|
/**
|
191
|
-
* Export public key to serializable format for server exchange
|
230
|
+
* Export public key to serializable format for server exchange.
|
192
231
|
*/
|
193
232
|
declare function exportPublicKey(publicKey: CryptoKey): Promise<SerializablePublicKey>;
|
194
233
|
/**
|
195
|
-
* Import server's public key from JWK format
|
234
|
+
* Import server's public key from JWK format.
|
196
235
|
*/
|
197
236
|
declare function importServerPublicKey(serverPublicKeyJWK: string): Promise<CryptoKey>;
|
198
237
|
/**
|
199
|
-
* Encrypt message for transmission to server
|
238
|
+
* Encrypt message for transmission to server.
|
200
239
|
*/
|
201
240
|
declare function encryptForServer(message: string, serverPublicKey: CryptoKey, serverKeyId: string): Promise<EncryptedMessage>;
|
202
241
|
/**
|
203
|
-
* Decrypt message received from server
|
242
|
+
* Decrypt message received from server.
|
204
243
|
*/
|
205
244
|
declare function decryptFromServer(encryptedMessage: EncryptedMessage, clientPrivateKey: CryptoKey): Promise<string>;
|
206
245
|
/**
|
207
|
-
* Create a complete crypto session with key exchange
|
246
|
+
* Create a complete crypto session with key exchange.
|
208
247
|
*/
|
209
248
|
declare function establishCryptoSession(keyExchangeResponse: KeyExchangeResponse, clientKeyPair: ClientCryptoKeyPair, deviceId: string): Promise<CryptoSession>;
|
210
249
|
/**
|
211
|
-
* Validate that a crypto session is still valid
|
250
|
+
* Validate that a crypto session is still valid.
|
212
251
|
*/
|
213
252
|
declare function isCryptoSessionValid(session: CryptoSession): boolean;
|
214
253
|
|
215
254
|
/**
|
216
|
-
* Utility functions for crypto operations
|
255
|
+
* Utility functions for crypto operations.
|
217
256
|
*/
|
218
257
|
/**
|
219
|
-
* Generate a unique device ID for this session
|
258
|
+
* Generate a unique device ID for this session.
|
220
259
|
*/
|
221
260
|
declare function generateDeviceId(): string;
|
222
261
|
/**
|
223
|
-
* Check if the current environment supports Web Crypto API
|
262
|
+
* Check if the current environment supports Web Crypto API.
|
224
263
|
*/
|
225
264
|
declare function isWebCryptoSupported(): boolean;
|
226
265
|
/**
|
227
|
-
* Validate that we're in a secure context (required for Web Crypto API)
|
266
|
+
* Validate that we're in a secure context (required for Web Crypto API).
|
228
267
|
*/
|
229
268
|
declare function isSecureContext(): boolean;
|
230
269
|
/**
|
231
|
-
* Check if encryption is available in the current environment
|
270
|
+
* Check if encryption is available in the current environment.
|
232
271
|
*/
|
233
272
|
declare function canUseEncryption(): boolean;
|
234
273
|
/**
|
235
|
-
* Convert ArrayBuffer to base64 string
|
274
|
+
* Convert ArrayBuffer to base64 string.
|
236
275
|
*/
|
237
276
|
declare function arrayBufferToBase64(buffer: ArrayBuffer): string;
|
238
277
|
/**
|
239
|
-
* Convert base64 string to ArrayBuffer
|
278
|
+
* Convert base64 string to ArrayBuffer.
|
240
279
|
*/
|
241
280
|
declare function base64ToArrayBuffer(base64: string): ArrayBuffer;
|
242
281
|
/**
|
243
|
-
* Safely stringify JSON with error handling
|
282
|
+
* Safely stringify JSON with error handling.
|
244
283
|
*/
|
245
284
|
declare function safeStringify(obj: unknown): string;
|
246
285
|
/**
|
247
|
-
* Safely parse JSON with error handling
|
286
|
+
* Safely parse JSON with error handling.
|
248
287
|
*/
|
249
288
|
declare function safeParse<T = unknown>(json: string): T | null;
|
250
289
|
/**
|
251
|
-
* Debug logger for crypto operations (only in development)
|
290
|
+
* Debug logger for crypto operations (only in development).
|
252
291
|
*
|
253
292
|
* ⚠️ SECURITY WARNING: Never log sensitive data such as:
|
254
293
|
* - Private or public key objects
|
@@ -256,7 +295,9 @@ declare function safeParse<T = unknown>(json: string): T | null;
|
|
256
295
|
* - Raw cryptographic material
|
257
296
|
* - Device IDs or session identifiers
|
258
297
|
*
|
259
|
-
* Only log non-sensitive metadata like algorithms, key sizes, operation status,
|
298
|
+
* Only log non-sensitive metadata like algorithms, key sizes, operation status,
|
299
|
+
* etc.
|
300
|
+
*
|
260
301
|
*/
|
261
302
|
declare function debugLog(message: string, ...args: unknown[]): void;
|
262
303
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@versini/sassysaint-common",
|
3
|
-
"version": "4.2.
|
3
|
+
"version": "4.2.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "Arno Versini",
|
6
6
|
"publishConfig": {
|
@@ -19,9 +19,11 @@
|
|
19
19
|
"build:types": "tsup",
|
20
20
|
"build": "npm-run-all --serial clean build:check build:js build:types",
|
21
21
|
"clean": "rimraf dist tmp",
|
22
|
+
"comments:fix": "comments src/**/*.ts* --merge-line-comments",
|
22
23
|
"dev:js": "vite build --watch --mode development",
|
23
24
|
"dev:types": "tsup --watch src",
|
24
25
|
"dev": "npm-run-all --parallel dev:js dev:types",
|
26
|
+
"fix": "npm-run-all lint:fix comments:fix",
|
25
27
|
"lint": "biome lint src",
|
26
28
|
"lint:fix": "biome check src --write --no-errors-on-unmatched",
|
27
29
|
"test": "vitest run",
|
@@ -30,5 +32,5 @@
|
|
30
32
|
"test:watch": "vitest",
|
31
33
|
"watch": "npm-run-all dev"
|
32
34
|
},
|
33
|
-
"gitHead": "
|
35
|
+
"gitHead": "e4097d73c3aac460481459f4b2c39d40b2f760f8"
|
34
36
|
}
|