@venizia/ignis-helpers 0.2.0-16 → 0.2.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.
Files changed (180) hide show
  1. package/README.md +3 -4
  2. package/dist/cjs/common/constants/mime.d.ts +67 -0
  3. package/dist/cjs/common/constants/mime.d.ts.map +1 -1
  4. package/dist/cjs/common/constants/mime.js +138 -1
  5. package/dist/cjs/common/constants/mime.js.map +1 -1
  6. package/dist/cjs/core.d.ts +3 -0
  7. package/dist/cjs/core.d.ts.map +1 -1
  8. package/dist/cjs/core.js +4 -0
  9. package/dist/cjs/core.js.map +1 -1
  10. package/dist/cjs/modules/network/index.d.ts +1 -0
  11. package/dist/cjs/modules/network/index.d.ts.map +1 -1
  12. package/dist/cjs/modules/network/index.js +1 -0
  13. package/dist/cjs/modules/network/index.js.map +1 -1
  14. package/dist/cjs/modules/network/url-safety/common/constants.d.ts +18 -0
  15. package/dist/cjs/modules/network/url-safety/common/constants.d.ts.map +1 -0
  16. package/dist/cjs/modules/network/url-safety/common/constants.js +23 -0
  17. package/dist/cjs/modules/network/url-safety/common/constants.js.map +1 -0
  18. package/dist/cjs/modules/network/url-safety/common/errors.d.ts +31 -0
  19. package/dist/cjs/modules/network/url-safety/common/errors.d.ts.map +1 -0
  20. package/dist/cjs/modules/network/url-safety/common/errors.js +30 -0
  21. package/dist/cjs/modules/network/url-safety/common/errors.js.map +1 -0
  22. package/dist/cjs/modules/network/url-safety/common/index.d.ts +4 -0
  23. package/dist/cjs/modules/network/url-safety/common/index.d.ts.map +1 -0
  24. package/dist/cjs/modules/network/url-safety/common/index.js +20 -0
  25. package/dist/cjs/modules/network/url-safety/common/index.js.map +1 -0
  26. package/dist/cjs/modules/network/url-safety/common/types.d.ts +24 -0
  27. package/dist/cjs/modules/network/url-safety/common/types.d.ts.map +1 -0
  28. package/dist/cjs/modules/network/url-safety/common/types.js +3 -0
  29. package/dist/cjs/modules/network/url-safety/common/types.js.map +1 -0
  30. package/dist/cjs/modules/network/url-safety/index.d.ts +4 -0
  31. package/dist/cjs/modules/network/url-safety/index.d.ts.map +1 -0
  32. package/dist/cjs/modules/network/url-safety/index.js +20 -0
  33. package/dist/cjs/modules/network/url-safety/index.js.map +1 -0
  34. package/dist/cjs/modules/network/url-safety/ingest.d.ts +52 -0
  35. package/dist/cjs/modules/network/url-safety/ingest.d.ts.map +1 -0
  36. package/dist/cjs/modules/network/url-safety/ingest.js +167 -0
  37. package/dist/cjs/modules/network/url-safety/ingest.js.map +1 -0
  38. package/dist/cjs/modules/network/url-safety/policy.d.ts +29 -0
  39. package/dist/cjs/modules/network/url-safety/policy.d.ts.map +1 -0
  40. package/dist/cjs/modules/network/url-safety/policy.js +114 -0
  41. package/dist/cjs/modules/network/url-safety/policy.js.map +1 -0
  42. package/dist/cjs/modules/redis/base/abstract.helper.d.ts.map +1 -1
  43. package/dist/cjs/modules/redis/base/abstract.helper.js +6 -1
  44. package/dist/cjs/modules/redis/base/abstract.helper.js.map +1 -1
  45. package/dist/cjs/modules/redis/common/constants.d.ts +4 -0
  46. package/dist/cjs/modules/redis/common/constants.d.ts.map +1 -1
  47. package/dist/cjs/modules/redis/common/constants.js +6 -1
  48. package/dist/cjs/modules/redis/common/constants.js.map +1 -1
  49. package/dist/cjs/modules/storage/base.d.ts +83 -49
  50. package/dist/cjs/modules/storage/base.d.ts.map +1 -1
  51. package/dist/cjs/modules/storage/base.js +188 -87
  52. package/dist/cjs/modules/storage/base.js.map +1 -1
  53. package/dist/cjs/modules/storage/bun-s3/helper.d.ts +58 -28
  54. package/dist/cjs/modules/storage/bun-s3/helper.d.ts.map +1 -1
  55. package/dist/cjs/modules/storage/bun-s3/helper.js +234 -52
  56. package/dist/cjs/modules/storage/bun-s3/helper.js.map +1 -1
  57. package/dist/cjs/modules/storage/bun-s3/utility.d.ts +9 -0
  58. package/dist/cjs/modules/storage/bun-s3/utility.d.ts.map +1 -1
  59. package/dist/cjs/modules/storage/bun-s3/utility.js +103 -24
  60. package/dist/cjs/modules/storage/bun-s3/utility.js.map +1 -1
  61. package/dist/cjs/modules/storage/common/constants.d.ts +15 -0
  62. package/dist/cjs/modules/storage/common/constants.d.ts.map +1 -0
  63. package/dist/cjs/modules/storage/common/constants.js +21 -0
  64. package/dist/cjs/modules/storage/common/constants.js.map +1 -0
  65. package/dist/cjs/modules/storage/common/errors.d.ts +22 -0
  66. package/dist/cjs/modules/storage/common/errors.d.ts.map +1 -0
  67. package/dist/cjs/modules/storage/common/errors.js +25 -0
  68. package/dist/cjs/modules/storage/common/errors.js.map +1 -0
  69. package/dist/cjs/modules/storage/common/index.d.ts +3 -0
  70. package/dist/cjs/modules/storage/common/index.d.ts.map +1 -1
  71. package/dist/cjs/modules/storage/common/index.js +3 -0
  72. package/dist/cjs/modules/storage/common/index.js.map +1 -1
  73. package/dist/cjs/modules/storage/common/types.d.ts +91 -38
  74. package/dist/cjs/modules/storage/common/types.d.ts.map +1 -1
  75. package/dist/cjs/modules/storage/common/utility.d.ts +7 -0
  76. package/dist/cjs/modules/storage/common/utility.d.ts.map +1 -0
  77. package/dist/cjs/modules/storage/common/utility.js +27 -0
  78. package/dist/cjs/modules/storage/common/utility.js.map +1 -0
  79. package/dist/cjs/modules/storage/disk/helper.d.ts +26 -28
  80. package/dist/cjs/modules/storage/disk/helper.d.ts.map +1 -1
  81. package/dist/cjs/modules/storage/disk/helper.js +125 -86
  82. package/dist/cjs/modules/storage/disk/helper.js.map +1 -1
  83. package/dist/cjs/modules/storage/in-memory/helper.d.ts +10 -5
  84. package/dist/cjs/modules/storage/in-memory/helper.d.ts.map +1 -1
  85. package/dist/cjs/modules/storage/in-memory/helper.js +17 -10
  86. package/dist/cjs/modules/storage/in-memory/helper.js.map +1 -1
  87. package/dist/cjs/modules/storage/minio/helper.d.ts +22 -28
  88. package/dist/cjs/modules/storage/minio/helper.d.ts.map +1 -1
  89. package/dist/cjs/modules/storage/minio/helper.js +87 -33
  90. package/dist/cjs/modules/storage/minio/helper.js.map +1 -1
  91. package/dist/esm/common/constants/mime.d.ts +67 -0
  92. package/dist/esm/common/constants/mime.d.ts.map +1 -1
  93. package/dist/esm/common/constants/mime.js +134 -0
  94. package/dist/esm/common/constants/mime.js.map +1 -1
  95. package/dist/esm/core.d.ts +3 -0
  96. package/dist/esm/core.d.ts.map +1 -1
  97. package/dist/esm/core.js +4 -0
  98. package/dist/esm/core.js.map +1 -1
  99. package/dist/esm/modules/network/index.d.ts +1 -0
  100. package/dist/esm/modules/network/index.d.ts.map +1 -1
  101. package/dist/esm/modules/network/index.js +1 -0
  102. package/dist/esm/modules/network/index.js.map +1 -1
  103. package/dist/esm/modules/network/url-safety/common/constants.d.ts +18 -0
  104. package/dist/esm/modules/network/url-safety/common/constants.d.ts.map +1 -0
  105. package/dist/esm/modules/network/url-safety/common/constants.js +18 -0
  106. package/dist/esm/modules/network/url-safety/common/constants.js.map +1 -0
  107. package/dist/esm/modules/network/url-safety/common/errors.d.ts +31 -0
  108. package/dist/esm/modules/network/url-safety/common/errors.d.ts.map +1 -0
  109. package/dist/esm/modules/network/url-safety/common/errors.js +26 -0
  110. package/dist/esm/modules/network/url-safety/common/errors.js.map +1 -0
  111. package/dist/esm/modules/network/url-safety/common/index.d.ts +4 -0
  112. package/dist/esm/modules/network/url-safety/common/index.d.ts.map +1 -0
  113. package/dist/esm/modules/network/url-safety/common/index.js +4 -0
  114. package/dist/esm/modules/network/url-safety/common/index.js.map +1 -0
  115. package/dist/esm/modules/network/url-safety/common/types.d.ts +24 -0
  116. package/dist/esm/modules/network/url-safety/common/types.d.ts.map +1 -0
  117. package/dist/esm/modules/network/url-safety/common/types.js +2 -0
  118. package/dist/esm/modules/network/url-safety/common/types.js.map +1 -0
  119. package/dist/esm/modules/network/url-safety/index.d.ts +4 -0
  120. package/dist/esm/modules/network/url-safety/index.d.ts.map +1 -0
  121. package/dist/esm/modules/network/url-safety/index.js +4 -0
  122. package/dist/esm/modules/network/url-safety/index.js.map +1 -0
  123. package/dist/esm/modules/network/url-safety/ingest.d.ts +52 -0
  124. package/dist/esm/modules/network/url-safety/ingest.d.ts.map +1 -0
  125. package/dist/esm/modules/network/url-safety/ingest.js +163 -0
  126. package/dist/esm/modules/network/url-safety/ingest.js.map +1 -0
  127. package/dist/esm/modules/network/url-safety/policy.d.ts +29 -0
  128. package/dist/esm/modules/network/url-safety/policy.d.ts.map +1 -0
  129. package/dist/esm/modules/network/url-safety/policy.js +109 -0
  130. package/dist/esm/modules/network/url-safety/policy.js.map +1 -0
  131. package/dist/esm/modules/redis/base/abstract.helper.d.ts.map +1 -1
  132. package/dist/esm/modules/redis/base/abstract.helper.js +7 -2
  133. package/dist/esm/modules/redis/base/abstract.helper.js.map +1 -1
  134. package/dist/esm/modules/redis/common/constants.d.ts +4 -0
  135. package/dist/esm/modules/redis/common/constants.d.ts.map +1 -1
  136. package/dist/esm/modules/redis/common/constants.js +4 -0
  137. package/dist/esm/modules/redis/common/constants.js.map +1 -1
  138. package/dist/esm/modules/storage/base.d.ts +83 -49
  139. package/dist/esm/modules/storage/base.d.ts.map +1 -1
  140. package/dist/esm/modules/storage/base.js +189 -88
  141. package/dist/esm/modules/storage/base.js.map +1 -1
  142. package/dist/esm/modules/storage/bun-s3/helper.d.ts +58 -28
  143. package/dist/esm/modules/storage/bun-s3/helper.d.ts.map +1 -1
  144. package/dist/esm/modules/storage/bun-s3/helper.js +235 -53
  145. package/dist/esm/modules/storage/bun-s3/helper.js.map +1 -1
  146. package/dist/esm/modules/storage/bun-s3/utility.d.ts +9 -0
  147. package/dist/esm/modules/storage/bun-s3/utility.d.ts.map +1 -1
  148. package/dist/esm/modules/storage/bun-s3/utility.js +100 -24
  149. package/dist/esm/modules/storage/bun-s3/utility.js.map +1 -1
  150. package/dist/esm/modules/storage/common/constants.d.ts +15 -0
  151. package/dist/esm/modules/storage/common/constants.d.ts.map +1 -0
  152. package/dist/esm/modules/storage/common/constants.js +15 -0
  153. package/dist/esm/modules/storage/common/constants.js.map +1 -0
  154. package/dist/esm/modules/storage/common/errors.d.ts +22 -0
  155. package/dist/esm/modules/storage/common/errors.d.ts.map +1 -0
  156. package/dist/esm/modules/storage/common/errors.js +21 -0
  157. package/dist/esm/modules/storage/common/errors.js.map +1 -0
  158. package/dist/esm/modules/storage/common/index.d.ts +3 -0
  159. package/dist/esm/modules/storage/common/index.d.ts.map +1 -1
  160. package/dist/esm/modules/storage/common/index.js +3 -0
  161. package/dist/esm/modules/storage/common/index.js.map +1 -1
  162. package/dist/esm/modules/storage/common/types.d.ts +91 -38
  163. package/dist/esm/modules/storage/common/types.d.ts.map +1 -1
  164. package/dist/esm/modules/storage/common/utility.d.ts +7 -0
  165. package/dist/esm/modules/storage/common/utility.d.ts.map +1 -0
  166. package/dist/esm/modules/storage/common/utility.js +23 -0
  167. package/dist/esm/modules/storage/common/utility.js.map +1 -0
  168. package/dist/esm/modules/storage/disk/helper.d.ts +26 -28
  169. package/dist/esm/modules/storage/disk/helper.d.ts.map +1 -1
  170. package/dist/esm/modules/storage/disk/helper.js +125 -86
  171. package/dist/esm/modules/storage/disk/helper.js.map +1 -1
  172. package/dist/esm/modules/storage/in-memory/helper.d.ts +10 -5
  173. package/dist/esm/modules/storage/in-memory/helper.d.ts.map +1 -1
  174. package/dist/esm/modules/storage/in-memory/helper.js +17 -10
  175. package/dist/esm/modules/storage/in-memory/helper.js.map +1 -1
  176. package/dist/esm/modules/storage/minio/helper.d.ts +22 -28
  177. package/dist/esm/modules/storage/minio/helper.d.ts.map +1 -1
  178. package/dist/esm/modules/storage/minio/helper.js +87 -33
  179. package/dist/esm/modules/storage/minio/helper.js.map +1 -1
  180. package/package.json +1 -1
