@juspay/neurolink 12.22.1 → 12.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/dist/adapters/providerImageAdapter.js +16 -11
  3. package/dist/browser/neurolink.min.js +386 -386
  4. package/dist/cli/factories/commandFactory.js +26 -3
  5. package/dist/constants/enums.d.ts +10 -0
  6. package/dist/constants/enums.js +11 -0
  7. package/dist/factories/providerDescriptors.d.ts +1 -1
  8. package/dist/factories/providerDescriptors.js +15 -13
  9. package/dist/image-gen/ImageGenService.js +16 -14
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js +1 -0
  12. package/dist/mcp/externalServerManager.d.ts +9 -0
  13. package/dist/mcp/externalServerManager.js +88 -16
  14. package/dist/neurolink.js +18 -11
  15. package/dist/providers/amazonBedrock/client.js +30 -1
  16. package/dist/providers/catalog/friendli.json +130 -0
  17. package/dist/providers/catalog/index.generated.d.ts +1 -1
  18. package/dist/providers/catalog/index.generated.js +3 -0
  19. package/dist/providers/catalog/mistral.json +1 -2
  20. package/dist/providers/catalog/schema.js +34 -0
  21. package/dist/providers/googleAiStudio/client.js +18 -2
  22. package/dist/providers/googleVertex/client.js +13 -4
  23. package/dist/providers/recraft.js +8 -1
  24. package/dist/proxy/accountRanking.d.ts +22 -0
  25. package/dist/proxy/accountRanking.js +86 -0
  26. package/dist/proxy/proxyConfig.js +78 -17
  27. package/dist/server/routes/claudeProxyRoutes.d.ts +12 -4
  28. package/dist/server/routes/claudeProxyRoutes.js +54 -84
  29. package/dist/types/cli.d.ts +2 -0
  30. package/dist/types/externalMcp.d.ts +20 -2
  31. package/dist/types/generate.d.ts +6 -1
  32. package/dist/types/mcp.d.ts +17 -0
  33. package/dist/types/providerCatalog.generated.d.ts +2 -2
  34. package/dist/types/providers.d.ts +4 -0
  35. package/dist/types/proxy.d.ts +3 -0
  36. package/dist/utils/imageDetection.d.ts +10 -0
  37. package/dist/utils/imageDetection.js +38 -12
  38. package/docs-site/static/search-index.json +1 -1
  39. package/package.json +3 -2
@@ -7,6 +7,16 @@
7
7
  * otherwise a wrong default (historically `image/jpeg`) makes Anthropic reject
8
8
  * PNG/GIF/WebP with a media-type mismatch 400.
9
9
  */
10
+ /**
11
+ * Detect an image's MIME type from its magic bytes, or `null` when the bytes
12
+ * match no known signature.
13
+ *
14
+ * Use this when the answer "not an image" has to be distinguishable from a
15
+ * default. `detectImageMimeType` collapses that distinction on purpose, which
16
+ * is right for a caller that already knows it holds an image and wrong for one
17
+ * deciding whether it does.
18
+ */
19
+ export declare function sniffImageMimeType(buffer: Buffer): string | null;
10
20
  /**
11
21
  * Detect an image's MIME type from its magic bytes. Returns `image/png` for
12
22
  * buffers that match no known signature (the safest neutral default for the
@@ -8,17 +8,27 @@
8
8
  * PNG/GIF/WebP with a media-type mismatch 400.
9
9
  */
10
10
  /**
11
- * Detect an image's MIME type from its magic bytes. Returns `image/png` for
12
- * buffers that match no known signature (the safest neutral default for the
13
- * Vertex image path).
11
+ * Detect an image's MIME type from its magic bytes, or `null` when the bytes
12
+ * match no known signature.
13
+ *
14
+ * Use this when the answer "not an image" has to be distinguishable from a
15
+ * default. `detectImageMimeType` collapses that distinction on purpose, which
16
+ * is right for a caller that already knows it holds an image and wrong for one
17
+ * deciding whether it does.
14
18
  */
15
- export function detectImageMimeType(buffer) {
16
- // PNG: 89 50 4E 47
19
+ export function sniffImageMimeType(buffer) {
20
+ // PNG: the full 8-byte signature 89 50 4E 47 0D 0A 1A 0A. The trailing four
21
+ // bytes matter — a truncated `iVBORw==` carries only the first four and is
22
+ // not a decodable image.
17
23
  if (buffer.length >= 8 &&
18
24
  buffer[0] === 0x89 &&
19
25
  buffer[1] === 0x50 &&
20
26
  buffer[2] === 0x4e &&
21
- buffer[3] === 0x47) {
27
+ buffer[3] === 0x47 &&
28
+ buffer[4] === 0x0d &&
29
+ buffer[5] === 0x0a &&
30
+ buffer[6] === 0x1a &&
31
+ buffer[7] === 0x0a) {
22
32
  return "image/png";
23
33
  }
24
34
  // JPEG: FF D8 FF
@@ -40,13 +50,29 @@ export function detectImageMimeType(buffer) {
40
50
  buffer[11] === 0x50) {
41
51
  return "image/webp";
42
52
  }
43
- // GIF: "GIF"
53
+ // GIF: the full 6-byte header "GIF87a" or "GIF89a". The version stamp is
54
+ // what separates a header from three coincidental letters — the old check
55
+ // compared only "GIF" while guarding on `length >= 6`, so any six bytes
56
+ // beginning with those letters (base64 `R0lGAAAA` decodes to 47 49 46 00
57
+ // 00 00) were labelled image/gif. This gate is what decides whether bytes
58
+ // are an image at all, so it is only as strict as its weakest signature.
44
59
  if (buffer.length >= 6 &&
45
- buffer[0] === 0x47 &&
46
- buffer[1] === 0x49 &&
47
- buffer[2] === 0x46) {
60
+ buffer[0] === 0x47 && // G
61
+ buffer[1] === 0x49 && // I
62
+ buffer[2] === 0x46 && // F
63
+ buffer[3] === 0x38 && // 8
64
+ (buffer[4] === 0x37 || buffer[4] === 0x39) && // 7 | 9
65
+ buffer[5] === 0x61 // a
66
+ ) {
48
67
  return "image/gif";
49
68
  }
50
- // Unknown — neutral default.
51
- return "image/png";
69
+ return null;
70
+ }
71
+ /**
72
+ * Detect an image's MIME type from its magic bytes. Returns `image/png` for
73
+ * buffers that match no known signature (the safest neutral default for the
74
+ * Vertex image path).
75
+ */
76
+ export function detectImageMimeType(buffer) {
77
+ return sniffImageMimeType(buffer) ?? "image/png";
52
78
  }