@fgv/ts-extras 5.1.0-20 → 5.1.0-22

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.
Files changed (89) hide show
  1. package/dist/packlets/ai-assist/apiClient.js +30 -25
  2. package/dist/packlets/ai-assist/apiClient.js.map +1 -1
  3. package/dist/packlets/ai-assist/converters.js +2 -1
  4. package/dist/packlets/ai-assist/converters.js.map +1 -1
  5. package/dist/packlets/ai-assist/endpoint.js +78 -0
  6. package/dist/packlets/ai-assist/endpoint.js.map +1 -0
  7. package/dist/packlets/ai-assist/index.js +2 -0
  8. package/dist/packlets/ai-assist/index.js.map +1 -1
  9. package/dist/packlets/ai-assist/jsonCompletion.js +95 -0
  10. package/dist/packlets/ai-assist/jsonCompletion.js.map +1 -0
  11. package/dist/packlets/ai-assist/jsonResponse.js +149 -0
  12. package/dist/packlets/ai-assist/jsonResponse.js.map +1 -0
  13. package/dist/packlets/ai-assist/model.js.map +1 -1
  14. package/dist/packlets/ai-assist/registry.js +26 -0
  15. package/dist/packlets/ai-assist/registry.js.map +1 -1
  16. package/dist/packlets/ai-assist/streamingAdapters/common.js.map +1 -1
  17. package/dist/packlets/ai-assist/streamingAdapters/openaiChat.js +2 -1
  18. package/dist/packlets/ai-assist/streamingAdapters/openaiChat.js.map +1 -1
  19. package/dist/packlets/ai-assist/streamingAdapters/openaiResponses.js +2 -1
  20. package/dist/packlets/ai-assist/streamingAdapters/openaiResponses.js.map +1 -1
  21. package/dist/packlets/ai-assist/streamingClient.js +11 -5
  22. package/dist/packlets/ai-assist/streamingClient.js.map +1 -1
  23. package/dist/packlets/crypto-utils/keyPairAlgorithmParams.js +6 -0
  24. package/dist/packlets/crypto-utils/keyPairAlgorithmParams.js.map +1 -1
  25. package/dist/packlets/crypto-utils/keystore/keyStore.js +81 -0
  26. package/dist/packlets/crypto-utils/keystore/keyStore.js.map +1 -1
  27. package/dist/packlets/crypto-utils/model.js +2 -1
  28. package/dist/packlets/crypto-utils/model.js.map +1 -1
  29. package/dist/packlets/crypto-utils/nodeCryptoProvider.js +21 -2
  30. package/dist/packlets/crypto-utils/nodeCryptoProvider.js.map +1 -1
  31. package/dist/ts-extras.d.ts +301 -6
  32. package/lib/packlets/ai-assist/apiClient.d.ts +29 -0
  33. package/lib/packlets/ai-assist/apiClient.d.ts.map +1 -1
  34. package/lib/packlets/ai-assist/apiClient.js +30 -25
  35. package/lib/packlets/ai-assist/apiClient.js.map +1 -1
  36. package/lib/packlets/ai-assist/converters.d.ts.map +1 -1
  37. package/lib/packlets/ai-assist/converters.js +2 -1
  38. package/lib/packlets/ai-assist/converters.js.map +1 -1
  39. package/lib/packlets/ai-assist/endpoint.d.ts +28 -0
  40. package/lib/packlets/ai-assist/endpoint.d.ts.map +1 -0
  41. package/lib/packlets/ai-assist/endpoint.js +82 -0
  42. package/lib/packlets/ai-assist/endpoint.js.map +1 -0
  43. package/lib/packlets/ai-assist/index.d.ts +2 -0
  44. package/lib/packlets/ai-assist/index.d.ts.map +1 -1
  45. package/lib/packlets/ai-assist/index.js +7 -1
  46. package/lib/packlets/ai-assist/index.js.map +1 -1
  47. package/lib/packlets/ai-assist/jsonCompletion.d.ts +93 -0
  48. package/lib/packlets/ai-assist/jsonCompletion.d.ts.map +1 -0
  49. package/lib/packlets/ai-assist/jsonCompletion.js +99 -0
  50. package/lib/packlets/ai-assist/jsonCompletion.js.map +1 -0
  51. package/lib/packlets/ai-assist/jsonResponse.d.ts +91 -0
  52. package/lib/packlets/ai-assist/jsonResponse.d.ts.map +1 -0
  53. package/lib/packlets/ai-assist/jsonResponse.js +154 -0
  54. package/lib/packlets/ai-assist/jsonResponse.js.map +1 -0
  55. package/lib/packlets/ai-assist/model.d.ts +9 -1
  56. package/lib/packlets/ai-assist/model.d.ts.map +1 -1
  57. package/lib/packlets/ai-assist/model.js.map +1 -1
  58. package/lib/packlets/ai-assist/registry.d.ts.map +1 -1
  59. package/lib/packlets/ai-assist/registry.js +26 -0
  60. package/lib/packlets/ai-assist/registry.js.map +1 -1
  61. package/lib/packlets/ai-assist/streamingAdapters/common.d.ts +8 -0
  62. package/lib/packlets/ai-assist/streamingAdapters/common.d.ts.map +1 -1
  63. package/lib/packlets/ai-assist/streamingAdapters/common.js.map +1 -1
  64. package/lib/packlets/ai-assist/streamingAdapters/openaiChat.d.ts.map +1 -1
  65. package/lib/packlets/ai-assist/streamingAdapters/openaiChat.js +2 -1
  66. package/lib/packlets/ai-assist/streamingAdapters/openaiChat.js.map +1 -1
  67. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.d.ts.map +1 -1
  68. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.js +2 -1
  69. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.js.map +1 -1
  70. package/lib/packlets/ai-assist/streamingClient.d.ts.map +1 -1
  71. package/lib/packlets/ai-assist/streamingClient.js +11 -5
  72. package/lib/packlets/ai-assist/streamingClient.js.map +1 -1
  73. package/lib/packlets/crypto-utils/keyPairAlgorithmParams.d.ts +14 -3
  74. package/lib/packlets/crypto-utils/keyPairAlgorithmParams.d.ts.map +1 -1
  75. package/lib/packlets/crypto-utils/keyPairAlgorithmParams.js +6 -0
  76. package/lib/packlets/crypto-utils/keyPairAlgorithmParams.js.map +1 -1
  77. package/lib/packlets/crypto-utils/keystore/keyStore.d.ts +43 -1
  78. package/lib/packlets/crypto-utils/keystore/keyStore.d.ts.map +1 -1
  79. package/lib/packlets/crypto-utils/keystore/keyStore.js +81 -0
  80. package/lib/packlets/crypto-utils/keystore/keyStore.js.map +1 -1
  81. package/lib/packlets/crypto-utils/model.d.ts +16 -2
  82. package/lib/packlets/crypto-utils/model.d.ts.map +1 -1
  83. package/lib/packlets/crypto-utils/model.js +2 -1
  84. package/lib/packlets/crypto-utils/model.js.map +1 -1
  85. package/lib/packlets/crypto-utils/nodeCryptoProvider.d.ts +7 -1
  86. package/lib/packlets/crypto-utils/nodeCryptoProvider.d.ts.map +1 -1
  87. package/lib/packlets/crypto-utils/nodeCryptoProvider.js +20 -1
  88. package/lib/packlets/crypto-utils/nodeCryptoProvider.js.map +1 -1
  89. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"nodeCryptoProvider.js","sourceRoot":"","sources":["../../../src/packlets/crypto-utils/nodeCryptoProvider.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,iFAAiF;AACjF,kDAAkD;AAClD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;AAEZ,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAU,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC3G,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AASlE;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAC7B;;;;;OAKG;IACI,KAAK,CAAC,OAAO,CAAC,SAAiB,EAAE,GAAe;QACrD,OAAO,aAAa,CAAC,GAAG,EAAE;YACxB,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,gBAAgB,EAAE,CAAC;gBAC9C,MAAM,IAAI,KAAK,CAAC,eAAe,SAAS,CAAC,gBAAgB,eAAe,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YACxF,CAAC;YAED,qBAAqB;YACrB,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAErD,gBAAgB;YAChB,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,GAAG,EAAE,EAAE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AO,OAAO,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAuB,IAAI,kBAAkB,EAAE,CAAC","sourcesContent":["// Copyright (c) 2024 Erik Fortune\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport * as crypto from 'crypto';\nimport { captureAsyncResult, captureResult, fail, Failure, Result, succeed, Success } from '@fgv/ts-utils';\nimport * as Constants from './constants';\nimport { keyPairAlgorithmParams } from './keyPairAlgorithmParams';\nimport {\n ICryptoProvider,\n IEncryptionResult,\n IWrapBytesOptions,\n IWrappedBytes,\n KeyPairAlgorithm\n} from './model';\n\n/**\n * Node.js implementation of {@link CryptoUtils.ICryptoProvider} using the built-in crypto module.\n * Uses AES-256-GCM for authenticated encryption.\n * @public\n */\nexport class NodeCryptoProvider implements ICryptoProvider {\n /**\n * Encrypts plaintext using AES-256-GCM.\n * @param plaintext - UTF-8 string to encrypt\n * @param key - 32-byte encryption key\n * @returns `Success` with encryption result, or `Failure` with an error.\n */\n public async encrypt(plaintext: string, key: Uint8Array): Promise<Result<IEncryptionResult>> {\n return captureResult(() => {\n if (key.length !== Constants.AES_256_KEY_SIZE) {\n throw new Error(`Key must be ${Constants.AES_256_KEY_SIZE} bytes, got ${key.length}`);\n }\n\n // Generate random IV\n const iv = crypto.randomBytes(Constants.GCM_IV_SIZE);\n\n // Create cipher\n const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);\n\n // Encrypt\n const encrypted = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()]);\n\n // Get auth tag\n const authTag = cipher.getAuthTag();\n\n return {\n iv: new Uint8Array(iv),\n authTag: new Uint8Array(authTag),\n encryptedData: new Uint8Array(encrypted)\n };\n });\n }\n\n /**\n * Decrypts ciphertext using AES-256-GCM.\n * @param encryptedData - Encrypted bytes\n * @param key - 32-byte decryption key\n * @param iv - Initialization vector (12 bytes)\n * @param authTag - GCM authentication tag (16 bytes)\n * @returns `Success` with decrypted UTF-8 string, or `Failure` with an error.\n */\n public async decrypt(\n encryptedData: Uint8Array,\n key: Uint8Array,\n iv: Uint8Array,\n authTag: Uint8Array\n ): Promise<Result<string>> {\n if (key.length !== Constants.AES_256_KEY_SIZE) {\n return fail(`Key must be ${Constants.AES_256_KEY_SIZE} bytes, got ${key.length}`);\n }\n if (iv.length !== Constants.GCM_IV_SIZE) {\n return fail(`IV must be ${Constants.GCM_IV_SIZE} bytes, got ${iv.length}`);\n }\n if (authTag.length !== Constants.GCM_AUTH_TAG_SIZE) {\n return fail(`Auth tag must be ${Constants.GCM_AUTH_TAG_SIZE} bytes, got ${authTag.length}`);\n }\n\n return captureResult(() => {\n // Create decipher\n const decipher = crypto.createDecipheriv('aes-256-gcm', Buffer.from(key), Buffer.from(iv));\n\n // Set auth tag\n decipher.setAuthTag(Buffer.from(authTag));\n\n // Decrypt\n const decrypted = Buffer.concat([decipher.update(Buffer.from(encryptedData)), decipher.final()]);\n\n return decrypted.toString('utf8');\n }).withErrorFormat((e) => `Decryption failed: ${e}`);\n }\n\n /**\n * Generates a random 32-byte key suitable for AES-256.\n * @returns `Success` with generated key, or `Failure` with an error.\n */\n public async generateKey(): Promise<Result<Uint8Array>> {\n return captureResult(() => {\n const key = crypto.randomBytes(Constants.AES_256_KEY_SIZE);\n return new Uint8Array(key);\n });\n }\n\n /**\n * Derives a key from a password using PBKDF2.\n * @param password - Password string\n * @param salt - Salt bytes (should be at least 16 bytes)\n * @param iterations - Number of iterations (recommend 100000+)\n * @returns `Success` with derived 32-byte key, or `Failure` with an error.\n */\n public async deriveKey(\n password: string,\n salt: Uint8Array,\n iterations: number\n ): Promise<Result<Uint8Array>> {\n if (iterations < 1) {\n return fail('Iterations must be at least 1');\n }\n if (salt.length < 8) {\n return fail('Salt should be at least 8 bytes');\n }\n\n return new Promise((resolve) => {\n crypto.pbkdf2(\n password,\n Buffer.from(salt),\n iterations,\n Constants.AES_256_KEY_SIZE,\n 'sha256',\n (err, derivedKey) => {\n /* c8 ignore next 3 - PBKDF2 internal errors are hard to trigger with valid parameters */\n if (err) {\n resolve(fail(`Key derivation failed: ${err.message}`));\n } else {\n resolve(succeed(new Uint8Array(derivedKey)));\n }\n }\n );\n });\n }\n\n /**\n * Computes a SHA-256 hash of the given data.\n * @param data - UTF-8 string to hash\n * @returns `Success` with hex-encoded hash string, or `Failure` with an error.\n */\n public async sha256(data: string): Promise<Result<string>> {\n return captureResult(() => {\n const hash = crypto.createHash('sha256');\n hash.update(data, 'utf8');\n return hash.digest('hex');\n });\n }\n\n // ============================================================================\n // Platform Utility Methods\n // ============================================================================\n\n /**\n * Generates cryptographically secure random bytes.\n * @param length - Number of bytes to generate\n * @returns Success with random bytes, or Failure with error\n */\n public generateRandomBytes(length: number): Result<Uint8Array> {\n if (length < 1) {\n return Failure.with('Length must be at least 1');\n }\n return captureResult(() => new Uint8Array(crypto.randomBytes(length)));\n }\n\n /**\n * Encodes binary data to base64 string.\n * @param data - Binary data to encode\n * @returns Base64-encoded string\n */\n public toBase64(data: Uint8Array): string {\n return Buffer.from(data).toString('base64');\n }\n\n /**\n * Decodes base64 string to binary data.\n * @param base64 - Base64-encoded string\n * @returns Success with decoded bytes, or Failure if invalid base64\n */\n public fromBase64(base64: string): Result<Uint8Array> {\n // Check for obviously invalid characters\n if (!/^[A-Za-z0-9+/]*={0,2}$/.test(base64)) {\n return Failure.with('Invalid base64 string');\n }\n return Success.with(new Uint8Array(Buffer.from(base64, 'base64')));\n }\n\n // ============================================================================\n // Asymmetric Key Operations\n // ============================================================================\n\n /**\n * Generates a new asymmetric keypair using Node's WebCrypto.\n * @param algorithm - The {@link CryptoUtils.KeyPairAlgorithm | algorithm} to use.\n * @param extractable - Whether the resulting keys may be exported.\n * @returns `Success` with the generated `CryptoKeyPair`, or `Failure` with an error.\n */\n public async generateKeyPair(\n algorithm: KeyPairAlgorithm,\n extractable: boolean\n ): Promise<Result<CryptoKeyPair>> {\n const params = keyPairAlgorithmParams[algorithm];\n const result = await captureAsyncResult(() =>\n crypto.webcrypto.subtle.generateKey(params.generateKey, extractable, params.keyPairUsages)\n );\n return result.withErrorFormat((e) => `Failed to generate ${algorithm} keypair: ${e}`);\n }\n\n /**\n * Exports a public `CryptoKey` as a JSON Web Key.\n * @remarks\n * Rejects non-public keys at runtime. WebCrypto's `exportKey('jwk', ...)`\n * does not enforce public-vs-private; without this guard a caller that\n * passed an extractable private key would receive its private fields\n * (`d`, `p`, `q`, ...) as JWK, defeating the method's name.\n * @param publicKey - Extractable public key to export.\n * @returns `Success` with the JWK, or `Failure` if not a public key or if export fails.\n */\n public async exportPublicKeyJwk(publicKey: CryptoKey): Promise<Result<JsonWebKey>> {\n if (publicKey.type !== 'public') {\n return fail(`exportPublicKeyJwk requires a public CryptoKey, got '${publicKey.type}'`);\n }\n const result = await captureAsyncResult(() => crypto.webcrypto.subtle.exportKey('jwk', publicKey));\n return result.withErrorFormat((e) => `Failed to export public key as JWK: ${e}`);\n }\n\n /**\n * Imports a public-key JWK as a `CryptoKey` for the requested algorithm.\n * @param jwk - The JSON Web Key produced by a prior export.\n * @param algorithm - The algorithm the key was generated for.\n * @returns `Success` with the imported public `CryptoKey`, or `Failure` with an error.\n */\n public async importPublicKeyJwk(jwk: JsonWebKey, algorithm: KeyPairAlgorithm): Promise<Result<CryptoKey>> {\n const params = keyPairAlgorithmParams[algorithm];\n const result = await captureAsyncResult(() =>\n crypto.webcrypto.subtle.importKey('jwk', jwk, params.importPublicKey, true, params.publicKeyUsages)\n );\n return result.withErrorFormat((e) => `Failed to import ${algorithm} public key from JWK: ${e}`);\n }\n\n /**\n * Wraps `plaintext` for the holder of `recipientPublicKey` using\n * ECIES (ECDH P-256 + HKDF-SHA256 + AES-GCM-256). See\n * {@link CryptoUtils.ICryptoProvider.wrapBytes | ICryptoProvider.wrapBytes}.\n * @param plaintext - The bytes to wrap.\n * @param recipientPublicKey - The recipient's ECDH P-256 public `CryptoKey`.\n * @param options - HKDF salt and info; see {@link CryptoUtils.IWrapBytesOptions | IWrapBytesOptions}.\n * @returns `Success` with the wrapped payload, or `Failure` with an error.\n */\n public async wrapBytes(\n plaintext: Uint8Array,\n recipientPublicKey: CryptoKey,\n options: IWrapBytesOptions\n ): Promise<Result<IWrappedBytes>> {\n const recipientCheck = checkEcdhP256(recipientPublicKey, 'public', 'recipient public key');\n if (recipientCheck.isFailure()) {\n return fail(`wrapBytes failed: ${recipientCheck.message}`);\n }\n const subtle = crypto.webcrypto.subtle;\n const result = await captureAsyncResult(async () => {\n const ephemeral = (await subtle.generateKey({ name: 'ECDH', namedCurve: 'P-256' }, true, [\n 'deriveKey'\n ])) as CryptoKeyPair;\n const hkdfBase = await subtle.deriveKey(\n { name: 'ECDH', public: recipientPublicKey },\n ephemeral.privateKey,\n { name: 'HKDF' },\n false,\n ['deriveKey']\n );\n const wrapKey = await subtle.deriveKey(\n { name: 'HKDF', salt: options.salt, info: options.info, hash: 'SHA-256' },\n hkdfBase,\n { name: 'AES-GCM', length: 256 },\n false,\n ['encrypt']\n );\n const nonce = crypto.randomBytes(Constants.GCM_IV_SIZE);\n const ctBuf = await subtle.encrypt({ name: 'AES-GCM', iv: nonce }, wrapKey, plaintext);\n const ephemeralPublicKey = await subtle.exportKey('jwk', ephemeral.publicKey);\n return {\n ephemeralPublicKey,\n nonce: this.toBase64(nonce),\n ciphertext: this.toBase64(new Uint8Array(ctBuf))\n };\n });\n return result.withErrorFormat((e) => `wrapBytes failed: ${e}`);\n }\n\n /**\n * Unwraps a payload produced by `wrapBytes` using the recipient's private\n * key. See {@link CryptoUtils.ICryptoProvider.unwrapBytes | ICryptoProvider.unwrapBytes}.\n * @param wrapped - The wrapped payload.\n * @param recipientPrivateKey - The recipient's ECDH P-256 private `CryptoKey`.\n * @param options - HKDF salt and info matching the wrap call.\n * @returns `Success` with the original `plaintext`, or `Failure` with an error.\n */\n public async unwrapBytes(\n wrapped: IWrappedBytes,\n recipientPrivateKey: CryptoKey,\n options: IWrapBytesOptions\n ): Promise<Result<Uint8Array>> {\n const recipientCheck = checkEcdhP256(recipientPrivateKey, 'private', 'recipient private key');\n if (recipientCheck.isFailure()) {\n return fail(`unwrapBytes failed: ${recipientCheck.message}`);\n }\n const nonceResult = this.fromBase64(wrapped.nonce);\n if (nonceResult.isFailure()) {\n return fail(`unwrapBytes failed: nonce: ${nonceResult.message}`);\n }\n if (nonceResult.value.length !== Constants.GCM_IV_SIZE) {\n return fail(\n `unwrapBytes failed: nonce must be ${Constants.GCM_IV_SIZE} bytes (got ${nonceResult.value.length})`\n );\n }\n const ciphertextResult = this.fromBase64(wrapped.ciphertext);\n if (ciphertextResult.isFailure()) {\n return fail(`unwrapBytes failed: ciphertext: ${ciphertextResult.message}`);\n }\n if (ciphertextResult.value.length < Constants.GCM_AUTH_TAG_SIZE) {\n return fail(\n `unwrapBytes failed: ciphertext must be at least ${Constants.GCM_AUTH_TAG_SIZE} bytes (got ${ciphertextResult.value.length})`\n );\n }\n const subtle = crypto.webcrypto.subtle;\n const result = await captureAsyncResult(async () => {\n const ephemeralPub = await subtle.importKey(\n 'jwk',\n wrapped.ephemeralPublicKey,\n { name: 'ECDH', namedCurve: 'P-256' },\n false,\n []\n );\n const hkdfBase = await subtle.deriveKey(\n { name: 'ECDH', public: ephemeralPub },\n recipientPrivateKey,\n { name: 'HKDF' },\n false,\n ['deriveKey']\n );\n const wrapKey = await subtle.deriveKey(\n { name: 'HKDF', salt: options.salt, info: options.info, hash: 'SHA-256' },\n hkdfBase,\n { name: 'AES-GCM', length: 256 },\n false,\n ['decrypt']\n );\n const ptBuf = await subtle.decrypt(\n { name: 'AES-GCM', iv: nonceResult.value },\n wrapKey,\n ciphertextResult.value\n );\n return new Uint8Array(ptBuf);\n });\n return result.withErrorFormat((e) => `unwrapBytes failed: ${e}`);\n }\n}\n\n/**\n * Verifies that `key` is an ECDH P-256 `CryptoKey` of the expected `keyType`\n * (public or private). Used by the wrap/unwrap methods to surface a clean\n * `Failure` instead of letting the WebCrypto deriveKey call throw a less\n * informative error later in the pipeline. Key usages are intentionally not\n * checked here: WebCrypto already produces a specific error if `deriveKey` is\n * not in `usages`, and `deriveBits` is an equally valid alternative usage that\n * an explicit check would have to track.\n * @param key - The CryptoKey to validate.\n * @param keyType - The required `key.type` ('public' for wrap, 'private' for unwrap).\n * @param label - Human-readable role label included in the failure message.\n * @returns `Success` with the key (unchanged) when the algorithm, curve, and\n * type all match; otherwise `Failure` with `<label> must be ECDH P-256 (...)`.\n */\nfunction checkEcdhP256(key: CryptoKey, keyType: 'public' | 'private', label: string): Result<CryptoKey> {\n if (key.algorithm.name !== 'ECDH') {\n return fail(`${label} must be ECDH P-256 (got algorithm '${key.algorithm.name}')`);\n }\n const namedCurve = (key.algorithm as EcKeyAlgorithm).namedCurve;\n if (namedCurve !== 'P-256') {\n return fail(`${label} must be ECDH P-256 (got curve '${namedCurve}')`);\n }\n if (key.type !== keyType) {\n return fail(`${label} must be a ${keyType} CryptoKey (got '${key.type}')`);\n }\n return succeed(key);\n}\n\n/**\n * Singleton instance of {@link CryptoUtils.NodeCryptoProvider}.\n * @public\n */\nexport const nodeCryptoProvider: NodeCryptoProvider = new NodeCryptoProvider();\n"]}