package/README.md CHANGED
@@ -80,7 +80,6 @@ backends you imported by name.
80
80
  | `/bullmq` | `BullMQHelper` | `bullmq` |
81
81
  | `/mqtt` | `MQTTClientHelper` | `mqtt` |
82
82
  | `/kafka` | `KafkaProducerHelper`, `KafkaConsumerHelper`, `KafkaAdminHelper`, ... | `@platformatic/kafka` |
83
- | `/minio` | `MinioHelper` | `minio` |
84
83
  | `/bun-s3` | `BunS3Helper` | none - Bun's native S3 client |
85
84
  | `/socket-io` | `SocketIOServerHelper`, `SocketIOClientHelper` | `socket.io`, `socket.io-client` (+ `@socket.io/redis-adapter`, `@socket.io/redis-emitter` for multi-node) |
86
85
  | `/axios` | `AxiosFetcher`, `AxiosNetworkRequest` | `axios` |
@@ -89,8 +88,8 @@ backends you imported by name.
89
88
  | `/dotenv-vault` | `DotenvVaultHelper` | `@dotenvx/dotenvx` |
90
89
 
91
90
  ```bash
92
- # example: pino logging + BullMQ jobs + MinIO storage
93
- bun add pino bullmq minio
91
+ # example: pino logging + BullMQ jobs
92
+ bun add pino bullmq
94
93
  ```
