@fgv/ts-extras 5.1.0-16 → 5.1.0-18
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.browser.js +2 -1
- package/dist/packlets/ai-assist/apiClient.js +570 -58
- package/dist/packlets/ai-assist/chatRequestBuilders.js +180 -0
- package/dist/packlets/ai-assist/index.js +4 -3
- package/dist/packlets/ai-assist/model.js +20 -3
- package/dist/packlets/ai-assist/registry.js +66 -10
- package/dist/packlets/ai-assist/sseParser.js +122 -0
- package/dist/packlets/ai-assist/streamingAdapters/anthropic.js +192 -0
- package/dist/packlets/ai-assist/streamingAdapters/common.js +77 -0
- package/dist/packlets/ai-assist/streamingAdapters/gemini.js +160 -0
- package/dist/packlets/ai-assist/streamingAdapters/openaiChat.js +149 -0
- package/dist/packlets/ai-assist/streamingAdapters/openaiResponses.js +163 -0
- package/dist/packlets/ai-assist/streamingAdapters/proxy.js +157 -0
- package/dist/packlets/ai-assist/streamingClient.js +88 -0
- package/dist/packlets/conversion/converters.js +1 -1
- package/dist/packlets/crypto-utils/index.browser.js +2 -0
- package/dist/packlets/crypto-utils/index.js +2 -0
- package/dist/packlets/crypto-utils/keyPairAlgorithmParams.js +47 -0
- package/dist/packlets/crypto-utils/keystore/converters.js +101 -9
- package/dist/packlets/crypto-utils/keystore/index.js +1 -0
- package/dist/packlets/crypto-utils/keystore/keyStore.js +271 -46
- package/dist/packlets/crypto-utils/keystore/model.js +22 -1
- package/dist/packlets/crypto-utils/keystore/privateKeyStorage.js +21 -0
- package/dist/packlets/crypto-utils/model.js +5 -0
- package/dist/packlets/crypto-utils/nodeCryptoProvider.js +44 -1
- package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js +2 -2
- package/dist/test/unit/crypto/keystore/inMemoryPrivateKeyStorage.js +78 -0
- package/dist/ts-extras.d.ts +1089 -37
- package/lib/index.browser.d.ts +2 -1
- package/lib/index.browser.js +3 -1
- package/lib/packlets/ai-assist/apiClient.d.ts +103 -1
- package/lib/packlets/ai-assist/apiClient.js +574 -58
- package/lib/packlets/ai-assist/chatRequestBuilders.d.ts +89 -0
- package/lib/packlets/ai-assist/chatRequestBuilders.js +189 -0
- package/lib/packlets/ai-assist/index.d.ts +4 -3
- package/lib/packlets/ai-assist/index.js +10 -1
- package/lib/packlets/ai-assist/model.d.ts +271 -2
- package/lib/packlets/ai-assist/model.js +21 -3
- package/lib/packlets/ai-assist/registry.d.ts +10 -1
- package/lib/packlets/ai-assist/registry.js +67 -11
- package/lib/packlets/ai-assist/sseParser.d.ts +45 -0
- package/lib/packlets/ai-assist/sseParser.js +127 -0
- package/lib/packlets/ai-assist/streamingAdapters/anthropic.d.ts +18 -0
- package/lib/packlets/ai-assist/streamingAdapters/anthropic.js +195 -0
- package/lib/packlets/ai-assist/streamingAdapters/common.d.ts +71 -0
- package/lib/packlets/ai-assist/streamingAdapters/common.js +81 -0
- package/lib/packlets/ai-assist/streamingAdapters/gemini.d.ts +19 -0
- package/lib/packlets/ai-assist/streamingAdapters/gemini.js +163 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiChat.d.ts +18 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiChat.js +152 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.d.ts +19 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.js +166 -0
- package/lib/packlets/ai-assist/streamingAdapters/proxy.d.ts +34 -0
- package/lib/packlets/ai-assist/streamingAdapters/proxy.js +160 -0
- package/lib/packlets/ai-assist/streamingClient.d.ts +33 -0
- package/lib/packlets/ai-assist/streamingClient.js +93 -0
- package/lib/packlets/conversion/converters.d.ts +1 -1
- package/lib/packlets/conversion/converters.js +1 -1
- package/lib/packlets/crypto-utils/index.browser.d.ts +1 -0
- package/lib/packlets/crypto-utils/index.browser.js +4 -1
- package/lib/packlets/crypto-utils/index.d.ts +1 -0
- package/lib/packlets/crypto-utils/index.js +4 -1
- package/lib/packlets/crypto-utils/keyPairAlgorithmParams.d.ts +39 -0
- package/lib/packlets/crypto-utils/keyPairAlgorithmParams.js +50 -0
- package/lib/packlets/crypto-utils/keystore/converters.d.ts +68 -6
- package/lib/packlets/crypto-utils/keystore/converters.js +100 -8
- package/lib/packlets/crypto-utils/keystore/index.d.ts +1 -0
- package/lib/packlets/crypto-utils/keystore/index.js +1 -0
- package/lib/packlets/crypto-utils/keystore/keyStore.d.ts +77 -9
- package/lib/packlets/crypto-utils/keystore/keyStore.js +271 -46
- package/lib/packlets/crypto-utils/keystore/model.d.ts +238 -19
- package/lib/packlets/crypto-utils/keystore/model.js +24 -2
- package/lib/packlets/crypto-utils/keystore/privateKeyStorage.d.ts +50 -0
- package/lib/packlets/crypto-utils/keystore/privateKeyStorage.js +22 -0
- package/lib/packlets/crypto-utils/model.d.ts +38 -0
- package/lib/packlets/crypto-utils/model.js +6 -1
- package/lib/packlets/crypto-utils/nodeCryptoProvider.d.ts +26 -1
- package/lib/packlets/crypto-utils/nodeCryptoProvider.js +43 -0
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts +2 -2
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js +2 -2
- package/package.json +7 -7
package/dist/ts-extras.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare type AiApiFormat = 'openai' | 'anthropic' | 'gemini';
|
|
|
23
23
|
declare namespace AiAssist {
|
|
24
24
|
export {
|
|
25
25
|
AiPrompt,
|
|
26
|
+
AiModelCapability,
|
|
26
27
|
AiProviderId,
|
|
27
28
|
AiServerToolType,
|
|
28
29
|
AiServerToolConfig,
|
|
@@ -31,23 +32,49 @@ declare namespace AiAssist {
|
|
|
31
32
|
IAiCompletionResponse,
|
|
32
33
|
IChatMessage,
|
|
33
34
|
AiApiFormat,
|
|
35
|
+
AiImageApiFormat,
|
|
34
36
|
IAiProviderDescriptor,
|
|
35
37
|
IAiAssistProviderConfig,
|
|
36
38
|
IAiAssistSettings,
|
|
37
39
|
DEFAULT_AI_ASSIST,
|
|
38
40
|
IAiAssistKeyStore,
|
|
41
|
+
IAiImageAttachment,
|
|
42
|
+
IAiImageData,
|
|
43
|
+
IAiImageGenerationOptions,
|
|
44
|
+
IAiImageGenerationParams,
|
|
45
|
+
IAiGeneratedImage,
|
|
46
|
+
IAiImageGenerationResponse,
|
|
47
|
+
IAiModelCapabilityRule,
|
|
48
|
+
IAiModelCapabilityConfig,
|
|
49
|
+
IAiModelInfo,
|
|
50
|
+
IAiStreamEvent,
|
|
51
|
+
IAiStreamTextDelta,
|
|
52
|
+
IAiStreamToolEvent,
|
|
53
|
+
IAiStreamDone,
|
|
54
|
+
IAiStreamError,
|
|
39
55
|
ModelSpec,
|
|
40
56
|
ModelSpecKey,
|
|
41
57
|
IModelSpecMap,
|
|
42
58
|
allModelSpecKeys,
|
|
43
59
|
MODEL_SPEC_BASE_KEY,
|
|
44
60
|
resolveModel,
|
|
61
|
+
toDataUrl,
|
|
45
62
|
allProviderIds,
|
|
46
63
|
getProviderDescriptors,
|
|
47
64
|
getProviderDescriptor,
|
|
65
|
+
DEFAULT_MODEL_CAPABILITY_CONFIG,
|
|
48
66
|
callProviderCompletion,
|
|
49
67
|
callProxiedCompletion,
|
|
68
|
+
callProviderImageGeneration,
|
|
69
|
+
callProxiedImageGeneration,
|
|
70
|
+
callProviderListModels,
|
|
71
|
+
callProxiedListModels,
|
|
50
72
|
IProviderCompletionParams,
|
|
73
|
+
IProviderImageGenerationParams,
|
|
74
|
+
IProviderListModelsParams,
|
|
75
|
+
callProviderCompletionStream,
|
|
76
|
+
callProxiedCompletionStream,
|
|
77
|
+
IProviderCompletionStreamParams,
|
|
51
78
|
aiProviderId,
|
|
52
79
|
aiServerToolType,
|
|
53
80
|
aiWebSearchToolConfig,
|
|
@@ -74,6 +101,25 @@ declare const aiAssistProviderConfig: Converter<IAiAssistProviderConfig>;
|
|
|
74
101
|
*/
|
|
75
102
|
declare const aiAssistSettings: Converter<IAiAssistSettings>;
|
|
76
103
|
|
|
104
|
+
/**
|
|
105
|
+
* API format categories for image-generation provider routing.
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
declare type AiImageApiFormat = 'openai-images' | 'gemini-imagen' | 'xai-images';
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Capability vocabulary used to describe what a model can do. Used as both
|
|
112
|
+
* a filter and as a tag in {@link AiAssist.IAiModelInfo.capabilities}.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* Adding a new capability is cheap; adding the *first* one after consumers
|
|
116
|
+
* already exist forces churn. The initial vocabulary is intentionally broad
|
|
117
|
+
* even though only `image-generation` is fully exercised today.
|
|
118
|
+
*
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
declare type AiModelCapability = 'chat' | 'tools' | 'vision' | 'image-generation';
|
|
122
|
+
|
|
77
123
|
/**
|
|
78
124
|
* A structured AI prompt with system/user split for direct API calls,
|
|
79
125
|
* and a lazily-constructed combined version for copy/paste workflows.
|
|
@@ -84,8 +130,18 @@ declare class AiPrompt {
|
|
|
84
130
|
readonly system: string;
|
|
85
131
|
/** User request: the specific entity generation request. */
|
|
86
132
|
readonly user: string;
|
|
87
|
-
|
|
88
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Optional image attachments. When present, vision-capable providers will
|
|
135
|
+
* include them in the user message; non-vision providers will reject the
|
|
136
|
+
* call up front (see {@link AiAssist.IAiProviderDescriptor.acceptsImageInput}).
|
|
137
|
+
*/
|
|
138
|
+
readonly attachments: ReadonlyArray<IAiImageAttachment>;
|
|
139
|
+
constructor(user: string, system: string, attachments?: ReadonlyArray<IAiImageAttachment>);
|
|
140
|
+
/**
|
|
141
|
+
* Combined single-string version (user + system joined) for copy/paste.
|
|
142
|
+
* When attachments are present, includes a sentinel noting they aren't
|
|
143
|
+
* part of the copied text.
|
|
144
|
+
*/
|
|
89
145
|
get combined(): string;
|
|
90
146
|
}
|
|
91
147
|
|
|
@@ -137,12 +193,30 @@ declare const aiToolEnablement: Converter<IAiToolEnablement>;
|
|
|
137
193
|
*/
|
|
138
194
|
declare const aiWebSearchToolConfig: Converter<IAiWebSearchToolConfig>;
|
|
139
195
|
|
|
196
|
+
/**
|
|
197
|
+
* All valid key pair algorithms.
|
|
198
|
+
* @public
|
|
199
|
+
*/
|
|
200
|
+
declare const allKeyPairAlgorithms: ReadonlyArray<KeyPairAlgorithm>;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* All valid asymmetric secret types.
|
|
204
|
+
* @public
|
|
205
|
+
*/
|
|
206
|
+
declare const allKeyStoreAsymmetricSecretTypes: ReadonlyArray<KeyStoreAsymmetricSecretType>;
|
|
207
|
+
|
|
140
208
|
/**
|
|
141
209
|
* All valid key store secret types.
|
|
142
210
|
* @public
|
|
143
211
|
*/
|
|
144
212
|
declare const allKeyStoreSecretTypes: ReadonlyArray<KeyStoreSecretType>;
|
|
145
213
|
|
|
214
|
+
/**
|
|
215
|
+
* All valid symmetric secret types.
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
218
|
+
declare const allKeyStoreSymmetricSecretTypes: ReadonlyArray<KeyStoreSymmetricSecretType>;
|
|
219
|
+
|
|
146
220
|
/**
|
|
147
221
|
* All valid {@link ModelSpecKey} values.
|
|
148
222
|
* @public
|
|
@@ -180,6 +254,55 @@ declare const base64String: Converter<string>;
|
|
|
180
254
|
*/
|
|
181
255
|
declare function callProviderCompletion(params: IProviderCompletionParams): Promise<Result<IAiCompletionResponse>>;
|
|
182
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Calls the appropriate streaming chat completion API for a given provider.
|
|
259
|
+
*
|
|
260
|
+
* @remarks
|
|
261
|
+
* Pre-flight rejection: when `descriptor.streamingCorsRestricted === true`
|
|
262
|
+
* and the call isn't being routed through a proxy, this returns
|
|
263
|
+
* `Result.fail` before fetch is invoked. Callers should route through
|
|
264
|
+
* {@link AiAssist.callProxiedCompletionStream} or surface the failure to the user.
|
|
265
|
+
*
|
|
266
|
+
* Connection-time failures (auth, network, non-2xx) surface as the outer
|
|
267
|
+
* `Result.fail`. Once iteration begins, errors mid-stream surface as a
|
|
268
|
+
* terminal error event ({@link AiAssist.IAiStreamError}) followed by the iterable
|
|
269
|
+
* ending. The final successful event is {@link AiAssist.IAiStreamDone}.
|
|
270
|
+
*
|
|
271
|
+
* @param params - Request parameters including descriptor, API key, prompt, and optional tools
|
|
272
|
+
* @returns A streaming iterable of unified events, or a Result.fail
|
|
273
|
+
* @public
|
|
274
|
+
*/
|
|
275
|
+
declare function callProviderCompletionStream(params: IProviderCompletionStreamParams): Promise<Result<AsyncIterable<IAiStreamEvent>>>;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Calls the appropriate image-generation API for a given provider.
|
|
279
|
+
*
|
|
280
|
+
* Routes based on `descriptor.imageApiFormat`:
|
|
281
|
+
* - `'openai-images'` for OpenAI (DALL-E, gpt-image-1)
|
|
282
|
+
* - `'xai-images'` for xAI Grok image models
|
|
283
|
+
* - `'gemini-imagen'` for Google Imagen
|
|
284
|
+
*
|
|
285
|
+
* Image-model selection reuses the existing `'image'` {@link ModelSpecKey}.
|
|
286
|
+
*
|
|
287
|
+
* @param params - Request parameters including descriptor, API key, and prompt
|
|
288
|
+
* @returns The generated images, or a failure
|
|
289
|
+
* @public
|
|
290
|
+
*/
|
|
291
|
+
declare function callProviderImageGeneration(params: IProviderImageGenerationParams): Promise<Result<IAiImageGenerationResponse>>;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Lists models available from a provider, with capabilities resolved from
|
|
295
|
+
* native provider info (where supplied) and a configurable rule set.
|
|
296
|
+
*
|
|
297
|
+
* Routes based on `descriptor.apiFormat` — listing reuses the existing
|
|
298
|
+
* format dispatch and does not require a separate descriptor field.
|
|
299
|
+
*
|
|
300
|
+
* @param params - Request parameters including descriptor, API key, and optional capability filter
|
|
301
|
+
* @returns The resolved model list, or a failure
|
|
302
|
+
* @public
|
|
303
|
+
*/
|
|
304
|
+
declare function callProviderListModels(params: IProviderListModelsParams): Promise<Result<ReadonlyArray<IAiModelInfo>>>;
|
|
305
|
+
|
|
183
306
|
/**
|
|
184
307
|
* Calls the AI completion endpoint on a proxy server instead of calling
|
|
185
308
|
* the provider API directly from the browser.
|
|
@@ -195,6 +318,68 @@ declare function callProviderCompletion(params: IProviderCompletionParams): Prom
|
|
|
195
318
|
*/
|
|
196
319
|
declare function callProxiedCompletion(proxyUrl: string, params: IProviderCompletionParams): Promise<Result<IAiCompletionResponse>>;
|
|
197
320
|
|
|
321
|
+
/**
|
|
322
|
+
* Calls the streaming chat endpoint on a proxy server instead of calling
|
|
323
|
+
* the provider directly from the browser.
|
|
324
|
+
*
|
|
325
|
+
* @remarks
|
|
326
|
+
* Proxy contract:
|
|
327
|
+
* - Endpoint: `POST ${proxyUrl}/api/ai/completion-stream`
|
|
328
|
+
* - Request body: same JSON as `/api/ai/completion` plus `"stream": true`
|
|
329
|
+
* - Response: `Content-Type: text/event-stream`; body is the unified
|
|
330
|
+
* {@link AiAssist.IAiStreamEvent} JSON-serialized one event per SSE `data:` line
|
|
331
|
+
* (no `event:` line needed since the type discriminator is in the JSON).
|
|
332
|
+
* - Error response (when the proxy can't even start): JSON `{error: string}`
|
|
333
|
+
* with a non-2xx status, surfaced as `proxy: ${error}`.
|
|
334
|
+
*
|
|
335
|
+
* The proxy server is responsible for opening the upstream SSE connection,
|
|
336
|
+
* translating provider-native events to the unified vocabulary, and
|
|
337
|
+
* forwarding events as they arrive (no buffering). The library does not
|
|
338
|
+
* ship a proxy implementation.
|
|
339
|
+
*
|
|
340
|
+
* @public
|
|
341
|
+
*/
|
|
342
|
+
declare function callProxiedCompletionStream(proxyUrl: string, params: IProviderCompletionStreamParams): Promise<Result<AsyncIterable<IAiStreamEvent>>>;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Calls the image-generation endpoint on a proxy server instead of calling
|
|
346
|
+
* the provider API directly from the browser.
|
|
347
|
+
*
|
|
348
|
+
* @remarks
|
|
349
|
+
* The proxy contract:
|
|
350
|
+
* - Endpoint: `POST ${proxyUrl}/api/ai/image-generation`
|
|
351
|
+
* - Request body: `{providerId, apiKey, params, modelOverride?}`
|
|
352
|
+
* - Success response body: an {@link IAiImageGenerationResponse}
|
|
353
|
+
* - Error response body: `{error: string}` (surfaced as `proxy: ${error}`)
|
|
354
|
+
*
|
|
355
|
+
* The proxy server is responsible for descriptor lookup, model resolution,
|
|
356
|
+
* provider dispatch, and response normalization.
|
|
357
|
+
*
|
|
358
|
+
* @param proxyUrl - Base URL of the proxy server (e.g. `http://localhost:3001`)
|
|
359
|
+
* @param params - Same parameters as {@link callProviderImageGeneration}
|
|
360
|
+
* @returns The generated images, or a failure
|
|
361
|
+
* @public
|
|
362
|
+
*/
|
|
363
|
+
declare function callProxiedImageGeneration(proxyUrl: string, params: IProviderImageGenerationParams): Promise<Result<IAiImageGenerationResponse>>;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Calls the model-listing endpoint on a proxy server.
|
|
367
|
+
*
|
|
368
|
+
* @remarks
|
|
369
|
+
* Proxy contract:
|
|
370
|
+
* - Endpoint: `POST ${proxyUrl}/api/ai/list-models`
|
|
371
|
+
* - Request body: `{providerId, apiKey, capability?}`. Capability config is
|
|
372
|
+
* not forwarded — the proxy applies its own (typically the same default
|
|
373
|
+
* the library ships).
|
|
374
|
+
* - Success response body: an `IAiModelInfo[]` (under key `models`) where
|
|
375
|
+
* `capabilities` is serialized as a string array (not Set, which doesn't
|
|
376
|
+
* round-trip through JSON).
|
|
377
|
+
* - Error response body: `{error: string}`, surfaced as `proxy: ${error}`.
|
|
378
|
+
*
|
|
379
|
+
* @public
|
|
380
|
+
*/
|
|
381
|
+
declare function callProxiedListModels(proxyUrl: string, params: IProviderListModelsParams): Promise<Result<ReadonlyArray<IAiModelInfo>>>;
|
|
382
|
+
|
|
198
383
|
declare namespace Constants {
|
|
199
384
|
export {
|
|
200
385
|
ENCRYPTED_FILE_FORMAT,
|
|
@@ -221,6 +406,12 @@ declare namespace Converters_2 {
|
|
|
221
406
|
export {
|
|
222
407
|
keystoreFormat,
|
|
223
408
|
keystoreSecretType,
|
|
409
|
+
keystoreSymmetricSecretType,
|
|
410
|
+
keystoreAsymmetricSecretType,
|
|
411
|
+
keyPairAlgorithm,
|
|
412
|
+
jsonWebKeyShape,
|
|
413
|
+
keystoreSymmetricEntryJson,
|
|
414
|
+
keystoreAsymmetricEntryJson,
|
|
224
415
|
keystoreSecretEntryJson,
|
|
225
416
|
keystoreVaultContents,
|
|
226
417
|
keystoreFile
|
|
@@ -273,6 +464,8 @@ declare namespace CryptoUtils {
|
|
|
273
464
|
Converters_3 as Converters,
|
|
274
465
|
DirectEncryptionProvider,
|
|
275
466
|
IDirectEncryptionProviderParams,
|
|
467
|
+
IKeyPairAlgorithmParams,
|
|
468
|
+
keyPairAlgorithmParams,
|
|
276
469
|
NodeCryptoProvider,
|
|
277
470
|
nodeCryptoProvider,
|
|
278
471
|
createEncryptedFile,
|
|
@@ -286,6 +479,8 @@ declare namespace CryptoUtils {
|
|
|
286
479
|
EncryptedFileFormat,
|
|
287
480
|
INamedSecret,
|
|
288
481
|
IEncryptionResult,
|
|
482
|
+
KeyPairAlgorithm,
|
|
483
|
+
allKeyPairAlgorithms,
|
|
289
484
|
KeyDerivationFunction,
|
|
290
485
|
IKeyDerivationParams,
|
|
291
486
|
IEncryptedFile,
|
|
@@ -347,6 +542,16 @@ declare const DEFAULT_ALGORITHM: "AES-256-GCM";
|
|
|
347
542
|
*/
|
|
348
543
|
declare const DEFAULT_KEYSTORE_ITERATIONS: number;
|
|
349
544
|
|
|
545
|
+
/**
|
|
546
|
+
* Default capability config used by `callProviderListModels` when callers
|
|
547
|
+
* don't supply their own. Patterns are intentionally narrow — false
|
|
548
|
+
* positives are worse than missing a model. Caller can override per call
|
|
549
|
+
* via {@link IProviderListModelsParams.capabilityConfig}.
|
|
550
|
+
*
|
|
551
|
+
* @public
|
|
552
|
+
*/
|
|
553
|
+
declare const DEFAULT_MODEL_CAPABILITY_CONFIG: IAiModelCapabilityConfig;
|
|
554
|
+
|
|
350
555
|
/**
|
|
351
556
|
* Default {@link Experimental.RangeOfFormats | formats} to use for both
|
|
352
557
|
* open-ended and complete {@link Experimental.RangeOf | RangeOf<T>}.
|
|
@@ -534,7 +739,7 @@ declare class ExtendedArray<T> extends Array<T> {
|
|
|
534
739
|
* If `onError` is `'failOnError'` (default), then the entire conversion fails if any element cannot
|
|
535
740
|
* be converted. If `onError` is `'ignoreErrors'`, then failing elements are silently ignored.
|
|
536
741
|
* @param converter - `Converter` used to convert each item in the array
|
|
537
|
-
* @param
|
|
742
|
+
* @param onError - Specifies treatment of unconvertible elements
|
|
538
743
|
* @beta
|
|
539
744
|
*/
|
|
540
745
|
declare function extendedArrayOf<T, TC = undefined>(label: string, converter: Converter<T, TC>, onError?: Conversion.OnError): Converter<ExtendedArray<T>, TC>;
|
|
@@ -652,6 +857,50 @@ declare namespace Hash {
|
|
|
652
857
|
}
|
|
653
858
|
export { Hash }
|
|
654
859
|
|
|
860
|
+
/**
|
|
861
|
+
* Options for adding an asymmetric keypair to the key store.
|
|
862
|
+
* @public
|
|
863
|
+
*/
|
|
864
|
+
declare interface IAddKeyPairOptions {
|
|
865
|
+
/**
|
|
866
|
+
* Algorithm to use for the new keypair.
|
|
867
|
+
*/
|
|
868
|
+
readonly algorithm: KeyPairAlgorithm;
|
|
869
|
+
/**
|
|
870
|
+
* Optional description for the entry.
|
|
871
|
+
*/
|
|
872
|
+
readonly description?: string;
|
|
873
|
+
/**
|
|
874
|
+
* Whether to replace an existing entry with the same name.
|
|
875
|
+
* Replacement mints a fresh storage `id` and best-effort deletes the
|
|
876
|
+
* displaced storage blob; see the keystore design doc for details.
|
|
877
|
+
*/
|
|
878
|
+
readonly replace?: boolean;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Result of adding an asymmetric keypair to the key store.
|
|
883
|
+
* @public
|
|
884
|
+
*/
|
|
885
|
+
declare interface IAddKeyPairResult {
|
|
886
|
+
/**
|
|
887
|
+
* The asymmetric entry that was added.
|
|
888
|
+
*/
|
|
889
|
+
readonly entry: IKeyStoreAsymmetricEntry;
|
|
890
|
+
/**
|
|
891
|
+
* Whether this replaced an existing entry.
|
|
892
|
+
*/
|
|
893
|
+
readonly replaced: boolean;
|
|
894
|
+
/**
|
|
895
|
+
* Best-effort warning from displaced-resource cleanup. Set when this call
|
|
896
|
+
* replaced a prior entry but the corresponding
|
|
897
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage}.delete failed; the new
|
|
898
|
+
* keypair is still committed and the orphaned blob is left for consumer-side
|
|
899
|
+
* GC to reconcile.
|
|
900
|
+
*/
|
|
901
|
+
readonly warning?: string;
|
|
902
|
+
}
|
|
903
|
+
|
|
655
904
|
/**
|
|
656
905
|
* Options for adding a secret derived from a password.
|
|
657
906
|
* @public
|
|
@@ -702,11 +951,19 @@ declare interface IAddSecretResult {
|
|
|
702
951
|
/**
|
|
703
952
|
* The secret entry that was added.
|
|
704
953
|
*/
|
|
705
|
-
readonly entry:
|
|
954
|
+
readonly entry: IKeyStoreSymmetricEntry;
|
|
706
955
|
/**
|
|
707
956
|
* Whether this replaced an existing secret.
|
|
708
957
|
*/
|
|
709
958
|
readonly replaced: boolean;
|
|
959
|
+
/**
|
|
960
|
+
* Best-effort warning from displaced-resource cleanup. Set when this call
|
|
961
|
+
* replaced an asymmetric-keypair entry but the corresponding
|
|
962
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage}.delete failed; the new
|
|
963
|
+
* entry is still committed and the orphaned blob is left for consumer-side
|
|
964
|
+
* GC to reconcile.
|
|
965
|
+
*/
|
|
966
|
+
readonly warning?: string;
|
|
710
967
|
}
|
|
711
968
|
|
|
712
969
|
/**
|
|
@@ -764,6 +1021,162 @@ declare interface IAiCompletionResponse {
|
|
|
764
1021
|
readonly truncated: boolean;
|
|
765
1022
|
}
|
|
766
1023
|
|
|
1024
|
+
/**
|
|
1025
|
+
* A single generated image.
|
|
1026
|
+
* @public
|
|
1027
|
+
*/
|
|
1028
|
+
declare interface IAiGeneratedImage extends IAiImageData {
|
|
1029
|
+
/**
|
|
1030
|
+
* The prompt as rewritten by the provider, if any. OpenAI's image models
|
|
1031
|
+
* commonly rewrite prompts; other providers do not.
|
|
1032
|
+
*/
|
|
1033
|
+
readonly revisedPrompt?: string;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
/**
|
|
1037
|
+
* Image attachment for a vision (image-input) prompt.
|
|
1038
|
+
*
|
|
1039
|
+
* @remarks
|
|
1040
|
+
* Extends {@link IAiImageData} with an OpenAI-specific `detail` hint that is
|
|
1041
|
+
* silently ignored by Anthropic, Gemini, and other providers.
|
|
1042
|
+
*
|
|
1043
|
+
* @public
|
|
1044
|
+
*/
|
|
1045
|
+
declare interface IAiImageAttachment extends IAiImageData {
|
|
1046
|
+
/**
|
|
1047
|
+
* OpenAI vision detail hint:
|
|
1048
|
+
* - `'low'`: faster, cheaper, lower fidelity
|
|
1049
|
+
* - `'high'`: slower, more expensive, higher fidelity
|
|
1050
|
+
* - `'auto'` (default): provider chooses
|
|
1051
|
+
*
|
|
1052
|
+
* Ignored by providers other than OpenAI.
|
|
1053
|
+
*/
|
|
1054
|
+
readonly detail?: 'low' | 'high' | 'auto';
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* Universal image representation used for both image input (vision prompts)
|
|
1059
|
+
* and image output (generation responses).
|
|
1060
|
+
*
|
|
1061
|
+
* @remarks
|
|
1062
|
+
* The base64 string is raw — no `data:` URL prefix. Use {@link AiAssist.toDataUrl} to
|
|
1063
|
+
* format it for browser-display contexts.
|
|
1064
|
+
*
|
|
1065
|
+
* @public
|
|
1066
|
+
*/
|
|
1067
|
+
declare interface IAiImageData {
|
|
1068
|
+
/** MIME type, e.g. `'image/png'`, `'image/jpeg'`, `'image/webp'`. */
|
|
1069
|
+
readonly mimeType: string;
|
|
1070
|
+
/** Base64-encoded image bytes (no `data:` prefix). */
|
|
1071
|
+
readonly base64: string;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* Options for image generation requests.
|
|
1076
|
+
*
|
|
1077
|
+
* @remarks
|
|
1078
|
+
* Provider compatibility is documented per field. The library does not
|
|
1079
|
+
* pre-validate against per-model constraints (e.g. `dall-e-3` rejects
|
|
1080
|
+
* `count > 1`); provider 400 errors surface through the failure path.
|
|
1081
|
+
*
|
|
1082
|
+
* @public
|
|
1083
|
+
*/
|
|
1084
|
+
declare interface IAiImageGenerationOptions {
|
|
1085
|
+
/**
|
|
1086
|
+
* Image dimensions. Used by openai-format providers (mapped to the
|
|
1087
|
+
* provider's `size` field). Ignored by Imagen — use
|
|
1088
|
+
* {@link IAiImageGenerationOptions.imagen} `aspectRatio` instead.
|
|
1089
|
+
*
|
|
1090
|
+
* Note: each model has its own accepted set; `dall-e-3` only accepts the
|
|
1091
|
+
* values listed here.
|
|
1092
|
+
*/
|
|
1093
|
+
readonly size?: '1024x1024' | '1024x1792' | '1792x1024' | 'auto';
|
|
1094
|
+
/**
|
|
1095
|
+
* Number of images to generate. Default 1.
|
|
1096
|
+
*
|
|
1097
|
+
* Note: `dall-e-3` rejects `count > 1`.
|
|
1098
|
+
*/
|
|
1099
|
+
readonly count?: number;
|
|
1100
|
+
/** Generation quality hint where supported. */
|
|
1101
|
+
readonly quality?: 'standard' | 'high';
|
|
1102
|
+
/** Random seed for reproducibility, where supported. */
|
|
1103
|
+
readonly seed?: number;
|
|
1104
|
+
/**
|
|
1105
|
+
* Imagen-specific options. Ignored by other providers.
|
|
1106
|
+
*/
|
|
1107
|
+
readonly imagen?: {
|
|
1108
|
+
readonly negativePrompt?: string;
|
|
1109
|
+
readonly aspectRatio?: '1:1' | '3:4' | '4:3' | '9:16' | '16:9';
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* Parameters for an image-generation request.
|
|
1115
|
+
* @public
|
|
1116
|
+
*/
|
|
1117
|
+
declare interface IAiImageGenerationParams {
|
|
1118
|
+
/** The text prompt describing the desired image. */
|
|
1119
|
+
readonly prompt: string;
|
|
1120
|
+
/** Optional generation options. */
|
|
1121
|
+
readonly options?: IAiImageGenerationOptions;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* Result of an image-generation call.
|
|
1126
|
+
* @public
|
|
1127
|
+
*/
|
|
1128
|
+
declare interface IAiImageGenerationResponse {
|
|
1129
|
+
/** The generated images, in provider-returned order. */
|
|
1130
|
+
readonly images: ReadonlyArray<IAiGeneratedImage>;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* Configuration that maps model id patterns to capabilities. Used to
|
|
1135
|
+
* augment (or, where the provider supplies no capability info, fully
|
|
1136
|
+
* derive) the capability set for each listed model.
|
|
1137
|
+
* @public
|
|
1138
|
+
*/
|
|
1139
|
+
declare interface IAiModelCapabilityConfig {
|
|
1140
|
+
/** Per-provider rules. Tried before {@link AiAssist.IAiModelCapabilityConfig.global}. */
|
|
1141
|
+
readonly perProvider?: {
|
|
1142
|
+
readonly [P in AiProviderId]?: ReadonlyArray<IAiModelCapabilityRule>;
|
|
1143
|
+
};
|
|
1144
|
+
/** Cross-provider fallback rules. */
|
|
1145
|
+
readonly global?: ReadonlyArray<IAiModelCapabilityRule>;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* One rule in an {@link IAiModelCapabilityConfig}. Multiple rules can match
|
|
1150
|
+
* a single model — their capability arrays are unioned.
|
|
1151
|
+
* @public
|
|
1152
|
+
*/
|
|
1153
|
+
declare interface IAiModelCapabilityRule {
|
|
1154
|
+
/** RegExp tested against the model id (using `.test`). */
|
|
1155
|
+
readonly idPattern: RegExp;
|
|
1156
|
+
/** Capabilities this rule attributes to matching models. */
|
|
1157
|
+
readonly capabilities: ReadonlyArray<AiModelCapability>;
|
|
1158
|
+
/**
|
|
1159
|
+
* Friendly display-name override for matching models. The function form
|
|
1160
|
+
* lets one rule format many ids (e.g. `(id) => id.toUpperCase()`).
|
|
1161
|
+
* If multiple matching rules supply `displayName`, the first match wins.
|
|
1162
|
+
*/
|
|
1163
|
+
readonly displayName?: string | ((id: string) => string);
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* Information about a single model returned by a provider's list endpoint,
|
|
1168
|
+
* with capabilities already resolved (native + config rules).
|
|
1169
|
+
* @public
|
|
1170
|
+
*/
|
|
1171
|
+
declare interface IAiModelInfo {
|
|
1172
|
+
/** Provider-native model identifier. */
|
|
1173
|
+
readonly id: string;
|
|
1174
|
+
/** Resolved capability set — union of native declarations and config rules. */
|
|
1175
|
+
readonly capabilities: ReadonlySet<AiModelCapability>;
|
|
1176
|
+
/** Friendly name for display, when known. */
|
|
1177
|
+
readonly displayName?: string;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
767
1180
|
/**
|
|
768
1181
|
* Describes a single AI provider — single source of truth for all metadata.
|
|
769
1182
|
* @public
|
|
@@ -787,6 +1200,99 @@ declare interface IAiProviderDescriptor {
|
|
|
787
1200
|
readonly supportedTools: ReadonlyArray<AiServerToolType>;
|
|
788
1201
|
/** Whether this provider's API enforces CORS restrictions that prevent direct browser calls. */
|
|
789
1202
|
readonly corsRestricted: boolean;
|
|
1203
|
+
/**
|
|
1204
|
+
* Whether this provider's streaming completion endpoint requires a proxy
|
|
1205
|
+
* for direct browser calls. Some providers gate streaming separately from
|
|
1206
|
+
* non-streaming (rare), so this is tracked independently from
|
|
1207
|
+
* {@link IAiProviderDescriptor.corsRestricted}.
|
|
1208
|
+
*
|
|
1209
|
+
* @remarks
|
|
1210
|
+
* When `true`, `callProviderCompletionStream` rejects up front unless the
|
|
1211
|
+
* call is being routed through a proxy.
|
|
1212
|
+
*/
|
|
1213
|
+
readonly streamingCorsRestricted: boolean;
|
|
1214
|
+
/**
|
|
1215
|
+
* Whether this provider's chat completions API accepts image input
|
|
1216
|
+
* (i.e. supports vision prompts). When false, calls with
|
|
1217
|
+
* `prompt.attachments` are rejected up front.
|
|
1218
|
+
*/
|
|
1219
|
+
readonly acceptsImageInput: boolean;
|
|
1220
|
+
/**
|
|
1221
|
+
* Which image-generation API format this provider uses, or undefined if it
|
|
1222
|
+
* does not support image generation.
|
|
1223
|
+
*
|
|
1224
|
+
* @remarks
|
|
1225
|
+
* Image-model selection reuses the existing `image` {@link ModelSpecKey}.
|
|
1226
|
+
* Providers with `imageApiFormat` set should declare a model in
|
|
1227
|
+
* `defaultModel.image`, e.g. `{ base: 'gpt-4o', image: 'dall-e-3' }`.
|
|
1228
|
+
*/
|
|
1229
|
+
readonly imageApiFormat?: AiImageApiFormat;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
/**
|
|
1233
|
+
* Terminal success event for a streaming completion. Carries the aggregated
|
|
1234
|
+
* full text and truncation status for callers that want both the progressive
|
|
1235
|
+
* UI and the complete result.
|
|
1236
|
+
* @public
|
|
1237
|
+
*/
|
|
1238
|
+
declare interface IAiStreamDone {
|
|
1239
|
+
readonly type: 'done';
|
|
1240
|
+
/** Whether the response was truncated due to token limits. */
|
|
1241
|
+
readonly truncated: boolean;
|
|
1242
|
+
/** The full concatenated text from all `text-delta` events. */
|
|
1243
|
+
readonly fullText: string;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* Terminal failure event for a streaming completion. After this event no
|
|
1248
|
+
* further events are emitted.
|
|
1249
|
+
*
|
|
1250
|
+
* @remarks
|
|
1251
|
+
* Connection-time failures (auth, network, pre-flight CORS rejection) are
|
|
1252
|
+
* surfaced via the outer `Result.fail` returned by
|
|
1253
|
+
* `callProviderCompletionStream` rather than as an `error` event, so callers
|
|
1254
|
+
* can distinguish "didn't start" from "started but errored mid-stream."
|
|
1255
|
+
*
|
|
1256
|
+
* @public
|
|
1257
|
+
*/
|
|
1258
|
+
declare interface IAiStreamError {
|
|
1259
|
+
readonly type: 'error';
|
|
1260
|
+
readonly message: string;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* Discriminated union of events emitted by a streaming completion.
|
|
1265
|
+
* @public
|
|
1266
|
+
*/
|
|
1267
|
+
declare type IAiStreamEvent = IAiStreamTextDelta | IAiStreamToolEvent | IAiStreamDone | IAiStreamError;
|
|
1268
|
+
|
|
1269
|
+
/**
|
|
1270
|
+
* A text-content delta arriving during a streaming completion.
|
|
1271
|
+
* @public
|
|
1272
|
+
*/
|
|
1273
|
+
declare interface IAiStreamTextDelta {
|
|
1274
|
+
readonly type: 'text-delta';
|
|
1275
|
+
/** The newly arrived text fragment. */
|
|
1276
|
+
readonly delta: string;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* A server-side tool progress event arriving during a streaming completion.
|
|
1281
|
+
* Surfaced for providers that emit explicit tool-progress markers (OpenAI
|
|
1282
|
+
* Responses API, Anthropic). Gemini's grounding doesn't emit these.
|
|
1283
|
+
* @public
|
|
1284
|
+
*/
|
|
1285
|
+
declare interface IAiStreamToolEvent {
|
|
1286
|
+
readonly type: 'tool-event';
|
|
1287
|
+
/** Which server-side tool this event describes. */
|
|
1288
|
+
readonly toolType: AiServerToolType;
|
|
1289
|
+
/** Tool lifecycle phase. */
|
|
1290
|
+
readonly phase: 'started' | 'completed';
|
|
1291
|
+
/**
|
|
1292
|
+
* Optional provider-specific detail. For web_search this is typically the
|
|
1293
|
+
* search query when available; format varies by provider.
|
|
1294
|
+
*/
|
|
1295
|
+
readonly detail?: string;
|
|
790
1296
|
}
|
|
791
1297
|
|
|
792
1298
|
/**
|
|
@@ -963,6 +1469,32 @@ declare interface ICryptoProvider {
|
|
|
963
1469
|
* @returns Success with decoded bytes, or Failure if invalid base64
|
|
964
1470
|
*/
|
|
965
1471
|
fromBase64(base64: string): Result<Uint8Array>;
|
|
1472
|
+
/**
|
|
1473
|
+
* Generates a new asymmetric keypair for the requested algorithm.
|
|
1474
|
+
* @param algorithm - The {@link CryptoUtils.KeyPairAlgorithm | algorithm} to use.
|
|
1475
|
+
* @param extractable - Whether the resulting `CryptoKey` objects may be exported.
|
|
1476
|
+
* Set `false` on backends that store `CryptoKey` references directly (e.g.
|
|
1477
|
+
* IndexedDB). Set `true` when the private key must round-trip through JWK or
|
|
1478
|
+
* PKCS#8 (e.g. encrypted-file backends).
|
|
1479
|
+
* @returns Success with the generated `CryptoKeyPair`, or Failure with error context.
|
|
1480
|
+
*/
|
|
1481
|
+
generateKeyPair(algorithm: KeyPairAlgorithm, extractable: boolean): Promise<Result<CryptoKeyPair>>;
|
|
1482
|
+
/**
|
|
1483
|
+
* Exports the public half of a keypair as a JSON Web Key.
|
|
1484
|
+
* @param publicKey - The public `CryptoKey` to export. Must be an `extractable`
|
|
1485
|
+
* key generated for an asymmetric algorithm.
|
|
1486
|
+
* @returns Success with the JWK, or Failure with error context.
|
|
1487
|
+
*/
|
|
1488
|
+
exportPublicKeyJwk(publicKey: CryptoKey): Promise<Result<JsonWebKey>>;
|
|
1489
|
+
/**
|
|
1490
|
+
* Re-imports a public-key JWK as a `CryptoKey` usable for verification or
|
|
1491
|
+
* encryption (depending on algorithm).
|
|
1492
|
+
* @param jwk - The JSON Web Key produced by {@link CryptoUtils.ICryptoProvider.exportPublicKeyJwk | exportPublicKeyJwk}.
|
|
1493
|
+
* @param algorithm - The {@link CryptoUtils.KeyPairAlgorithm | algorithm} the
|
|
1494
|
+
* key was generated for. Determines the import parameters and key usages.
|
|
1495
|
+
* @returns Success with the imported public `CryptoKey`, or Failure with error context.
|
|
1496
|
+
*/
|
|
1497
|
+
importPublicKeyJwk(jwk: JsonWebKey, algorithm: KeyPairAlgorithm): Promise<Result<CryptoKey>>;
|
|
966
1498
|
}
|
|
967
1499
|
|
|
968
1500
|
/**
|
|
@@ -1108,10 +1640,10 @@ declare interface IEncryptionResult {
|
|
|
1108
1640
|
*/
|
|
1109
1641
|
declare interface IImportKeyOptions extends IImportSecretOptions {
|
|
1110
1642
|
/**
|
|
1111
|
-
*
|
|
1643
|
+
* Symmetric secret type classification for the imported key material.
|
|
1112
1644
|
* @defaultValue 'encryption-key'
|
|
1113
1645
|
*/
|
|
1114
|
-
readonly type?:
|
|
1646
|
+
readonly type?: KeyStoreSymmetricSecretType;
|
|
1115
1647
|
}
|
|
1116
1648
|
|
|
1117
1649
|
/**
|
|
@@ -1145,6 +1677,111 @@ declare interface IKeyDerivationParams {
|
|
|
1145
1677
|
readonly iterations: number;
|
|
1146
1678
|
}
|
|
1147
1679
|
|
|
1680
|
+
/**
|
|
1681
|
+
* WebCrypto parameters for a single {@link CryptoUtils.KeyPairAlgorithm}.
|
|
1682
|
+
* Implementations of {@link CryptoUtils.ICryptoProvider} use this table to
|
|
1683
|
+
* translate the small public algorithm enum into the WebCrypto algorithm
|
|
1684
|
+
* objects and key-usage arrays expected by `crypto.subtle`.
|
|
1685
|
+
* @public
|
|
1686
|
+
*/
|
|
1687
|
+
declare interface IKeyPairAlgorithmParams {
|
|
1688
|
+
/**
|
|
1689
|
+
* Algorithm parameters for `crypto.subtle.generateKey`. Always an asymmetric
|
|
1690
|
+
* variant — these algorithms produce a `CryptoKeyPair`, not a single key.
|
|
1691
|
+
*/
|
|
1692
|
+
readonly generateKey: RsaHashedKeyGenParams | EcKeyGenParams;
|
|
1693
|
+
/**
|
|
1694
|
+
* Algorithm parameters for `crypto.subtle.importKey('jwk', ...)` when
|
|
1695
|
+
* importing the public half of a keypair.
|
|
1696
|
+
*/
|
|
1697
|
+
readonly importPublicKey: RsaHashedImportParams | EcKeyImportParams;
|
|
1698
|
+
/**
|
|
1699
|
+
* Default key usages for the generated `CryptoKeyPair`. Both halves receive
|
|
1700
|
+
* the usages WebCrypto considers valid for their role; the platform filters.
|
|
1701
|
+
*/
|
|
1702
|
+
readonly keyPairUsages: ReadonlyArray<KeyUsage>;
|
|
1703
|
+
/**
|
|
1704
|
+
* Key usages applied when re-importing only the public key.
|
|
1705
|
+
*/
|
|
1706
|
+
readonly publicKeyUsages: ReadonlyArray<KeyUsage>;
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
/**
|
|
1710
|
+
* An asymmetric keypair entry stored in the vault (in-memory representation).
|
|
1711
|
+
* Holds only the public key (as a JWK) and a stable handle (`id`) the
|
|
1712
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage} provider uses to fetch the private key.
|
|
1713
|
+
* @public
|
|
1714
|
+
*/
|
|
1715
|
+
declare interface IKeyStoreAsymmetricEntry {
|
|
1716
|
+
/**
|
|
1717
|
+
* Unique name for this entry (used as vault lookup key, renameable).
|
|
1718
|
+
*/
|
|
1719
|
+
readonly name: string;
|
|
1720
|
+
/**
|
|
1721
|
+
* Asymmetric secret type discriminator.
|
|
1722
|
+
*/
|
|
1723
|
+
readonly type: KeyStoreAsymmetricSecretType;
|
|
1724
|
+
/**
|
|
1725
|
+
* Immutable handle used by {@link CryptoUtils.KeyStore.IPrivateKeyStorage} to address the
|
|
1726
|
+
* private key. Independent of `name`; survives renames.
|
|
1727
|
+
*/
|
|
1728
|
+
readonly id: string;
|
|
1729
|
+
/**
|
|
1730
|
+
* Algorithm used to generate this keypair.
|
|
1731
|
+
*/
|
|
1732
|
+
readonly algorithm: KeyPairAlgorithm;
|
|
1733
|
+
/**
|
|
1734
|
+
* The public key as a JSON Web Key.
|
|
1735
|
+
*/
|
|
1736
|
+
readonly publicKeyJwk: JsonWebKey;
|
|
1737
|
+
/**
|
|
1738
|
+
* Optional description for this entry.
|
|
1739
|
+
*/
|
|
1740
|
+
readonly description?: string;
|
|
1741
|
+
/**
|
|
1742
|
+
* When this entry was added (ISO 8601).
|
|
1743
|
+
*/
|
|
1744
|
+
readonly createdAt: string;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* JSON-serializable representation of an asymmetric keypair entry.
|
|
1749
|
+
* The private key is not present here — it lives in the
|
|
1750
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage} provider, addressed by `id`.
|
|
1751
|
+
* @public
|
|
1752
|
+
*/
|
|
1753
|
+
declare interface IKeyStoreAsymmetricEntryJson {
|
|
1754
|
+
/**
|
|
1755
|
+
* Unique name for this entry.
|
|
1756
|
+
*/
|
|
1757
|
+
readonly name: string;
|
|
1758
|
+
/**
|
|
1759
|
+
* Asymmetric secret type discriminator.
|
|
1760
|
+
*/
|
|
1761
|
+
readonly type: KeyStoreAsymmetricSecretType;
|
|
1762
|
+
/**
|
|
1763
|
+
* Immutable handle used by {@link CryptoUtils.KeyStore.IPrivateKeyStorage} to address the
|
|
1764
|
+
* private key.
|
|
1765
|
+
*/
|
|
1766
|
+
readonly id: string;
|
|
1767
|
+
/**
|
|
1768
|
+
* Algorithm used to generate this keypair.
|
|
1769
|
+
*/
|
|
1770
|
+
readonly algorithm: KeyPairAlgorithm;
|
|
1771
|
+
/**
|
|
1772
|
+
* The public key as a JSON Web Key.
|
|
1773
|
+
*/
|
|
1774
|
+
readonly publicKeyJwk: JsonWebKey;
|
|
1775
|
+
/**
|
|
1776
|
+
* Optional description.
|
|
1777
|
+
*/
|
|
1778
|
+
readonly description?: string;
|
|
1779
|
+
/**
|
|
1780
|
+
* When this entry was added (ISO 8601).
|
|
1781
|
+
*/
|
|
1782
|
+
readonly createdAt: string;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1148
1785
|
/**
|
|
1149
1786
|
* Parameters for creating a new key store.
|
|
1150
1787
|
* @public
|
|
@@ -1158,8 +1795,26 @@ declare interface IKeyStoreCreateParams {
|
|
|
1158
1795
|
* PBKDF2 iterations (defaults to DEFAULT_KEYSTORE_ITERATIONS).
|
|
1159
1796
|
*/
|
|
1160
1797
|
readonly iterations?: number;
|
|
1798
|
+
/**
|
|
1799
|
+
* Optional private-key storage backend. Required to use `addKeyPair` /
|
|
1800
|
+
* `getKeyPair`; absent backends still permit opening, listing, and reading
|
|
1801
|
+
* public-key metadata for asymmetric entries.
|
|
1802
|
+
*/
|
|
1803
|
+
readonly privateKeyStorage?: IPrivateKeyStorage;
|
|
1161
1804
|
}
|
|
1162
1805
|
|
|
1806
|
+
/**
|
|
1807
|
+
* Any vault entry, discriminated by `type`.
|
|
1808
|
+
* @public
|
|
1809
|
+
*/
|
|
1810
|
+
declare type IKeyStoreEntry = IKeyStoreSymmetricEntry | IKeyStoreAsymmetricEntry;
|
|
1811
|
+
|
|
1812
|
+
/**
|
|
1813
|
+
* Any JSON vault entry, discriminated by `type`.
|
|
1814
|
+
* @public
|
|
1815
|
+
*/
|
|
1816
|
+
declare type IKeyStoreEntryJson = IKeyStoreSymmetricEntryJson | IKeyStoreAsymmetricEntryJson;
|
|
1817
|
+
|
|
1163
1818
|
/**
|
|
1164
1819
|
* The encrypted key store file format.
|
|
1165
1820
|
* @public
|
|
@@ -1204,22 +1859,46 @@ declare interface IKeyStoreOpenParams {
|
|
|
1204
1859
|
* The encrypted key store file content.
|
|
1205
1860
|
*/
|
|
1206
1861
|
readonly keystoreFile: IKeyStoreFile;
|
|
1862
|
+
/**
|
|
1863
|
+
* Optional private-key storage backend. Required to use `addKeyPair` /
|
|
1864
|
+
* `getKeyPair`; absent backends still permit opening, listing, and reading
|
|
1865
|
+
* public-key metadata for asymmetric entries.
|
|
1866
|
+
*/
|
|
1867
|
+
readonly privateKeyStorage?: IPrivateKeyStorage;
|
|
1207
1868
|
}
|
|
1208
1869
|
|
|
1209
1870
|
/**
|
|
1210
|
-
*
|
|
1871
|
+
* Backwards-compatible alias for {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntry}.
|
|
1872
|
+
* @deprecated Use {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntry} for symmetric
|
|
1873
|
+
* entries or {@link CryptoUtils.KeyStore.IKeyStoreEntry} for the discriminated union.
|
|
1874
|
+
* @public
|
|
1875
|
+
*/
|
|
1876
|
+
declare type IKeyStoreSecretEntry = IKeyStoreSymmetricEntry;
|
|
1877
|
+
|
|
1878
|
+
/**
|
|
1879
|
+
* Backwards-compatible alias for {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntryJson}.
|
|
1880
|
+
* @deprecated Use {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntryJson} for
|
|
1881
|
+
* symmetric entries or {@link CryptoUtils.KeyStore.IKeyStoreEntryJson} for the
|
|
1882
|
+
* discriminated union.
|
|
1211
1883
|
* @public
|
|
1212
1884
|
*/
|
|
1213
|
-
declare
|
|
1885
|
+
declare type IKeyStoreSecretEntryJson = IKeyStoreSymmetricEntryJson;
|
|
1886
|
+
|
|
1887
|
+
/**
|
|
1888
|
+
* A symmetric secret entry stored in the vault (in-memory representation).
|
|
1889
|
+
* Holds the raw key material directly — for `'encryption-key'` it is a 32-byte
|
|
1890
|
+
* AES-256 key; for `'api-key'` it is the UTF-8 encoded API key string.
|
|
1891
|
+
* @public
|
|
1892
|
+
*/
|
|
1893
|
+
declare interface IKeyStoreSymmetricEntry {
|
|
1214
1894
|
/**
|
|
1215
1895
|
* Unique name for this secret (used as lookup key).
|
|
1216
1896
|
*/
|
|
1217
1897
|
readonly name: string;
|
|
1218
1898
|
/**
|
|
1219
|
-
*
|
|
1220
|
-
* Defaults to `'encryption-key'` for backwards compatibility.
|
|
1899
|
+
* Symmetric secret type discriminator.
|
|
1221
1900
|
*/
|
|
1222
|
-
readonly type:
|
|
1901
|
+
readonly type: KeyStoreSymmetricSecretType;
|
|
1223
1902
|
/**
|
|
1224
1903
|
* The secret data.
|
|
1225
1904
|
* - For `'encryption-key'`: 32-byte AES-256 key.
|
|
@@ -1237,19 +1916,34 @@ declare interface IKeyStoreSecretEntry {
|
|
|
1237
1916
|
}
|
|
1238
1917
|
|
|
1239
1918
|
/**
|
|
1240
|
-
* JSON-serializable
|
|
1919
|
+
* JSON-serializable representation of a symmetric secret entry.
|
|
1920
|
+
*
|
|
1921
|
+
* @remarks
|
|
1922
|
+
* Describes the *normalized* shape after parsing. `type` is required here
|
|
1923
|
+
* because the converter (see
|
|
1924
|
+
* {@link CryptoUtils.KeyStore.Converters.keystoreSymmetricEntryJson | keystoreSymmetricEntryJson})
|
|
1925
|
+
* injects the default `'encryption-key'` when reading vaults written before
|
|
1926
|
+
* asymmetric-keypair support added the discriminator. Raw on-wire bytes from
|
|
1927
|
+
* a legacy vault may therefore omit `type`; downstream code only ever sees
|
|
1928
|
+
* the post-conversion shape declared here.
|
|
1929
|
+
*
|
|
1241
1930
|
* @public
|
|
1242
1931
|
*/
|
|
1243
|
-
declare interface
|
|
1932
|
+
declare interface IKeyStoreSymmetricEntryJson {
|
|
1244
1933
|
/**
|
|
1245
1934
|
* Unique name for this secret.
|
|
1246
1935
|
*/
|
|
1247
1936
|
readonly name: string;
|
|
1248
1937
|
/**
|
|
1249
|
-
*
|
|
1250
|
-
*
|
|
1938
|
+
* Symmetric secret type discriminator.
|
|
1939
|
+
*
|
|
1940
|
+
* Required on this normalized model type. Vaults written prior to the
|
|
1941
|
+
* asymmetric-keypair support may omit this field on the wire; the
|
|
1942
|
+
* converter injects `'encryption-key'` when missing for backwards
|
|
1943
|
+
* compatibility, so by the time a value of this type is observed the
|
|
1944
|
+
* discriminator is always present.
|
|
1251
1945
|
*/
|
|
1252
|
-
readonly type
|
|
1946
|
+
readonly type: KeyStoreSymmetricSecretType;
|
|
1253
1947
|
/**
|
|
1254
1948
|
* Base64-encoded secret data.
|
|
1255
1949
|
*/
|
|
@@ -1265,7 +1959,7 @@ declare interface IKeyStoreSecretEntryJson {
|
|
|
1265
1959
|
}
|
|
1266
1960
|
|
|
1267
1961
|
/**
|
|
1268
|
-
* The decrypted vault contents - a versioned map of
|
|
1962
|
+
* The decrypted vault contents - a versioned map of entries.
|
|
1269
1963
|
* @public
|
|
1270
1964
|
*/
|
|
1271
1965
|
declare interface IKeyStoreVaultContents {
|
|
@@ -1274,9 +1968,9 @@ declare interface IKeyStoreVaultContents {
|
|
|
1274
1968
|
*/
|
|
1275
1969
|
readonly version: KeyStoreFormat;
|
|
1276
1970
|
/**
|
|
1277
|
-
* Map of
|
|
1971
|
+
* Map of entry name to entry (symmetric or asymmetric).
|
|
1278
1972
|
*/
|
|
1279
|
-
readonly secrets: Record<string,
|
|
1973
|
+
readonly secrets: Record<string, IKeyStoreEntryJson>;
|
|
1280
1974
|
}
|
|
1281
1975
|
|
|
1282
1976
|
/**
|
|
@@ -1359,6 +2053,55 @@ declare interface INamedSecret {
|
|
|
1359
2053
|
readonly key: Uint8Array;
|
|
1360
2054
|
}
|
|
1361
2055
|
|
|
2056
|
+
/**
|
|
2057
|
+
* Pluggable backend that persists raw asymmetric private keys outside of the
|
|
2058
|
+
* encrypted keystore vault. Concrete implementations live in platform-specific
|
|
2059
|
+
* packages (e.g. an IndexedDB-backed implementation in `@fgv/ts-web-extras` or
|
|
2060
|
+
* an encrypted-file implementation in `@fgv/ts-chocolate`).
|
|
2061
|
+
*
|
|
2062
|
+
* The keystore writes storage-first: a private key is always stored here
|
|
2063
|
+
* before the corresponding public-key vault entry is committed. Conversely,
|
|
2064
|
+
* deletes hit the vault first and then this storage best-effort. As a result,
|
|
2065
|
+
* crashes or skipped saves can leave orphaned blobs here; callers are expected
|
|
2066
|
+
* to reconcile via {@link CryptoUtils.KeyStore.IPrivateKeyStorage.list} cross-referenced
|
|
2067
|
+
* against the keystore's asymmetric entries.
|
|
2068
|
+
*
|
|
2069
|
+
* @public
|
|
2070
|
+
*/
|
|
2071
|
+
declare interface IPrivateKeyStorage {
|
|
2072
|
+
/**
|
|
2073
|
+
* Whether keys generated for this backend may be marked
|
|
2074
|
+
* `extractable: false`. `true` on backends that store `CryptoKey`
|
|
2075
|
+
* objects directly (e.g. IndexedDB). `false` on backends that must
|
|
2076
|
+
* round-trip via JWK (e.g. encrypted-file backends).
|
|
2077
|
+
*/
|
|
2078
|
+
readonly supportsNonExtractable: boolean;
|
|
2079
|
+
/**
|
|
2080
|
+
* Stores `key` under `id`. Returns the stored `id` on success so the
|
|
2081
|
+
* call can compose into a Result chain.
|
|
2082
|
+
* @param id - Storage handle to write under.
|
|
2083
|
+
* @param key - The private `CryptoKey` to persist.
|
|
2084
|
+
*/
|
|
2085
|
+
store(id: string, key: CryptoKey): Promise<Result<string>>;
|
|
2086
|
+
/**
|
|
2087
|
+
* Loads the private key previously stored under `id`.
|
|
2088
|
+
* @param id - Storage handle to look up.
|
|
2089
|
+
*/
|
|
2090
|
+
load(id: string): Promise<Result<CryptoKey>>;
|
|
2091
|
+
/**
|
|
2092
|
+
* Deletes the entry stored under `id`. Returns the deleted `id` on
|
|
2093
|
+
* success so the call can compose into a Result chain.
|
|
2094
|
+
* @param id - Storage handle to remove.
|
|
2095
|
+
*/
|
|
2096
|
+
delete(id: string): Promise<Result<string>>;
|
|
2097
|
+
/**
|
|
2098
|
+
* Lists every `id` currently held by the backend. Used by consumers to
|
|
2099
|
+
* garbage-collect orphans left by crashes or aborted sessions; the
|
|
2100
|
+
* keystore itself does not invoke this automatically.
|
|
2101
|
+
*/
|
|
2102
|
+
list(): Promise<Result<readonly string[]>>;
|
|
2103
|
+
}
|
|
2104
|
+
|
|
1362
2105
|
/**
|
|
1363
2106
|
* Parameters for a provider completion request.
|
|
1364
2107
|
* @public
|
|
@@ -1383,6 +2126,97 @@ declare interface IProviderCompletionParams {
|
|
|
1383
2126
|
readonly logger?: Logging.ILogger;
|
|
1384
2127
|
/** Server-side tools to include in the request. Overrides settings-level tool config when provided. */
|
|
1385
2128
|
readonly tools?: ReadonlyArray<AiServerToolConfig>;
|
|
2129
|
+
/** Optional abort signal for cancelling the in-flight request. */
|
|
2130
|
+
readonly signal?: AbortSignal;
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
/**
|
|
2134
|
+
* Parameters for a streaming completion request. Structurally identical to
|
|
2135
|
+
* the non-streaming `IProviderCompletionParams`; kept as its own interface
|
|
2136
|
+
* so callers can be explicit about which path they're invoking.
|
|
2137
|
+
*
|
|
2138
|
+
* @public
|
|
2139
|
+
*/
|
|
2140
|
+
declare interface IProviderCompletionStreamParams {
|
|
2141
|
+
/** The provider descriptor */
|
|
2142
|
+
readonly descriptor: IAiProviderDescriptor;
|
|
2143
|
+
/** API key for authentication */
|
|
2144
|
+
readonly apiKey: string;
|
|
2145
|
+
/** The structured prompt to send */
|
|
2146
|
+
readonly prompt: AiPrompt;
|
|
2147
|
+
/**
|
|
2148
|
+
* Prior conversation history to insert between the system prompt and the
|
|
2149
|
+
* prompt's user message. The new user turn (carried by `prompt.user`) is
|
|
2150
|
+
* always sent last, so the wire shape becomes
|
|
2151
|
+
* `[system, ...messagesBefore, user=prompt.user]`.
|
|
2152
|
+
*/
|
|
2153
|
+
readonly messagesBefore?: ReadonlyArray<IChatMessage>;
|
|
2154
|
+
/** Sampling temperature (default: 0.7) */
|
|
2155
|
+
readonly temperature?: number;
|
|
2156
|
+
/** Optional model override — string or context-aware map. */
|
|
2157
|
+
readonly modelOverride?: ModelSpec;
|
|
2158
|
+
/** Optional logger for request/response observability. */
|
|
2159
|
+
readonly logger?: Logging.ILogger;
|
|
2160
|
+
/** Server-side tools to include in the request. */
|
|
2161
|
+
readonly tools?: ReadonlyArray<AiServerToolConfig>;
|
|
2162
|
+
/** Optional abort signal for cancelling the in-flight stream. */
|
|
2163
|
+
readonly signal?: AbortSignal;
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
/**
|
|
2167
|
+
* Parameters for an image-generation request.
|
|
2168
|
+
* @public
|
|
2169
|
+
*/
|
|
2170
|
+
declare interface IProviderImageGenerationParams {
|
|
2171
|
+
/** The provider descriptor */
|
|
2172
|
+
readonly descriptor: IAiProviderDescriptor;
|
|
2173
|
+
/** API key for authentication */
|
|
2174
|
+
readonly apiKey: string;
|
|
2175
|
+
/** The image-generation request */
|
|
2176
|
+
readonly params: IAiImageGenerationParams;
|
|
2177
|
+
/** Optional model override — string or context-aware map (uses descriptor.defaultModel.image otherwise) */
|
|
2178
|
+
readonly modelOverride?: ModelSpec;
|
|
2179
|
+
/** Optional logger for request/response observability. */
|
|
2180
|
+
readonly logger?: Logging.ILogger;
|
|
2181
|
+
/** Optional abort signal for cancelling the in-flight request. */
|
|
2182
|
+
readonly signal?: AbortSignal;
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
/**
|
|
2186
|
+
* Parameters for a list-models request.
|
|
2187
|
+
* @public
|
|
2188
|
+
*/
|
|
2189
|
+
declare interface IProviderListModelsParams {
|
|
2190
|
+
/** The provider descriptor */
|
|
2191
|
+
readonly descriptor: IAiProviderDescriptor;
|
|
2192
|
+
/** API key for authentication */
|
|
2193
|
+
readonly apiKey: string;
|
|
2194
|
+
/** Optional capability filter; when set, only models declaring this capability are returned. */
|
|
2195
|
+
readonly capability?: AiModelCapability;
|
|
2196
|
+
/** Optional capability config override (defaults to {@link DEFAULT_MODEL_CAPABILITY_CONFIG}). */
|
|
2197
|
+
readonly capabilityConfig?: IAiModelCapabilityConfig;
|
|
2198
|
+
/** Optional logger for request/response observability. */
|
|
2199
|
+
readonly logger?: Logging.ILogger;
|
|
2200
|
+
/** Optional abort signal for cancelling the in-flight request. */
|
|
2201
|
+
readonly signal?: AbortSignal;
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2204
|
+
/**
|
|
2205
|
+
* Result of removing a secret from the key store.
|
|
2206
|
+
* @public
|
|
2207
|
+
*/
|
|
2208
|
+
declare interface IRemoveSecretResult {
|
|
2209
|
+
/**
|
|
2210
|
+
* The secret entry that was removed from the vault.
|
|
2211
|
+
*/
|
|
2212
|
+
readonly entry: IKeyStoreEntry;
|
|
2213
|
+
/**
|
|
2214
|
+
* Best-effort warning from {@link CryptoUtils.KeyStore.IPrivateKeyStorage}.delete
|
|
2215
|
+
* for asymmetric entries when the storage call failed. The vault entry is
|
|
2216
|
+
* still considered removed and the orphaned blob is left for consumer-side
|
|
2217
|
+
* GC to reconcile.
|
|
2218
|
+
*/
|
|
2219
|
+
readonly warning?: string;
|
|
1386
2220
|
}
|
|
1387
2221
|
|
|
1388
2222
|
/**
|
|
@@ -1516,6 +2350,24 @@ declare interface JarRecordParserOptions {
|
|
|
1516
2350
|
readonly fixedContinuationSize?: number;
|
|
1517
2351
|
}
|
|
1518
2352
|
|
|
2353
|
+
/**
|
|
2354
|
+
* In-place shape check for a JSON Web Key. Asserts only that the input is a
|
|
2355
|
+
* non-array object whose `kty` discriminator is a string; every other JWK
|
|
2356
|
+
* field passes through untouched. This is intentionally **not** a true JWK
|
|
2357
|
+
* validator — per-algorithm correctness (RSA `n`/`e`, EC `crv`/`x`/`y`,
|
|
2358
|
+
* key-size constraints, etc.) is delegated to `crypto.subtle.importKey` at
|
|
2359
|
+
* first use, which is the authoritative checker. The "shape" suffix in the
|
|
2360
|
+
* name is the warning sign for readers expecting full validation.
|
|
2361
|
+
* @remarks
|
|
2362
|
+
* Built with `Validators.object` (in-place, non-strict) so unknown JWK fields
|
|
2363
|
+
* survive the round-trip; the cast to `FieldValidators<JsonWebKey>` is required
|
|
2364
|
+
* only because TypeScript's mapped type demands an entry for every key in
|
|
2365
|
+
* `JsonWebKey`. At runtime the `ObjectValidator` only inspects keys present in
|
|
2366
|
+
* the field-validators map.
|
|
2367
|
+
* @public
|
|
2368
|
+
*/
|
|
2369
|
+
declare const jsonWebKeyShape: Validator<JsonWebKey>;
|
|
2370
|
+
|
|
1519
2371
|
/**
|
|
1520
2372
|
* Supported key derivation functions.
|
|
1521
2373
|
* @public
|
|
@@ -1534,18 +2386,54 @@ declare const keyDerivationFunction: Converter<KeyDerivationFunction>;
|
|
|
1534
2386
|
*/
|
|
1535
2387
|
declare const keyDerivationParams: Converter<IKeyDerivationParams>;
|
|
1536
2388
|
|
|
2389
|
+
/**
|
|
2390
|
+
* Asymmetric keypair algorithms supported by the crypto provider.
|
|
2391
|
+
* - `'ecdsa-p256'`: ECDSA over the P-256 curve, for signing.
|
|
2392
|
+
* - `'rsa-oaep-2048'`: RSA-OAEP, 2048-bit modulus with SHA-256, for encryption.
|
|
2393
|
+
* @public
|
|
2394
|
+
*/
|
|
2395
|
+
declare type KeyPairAlgorithm = 'ecdsa-p256' | 'rsa-oaep-2048';
|
|
2396
|
+
|
|
2397
|
+
/**
|
|
2398
|
+
* Converter for {@link CryptoUtils.KeyStore.KeyPairAlgorithm | key pair algorithm}.
|
|
2399
|
+
* @public
|
|
2400
|
+
*/
|
|
2401
|
+
declare const keyPairAlgorithm: Converter<KeyPairAlgorithm>;
|
|
2402
|
+
|
|
2403
|
+
/**
|
|
2404
|
+
* Lookup table from {@link CryptoUtils.KeyPairAlgorithm} to the WebCrypto
|
|
2405
|
+
* parameters needed to drive `crypto.subtle`. Shared between every
|
|
2406
|
+
* {@link CryptoUtils.ICryptoProvider} implementation since both Node and
|
|
2407
|
+
* browser providers speak the same WebCrypto API. Exposed for downstream
|
|
2408
|
+
* provider implementations (e.g. browser-side providers in `@fgv/ts-web-extras`).
|
|
2409
|
+
* @public
|
|
2410
|
+
*/
|
|
2411
|
+
declare const keyPairAlgorithmParams: Readonly<Record<KeyPairAlgorithm, IKeyPairAlgorithmParams>>;
|
|
2412
|
+
|
|
1537
2413
|
declare namespace KeyStore {
|
|
1538
2414
|
export {
|
|
1539
2415
|
Converters_2 as Converters,
|
|
1540
2416
|
KeyStore_2 as KeyStore,
|
|
1541
2417
|
isKeyStoreFile,
|
|
2418
|
+
allKeyPairAlgorithms,
|
|
2419
|
+
KeyPairAlgorithm,
|
|
1542
2420
|
KeyStoreFormat,
|
|
1543
2421
|
KEYSTORE_FORMAT,
|
|
1544
2422
|
DEFAULT_KEYSTORE_ITERATIONS,
|
|
1545
2423
|
MIN_SALT_LENGTH,
|
|
2424
|
+
KeyStoreSymmetricSecretType,
|
|
2425
|
+
allKeyStoreSymmetricSecretTypes,
|
|
2426
|
+
KeyStoreAsymmetricSecretType,
|
|
2427
|
+
allKeyStoreAsymmetricSecretTypes,
|
|
1546
2428
|
KeyStoreSecretType,
|
|
1547
2429
|
allKeyStoreSecretTypes,
|
|
2430
|
+
IKeyStoreSymmetricEntry,
|
|
2431
|
+
IKeyStoreAsymmetricEntry,
|
|
2432
|
+
IKeyStoreEntry,
|
|
1548
2433
|
IKeyStoreSecretEntry,
|
|
2434
|
+
IKeyStoreSymmetricEntryJson,
|
|
2435
|
+
IKeyStoreAsymmetricEntryJson,
|
|
2436
|
+
IKeyStoreEntryJson,
|
|
1549
2437
|
IKeyStoreSecretEntryJson,
|
|
1550
2438
|
IKeyStoreVaultContents,
|
|
1551
2439
|
IKeyStoreFile,
|
|
@@ -1558,7 +2446,11 @@ declare namespace KeyStore {
|
|
|
1558
2446
|
IImportKeyOptions,
|
|
1559
2447
|
IAddSecretFromPasswordOptions,
|
|
1560
2448
|
DEFAULT_SECRET_ITERATIONS,
|
|
1561
|
-
IAddSecretFromPasswordResult
|
|
2449
|
+
IAddSecretFromPasswordResult,
|
|
2450
|
+
IAddKeyPairOptions,
|
|
2451
|
+
IAddKeyPairResult,
|
|
2452
|
+
IRemoveSecretResult,
|
|
2453
|
+
IPrivateKeyStorage
|
|
1562
2454
|
}
|
|
1563
2455
|
}
|
|
1564
2456
|
|
|
@@ -1595,6 +2487,7 @@ declare namespace KeyStore {
|
|
|
1595
2487
|
*/
|
|
1596
2488
|
declare class KeyStore_2 implements IEncryptionProvider {
|
|
1597
2489
|
private readonly _cryptoProvider;
|
|
2490
|
+
private readonly _privateKeyStorage;
|
|
1598
2491
|
private readonly _iterations;
|
|
1599
2492
|
private _keystoreFile;
|
|
1600
2493
|
private _salt;
|
|
@@ -1693,12 +2586,23 @@ declare class KeyStore_2 implements IEncryptionProvider {
|
|
|
1693
2586
|
*/
|
|
1694
2587
|
listSecrets(): Result<readonly string[]>;
|
|
1695
2588
|
/**
|
|
1696
|
-
* Gets a secret by name.
|
|
2589
|
+
* Gets a secret by name. Returns the {@link CryptoUtils.KeyStore.IKeyStoreEntry | discriminated union}
|
|
2590
|
+
* — callers must check `entry.type` before accessing `key`/`id` since asymmetric
|
|
2591
|
+
* entries carry no raw key material.
|
|
1697
2592
|
* @param name - Name of the secret
|
|
1698
2593
|
* @returns Success with secret entry, Failure if not found or locked
|
|
1699
2594
|
* @public
|
|
1700
2595
|
*/
|
|
1701
|
-
getSecret(name: string): Result<
|
|
2596
|
+
getSecret(name: string): Result<IKeyStoreEntry>;
|
|
2597
|
+
/**
|
|
2598
|
+
* Returns the public-key JWK for an asymmetric-keypair entry.
|
|
2599
|
+
* Available without {@link CryptoUtils.KeyStore.IPrivateKeyStorage} since the
|
|
2600
|
+
* public key lives in the vault metadata directly.
|
|
2601
|
+
* @param name - Name of the entry
|
|
2602
|
+
* @returns Success with the JWK, Failure if not found, locked, or wrong type
|
|
2603
|
+
* @public
|
|
2604
|
+
*/
|
|
2605
|
+
getPublicKeyJwk(name: string): Result<JsonWebKey>;
|
|
1702
2606
|
/**
|
|
1703
2607
|
* Checks if a secret exists.
|
|
1704
2608
|
* @param name - Name of the secret
|
|
@@ -1728,7 +2632,7 @@ declare class KeyStore_2 implements IEncryptionProvider {
|
|
|
1728
2632
|
* @returns Success with entry, Failure if locked, key invalid, or exists and !replace
|
|
1729
2633
|
* @public
|
|
1730
2634
|
*/
|
|
1731
|
-
importSecret(name: string, key: Uint8Array, options?: IImportKeyOptions): Result<IAddSecretResult
|
|
2635
|
+
importSecret(name: string, key: Uint8Array, options?: IImportKeyOptions): Promise<Result<IAddSecretResult>>;
|
|
1732
2636
|
/**
|
|
1733
2637
|
* Adds a secret derived from a password using PBKDF2.
|
|
1734
2638
|
*
|
|
@@ -1745,12 +2649,16 @@ declare class KeyStore_2 implements IEncryptionProvider {
|
|
|
1745
2649
|
*/
|
|
1746
2650
|
addSecretFromPassword(name: string, password: string, options?: IAddSecretFromPasswordOptions): Promise<Result<IAddSecretFromPasswordResult>>;
|
|
1747
2651
|
/**
|
|
1748
|
-
* Removes a secret by name.
|
|
2652
|
+
* Removes a secret by name. Vault-first: the in-memory vault entry is dropped
|
|
2653
|
+
* before any storage cleanup runs. For asymmetric-keypair entries, best-effort
|
|
2654
|
+
* calls {@link CryptoUtils.KeyStore.IPrivateKeyStorage}.delete on the entry's
|
|
2655
|
+
* `id`; a failure is reported via `warning` on the result but does not roll
|
|
2656
|
+
* back the vault removal.
|
|
1749
2657
|
* @param name - Name of the secret to remove
|
|
1750
|
-
* @returns Success with removed entry, Failure if not found or locked
|
|
2658
|
+
* @returns Success with removed entry (and optional warning), Failure if not found or locked
|
|
1751
2659
|
* @public
|
|
1752
2660
|
*/
|
|
1753
|
-
removeSecret(name: string): Result<
|
|
2661
|
+
removeSecret(name: string): Promise<Result<IRemoveSecretResult>>;
|
|
1754
2662
|
/**
|
|
1755
2663
|
* Imports an API key string into the vault.
|
|
1756
2664
|
* The string is UTF-8 encoded and stored with type `'api-key'`.
|
|
@@ -1760,7 +2668,7 @@ declare class KeyStore_2 implements IEncryptionProvider {
|
|
|
1760
2668
|
* @returns Success with entry, Failure if locked, empty, or exists and !replace
|
|
1761
2669
|
* @public
|
|
1762
2670
|
*/
|
|
1763
|
-
importApiKey(name: string, apiKey: string, options?: IImportSecretOptions): Result<IAddSecretResult
|
|
2671
|
+
importApiKey(name: string, apiKey: string, options?: IImportSecretOptions): Promise<Result<IAddSecretResult>>;
|
|
1764
2672
|
/**
|
|
1765
2673
|
* Retrieves an API key string by name.
|
|
1766
2674
|
* Only works for secrets with type `'api-key'`.
|
|
@@ -1769,6 +2677,41 @@ declare class KeyStore_2 implements IEncryptionProvider {
|
|
|
1769
2677
|
* @public
|
|
1770
2678
|
*/
|
|
1771
2679
|
getApiKey(name: string): Result<string>;
|
|
2680
|
+
/**
|
|
2681
|
+
* Adds a new asymmetric keypair to the vault. Storage-first: the private key
|
|
2682
|
+
* is stored under a freshly-minted `id` before the public-key vault entry is
|
|
2683
|
+
* committed. If the storage call fails, no vault entry is written and the
|
|
2684
|
+
* operation returns Failure.
|
|
2685
|
+
*
|
|
2686
|
+
* When `replace: true` displaces an existing entry (asymmetric or symmetric),
|
|
2687
|
+
* a fresh `id` is minted; the displaced entry's resources are released
|
|
2688
|
+
* best-effort. Failure of the storage delete is reported via `warning` on the
|
|
2689
|
+
* result but does not roll back the replacement.
|
|
2690
|
+
*
|
|
2691
|
+
* Requires a {@link CryptoUtils.KeyStore.IPrivateKeyStorage} backend
|
|
2692
|
+
* supplied at construction.
|
|
2693
|
+
*
|
|
2694
|
+
* @param name - Unique name for the entry
|
|
2695
|
+
* @param options - Algorithm, optional description, replace flag
|
|
2696
|
+
* @returns Success with the new entry, Failure if locked, no provider, or storage write failed
|
|
2697
|
+
* @public
|
|
2698
|
+
*/
|
|
2699
|
+
addKeyPair(name: string, options: IAddKeyPairOptions): Promise<Result<IAddKeyPairResult>>;
|
|
2700
|
+
/**
|
|
2701
|
+
* Retrieves the keypair for an asymmetric-keypair entry. The private key is
|
|
2702
|
+
* loaded from {@link CryptoUtils.KeyStore.IPrivateKeyStorage} on every call —
|
|
2703
|
+
* the keystore never caches private `CryptoKey` references between calls.
|
|
2704
|
+
* The public key is re-imported from the vault's JWK so callers always
|
|
2705
|
+
* receive a `CryptoKey` rather than the JWK form.
|
|
2706
|
+
* @param name - Name of the entry
|
|
2707
|
+
* @returns Success with `{ publicKey, privateKey }`, Failure if not found,
|
|
2708
|
+
* locked, wrong type, no provider, or storage load failed.
|
|
2709
|
+
* @public
|
|
2710
|
+
*/
|
|
2711
|
+
getKeyPair(name: string): Promise<Result<{
|
|
2712
|
+
publicKey: CryptoKey;
|
|
2713
|
+
privateKey: CryptoKey;
|
|
2714
|
+
}>>;
|
|
1772
2715
|
/**
|
|
1773
2716
|
* Lists secret names filtered by type.
|
|
1774
2717
|
* @param type - The secret type to filter by
|
|
@@ -1783,7 +2726,7 @@ declare class KeyStore_2 implements IEncryptionProvider {
|
|
|
1783
2726
|
* @returns Success with updated entry, Failure if source not found, target exists, or locked
|
|
1784
2727
|
* @public
|
|
1785
2728
|
*/
|
|
1786
|
-
renameSecret(oldName: string, newName: string): Result<
|
|
2729
|
+
renameSecret(oldName: string, newName: string): Result<IKeyStoreEntry>;
|
|
1787
2730
|
/**
|
|
1788
2731
|
* Saves the key store, returning the encrypted file content.
|
|
1789
2732
|
* Requires the master password to encrypt.
|
|
@@ -1840,6 +2783,23 @@ declare class KeyStore_2 implements IEncryptionProvider {
|
|
|
1840
2783
|
* Shared by `unlock()` and `unlockWithKey()`.
|
|
1841
2784
|
*/
|
|
1842
2785
|
private _decryptVault;
|
|
2786
|
+
/**
|
|
2787
|
+
* Releases the resources held by an entry being displaced from the vault.
|
|
2788
|
+
* Symmetric entries get their key buffer zeroed in place. Asymmetric entries
|
|
2789
|
+
* have their private-key blob best-effort deleted from
|
|
2790
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage}; if the storage call fails,
|
|
2791
|
+
* a warning string is returned but the displacement still proceeds — the
|
|
2792
|
+
* orphaned blob is left for consumer-side GC. Without a configured provider,
|
|
2793
|
+
* asymmetric cleanup is silently skipped.
|
|
2794
|
+
* @returns A warning string if storage cleanup failed, otherwise undefined.
|
|
2795
|
+
*/
|
|
2796
|
+
private _releaseEntryResources;
|
|
2797
|
+
/**
|
|
2798
|
+
* Mints a fresh UUID v4 storage handle using the crypto provider's
|
|
2799
|
+
* {@link CryptoUtils.ICryptoProvider.generateRandomBytes | generateRandomBytes}.
|
|
2800
|
+
* Random-bytes failures propagate as Failure.
|
|
2801
|
+
*/
|
|
2802
|
+
private _generateId;
|
|
1843
2803
|
}
|
|
1844
2804
|
|
|
1845
2805
|
/**
|
|
@@ -1848,6 +2808,31 @@ declare class KeyStore_2 implements IEncryptionProvider {
|
|
|
1848
2808
|
*/
|
|
1849
2809
|
declare const KEYSTORE_FORMAT: KeyStoreFormat;
|
|
1850
2810
|
|
|
2811
|
+
/**
|
|
2812
|
+
* Converter for {@link CryptoUtils.KeyStore.IKeyStoreAsymmetricEntryJson | asymmetric keypair entry} in JSON form.
|
|
2813
|
+
* The `publicKeyJwk` field passes through {@link CryptoUtils.KeyStore.Converters.jsonWebKeyShape | jsonWebKeyShape}
|
|
2814
|
+
* (shape check only — see its docs); cryptographic correctness is enforced by
|
|
2815
|
+
* `crypto.subtle.importKey` at use.
|
|
2816
|
+
* @public
|
|
2817
|
+
*/
|
|
2818
|
+
declare const keystoreAsymmetricEntryJson: Converter<IKeyStoreAsymmetricEntryJson>;
|
|
2819
|
+
|
|
2820
|
+
/**
|
|
2821
|
+
* Discriminator for asymmetric secret types stored in the vault.
|
|
2822
|
+
* - `'asymmetric-keypair'`: A public/private key pair. The public key is held in
|
|
2823
|
+
* the vault as a JWK; the private key lives in the supplied
|
|
2824
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage} provider.
|
|
2825
|
+
* @public
|
|
2826
|
+
*/
|
|
2827
|
+
declare type KeyStoreAsymmetricSecretType = 'asymmetric-keypair';
|
|
2828
|
+
|
|
2829
|
+
/**
|
|
2830
|
+
* Converter for {@link CryptoUtils.KeyStore.KeyStoreAsymmetricSecretType | asymmetric secret type} discriminator.
|
|
2831
|
+
* Accepts only `'asymmetric-keypair'`.
|
|
2832
|
+
* @public
|
|
2833
|
+
*/
|
|
2834
|
+
declare const keystoreAsymmetricSecretType: Converter<KeyStoreAsymmetricSecretType>;
|
|
2835
|
+
|
|
1851
2836
|
/**
|
|
1852
2837
|
* Converter for {@link CryptoUtils.KeyStore.IKeyStoreFile | encrypted key store file}.
|
|
1853
2838
|
* @public
|
|
@@ -1873,25 +2858,59 @@ declare const keystoreFormat: Converter<KeyStoreFormat>;
|
|
|
1873
2858
|
declare type KeyStoreLockState = 'locked' | 'unlocked';
|
|
1874
2859
|
|
|
1875
2860
|
/**
|
|
1876
|
-
*
|
|
1877
|
-
*
|
|
2861
|
+
* Discriminated-union converter for any {@link CryptoUtils.KeyStore.IKeyStoreEntryJson | key store entry} in JSON form.
|
|
2862
|
+
* Routes by the `type` field: `'asymmetric-keypair'` is parsed by
|
|
2863
|
+
* {@link CryptoUtils.KeyStore.Converters.keystoreAsymmetricEntryJson | keystoreAsymmetricEntryJson},
|
|
2864
|
+
* anything else (including a missing `type` field for backwards compatibility) by
|
|
2865
|
+
* {@link CryptoUtils.KeyStore.Converters.keystoreSymmetricEntryJson | keystoreSymmetricEntryJson}.
|
|
1878
2866
|
* @public
|
|
1879
2867
|
*/
|
|
1880
|
-
declare const keystoreSecretEntryJson: Converter<
|
|
2868
|
+
declare const keystoreSecretEntryJson: Converter<IKeyStoreEntryJson>;
|
|
1881
2869
|
|
|
1882
2870
|
/**
|
|
1883
|
-
* Discriminator for secret
|
|
2871
|
+
* Discriminator for any secret type stored in the vault.
|
|
2872
|
+
* @public
|
|
2873
|
+
*/
|
|
2874
|
+
declare type KeyStoreSecretType = KeyStoreSymmetricSecretType | KeyStoreAsymmetricSecretType;
|
|
2875
|
+
|
|
2876
|
+
/**
|
|
2877
|
+
* Converter for {@link CryptoUtils.KeyStore.KeyStoreSecretType | any key store secret type} discriminator.
|
|
2878
|
+
* Accepts both symmetric and asymmetric type values.
|
|
2879
|
+
* @public
|
|
2880
|
+
*/
|
|
2881
|
+
declare const keystoreSecretType: Converter<KeyStoreSecretType>;
|
|
2882
|
+
|
|
2883
|
+
/**
|
|
2884
|
+
* Converter for {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntryJson | symmetric secret entry} in JSON form.
|
|
2885
|
+
*
|
|
2886
|
+
* @remarks
|
|
2887
|
+
* Backwards compatibility with vaults written before asymmetric-keypair
|
|
2888
|
+
* support: those entries may lack the `type` discriminator on the wire. To
|
|
2889
|
+
* keep the model type honest (`type` is required on
|
|
2890
|
+
* {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntryJson}, see its docs),
|
|
2891
|
+
* we declare `type` in `optionalFields` so the inner `Converters.object` will
|
|
2892
|
+
* accept input without it, then `.map()` injects the default
|
|
2893
|
+
* `'encryption-key'` when missing. The output therefore always carries the
|
|
2894
|
+
* discriminator and downstream code never sees the legacy missing-type form.
|
|
2895
|
+
*
|
|
2896
|
+
* @public
|
|
2897
|
+
*/
|
|
2898
|
+
declare const keystoreSymmetricEntryJson: Converter<IKeyStoreSymmetricEntryJson>;
|
|
2899
|
+
|
|
2900
|
+
/**
|
|
2901
|
+
* Discriminator for symmetric secret types stored in the vault.
|
|
1884
2902
|
* - `'encryption-key'`: A 32-byte AES-256 encryption key.
|
|
1885
2903
|
* - `'api-key'`: An arbitrary-length API key string (UTF-8 encoded).
|
|
1886
2904
|
* @public
|
|
1887
2905
|
*/
|
|
1888
|
-
declare type
|
|
2906
|
+
declare type KeyStoreSymmetricSecretType = 'encryption-key' | 'api-key';
|
|
1889
2907
|
|
|
1890
2908
|
/**
|
|
1891
|
-
* Converter for {@link CryptoUtils.KeyStore.
|
|
2909
|
+
* Converter for {@link CryptoUtils.KeyStore.KeyStoreSymmetricSecretType | symmetric secret type} discriminator.
|
|
2910
|
+
* Accepts only `'encryption-key'` and `'api-key'`.
|
|
1892
2911
|
* @public
|
|
1893
2912
|
*/
|
|
1894
|
-
declare const
|
|
2913
|
+
declare const keystoreSymmetricSecretType: Converter<KeyStoreSymmetricSecretType>;
|
|
1895
2914
|
|
|
1896
2915
|
/**
|
|
1897
2916
|
* Converter for {@link CryptoUtils.KeyStore.IKeyStoreVaultContents | key store vault contents} (decrypted state).
|
|
@@ -2105,6 +3124,31 @@ declare class NodeCryptoProvider implements ICryptoProvider {
|
|
|
2105
3124
|
* @returns Success with decoded bytes, or Failure if invalid base64
|
|
2106
3125
|
*/
|
|
2107
3126
|
fromBase64(base64: string): Result<Uint8Array>;
|
|
3127
|
+
/**
|
|
3128
|
+
* Generates a new asymmetric keypair using Node's WebCrypto.
|
|
3129
|
+
* @param algorithm - The {@link CryptoUtils.KeyPairAlgorithm | algorithm} to use.
|
|
3130
|
+
* @param extractable - Whether the resulting keys may be exported.
|
|
3131
|
+
* @returns `Success` with the generated `CryptoKeyPair`, or `Failure` with an error.
|
|
3132
|
+
*/
|
|
3133
|
+
generateKeyPair(algorithm: KeyPairAlgorithm, extractable: boolean): Promise<Result<CryptoKeyPair>>;
|
|
3134
|
+
/**
|
|
3135
|
+
* Exports a public `CryptoKey` as a JSON Web Key.
|
|
3136
|
+
* @remarks
|
|
3137
|
+
* Rejects non-public keys at runtime. WebCrypto's `exportKey('jwk', ...)`
|
|
3138
|
+
* does not enforce public-vs-private; without this guard a caller that
|
|
3139
|
+
* passed an extractable private key would receive its private fields
|
|
3140
|
+
* (`d`, `p`, `q`, ...) as JWK, defeating the method's name.
|
|
3141
|
+
* @param publicKey - Extractable public key to export.
|
|
3142
|
+
* @returns `Success` with the JWK, or `Failure` if not a public key or if export fails.
|
|
3143
|
+
*/
|
|
3144
|
+
exportPublicKeyJwk(publicKey: CryptoKey): Promise<Result<JsonWebKey>>;
|
|
3145
|
+
/**
|
|
3146
|
+
* Imports a public-key JWK as a `CryptoKey` for the requested algorithm.
|
|
3147
|
+
* @param jwk - The JSON Web Key produced by a prior export.
|
|
3148
|
+
* @param algorithm - The algorithm the key was generated for.
|
|
3149
|
+
* @returns `Success` with the imported public `CryptoKey`, or `Failure` with an error.
|
|
3150
|
+
*/
|
|
3151
|
+
importPublicKeyJwk(jwk: JsonWebKey, algorithm: KeyPairAlgorithm): Promise<Result<CryptoKey>>;
|
|
2108
3152
|
}
|
|
2109
3153
|
|
|
2110
3154
|
/**
|
|
@@ -2377,6 +3421,14 @@ declare function templateString(defaultContext?: unknown): Conversion.StringConv
|
|
|
2377
3421
|
*/
|
|
2378
3422
|
declare function toBase64(bytes: Uint8Array): string;
|
|
2379
3423
|
|
|
3424
|
+
/**
|
|
3425
|
+
* Formats an {@link IAiImageData} as a `data:` URL suitable for browser display.
|
|
3426
|
+
* @param image - The image to format
|
|
3427
|
+
* @returns A `data:<mime>;base64,<data>` URL string
|
|
3428
|
+
* @public
|
|
3429
|
+
*/
|
|
3430
|
+
declare function toDataUrl(image: IAiImageData): string;
|
|
3431
|
+
|
|
2380
3432
|
/**
|
|
2381
3433
|
* Attempts to parse and decrypt a JSON object as an {@link CryptoUtils.IEncryptedFile | encrypted file}.
|
|
2382
3434
|
* @typeParam TPayload - Expected type of decrypted content
|
|
@@ -2576,8 +3628,8 @@ declare class ZipFileTreeAccessors<TCT extends string = string> implements FileT
|
|
|
2576
3628
|
private constructor();
|
|
2577
3629
|
/**
|
|
2578
3630
|
* Default function to infer the content type of a file.
|
|
2579
|
-
* @param
|
|
2580
|
-
* @param
|
|
3631
|
+
* @param __filePath - The path of the file.
|
|
3632
|
+
* @param __provided - Optional supplied content type.
|
|
2581
3633
|
* @returns `Success` with the content type of the file if successful, or
|
|
2582
3634
|
* `Failure` with an error message otherwise.
|
|
2583
3635
|
* @remarks This default implementation always returns `Success` with `undefined`.
|