1
+ {"version":3,"file":"nodeCryptoProvider.js","sourceRoot":"","sources":["../../../src/packlets/crypto-utils/nodeCryptoProvider.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,iFAAiF;AACjF,kDAAkD;AAClD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;AAEZ,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,IAAI,EACJ,OAAO,EACP,YAAY,EAEZ,OAAO,EACP,OAAO,EAER,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AASlE;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAC7B;;;;;OAKG;IACI,KAAK,CAAC,OAAO,CAAC,SAAiB,EAAE,GAAe;QACrD,OAAO,aAAa,CAAC,GAAG,EAAE;YACxB,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,gBAAgB,EAAE,CAAC;gBAC9C,MAAM,IAAI,KAAK,CAAC,eAAe,SAAS,CAAC,gBAAgB,eAAe,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YACxF,CAAC;YAED,qBAAqB;YACrB,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAErD,gBAAgB;YAChB,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;YA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AAS,CAAC,IAAI,IAAI,CAAC,CAAC;IACrF,CAAC;IACD,MAAM,UAAU,GAAI,GAAG,CAAC,SAA4B,CAAC,UAAU,CAAC;IAChE,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,GAAG,KAAK,mCAAmC,UAAU,IAAI,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,GAAG,KAAK,cAAc,OAAO,oBAAoB,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAuB,IAAI,kBAAkB,EAAE,CAAC","sourcesContent":["// Copyright (c) 2024 Erik Fortune\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport * as crypto from 'crypto';\nimport {\n captureAsyncResult,\n captureResult,\n fail,\n Failure,\n generateUuid,\n Result,\n succeed,\n Success,\n Uuid\n} from '@fgv/ts-utils';\nimport * as Constants from './constants';\nimport { keyPairAlgorithmParams } from './keyPairAlgorithmParams';\nimport {\n ICryptoProvider,\n IEncryptionResult,\n IWrapBytesOptions,\n IWrappedBytes,\n KeyPairAlgorithm\n} from './model';\n\n/**\n * Node.js implementation of {@link CryptoUtils.ICryptoProvider} using the built-in crypto module.\n * Uses AES-256-GCM for authenticated encryption.\n * @public\n */\nexport class NodeCryptoProvider implements ICryptoProvider {\n /**\n * Encrypts plaintext using AES-256-GCM.\n * @param plaintext - UTF-8 string to encrypt\n * @param key - 32-byte encryption key\n * @returns `Success` with encryption result, or `Failure` with an error.\n */\n public async encrypt(plaintext: string, key: Uint8Array): Promise<Result<IEncryptionResult>> {\n return captureResult(() => {\n if (key.length !== Constants.AES_256_KEY_SIZE) {\n throw new Error(`Key must be ${Constants.AES_256_KEY_SIZE} bytes, got ${key.length}`);\n }\n\n // Generate random IV\n const iv = crypto.randomBytes(Constants.GCM_IV_SIZE);\n\n // Create cipher\n const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);\n\n // Encrypt\n const encrypted = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()]);\n\n // Get auth tag\n const authTag = cipher.getAuthTag();\n\n return {\n iv: new Uint8Array(iv),\n authTag: new Uint8Array(authTag),\n encryptedData: new Uint8Array(encrypted)\n };\n });\n }\n\n /**\n * Decrypts ciphertext using AES-256-GCM.\n * @param encryptedData - Encrypted bytes\n * @param key - 32-byte decryption key\n * @param iv - Initialization vector (12 bytes)\n * @param authTag - GCM authentication tag (16 bytes)\n * @returns `Success` with decrypted UTF-8 string, or `Failure` with an error.\n */\n public async decrypt(\n encryptedData: Uint8Array,\n key: Uint8Array,\n iv: Uint8Array,\n authTag: Uint8Array\n ): Promise<Result<string>> {\n if (key.length !== Constants.AES_256_KEY_SIZE) {\n return fail(`Key must be ${Constants.AES_256_KEY_SIZE} bytes, got ${key.length}`);\n }\n if (iv.length !== Constants.GCM_IV_SIZE) {\n return fail(`IV must be ${Constants.GCM_IV_SIZE} bytes, got ${iv.length}`);\n }\n if (authTag.length !== Constants.GCM_AUTH_TAG_SIZE) {\n return fail(`Auth tag must be ${Constants.GCM_AUTH_TAG_SIZE} bytes, got ${authTag.length}`);\n }\n\n return captureResult(() => {\n // Create decipher\n const decipher = crypto.createDecipheriv('aes-256-gcm', Buffer.from(key), Buffer.from(iv));\n\n // Set auth tag\n decipher.setAuthTag(Buffer.from(authTag));\n\n // Decrypt\n const decrypted = Buffer.concat([decipher.update(Buffer.from(encryptedData)), decipher.final()]);\n\n return decrypted.toString('utf8');\n }).withErrorFormat((e) => `Decryption failed: ${e}`);\n }\n\n /**\n * Generates a random 32-byte key suitable for AES-256.\n * @returns `Success` with generated key, or `Failure` with an error.\n */\n public async generateKey(): Promise<Result<Uint8Array>> {\n return captureResult(() => {\n const key = crypto.randomBytes(Constants.AES_256_KEY_SIZE);\n return new Uint8Array(key);\n });\n }\n\n /**\n * Derives a key from a password using PBKDF2.\n * @param password - Password string\n * @param salt - Salt bytes (should be at least 16 bytes)\n * @param iterations - Number of iterations (recommend 100000+)\n * @returns `Success` with derived 32-byte key, or `Failure` with an error.\n */\n public async deriveKey(\n password: string,\n salt: Uint8Array,\n iterations: number\n ): Promise<Result<Uint8Array>> {\n if (iterations < 1) {\n return fail('Iterations must be at least 1');\n }\n if (salt.length < 8) {\n return fail('Salt should be at least 8 bytes');\n }\n\n return new Promise((resolve) => {\n crypto.pbkdf2(\n password,\n Buffer.from(salt),\n iterations,\n Constants.AES_256_KEY_SIZE,\n 'sha256',\n (err, derivedKey) => {\n /* c8 ignore next 3 - PBKDF2 internal errors are hard to trigger with valid parameters */\n if (err) {\n resolve(fail(`Key derivation failed: ${err.message}`));\n } else {\n resolve(succeed(new Uint8Array(derivedKey)));\n }\n }\n );\n });\n }\n\n /**\n * Computes a SHA-256 hash of the given data.\n * @param data - UTF-8 string to hash\n * @returns `Success` with hex-encoded hash string, or `Failure` with an error.\n */\n public async sha256(data: string): Promise<Result<string>> {\n return captureResult(() => {\n const hash = crypto.createHash('sha256');\n hash.update(data, 'utf8');\n return hash.digest('hex');\n });\n }\n\n // ============================================================================\n // Platform Utility Methods\n // ============================================================================\n\n /**\n * Generates cryptographically secure random bytes.\n * @param length - Number of bytes to generate\n * @returns Success with random bytes, or Failure with error\n */\n public generateRandomBytes(length: number): Result<Uint8Array> {\n if (length < 1) {\n return Failure.with('Length must be at least 1');\n }\n return captureResult(() => new Uint8Array(crypto.randomBytes(length)));\n }\n\n /**\n * Generates a cryptographically random UUIDv4 via the platform Web Crypto API.\n * @returns `Success` with the generated UUID, or `Failure` if the runtime\n * does not expose `globalThis.crypto.randomUUID`.\n */\n public generateUuid(): Result<Uuid> {\n return captureResult(() => generateUuid());\n }\n\n /**\n * Encodes binary data to base64 string.\n * @param data - Binary data to encode\n * @returns Base64-encoded string\n */\n public toBase64(data: Uint8Array): string {\n return Buffer.from(data).toString('base64');\n }\n\n /**\n * Decodes base64 string to binary data.\n * @param base64 - Base64-encoded string\n * @returns Success with decoded bytes, or Failure if invalid base64\n */\n public fromBase64(base64: string): Result<Uint8Array> {\n // Check for obviously invalid characters\n if (!/^[A-Za-z0-9+/]*={0,2}$/.test(base64)) {\n return Failure.with('Invalid base64 string');\n }\n return Success.with(new Uint8Array(Buffer.from(base64, 'base64')));\n }\n\n // ============================================================================\n // Asymmetric Key Operations\n // ============================================================================\n\n /**\n * Generates a new asymmetric keypair using Node's WebCrypto.\n * @param algorithm - The {@link CryptoUtils.KeyPairAlgorithm | algorithm} to use.\n * @param extractable - Whether the resulting keys may be exported.\n * @returns `Success` with the generated `CryptoKeyPair`, or `Failure` with an error.\n */\n public async generateKeyPair(\n algorithm: KeyPairAlgorithm,\n extractable: boolean\n ): Promise<Result<CryptoKeyPair>> {\n const params = keyPairAlgorithmParams[algorithm];\n // Widening upcast to `AlgorithmIdentifier` steers TS to subtle.generateKey's\n // broad overload, which accepts the Ed25519 `{ name: 'Ed25519' }` shape and\n // returns `CryptoKey | CryptoKeyPair`. The narrowing back to `CryptoKeyPair`\n // is a runtime check via the `in` operator, not a type assertion.\n const result = await captureAsyncResult(async () => {\n const generated = await crypto.webcrypto.subtle.generateKey(\n params.generateKey as AlgorithmIdentifier,\n extractable,\n [...params.keyPairUsages]\n );\n if ('privateKey' in generated && 'publicKey' in generated) {\n return generated;\n }\n /* c8 ignore next - unreachable: every entry in keyPairAlgorithmParams produces a keypair */\n throw new Error(`${algorithm} unexpectedly produced a single CryptoKey`);\n });\n return result.withErrorFormat((e) => `Failed to generate ${algorithm} keypair: ${e}`);\n }\n\n /**\n * Exports a public `CryptoKey` as a JSON Web Key.\n * @remarks\n * Rejects non-public keys at runtime. WebCrypto's `exportKey('jwk', ...)`\n * does not enforce public-vs-private; without this guard a caller that\n * passed an extractable private key would receive its private fields\n * (`d`, `p`, `q`, ...) as JWK, defeating the method's name.\n * @param publicKey - Extractable public key to export.\n * @returns `Success` with the JWK, or `Failure` if not a public key or if export fails.\n */\n public async exportPublicKeyJwk(publicKey: CryptoKey): Promise<Result<JsonWebKey>> {\n if (publicKey.type !== 'public') {\n return fail(`exportPublicKeyJwk requires a public CryptoKey, got '${publicKey.type}'`);\n }\n const result = await captureAsyncResult(() => crypto.webcrypto.subtle.exportKey('jwk', publicKey));\n return result.withErrorFormat((e) => `Failed to export public key as JWK: ${e}`);\n }\n\n /**\n * Imports a public-key JWK as a `CryptoKey` for the requested algorithm.\n * @param jwk - The JSON Web Key produced by a prior export.\n * @param algorithm - The algorithm the key was generated for.\n * @returns `Success` with the imported public `CryptoKey`, or `Failure` with an error.\n */\n public async importPublicKeyJwk(jwk: JsonWebKey, algorithm: KeyPairAlgorithm): Promise<Result<CryptoKey>> {\n const params = keyPairAlgorithmParams[algorithm];\n const result = await captureAsyncResult(() =>\n crypto.webcrypto.subtle.importKey('jwk', jwk, params.importPublicKey, true, params.publicKeyUsages)\n );\n return result.withErrorFormat((e) => `Failed to import ${algorithm} public key from JWK: ${e}`);\n }\n\n /**\n * Wraps `plaintext` for the holder of `recipientPublicKey` using\n * ECIES (ECDH P-256 + HKDF-SHA256 + AES-GCM-256). See\n * {@link CryptoUtils.ICryptoProvider.wrapBytes | ICryptoProvider.wrapBytes}.\n * @param plaintext - The bytes to wrap.\n * @param recipientPublicKey - The recipient's ECDH P-256 public `CryptoKey`.\n * @param options - HKDF salt and info; see {@link CryptoUtils.IWrapBytesOptions | IWrapBytesOptions}.\n * @returns `Success` with the wrapped payload, or `Failure` with an error.\n */\n public async wrapBytes(\n plaintext: Uint8Array,\n recipientPublicKey: CryptoKey,\n options: IWrapBytesOptions\n ): Promise<Result<IWrappedBytes>> {\n const recipientCheck = checkEcdhP256(recipientPublicKey, 'public', 'recipient public key');\n if (recipientCheck.isFailure()) {\n return fail(`wrapBytes failed: ${recipientCheck.message}`);\n }\n const subtle = crypto.webcrypto.subtle;\n const result = await captureAsyncResult(async () => {\n const ephemeral = (await subtle.generateKey({ name: 'ECDH', namedCurve: 'P-256' }, true, [\n 'deriveKey'\n ])) as CryptoKeyPair;\n const hkdfBase = await subtle.deriveKey(\n { name: 'ECDH', public: recipientPublicKey },\n ephemeral.privateKey,\n { name: 'HKDF' },\n false,\n ['deriveKey']\n );\n const wrapKey = await subtle.deriveKey(\n { name: 'HKDF', salt: options.salt, info: options.info, hash: 'SHA-256' },\n hkdfBase,\n { name: 'AES-GCM', length: 256 },\n false,\n ['encrypt']\n );\n const nonce = crypto.randomBytes(Constants.GCM_IV_SIZE);\n const ctBuf = await subtle.encrypt({ name: 'AES-GCM', iv: nonce }, wrapKey, plaintext);\n const ephemeralPublicKey = await subtle.exportKey('jwk', ephemeral.publicKey);\n return {\n ephemeralPublicKey,\n nonce: this.toBase64(nonce),\n ciphertext: this.toBase64(new Uint8Array(ctBuf))\n };\n });\n return result.withErrorFormat((e) => `wrapBytes failed: ${e}`);\n }\n\n /**\n * Unwraps a payload produced by `wrapBytes` using the recipient's private\n * key. See {@link CryptoUtils.ICryptoProvider.unwrapBytes | ICryptoProvider.unwrapBytes}.\n * @param wrapped - The wrapped payload.\n * @param recipientPrivateKey - The recipient's ECDH P-256 private `CryptoKey`.\n * @param options - HKDF salt and info matching the wrap call.\n * @returns `Success` with the original `plaintext`, or `Failure` with an error.\n */\n public async unwrapBytes(\n wrapped: IWrappedBytes,\n recipientPrivateKey: CryptoKey,\n options: IWrapBytesOptions\n ): Promise<Result<Uint8Array>> {\n const recipientCheck = checkEcdhP256(recipientPrivateKey, 'private', 'recipient private key');\n if (recipientCheck.isFailure()) {\n return fail(`unwrapBytes failed: ${recipientCheck.message}`);\n }\n const nonceResult = this.fromBase64(wrapped.nonce);\n if (nonceResult.isFailure()) {\n return fail(`unwrapBytes failed: nonce: ${nonceResult.message}`);\n }\n if (nonceResult.value.length !== Constants.GCM_IV_SIZE) {\n return fail(\n `unwrapBytes failed: nonce must be ${Constants.GCM_IV_SIZE} bytes (got ${nonceResult.value.length})`\n );\n }\n const ciphertextResult = this.fromBase64(wrapped.ciphertext);\n if (ciphertextResult.isFailure()) {\n return fail(`unwrapBytes failed: ciphertext: ${ciphertextResult.message}`);\n }\n if (ciphertextResult.value.length < Constants.GCM_AUTH_TAG_SIZE) {\n return fail(\n `unwrapBytes failed: ciphertext must be at least ${Constants.GCM_AUTH_TAG_SIZE} bytes (got ${ciphertextResult.value.length})`\n );\n }\n const subtle = crypto.webcrypto.subtle;\n const result = await captureAsyncResult(async () => {\n const ephemeralPub = await subtle.importKey(\n 'jwk',\n wrapped.ephemeralPublicKey,\n { name: 'ECDH', namedCurve: 'P-256' },\n false,\n []\n );\n const hkdfBase = await subtle.deriveKey(\n { name: 'ECDH', public: ephemeralPub },\n recipientPrivateKey,\n { name: 'HKDF' },\n false,\n ['deriveKey']\n );\n const wrapKey = await subtle.deriveKey(\n { name: 'HKDF', salt: options.salt, info: options.info, hash: 'SHA-256' },\n hkdfBase,\n { name: 'AES-GCM', length: 256 },\n false,\n ['decrypt']\n );\n const ptBuf = await subtle.decrypt(\n { name: 'AES-GCM', iv: nonceResult.value },\n wrapKey,\n ciphertextResult.value\n );\n return new Uint8Array(ptBuf);\n });\n return result.withErrorFormat((e) => `unwrapBytes failed: ${e}`);\n }\n}\n\n/**\n * Verifies that `key` is an ECDH P-256 `CryptoKey` of the expected `keyType`\n * (public or private). Used by the wrap/unwrap methods to surface a clean\n * `Failure` instead of letting the WebCrypto deriveKey call throw a less\n * informative error later in the pipeline. Key usages are intentionally not\n * checked here: WebCrypto already produces a specific error if `deriveKey` is\n * not in `usages`, and `deriveBits` is an equally valid alternative usage that\n * an explicit check would have to track.\n * @param key - The CryptoKey to validate.\n * @param keyType - The required `key.type` ('public' for wrap, 'private' for unwrap).\n * @param label - Human-readable role label included in the failure message.\n * @returns `Success` with the key (unchanged) when the algorithm, curve, and\n * type all match; otherwise `Failure` with `<label> must be ECDH P-256 (...)`.\n */\nfunction checkEcdhP256(key: CryptoKey, keyType: 'public' | 'private', label: string): Result<CryptoKey> {\n if (key.algorithm.name !== 'ECDH') {\n return fail(`${label} must be ECDH P-256 (got algorithm '${key.algorithm.name}')`);\n }\n const namedCurve = (key.algorithm as EcKeyAlgorithm).namedCurve;\n if (namedCurve !== 'P-256') {\n return fail(`${label} must be ECDH P-256 (got curve '${namedCurve}')`);\n }\n if (key.type !== keyType) {\n return fail(`${label} must be a ${keyType} CryptoKey (got '${key.type}')`);\n }\n return succeed(key);\n}\n\n/**\n * Singleton instance of {@link CryptoUtils.NodeCryptoProvider}.\n * @public\n */\nexport const nodeCryptoProvider: NodeCryptoProvider = new NodeCryptoProvider();\n"]}
@@ -6,6 +6,7 @@ import { Hash as Hash_2 } from '@fgv/ts-utils';
6
6
  import { JsonValue } from '@fgv/ts-json-base';
7
7
  import { Logging } from '@fgv/ts-utils';
8
8
  import { Result } from '@fgv/ts-utils';
9
+ import { Uuid } from '@fgv/ts-utils';
9
10
  import { Validator } from '@fgv/ts-utils';
10
11
 
11
12
  /**
@@ -87,7 +88,17 @@ declare namespace AiAssist {
87
88
  aiAssistSettings,
88
89
  modelSpecKey,
89
90
  modelSpec,
90
- resolveEffectiveTools
91
+ resolveEffectiveTools,
92
+ extractJsonText,
93
+ fencedStringifiedJson,
94
+ IFencedStringifiedJsonExtractorOptions,
95
+ IFencedStringifiedJsonOptions,
96
+ JsonTextExtractor,
97
+ generateJsonCompletion,
98
+ SMART_JSON_PROMPT_HINT,
99
+ IGenerateJsonCompletionParams,
100
+ IGenerateJsonCompletionResult,
101
+ JsonPromptHint
91
102
  }
92
103
  }
93
104
  export { AiAssist }
@@ -163,7 +174,7 @@ declare class AiPrompt {
163
174
  * All known AI provider identifiers.
164
175
  * @public
165
176
  */
166
- declare type AiProviderId = 'copy-paste' | 'xai-grok' | 'openai' | 'anthropic' | 'google-gemini' | 'groq' | 'mistral';
177
+ declare type AiProviderId = 'copy-paste' | 'xai-grok' | 'openai' | 'openai-compat' | 'anthropic' | 'google-gemini' | 'groq' | 'mistral' | 'ollama';
167
178
 
168
179
  /**
169
180
  * Converter for {@link AiProviderId}.
@@ -768,6 +779,54 @@ declare class ExtendedArray<T> extends Array<T> {
768
779
  */
769
780
  declare function extendedArrayOf<T, TC = undefined>(label: string, converter: Converter<T, TC>, onError?: Conversion.OnError): Converter<ExtendedArray<T>, TC>;
770
781
 
782
+ /**
783
+ * Default {@link AiAssist.JsonTextExtractor | extractor} for LLM responses. Tolerates:
784
+ *
785
+ * - Leading/trailing whitespace and a leading byte-order mark.
786
+ * - Markdown code fences (with or without a language tag).
787
+ * - Conversational preamble before the first `{` or `[`.
788
+ * - Trailing prose after the matched closing `}` or `]`.
789
+ *
790
+ * Out of scope: repairing malformed JSON, handling smart quotes, etc.
791
+ *
792
+ * @param text - Raw model output.
793
+ * @returns A `Result<string>` containing the JSON-shaped substring, or a
794
+ * `Failure` if no JSON-shaped substring was found.
795
+ * @public
796
+ */
797
+ declare const extractJsonText: JsonTextExtractor;
798
+
799
+ /**
800
+ * Creates a `Converter` that accepts raw LLM response text, runs it through a
801
+ * tolerant extractor (default: {@link AiAssist.extractJsonText}), parses the
802
+ * extracted substring as JSON, and applies an optional inner converter or
803
+ * validator.
804
+ *
805
+ * @example
806
+ * ```ts
807
+ * const converter = fencedStringifiedJson({ inner: myShapeConverter });
808
+ * const result = converter.convert(llmText); // Result<MyShape>
809
+ * ```
810
+ *
811
+ * @param options - Optional extractor; omit to keep the default. Without an
812
+ * `inner` step, the converter resolves to the parsed `JsonValue`.
813
+ * @returns A `Converter<JsonValue>`.
814
+ * @public
815
+ */
816
+ declare function fencedStringifiedJson(options?: IFencedStringifiedJsonExtractorOptions): Converter<JsonValue>;
817
+
818
+ /**
819
+ * Creates a `Converter` that accepts raw LLM response text, runs it through a
820
+ * tolerant extractor (default: {@link AiAssist.extractJsonText}), parses the
821
+ * extracted substring as JSON, and applies the supplied inner converter or
822
+ * validator.
823
+ *
824
+ * @param options - Required `inner` converter/validator and optional extractor.
825
+ * @returns A `Converter<T>`.
826
+ * @public
827
+ */
828
+ declare function fencedStringifiedJson<T>(options: IFencedStringifiedJsonOptions<T>): Converter<T>;
829
+
771
830
  /**
772
831
  * Formats a list of items using the supplied template and formatter, one result
773
832
  * per output line.
@@ -859,6 +918,27 @@ declare const GCM_AUTH_TAG_SIZE: number;
859
918
  */
860
919
  declare const GCM_IV_SIZE: number;
861
920
 
921
+ /**
922
+ * Calls {@link AiAssist.callProviderCompletion}, then runs the response text
923
+ * through a tolerant JSON converter (default:
924
+ * {@link AiAssist.fencedStringifiedJson}) and the caller's
925
+ * `converter`/`validator`. Returns the validated value plus the raw text and
926
+ * underlying completion response for diagnostics.
927
+ *
928
+ * @remarks
929
+ * The default smart prompt hint asks the model to emit raw JSON. The read-side
930
+ * extractor still tolerates fences and prose, so models that ignore the hint
931
+ * are still handled.
932
+ *
933
+ * Either `converter` or `jsonConverter` must be provided; passing both lets
934
+ * `jsonConverter` win.
935
+ *
936
+ * @param params - Provider parameters plus JSON validation options.
937
+ * @returns The validated value, the raw text, and the underlying response.
938
+ * @public
939
+ */
940
+ declare function generateJsonCompletion<T>(params: IGenerateJsonCompletionParams<T>): Promise<Result<IGenerateJsonCompletionResult<T>>>;
941
+
862
942
  /**
863
943
  * Get a provider descriptor by id.
864
944
  * @param id - The provider identifier
@@ -1017,6 +1097,14 @@ declare interface IAiAssistProviderConfig {
1017
1097
  readonly model?: ModelSpec;
1018
1098
  /** Tool enablement/configuration. Tools are disabled unless explicitly enabled. */
1019
1099
  readonly tools?: ReadonlyArray<IAiToolEnablement>;
1100
+ /**
1101
+ * Optional caller-supplied endpoint URL (http/https). Overrides
1102
+ * `descriptor.baseUrl` for this provider. Used to point a provider at a
1103
+ * self-hosted server (Ollama, LM Studio, llama.cpp's openai-server) or a
1104
+ * local proxy. Validation lives in `@fgv/ts-extras` — query strings,
1105
+ * fragments, and userinfo are rejected.
1106
+ */
1107
+ readonly endpoint?: string;
1020
1108
  }