95
94
 
96
95
  Everything else - Redis (`ioredis` is a real dependency), disk and in-memory storage, crypto,
@@ -103,7 +102,7 @@ network, UID, env, pool, worker threads - comes straight off the root barrel.
103
102
  | [logger](https://ignis.venizia.ai/extensions/helpers/logger/) | Scoped `ILogger` over a pluggable winston or pino backend, plus `HfLogger` for hot paths |
104
103
  | [redis](https://ignis.venizia.ai/extensions/helpers/redis/) | Single, cluster, and sentinel clients over `ioredis`: key-value, hash, RedisJSON, pub/sub |
105
104
  | [queue](https://ignis.venizia.ai/extensions/helpers/queue/) | BullMQ jobs, MQTT topics, [Kafka](https://ignis.venizia.ai/extensions/helpers/kafka/) producers and consumers, plus an in-process `SequentialQueueHelper` |
106
- | [storage](https://ignis.venizia.ai/extensions/helpers/storage/) | One `IStorageHelper` interface over MinIO/S3, Bun S3, local disk, and memory |
105
+ | [storage](https://ignis.venizia.ai/extensions/helpers/storage/) | One `IStorageHelper` interface over any S3-compatible provider, local disk, and memory |
107
106
  | [crypto](https://ignis.venizia.ai/extensions/helpers/crypto/) | `AES`, `RSA`, `ECDH` - encryption, signing, and key exchange |
108
107
  | [cron](https://ignis.venizia.ai/extensions/helpers/cron/) | `CronHelper`: declarative schedules with lifecycle hooks |
109
108
  | [socket](https://ignis.venizia.ai/extensions/helpers/socket-io/) | Socket.IO server and client, plus a [Bun-native WebSocket](https://ignis.venizia.ai/extensions/helpers/websocket/) server |
@@ -4,6 +4,73 @@ export declare class MimeTypes {
4
4
  static readonly IMAGE = "image";
5
5
  static readonly VIDEO = "video";
6
6
  static readonly TEXT = "text";
7
+ static readonly SCHEME_SET: Set<string>;
8
+ static isValid(value: string): boolean;
7
9
  }
8
10
  export type TMimeTypes = TConstValue<typeof MimeTypes>;
11
+ /** The leading dot is part of the value: `path.extname` returns one. */
12
+ export declare class FileExtensions {
13
+ static readonly PNG = ".png";
14
+ static readonly JPG = ".jpg";
15
+ static readonly JPEG = ".jpeg";
16
+ static readonly GIF = ".gif";
17
+ static readonly WEBP = ".webp";
18
+ static readonly SVG = ".svg";
19
+ static readonly PDF = ".pdf";
20
+ static readonly JSON = ".json";
21
+ static readonly TXT = ".txt";
22
+ static readonly HTML = ".html";
23
+ static readonly CSS = ".css";
24
+ static readonly JS = ".js";
25
+ static readonly MP4 = ".mp4";
26
+ static readonly WEBM = ".webm";
27
+ static readonly MP3 = ".mp3";
28
+ static readonly WAV = ".wav";
29
+ static readonly ZIP = ".zip";
30
+ static readonly CSV = ".csv";
31
+ static readonly XML = ".xml";
32
+ static readonly SCHEME_SET: Set<string>;
33
+ static isValid(value: string): boolean;
34
+ }
35
+ export type TFileExtension = TConstValue<typeof FileExtensions>;
36
+ /** Full content types, as they go on the wire. `MimeTypes` holds only the top-level part. */
37
+ export declare class ContentTypes {
38
+ static readonly OCTET_STREAM = "application/octet-stream";
39
+ static readonly PNG = "image/png";
40
+ static readonly JPEG = "image/jpeg";
41
+ static readonly GIF = "image/gif";
42
+ static readonly WEBP = "image/webp";
43
+ static readonly SVG = "image/svg+xml";
44
+ static readonly PDF = "application/pdf";
45
+ static readonly JSON = "application/json";
46
+ static readonly PLAIN_TEXT = "text/plain";
47
+ static readonly HTML = "text/html";
48
+ static readonly CSS = "text/css";
49
+ static readonly JAVASCRIPT = "text/javascript";
50
+ static readonly MP4 = "video/mp4";
51
+ static readonly WEBM = "video/webm";
52
+ static readonly MPEG_AUDIO = "audio/mpeg";
53
+ static readonly WAV = "audio/wav";
54
+ static readonly ZIP = "application/zip";
55
+ static readonly CSV = "text/csv";
56
+ static readonly XML = "application/xml";
57
+ static readonly SCHEME_SET: Set<string>;
58
+ static isValid(value: string): boolean;
59
+ }
60
+ export type TContentType = TConstValue<typeof ContentTypes>;
61
+ /** The extension table and the lookup that reads it, together - the `DurationMultipliers` shape. */
62
+ export declare class ContentTypeTable {
63
+ /** `satisfies` makes the table total; the declared `string` key keeps a lookup cast-free. */
64
+ static readonly BY_EXTENSION: Readonly<Partial<Record<string, TContentType>>>;
65
+ /**
66
+ * The content type an object name implies. `node:path` is deliberately not used: this file is
67
+ * reachable from the browser-pure `./common` subpath, and an extension is the tail after the last
68
+ * dot either way.
69
+ */
70
+ static resolve(opts: {
71
+ filename: string;
72
+ }): TContentType;
73
+ }
74
+ /** Published before the table moved onto the class; kept as the one-line delegate it now is. */
75
+ export declare const CONTENT_TYPE_BY_EXTENSION: Readonly<Partial<Record<string, TContentType>>>;
9
76
  //# sourceMappingURL=mime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mime.d.ts","sourceRoot":"","sources":["../../../../src/common/constants/mime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,qBAAa,SAAS;IACpB,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAa;IACpC,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW;IAChC,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW;IAChC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;CAC/B;AACD,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,SAAS,CAAC,CAAC"}
1
+ {"version":3,"file":"mime.d.ts","sourceRoot":"","sources":["../../../../src/common/constants/mime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC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AAG,WAAW,CAAC,OAAO,YAAY,CAAC,CAAC;AAE5D,oGAAoG;AACpG,qBAAa,gBAAgB;IAC3B,6FAA6F;IAC7F,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAoBlB;IAE3D;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,YAAY;CAOzD;AAED,gGAAgG;AAChG,eAAO,MAAM,yBAAyB,iDAAgC,CAAC"}
@@ -1,11 +1,148 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MimeTypes = void 0;
3
+ exports.CONTENT_TYPE_BY_EXTENSION = exports.ContentTypeTable = exports.ContentTypes = exports.FileExtensions = exports.MimeTypes = void 0;
4
4
  class MimeTypes {
5
5
  static { this.UNKNOWN = 'unknown'; }
6
6
  static { this.IMAGE = 'image'; }
7
7
  static { this.VIDEO = 'video'; }
8
8
  static { this.TEXT = 'text'; }
9
+ static { this.SCHEME_SET = new Set([this.UNKNOWN, this.IMAGE, this.VIDEO, this.TEXT]); }
10
+ static isValid(value) {
11
+ return this.SCHEME_SET.has(value);
12
+ }
9
13
  }
10
14
  exports.MimeTypes = MimeTypes;
15
+ /** The leading dot is part of the value: `path.extname` returns one. */
16
+ class FileExtensions {
17
+ static { this.PNG = '.png'; }
18
+ static { this.JPG = '.jpg'; }
19
+ static { this.JPEG = '.jpeg'; }
20
+ static { this.GIF = '.gif'; }
21
+ static { this.WEBP = '.webp'; }
22
+ static { this.SVG = '.svg'; }
23
+ static { this.PDF = '.pdf'; }
24
+ static { this.JSON = '.json'; }
25
+ static { this.TXT = '.txt'; }
26
+ static { this.HTML = '.html'; }
27
+ static { this.CSS = '.css'; }
28
+ static { this.JS = '.js'; }
29
+ static { this.MP4 = '.mp4'; }
30
+ static { this.WEBM = '.webm'; }
31
+ static { this.MP3 = '.mp3'; }
32
+ static { this.WAV = '.wav'; }
33
+ static { this.ZIP = '.zip'; }
34
+ static { this.CSV = '.csv'; }
35
+ static { this.XML = '.xml'; }
36
+ static { this.SCHEME_SET = new Set([
37
+ this.PNG,
38
+ this.JPG,
39
+ this.JPEG,
40
+ this.GIF,
41
+ this.WEBP,
42
+ this.SVG,
43
+ this.PDF,
44
+ this.JSON,
45
+ this.TXT,
46
+ this.HTML,
47
+ this.CSS,
48
+ this.JS,
49
+ this.MP4,
50
+ this.WEBM,
51
+ this.MP3,
52
+ this.WAV,
53
+ this.ZIP,
54
+ this.CSV,
55
+ this.XML,
56
+ ]); }
57
+ static isValid(value) {
58
+ return this.SCHEME_SET.has(value);
59
+ }
60
+ }
61
+ exports.FileExtensions = FileExtensions;
62
+ /** Full content types, as they go on the wire. `MimeTypes` holds only the top-level part. */
63
+ class ContentTypes {
64
+ static { this.OCTET_STREAM = 'application/octet-stream'; }
65
+ static { this.PNG = 'image/png'; }
66
+ static { this.JPEG = 'image/jpeg'; }
67
+ static { this.GIF = 'image/gif'; }
68
+ static { this.WEBP = 'image/webp'; }
69
+ static { this.SVG = 'image/svg+xml'; }
70
+ static { this.PDF = 'application/pdf'; }
71
+ static { this.JSON = 'application/json'; }
72
+ static { this.PLAIN_TEXT = 'text/plain'; }
73
+ static { this.HTML = 'text/html'; }
74
+ static { this.CSS = 'text/css'; }
75
+ static { this.JAVASCRIPT = 'text/javascript'; }
76
+ static { this.MP4 = 'video/mp4'; }
77
+ static { this.WEBM = 'video/webm'; }
78
+ static { this.MPEG_AUDIO = 'audio/mpeg'; }
79
+ static { this.WAV = 'audio/wav'; }
80
+ static { this.ZIP = 'application/zip'; }
81
+ static { this.CSV = 'text/csv'; }
82
+ static { this.XML = 'application/xml'; }
83
+ static { this.SCHEME_SET = new Set([
84
+ this.OCTET_STREAM,
85
+ this.PNG,
86
+ this.JPEG,
87
+ this.GIF,
88
+ this.WEBP,
89
+ this.SVG,
90
+ this.PDF,
91
+ this.JSON,
92
+ this.PLAIN_TEXT,
93
+ this.HTML,
94
+ this.CSS,
95
+ this.JAVASCRIPT,
96
+ this.MP4,
97
+ this.WEBM,
98
+ this.MPEG_AUDIO,
99
+ this.WAV,
100
+ this.ZIP,
101
+ this.CSV,
102
+ this.XML,
103
+ ]); }
104
+ static isValid(value) {
105
+ return this.SCHEME_SET.has(value);
106
+ }
107
+ }
108
+ exports.ContentTypes = ContentTypes;
109
+ /** The extension table and the lookup that reads it, together - the `DurationMultipliers` shape. */
110
+ class ContentTypeTable {
111
+ /** `satisfies` makes the table total; the declared `string` key keeps a lookup cast-free. */
112
+ static { this.BY_EXTENSION = {
113
+ [FileExtensions.PNG]: ContentTypes.PNG,
114
+ [FileExtensions.JPG]: ContentTypes.JPEG,
115
+ [FileExtensions.JPEG]: ContentTypes.JPEG,
116
+ [FileExtensions.GIF]: ContentTypes.GIF,
117
+ [FileExtensions.WEBP]: ContentTypes.WEBP,
118
+ [FileExtensions.SVG]: ContentTypes.SVG,
119
+ [FileExtensions.PDF]: ContentTypes.PDF,
120
+ [FileExtensions.JSON]: ContentTypes.JSON,
121
+ [FileExtensions.TXT]: ContentTypes.PLAIN_TEXT,
122
+ [FileExtensions.HTML]: ContentTypes.HTML,
123
+ [FileExtensions.CSS]: ContentTypes.CSS,
124
+ [FileExtensions.JS]: ContentTypes.JAVASCRIPT,
125
+ [FileExtensions.MP4]: ContentTypes.MP4,
126
+ [FileExtensions.WEBM]: ContentTypes.WEBM,
127
+ [FileExtensions.MP3]: ContentTypes.MPEG_AUDIO,
128
+ [FileExtensions.WAV]: ContentTypes.WAV,
129
+ [FileExtensions.ZIP]: ContentTypes.ZIP,
130
+ [FileExtensions.CSV]: ContentTypes.CSV,
131
+ [FileExtensions.XML]: ContentTypes.XML,
132
+ }; }
133
+ /**
134
+ * The content type an object name implies. `node:path` is deliberately not used: this file is
135
+ * reachable from the browser-pure `./common` subpath, and an extension is the tail after the last
136
+ * dot either way.
137
+ */
138
+ static resolve(opts) {
139
+ const { filename } = opts;
140
+ const lastDot = filename.lastIndexOf('.');
141
+ const extension = lastDot === -1 ? '' : filename.slice(lastDot).toLowerCase();
142
+ return this.BY_EXTENSION[extension] ?? ContentTypes.OCTET_STREAM;
143
+ }
144
+ }
145
+ exports.ContentTypeTable = ContentTypeTable;
146
+ /** Published before the table moved onto the class; kept as the one-line delegate it now is. */
147
+ exports.CONTENT_TYPE_BY_EXTENSION = ContentTypeTable.BY_EXTENSION;
11
148
  //# sourceMappingURL=mime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mime.js","sourceRoot":"","sources":["../../../../src/common/constants/mime.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAS;aACJ,YAAO,GAAG,SAAS,CAAC;aACpB,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;;AAJhC,8BAKC"}
1
+ {"version":3,"file":"mime.js","sourceRoot":"","sources":["../../../../src/common/constants/mime.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAS;aACJ,YAAO,GAAG,SAAS,CAAC;aACpB,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhG,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAVH,8BAWC;AAGD,wEAAwE;AACxE,MAAa,cAAc;aACT,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,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CAAC;QAC1C,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QAE9E,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,YAAY,CAAC,YAAY,CAAC;IACnE,CAAC;;AAnCH,4CAoCC;AAED,gGAAgG;AACnF,QAAA,yBAAyB,GAAG,gBAAgB,CAAC,YAAY,CAAC"}
@@ -7,6 +7,9 @@ export * from './modules/queue/internal/hf';
7
7
  export type { ILogger, ILoggerProvider, TLogLevel } from './modules/logger/common/types';
8
8
  export { LogLevels } from './modules/logger/common/types';
9
9
  export * from './modules/network/http-request/fetcher/base-fetcher';
10
+ export * from './modules/network/url-safety/policy';
11
+ export * from './modules/network/url-safety/common/constants';
12
+ export type { IUrlSafetyPolicy } from './modules/network/url-safety/common/types';
10
13
  export { RetryHelper } from './modules/retry/helper';
11
14
  export { RetryBackoffStrategies, RetryJitterModes } from './modules/retry/common/constants';
12
15
  export type { TRetryBackoffStrategy, TRetryJitterMode } from './modules/retry/common/constants';
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,cAAc,qDAAqD,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,O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,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,cAAc,qDAAqD,CAAC;AAGpE,cAAc,qCAAqC,CAAC;AACpD,cAAc,+CAA+C,CAAC;AAC9D,YAAY,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAC5F,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAChG,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,YAAY,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,aAAa,GACd,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAKvE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,YAAY,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC"}
package/dist/cjs/core.js CHANGED
@@ -28,6 +28,10 @@ __exportStar(require("./modules/queue/internal/hf"), exports);
28
28
  var types_1 = require("./modules/logger/common/types");
29
29
  Object.defineProperty(exports, "LogLevels", { enumerable: true, get: function () { return types_1.LogLevels; } });
30
30
  __exportStar(require("./modules/network/http-request/fetcher/base-fetcher"), exports);
31
+ // The url guard, pure half only: `UrlPolicy` decides a url and a literal address with string and
32
+ // number work. Its sibling `UrlIngest` reaches `node:dns` and stays out of this subpath.
33
+ __exportStar(require("./modules/network/url-safety/policy"), exports);
34
+ __exportStar(require("./modules/network/url-safety/common/constants"), exports);
31
35
  var helper_1 = require("./modules/retry/helper");
32
36
  Object.defineProperty(exports, "RetryHelper", { enumerable: true, get: function () { return helper_1.RetryHelper; } });
33
37
  var constants_1 = require("./modules/retry/common/constants");
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAAnC,kGAAA,UAAU,OAAA;AACnB,6FAA6F;AAC7F,8DAA8D;AAC9D,6CAAuD;AAA9C,yGAAA,gBAAgB,OAAA;AACzB,kDAAgC;AAChC,gDAA8B;AAC9B,iDAA+B;AAC/B,8DAA4C;AAE5C,uDAA0D;AAAjD,kGAAA,SAAS,OAAA;AAClB,sFAAoE;AACpE,iDAAqD;AAA5C,qGAAA,WAAW,OAAA;AACpB,8DAA4F;AAAnF,mHAAA,sBAAsB,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AAGjD,gDAAmD;AAA1C,oGAAA,UAAU,OAAA;AACnB,4CAAiD;AAAxC,kGAAA,UAAU,OAAA;AACnB,kDAAqD;AAA5C,sGAAA,WAAW,OAAA;AAepB,gGAAgG;AAChG,6FAA6F;AAC7F,iGAAiG;AACjG,0DAA0D;AAC1D,2DAAiF;AAAxE,0GAAA,SAAS,OAAA;AAAE,oGAAA,GAAG,OAAA;AAAE,wGAAA,OAAO,OAAA;AAAE,4GAAA,WAAW,OAAA;AAC7C,uEAAgF;AAAvE,oIAAA,6BAA6B,OAAA;AACtC,yEAAuE;AAA9D,2HAAA,mBAAmB,OAAA"}
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAA4C;AAAnC,kGAAA,UAAU,OAAA;AACnB,6FAA6F;AAC7F,8DAA8D;AAC9D,6CAAuD;AAA9C,yGAAA,gBAAgB,OAAA;AACzB,kDAAgC;AAChC,gDAA8B;AAC9B,iDAA+B;AAC/B,8DAA4C;AAE5C,uDAA0D;AAAjD,kGAAA,SAAS,OAAA;AAClB,sFAAoE;AACpE,iGAAiG;AACjG,yFAAyF;AACzF,sEAAoD;AACpD,gFAA8D;AAE9D,iDAAqD;AAA5C,qGAAA,WAAW,OAAA;AACpB,8DAA4F;AAAnF,mHAAA,sBAAsB,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AAGjD,gDAAmD;AAA1C,oGAAA,UAAU,OAAA;AACnB,4CAAiD;AAAxC,kGAAA,UAAU,OAAA;AACnB,kDAAqD;AAA5C,sGAAA,WAAW,OAAA;AAepB,gGAAgG;AAChG,6FAA6F;AAC7F,iGAAiG;AACjG,0DAA0D;AAC1D,2DAAiF;AAAxE,0GAAA,SAAS,OAAA;AAAE,oGAAA,GAAG,OAAA;AAAE,wGAAA,OAAO,OAAA;AAAE,4GAAA,WAAW,OAAA;AAC7C,uEAAgF;AAAvE,oIAAA,6BAA6B,OAAA;AACtC,yEAAuE;AAA9D,2HAAA,mBAAmB,OAAA"}
@@ -1,4 +1,5 @@
1
1
  export * from './http-request';
2
2
  export * from './tcp-socket';
3
3
  export * from './udp-socket';
4
+ export * from './url-safety';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/network/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/network/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./http-request"), exports);
18
18
  __exportStar(require("./tcp-socket"), exports);
19
19
  __exportStar(require("./udp-socket"), exports);
20
+ __exportStar(require("./url-safety"), exports);
20
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/network/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,+CAA6B;AAC7B,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/network/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,+CAA6B;AAC7B,+CAA6B;AAC7B,+CAA6B"}
@@ -0,0 +1,18 @@
1
+ import { TConstValue } from '../../../../common/types';
2
+ /** The only schemes a guarded fetch will speak. `file:` and `gopher:` are the classic SSRF pivots. */
3
+ export declare class UrlSchemes {
4
+ static readonly HTTP = "http:";
5
+ static readonly HTTPS = "https:";
6
+ static readonly SCHEME_SET: Set<string>;
7
+ static isValid(value: string): boolean;
8
+ }
9
+ export type TUrlScheme = TConstValue<typeof UrlSchemes>;
10
+ /** Safe by default: https only, no private address, three hops, ten seconds. */
11
+ export declare class UrlSafetyDefaults {
12
+ static readonly ALLOWED_SCHEMES: string[];
13
+ static readonly ALLOW_PRIVATE_ADDRESS = false;
14
+ static readonly MAX_REDIRECTS = 3;
15
+ static readonly TIMEOUT_MILLISECONDS = 10000;
16
+ static readonly MAX_BYTES: number;
17
+ }
18
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/network/url-safety/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,sGAAsG;AACtG,qBAAa,UAAU;IACrB,MAAM,CAAC,QAAQ,CAAC,IAAI,WAAW;IAC/B,MAAM,CAAC,QAAQ,CAAC,KAAK,YAAY;IAEjC,MAAM,CAAC,QAAQ,CAAC,UAAU,cAA4C;IAEtE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AACD,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,UAAU,CAAC,CAAC;AAExD,gFAAgF;AAChF,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,EAAE,CAAsB;IAC/D,MAAM,CAAC,QAAQ,CAAC,qBAAqB,SAAS;IAC9C,MAAM,CAAC,QAAQ,CAAC,aAAa,KAAK;IAClC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,SAAU;IAC9C,MAAM,CAAC,QAAQ,CAAC,SAAS,SAAoB;CAC9C"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UrlSafetyDefaults = exports.UrlSchemes = void 0;
4
+ /** The only schemes a guarded fetch will speak. `file:` and `gopher:` are the classic SSRF pivots. */
5
+ class UrlSchemes {
6
+ static { this.HTTP = 'http:'; }
7
+ static { this.HTTPS = 'https:'; }
8
+ static { this.SCHEME_SET = new Set([this.HTTP, this.HTTPS]); }
9
+ static isValid(value) {
10
+ return this.SCHEME_SET.has(value);
11
+ }
12
+ }
13
+ exports.UrlSchemes = UrlSchemes;
14
+ /** Safe by default: https only, no private address, three hops, ten seconds. */
15
+ class UrlSafetyDefaults {
16
+ static { this.ALLOWED_SCHEMES = [UrlSchemes.HTTPS]; }
17
+ static { this.ALLOW_PRIVATE_ADDRESS = false; }
18
+ static { this.MAX_REDIRECTS = 3; }
19
+ static { this.TIMEOUT_MILLISECONDS = 10_000; }
20
+ static { this.MAX_BYTES = 10 * 1024 * 1024; }
21
+ }
22
+ exports.UrlSafetyDefaults = UrlSafetyDefaults;
23
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../src/modules/network/url-safety/common/constants.ts"],"names":[],"mappings":";;;AAEA,sGAAsG;AACtG,MAAa,UAAU;aACL,SAAI,GAAG,OAAO,CAAC;aACf,UAAK,GAAG,QAAQ,CAAC;aAEjB,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAEtE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AARH,gCASC;AAGD,gFAAgF;AAChF,MAAa,iBAAiB;aACZ,oBAAe,GAAa,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;aAC/C,0BAAqB,GAAG,KAAK,CAAC;aAC9B,kBAAa,GAAG,CAAC,CAAC;aAClB,yBAAoB,GAAG,MAAM,CAAC;aAC9B,cAAS,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;;AAL/C,8CAMC"}
@@ -0,0 +1,31 @@
1
+ import type { TRegisterErrors } from '@venizia/ignis-inversion';
2
+ /**
3
+ * A url the policy refuses is refused forever - the same url will never be allowed. A caller that
4
+ * retries on failure has to tell that apart from a host that timed out, or it retries a rejection
5
+ * and turns the guard into a repeat scanner.
6
+ */
7
+ export declare const UrlSafetyErrors: {
8
+ readonly URL_REFUSED: {
9
+ readonly message: {
10
+ readonly text: "Url refused by the safety policy";
11
+ readonly code: "core.url_safety.url_refused";
12
+ };
13
+ readonly statusCode: 400;
14
+ readonly category: "business";
15
+ };
16
+ };
17
+ declare module '@venizia/ignis-inversion' {
18
+ interface IErrorKeyRegistry extends TRegisterErrors<typeof UrlSafetyErrors> {
19
+ }
20
+ }
21
+ /**
22
+ * True when the url will never be allowed, whatever happens next: a bad scheme, a non-public
23
+ * address, a host outside the allow-list, a malformed url, or too many hops. Retrying any of those
24
+ * repeats the same rejection - drop the work instead.
25
+ *
26
+ * A timeout, a DNS failure or a 5xx answers `false`: those are worth another attempt.
27
+ */
28
+ export declare const isUrlRefusedError: (opts: {
29
+ error: unknown;
30
+ }) => boolean;
31
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/network/url-safety/common/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGlF;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;;;;CAMyB,CAAC;AAEtD,OAAO,QAAQ,0BAA0B,CAAC;IACxC,UAAU,iBAAkB,SAAQ,eAAe,CAAC,OAAO,eAAe,CAAC;KAAG;CAC/E;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,KAAG,OAG5D,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUrlRefusedError = exports.UrlSafetyErrors = void 0;
4
+ const constants_1 = require("../../../../common/constants");
5
+ const ignis_inversion_1 = require("@venizia/ignis-inversion");
6
+ /**
7
+ * A url the policy refuses is refused forever - the same url will never be allowed. A caller that
8
+ * retries on failure has to tell that apart from a host that timed out, or it retries a rejection
9
+ * and turns the guard into a repeat scanner.
10
+ */
11
+ exports.UrlSafetyErrors = {
12
+ URL_REFUSED: {
13
+ message: { text: 'Url refused by the safety policy', code: 'core.url_safety.url_refused' },
14
+ statusCode: constants_1.HTTP.ResultCodes.RS_4.BadRequest,
15
+ category: ignis_inversion_1.ErrorScopes.BUSINESS,
16
+ },
17
+ };
18
+ /**
19
+ * True when the url will never be allowed, whatever happens next: a bad scheme, a non-public
20
+ * address, a host outside the allow-list, a malformed url, or too many hops. Retrying any of those
21
+ * repeats the same rejection - drop the work instead.
22
+ *
23
+ * A timeout, a DNS failure or a 5xx answers `false`: those are worth another attempt.
24
+ */
25
+ const isUrlRefusedError = (opts) => {
26
+ const source = opts.error;
27
+ return source?.normalized?.code === exports.UrlSafetyErrors.URL_REFUSED.message.code;
28
+ };
29
+ exports.isUrlRefusedError = isUrlRefusedError;
30
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../../src/modules/network/url-safety/common/errors.ts"],"names":[],"mappings":";;;AAAA,kDAA0C;AAE1C,8DAAuD;AAEvD;;;;GAIG;AACU,QAAA,eAAe,GAAG;IAC7B,WAAW,EAAE;QACX,OAAO,EAAE,EAAE,IAAI,EAAE,kCAAkC,EAAE,IAAI,EAAE,6BAA6B,EAAE;QAC1F,UAAU,EAAE,gBAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;QAC5C,QAAQ,EAAE,6BAAW,CAAC,QAAQ;KAC/B;CACkD,CAAC;AAMtD;;;;;;GAMG;AACI,MAAM,iBAAiB,GAAG,CAAC,IAAwB,EAAW,EAAE;IACrE,MAAM,MAAM,GAAG,IAAI,CAAC,KAA2C,CAAC;IAChE,OAAO,MAAM,EAAE,UAAU,EAAE,IAAI,KAAK,uBAAe,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;AAC/E,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B"}
@@ -0,0 +1,4 @@
1
+ export * from './constants';
2
+ export * from './errors';
3
+ export * from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/network/url-safety/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./errors"), exports);
19
+ __exportStar(require("./types"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/modules/network/url-safety/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB"}
@@ -0,0 +1,24 @@
1
+ import type { IDuration } from '../../../../common/constants/duration';
2
+ /**
3
+ * What a caller will accept from an untrusted url. Every field is per call: an app that must reach
4
+ * plain `http` says so at the call site rather than weakening a build-time constant for everyone.
5
+ */
6
+ export interface IUrlSafetyPolicy {
7
+ /** Defaults to `['https:']`. */
8
+ allowedSchemes?: string[];
9
+ /**
10
+ * Defaults to `false`. Turning it on in a path that takes urls from user input re-opens the
11
+ * server-side request forgery this guard exists to close - a request can then be steered at
12
+ * `169.254.169.254` and the cloud credentials behind it.
13
+ */
14
+ allowPrivateAddress?: boolean;
15
+ /** When set, nothing outside the list passes, whatever it resolves to. */
16
+ allowedHosts?: string[];
17
+ /** Defaults to 3. Each hop is re-checked, so a public host cannot bounce into a private one. */
18
+ maxRedirects?: number;
19
+ /** Defaults to 10 seconds. A slow host holds a worker slot for exactly this long. */
20
+ timeout?: IDuration;
21
+ /** Defaults to 10 MB. The read stops and cancels the moment the body crosses it. */
22
+ maxBytes?: number;
23
+ }
24
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/network/url-safety/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,gGAAgG;IAChG,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,qFAAqF;IACrF,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/network/url-safety/common/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export * from './common';
2
+ export * from './policy';
3
+ export * from './ingest';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/network/url-safety/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common"), exports);
18
+ __exportStar(require("./policy"), exports);
19
+ __exportStar(require("./ingest"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/network/url-safety/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB"}
@@ -0,0 +1,52 @@
1
+ import type { IUrlSafetyPolicy } from './common/types';
2
+ /** Fetching an untrusted url without letting it reach inside the network. */
3
+ export declare class UrlIngest {
4
+ /**
5
+ * Rejects when ANY resolved address is non-public. Checking only the first walks straight into a
6
+ * host that publishes one public A record beside an internal one.
7
+ *
8
+ * A rebinding window remains: the address can change between this check and the connect. Closing
9
+ * it means connecting to the resolved address and setting `Host` by hand, which no fetch API
10
+ * exposes.
11
+ */
12
+ static assertPublicHost(opts: {
13
+ hostname: string;
14
+ policy?: IUrlSafetyPolicy;
15
+ }): Promise<void>;
16
+ /** Both halves, in the order they must run: shape first, then the network. */
17
+ static assertReachableUrl(opts: {
18
+ url: string;
19
+ policy?: IUrlSafetyPolicy;
20
+ }): Promise<URL>;
21
+ private static readTimeoutMilliseconds;
22
+ /**
23
+ * A GET that an untrusted url cannot steer inside the network. Redirects are followed by hand so
24
+ * every hop is re-checked - `redirect: 'follow'` would land on an internal host with no second
25
+ * look.
26
+ *
27
+ * The body is returned unread: the caller decides whether to stream it onward or cap it with
28
+ * {@link UrlIngest.readCappedBody}. Nothing is buffered here.
29
+ */
30
+ static fetchGuarded(opts: {
31
+ url: string;
32
+ policy?: IUrlSafetyPolicy;
33
+ headers?: Record<string, string>;
34
+ }): Promise<Response>;
35
+ /**
36
+ * Enforces `maxBytes` on a stream nothing reads into this process - the shape a caller wants when
37
+ * the body is piped onward rather than held. Without it a `maxBytes` policy is inert on that path.
38
+ */
39
+ static capStream(opts: {
40
+ source: ReadableStream<Uint8Array>;
41
+ policy?: IUrlSafetyPolicy;
42
+ }): ReadableStream<Uint8Array>;
43
+ /**
44
+ * Reads a body that must not exceed `maxBytes`, cancelling the moment it does. `content-length` is
45
+ * checked first because it is free, and counted anyway because it may be absent or lie.
46
+ */
47
+ static readCappedBody(opts: {
48
+ response: Response;
49
+ policy?: IUrlSafetyPolicy;
50
+ }): Promise<Buffer>;
51
+ }
52
+ //# sourceMappingURL=ingest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../../../../../src/modules/network/url-safety/ingest.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,6EAA6E;AAC7E,qBAAa,SAAS;IACpB;;;;;;;OAOG;WACU,gBAAgB,CAAC,IAAI,EAAE;QAClC,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,gBAAgB,CAAC;KAC3B,GAAG,OAAO,CAAC,IAAI,CAAC;IA+BjB,8EAA8E;WACjE,kBAAkB,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,gBAAgB,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAM/F,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAMtC;;;;;;;OAOG;WACU,YAAY,CAAC,IAAI,EAAE;QAC9B,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,CAAC,EAAE,gBAAgB,CAAC;QAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAgDrB;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;QACrB,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;QACnC,MAAM,CAAC,EAAE,gBAAgB,CAAC;KAC3B,GAAG,cAAc,CAAC,UAAU,CAAC;IA0B9B;;;OAGG;WACU,cAAc,CAAC,IAAI,EAAE;QAChC,QAAQ,EAAE,QAAQ,CAAC;QACnB,MAAM,CAAC,EAAE,gBAAgB,CAAC;KAC3B,GAAG,OAAO,CAAC,MAAM,CAAC;CA2CpB"}