1021
1109
 
1022
1110
  /**
@@ -1532,6 +1620,15 @@ declare interface ICryptoProvider {
1532
1620
  * @returns Success with random bytes, or Failure with error
1533
1621
  */
1534
1622
  generateRandomBytes(length: number): Result<Uint8Array>;
1623
+ /**
1624
+ * Generates a cryptographically random UUIDv4 using the provider's
1625
+ * underlying source of randomness. The default Node and browser
1626
+ * implementations delegate to `globalThis.crypto.randomUUID`;
1627
+ * deterministic providers (e.g. test stubs) may override to produce
1628
+ * reproducible values.
1629
+ * @returns Success with a canonical UUID, or Failure with error.
1630
+ */
1631
+ generateUuid(): Result<Uuid>;
1535
1632
  /**
1536
1633
  * Encodes binary data to base64 string.
1537
1634
  * @param data - Binary data to encode
@@ -1749,6 +1846,70 @@ declare interface IEncryptionResult {
1749
1846
  readonly encryptedData: Uint8Array;
1750
1847
  }
1751
1848
 
1849
+ /**
1850
+ * Options shared by every {@link AiAssist.fencedStringifiedJson} call.
1851
+ * @public
1852
+ */
1853
+ declare interface IFencedStringifiedJsonExtractorOptions {
1854
+ /**
1855
+ * Optional pre-parse extractor. Defaults to {@link AiAssist.extractJsonText}.
1856
+ * Provide a custom extractor to handle response shapes the default does not
1857
+ * understand.
1858
+ */
1859
+ readonly extractor?: JsonTextExtractor;
1860
+ }
1861
+
1862
+ /**
1863
+ * Options for the validating overload of {@link AiAssist.fencedStringifiedJson}.
1864
+ * `inner` is required so the typed `Converter<T>` return value can never lie
1865
+ * about the runtime shape.
1866
+ * @public
1867
+ */
1868
+ declare interface IFencedStringifiedJsonOptions<T> extends IFencedStringifiedJsonExtractorOptions {
1869
+ /** Inner converter or validator applied to the parsed JSON value. */
1870
+ readonly inner: Converter<T> | Validator<T>;
1871
+ }
1872
+
1873
+ /**
1874
+ * Parameters for {@link AiAssist.generateJsonCompletion}. Extends
1875
+ * {@link AiAssist.IProviderCompletionParams} with JSON-validation knobs.
1876
+ * @public
1877
+ */
1878
+ declare interface IGenerateJsonCompletionParams<T> extends IProviderCompletionParams {
1879
+ /**
1880
+ * Caller-supplied `Converter<T>` or `Validator<T>` applied to the parsed
1881
+ * JSON value. Wrapped internally in {@link AiAssist.fencedStringifiedJson}
1882
+ * unless {@link AiAssist.IGenerateJsonCompletionParams.jsonConverter} is
1883
+ * provided.
1884
+ */
1885
+ readonly converter?: Converter<T> | Validator<T>;
1886
+ /**
1887
+ * Full string-to-`T` pipeline override. When supplied, takes precedence over
1888
+ * {@link AiAssist.IGenerateJsonCompletionParams.converter} and lets the
1889
+ * caller plug in a custom extractor or skip the default fence tolerance
1890
+ * entirely.
1891
+ */
1892
+ readonly jsonConverter?: Converter<T>;
1893
+ /**
1894
+ * Controls the optional system-prompt augmentation. Defaults to `'smart'`.
1895
+ * Pass `'none'` to disable, or a string to append custom guidance.
1896
+ */
1897
+ readonly promptHint?: JsonPromptHint;
1898
+ }
1899
+
1900
+ /**
1901
+ * Successful result of {@link AiAssist.generateJsonCompletion}.
1902
+ * @public
1903
+ */
1904
+ declare interface IGenerateJsonCompletionResult<T> {
1905
+ /** The validated JSON value. */
1906
+ readonly value: T;
1907
+ /** The raw response text returned by the provider. */
1908
+ readonly raw: string;
1909
+ /** The full underlying completion response. */
1910
+ readonly response: IAiCompletionResponse;
1911
+ }
1912
+
1752
1913
  /**
1753
1914
  * Options for importing raw key material via {@link KeyStore.importSecret}.
1754
1915
  * Extends {@link IImportSecretOptions} with a type classification.
@@ -1804,13 +1965,24 @@ declare interface IKeyPairAlgorithmParams {
1804
1965
  /**
1805
1966
  * Algorithm parameters for `crypto.subtle.generateKey`. Always an asymmetric
1806
1967
  * variant — these algorithms produce a `CryptoKeyPair`, not a single key.
1968
+ * The literal `{ name: 'Ed25519' }` member covers WebCrypto's Secure-Curves
1969
+ * Ed25519 algorithm, which takes only a `name`; using a literal rather than
1970
+ * the base `Algorithm` keeps the union closed to the algorithms this table
1971
+ * supports.
1807
1972
  */
1808
- readonly generateKey: RsaHashedKeyGenParams | EcKeyGenParams;
1973
+ readonly generateKey: RsaHashedKeyGenParams | EcKeyGenParams | {
1974
+ readonly name: 'Ed25519';
1975
+ };
1809
1976
  /**
1810
1977
  * Algorithm parameters for `crypto.subtle.importKey('jwk', ...)` when
1811
- * importing the public half of a keypair.
1978
+ * importing the public half of a keypair. The literal `{ name: 'Ed25519' }`
1979
+ * member covers Ed25519 imports, which take only a `name`; using a literal
1980
+ * rather than the base `Algorithm` keeps the union closed to the algorithms
1981
+ * this table supports.
1812
1982
  */
1813
- readonly importPublicKey: RsaHashedImportParams | EcKeyImportParams;
1983
+ readonly importPublicKey: RsaHashedImportParams | EcKeyImportParams | {
1984
+ readonly name: 'Ed25519';
1985
+ };
1814
1986
  /**
1815
1987
  * Default key usages for the generated `CryptoKeyPair`. Both halves receive
1816
1988
  * the usages WebCrypto considers valid for their role; the platform filters.
@@ -2244,6 +2416,21 @@ declare interface IProviderCompletionParams {
2244
2416
  readonly tools?: ReadonlyArray<AiServerToolConfig>;
2245
2417
  /** Optional abort signal for cancelling the in-flight request. */
2246
2418
  readonly signal?: AbortSignal;
2419
+ /**
2420
+ * Optional override of the descriptor's default base URL. When set, the
2421
+ * dispatcher uses this URL (scheme + host + optional port + optional path
2422
+ * prefix) and appends the descriptor's per-route suffix (e.g.
2423
+ * `/chat/completions`) the same way it composes against the default.
2424
+ *
2425
+ * Must be a well-formed `http`/`https` URL string. Used to dispatch the same
2426
+ * provider descriptor against a self-hosted or local endpoint (e.g.
2427
+ * `http://localhost:11434/v1` for Ollama, or LAN-hosted OpenAI-compatible
2428
+ * servers).
2429
+ *
2430
+ * Setting `endpoint` does not change the auth shape: providers with
2431
+ * `needsSecret === true` still require an API key.
2432
+ */
2433
+ readonly endpoint?: string;
2247
2434
  }
2248
2435
 
2249
2436
  /**
@@ -2277,6 +2464,14 @@ declare interface IProviderCompletionStreamParams {
2277
2464
  readonly tools?: ReadonlyArray<AiServerToolConfig>;
2278
2465
  /** Optional abort signal for cancelling the in-flight stream. */
2279
2466
  readonly signal?: AbortSignal;
2467
+ /**
2468
+ * Optional override of the descriptor's default base URL. Same semantics as
2469
+ * the non-streaming completion path: a well-formed `http`/`https` URL is
2470
+ * substituted for `descriptor.baseUrl` when composing the streaming
2471
+ * request, with the per-format suffix appended unchanged. Validated at the
2472
+ * dispatcher; auth shape is unaffected.
2473
+ */
2474
+ readonly endpoint?: string;
2280
2475
  }
2281
2476
 
2282
2477
  /**
@@ -2296,6 +2491,14 @@ declare interface IProviderImageGenerationParams {
2296
2491
  readonly logger?: Logging.ILogger;
2297
2492
  /** Optional abort signal for cancelling the in-flight request. */
2298
2493
  readonly signal?: AbortSignal;
2494
+ /**
2495
+ * Optional override of the descriptor's default base URL. Same semantics as
2496
+ * the non-streaming completion path's endpoint: a well-formed `http`/`https`
2497
+ * URL substituted for `descriptor.baseUrl` when composing the request, with
2498
+ * the per-route suffix (e.g. `/images/generations`, `:predict`) appended
2499
+ * unchanged.
2500
+ */
2501
+ readonly endpoint?: string;
2299
2502
  }
2300
2503
 
2301
2504
  /**
@@ -2315,6 +2518,12 @@ declare interface IProviderListModelsParams {
2315
2518
  readonly logger?: Logging.ILogger;
2316
2519
  /** Optional abort signal for cancelling the in-flight request. */
2317
2520
  readonly signal?: AbortSignal;
2521
+ /**
2522
+ * Optional override of the descriptor's default base URL — a well-formed
2523
+ * `http`/`https` URL substituted for `descriptor.baseUrl`, with the
2524
+ * per-format `/models` route appended unchanged.
2525
+ */
2526
+ readonly endpoint?: string;
2318
2527
  }
2319
2528
 
2320
2529
  /**
@@ -2519,6 +2728,31 @@ declare interface JarRecordParserOptions {
2519
2728
  readonly fixedContinuationSize?: number;
2520
2729
  }
2521
2730
 
2731
+ /**
2732
+ * Controls the optional system-prompt augmentation applied by
2733
+ * {@link AiAssist.generateJsonCompletion}.
2734
+ *
2735
+ * - `'smart'` (default): append {@link AiAssist.SMART_JSON_PROMPT_HINT}.
2736
+ * - `'none'`: do not modify the prompt.
2737
+ * - A string: append the supplied text verbatim.
2738
+ *
2739
+ * @remarks
2740
+ * The `string & {}` branch is the standard TypeScript trick that prevents
2741
+ * the literal members from being widened away — callers still get
2742
+ * autocomplete for `'smart'` and `'none'` while accepting any string.
2743
+ *
2744
+ * @public
2745
+ */
2746
+ declare type JsonPromptHint = 'smart' | 'none' | (string & {});
2747
+
2748
+ /**
2749
+ * A function that pulls a JSON-shaped substring out of arbitrary model text.
2750
+ * Implementations strip whatever wrappers the model added (fences, preamble,
2751
+ * trailing prose) and return the JSON-shaped substring ready for `JSON.parse`.
2752
+ * @public
2753
+ */
2754
+ declare type JsonTextExtractor = (text: string) => Result<string>;
2755
+
2522
2756
  /**
2523
2757
  * In-place shape check for a JSON Web Key. Asserts only that the input is a
2524
2758
  * non-array object whose `kty` discriminator is a string; every other JWK
@@ -2563,9 +2797,14 @@ declare const keyDerivationParams: Converter<IKeyDerivationParams>;
2563
2797
  * (e.g. as the recipient keypair in
2564
2798
  * {@link CryptoUtils.ICryptoProvider.wrapBytes | wrapBytes} /
2565
2799
  * {@link CryptoUtils.ICryptoProvider.unwrapBytes | unwrapBytes}).
2800
+ * - `'ed25519'`: EdDSA over the Edwards25519 curve, for signing.
2801
+ * Deterministic — the per-signature nonce is derived from the private key
2802
+ * and message rather than sampled randomly, eliminating the random-nonce
2803
+ * reuse risk that ECDSA carries. Distinct from X25519 (key agreement over
2804
+ * the Montgomery form, Curve25519).
2566
2805
  * @public
2567
2806
  */
2568
- declare type KeyPairAlgorithm = 'ecdsa-p256' | 'rsa-oaep-2048' | 'ecdh-p256';
2807
+ declare type KeyPairAlgorithm = 'ecdsa-p256' | 'rsa-oaep-2048' | 'ecdh-p256' | 'ed25519';
2569
2808
 
2570
2809
  /**
2571
2810
  * Converter for {@link CryptoUtils.KeyStore.KeyPairAlgorithm | key pair algorithm}.
@@ -2821,6 +3060,41 @@ declare class KeyStore_2 implements IEncryptionProvider {
2821
3060
  * @public
2822
3061
  */
2823
3062
  addSecretFromPassword(name: string, password: string, options?: IAddSecretFromPasswordOptions): Promise<Result<IAddSecretFromPasswordResult>>;
3063
+ /**
3064
+ * Verifies that a candidate password derives the same key material currently
3065
+ * stored under `name`, using the supplied
3066
+ * {@link CryptoUtils.IKeyDerivationParams | key derivation parameters}.
3067
+ *
3068
+ * The keystore does not persist per-slot key derivation parameters with the
3069
+ * entry — callers receive them from `addSecretFromPassword` and store them
3070
+ * alongside the encrypted artifact (or wherever else makes sense). Pass
3071
+ * those same parameters here for verification.
3072
+ *
3073
+ * Re-derives a key from `password` + `keyDerivation`, then compares it to
3074
+ * the stored key material in constant time. Restricted to entries of type
3075
+ * `'encryption-key'` — the type produced by `addSecretFromPassword`. Other
3076
+ * symmetric types (`'api-key'`) and asymmetric entries are rejected so
3077
+ * the boolean result reflects "this slot accepts this password" rather
3078
+ * than an incidental byte-equality match against unrelated material.
3079
+ *
3080
+ * Note: the keystore does not currently flag whether an `'encryption-key'`
3081
+ * entry was actually password-derived (vs. random via `addSecret` or raw
3082
+ * via `importSecret`). A `true` result therefore means "the candidate
3083
+ * password produces the same 32 bytes currently stored", which is what
3084
+ * the equivalent consumer-side helper (`verifyGatePassword`) already
3085
+ * implies for entries it manages.
3086
+ *
3087
+ * @param name - Name of the secret to verify against
3088
+ * @param password - Candidate password to test
3089
+ * @param keyDerivation - The key derivation parameters returned by
3090
+ * `addSecretFromPassword` when the secret was created. Only
3091
+ * `kdf: 'pbkdf2'` is supported.
3092
+ * @returns Success(true) when the candidate matches the stored key,
3093
+ * Success(false) when it does not, Failure if locked, secret missing,
3094
+ * wrong type, unsupported `kdf`, or key derivation fails
3095
+ * @public
3096
+ */
3097
+ verifySecretFromPassword(name: string, password: string, keyDerivation: IKeyDerivationParams): Promise<Result<boolean>>;
2824
3098
  /**
2825
3099
  * Removes a secret by name. Vault-first: the in-memory vault entry is dropped
2826
3100
  * before any storage cleanup runs. For asymmetric-keypair entries, best-effort
@@ -2967,6 +3241,13 @@ declare class KeyStore_2 implements IEncryptionProvider {
2967
3241
  * @returns A warning string if storage cleanup failed, otherwise undefined.
2968
3242
  */
2969
3243
  private _releaseEntryResources;
3244
+ /**
3245
+ * Constant-time byte comparison. Returns false immediately for length
3246
+ * mismatch (length is not secret); for equal-length inputs, walks the full
3247
+ * buffer accumulating differences via XOR so the running time does not leak
3248
+ * the position of the first differing byte.
3249
+ */
3250
+ private static _timingSafeEqual;
2970
3251
  /**
2971
3252
  * Mints a fresh UUID v4 storage handle using the crypto provider's
2972
3253
  * {@link CryptoUtils.ICryptoProvider.generateRandomBytes | generateRandomBytes}.
@@ -3285,6 +3566,12 @@ declare class NodeCryptoProvider implements ICryptoProvider {
3285
3566
  * @returns Success with random bytes, or Failure with error
3286
3567
  */
3287
3568
  generateRandomBytes(length: number): Result<Uint8Array>;
3569
+ /**
3570
+ * Generates a cryptographically random UUIDv4 via the platform Web Crypto API.
3571
+ * @returns `Success` with the generated UUID, or `Failure` if the runtime
3572
+ * does not expose `globalThis.crypto.randomUUID`.
3573
+ */
3574
+ generateUuid(): Result<Uuid>;
3288
3575
  /**
3289
3576
  * Encodes binary data to base64 string.
3290
3577
  * @param data - Binary data to encode
@@ -3609,6 +3896,14 @@ declare function resolveModel(spec: ModelSpec, context?: string): string;
3609
3896
  */
3610
3897
  declare type SecretProvider = (secretName: string) => Promise<Result<Uint8Array>>;
3611
3898
 
3899
+ /**
3900
+ * Default system-prompt suffix appended when {@link AiAssist.IGenerateJsonCompletionParams.promptHint}
3901
+ * is `'smart'` (the default). Designed to discourage code fences and prose in
3902
+ * the model's response while still tolerating them via the read-side extractor.
3903
+ * @public
3904
+ */
3905
+ declare const SMART_JSON_PROMPT_HINT: string;
3906
+
3612
3907
  /**
3613
3908
  * Whether a provider declares any image-generation capability at all.
3614
3909
  *
@@ -26,6 +26,21 @@ export interface IProviderCompletionParams {
26
26
  readonly tools?: ReadonlyArray<AiServerToolConfig>;
27
27
  /** Optional abort signal for cancelling the in-flight request. */
28
28
  readonly signal?: AbortSignal;
29
+ /**
30
+ * Optional override of the descriptor's default base URL. When set, the
31
+ * dispatcher uses this URL (scheme + host + optional port + optional path
32
+ * prefix) and appends the descriptor's per-route suffix (e.g.
33
+ * `/chat/completions`) the same way it composes against the default.
34
+ *
35
+ * Must be a well-formed `http`/`https` URL string. Used to dispatch the same
36
+ * provider descriptor against a self-hosted or local endpoint (e.g.
37
+ * `http://localhost:11434/v1` for Ollama, or LAN-hosted OpenAI-compatible
38
+ * servers).
39
+ *
40
+ * Setting `endpoint` does not change the auth shape: providers with
41
+ * `needsSecret === true` still require an API key.
42
+ */
43
+ readonly endpoint?: string;
29
44
  }
30
45
  /**
31
46
  * Calls the appropriate chat completion API for a given provider.
@@ -62,6 +77,14 @@ export interface IProviderImageGenerationParams {
62
77
  readonly logger?: Logging.ILogger;
63
78
  /** Optional abort signal for cancelling the in-flight request. */
64
79
  readonly signal?: AbortSignal;
80
+ /**
81
+ * Optional override of the descriptor's default base URL. Same semantics as
82
+ * the non-streaming completion path's endpoint: a well-formed `http`/`https`
83
+ * URL substituted for `descriptor.baseUrl` when composing the request, with
84
+ * the per-route suffix (e.g. `/images/generations`, `:predict`) appended
85
+ * unchanged.
86
+ */
87
+ readonly endpoint?: string;
65
88
  }
66
89
  /**
67
90
  * Calls the appropriate image-generation API for a given provider.
@@ -100,6 +123,12 @@ export interface IProviderListModelsParams {
100
123
  readonly logger?: Logging.ILogger;
101
124
  /** Optional abort signal for cancelling the in-flight request. */
102
125
  readonly signal?: AbortSignal;
126
+ /**
127
+ * Optional override of the descriptor's default base URL — a well-formed
128
+ * `http`/`https` URL substituted for `descriptor.baseUrl`, with the
129
+ * per-format `/models` route appended unchanged.
130
+ */
131
+ readonly endpoint?: string;
103
132
  }
104
133
  /**
105
134
  * Lists models available from a provider, with capabilities resolved from
@@ -1 +1 @@
1
- {"version":3,"file":"apiClient.d.ts","sourceRoot":"","sources":["../../../src/packlets/ai-assist/apiClient.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAQ,KAAK,OAAO,EAAc,MAAM,EAAuC,MAAM,eAAe,CAAC;AAE5G,OAAO,EACL,QAAQ,EACR,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAI1B,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAE7B,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,SAAS,EAEf,MAAM,SAAS,CAAC;AAyBjB;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,8BAA8B;IAC9B,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC3C,iCAAiC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAC1D,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,qGAAqG;IACrG,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC;IACnC,0DAA0D;IAC1D,Q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