@voxgig/sdkgen 4.32.1 → 4.33.0

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 (411) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/helpers/naming.js +1 -1
  3. package/dist/helpers/naming.js.map +1 -1
  4. package/dist/tsconfig.tsbuildinfo +1 -1
  5. package/model/sdkgen.aontu +7 -1
  6. package/package.json +1 -1
  7. package/project/.sdk/model/feature/debug.aontu +3 -1
  8. package/project/.sdk/src/cmp/c/PrepareAuth_c.ts +8 -28
  9. package/project/.sdk/src/cmp/c/TestClean_c.ts +774 -0
  10. package/project/.sdk/src/cmp/c/Test_c.ts +3 -0
  11. package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +16 -5
  12. package/project/.sdk/src/cmp/c/fragment/Main.fragment.c +1 -1
  13. package/project/.sdk/src/cmp/clojure/PrepareAuth_clojure.ts +3 -0
  14. package/project/.sdk/src/cmp/clojure/TestClean_clojure.ts +473 -0
  15. package/project/.sdk/src/cmp/clojure/Test_clojure.ts +6 -0
  16. package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +18 -8
  17. package/project/.sdk/src/cmp/cpp/PrepareAuth_cpp.ts +3 -0
  18. package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +782 -0
  19. package/project/.sdk/src/cmp/cpp/TestEntity_cpp.ts +1 -1
  20. package/project/.sdk/src/cmp/cpp/Test_cpp.ts +2 -0
  21. package/project/.sdk/src/cmp/csharp/PrepareAuth_csharp.ts +3 -0
  22. package/project/.sdk/src/cmp/csharp/TestClean_csharp.ts +887 -0
  23. package/project/.sdk/src/cmp/csharp/Test_csharp.ts +2 -0
  24. package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +68 -4
  25. package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +8 -2
  26. package/project/.sdk/src/cmp/csharp/fragment/SdkError.fragment.cs +49 -0
  27. package/project/.sdk/src/cmp/elixir/PrepareAuth_elixir.ts +3 -0
  28. package/project/.sdk/src/cmp/elixir/Schema_elixir.ts +20 -10
  29. package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +666 -0
  30. package/project/.sdk/src/cmp/elixir/Test_elixir.ts +4 -0
  31. package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +1 -1
  32. package/project/.sdk/src/cmp/elixir/fragment/Pipeline.fragment.ex +14 -2
  33. package/project/.sdk/src/cmp/go/PrepareAuth_go.ts +3 -0
  34. package/project/.sdk/src/cmp/go/TestClean_go.ts +804 -0
  35. package/project/.sdk/src/cmp/go/Test_go.ts +3 -0
  36. package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +54 -4
  37. package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +27 -2
  38. package/project/.sdk/src/cmp/java/PrepareAuth_java.ts +3 -0
  39. package/project/.sdk/src/cmp/java/TestClean_java.ts +884 -0
  40. package/project/.sdk/src/cmp/java/Test_java.ts +2 -0
  41. package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +56 -11
  42. package/project/.sdk/src/cmp/java/fragment/SdkError.fragment.java +36 -3
  43. package/project/.sdk/src/cmp/js/PrepareAuth_js.ts +3 -0
  44. package/project/.sdk/src/cmp/js/TestClean_js.ts +458 -0
  45. package/project/.sdk/src/cmp/js/Test_js.ts +2 -0
  46. package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +5 -4
  47. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +7 -1
  48. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +7 -1
  49. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +7 -1
  50. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +7 -1
  51. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +7 -1
  52. package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +11 -2
  53. package/project/.sdk/src/cmp/js/fragment/SdkError.fragment.js +17 -1
  54. package/project/.sdk/src/cmp/kotlin/Package_kotlin.ts +5 -0
  55. package/project/.sdk/src/cmp/kotlin/PrepareAuth_kotlin.ts +3 -0
  56. package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +654 -0
  57. package/project/.sdk/src/cmp/kotlin/Test_kotlin.ts +3 -0
  58. package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +44 -11
  59. package/project/.sdk/src/cmp/kotlin/fragment/SdkError.fragment.kt +31 -0
  60. package/project/.sdk/src/cmp/lua/PrepareAuth_lua.ts +3 -0
  61. package/project/.sdk/src/cmp/lua/TestClean_lua.ts +769 -0
  62. package/project/.sdk/src/cmp/lua/Test_lua.ts +3 -0
  63. package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +77 -1
  64. package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +49 -2
  65. package/project/.sdk/src/cmp/ocaml/Entity_ocaml.ts +3 -2
  66. package/project/.sdk/src/cmp/ocaml/PrepareAuth_ocaml.ts +4 -25
  67. package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +538 -0
  68. package/project/.sdk/src/cmp/ocaml/Test_ocaml.ts +5 -0
  69. package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +16 -4
  70. package/project/.sdk/src/cmp/perl/PrepareAuth_perl.ts +3 -0
  71. package/project/.sdk/src/cmp/perl/TestClean_perl.ts +619 -0
  72. package/project/.sdk/src/cmp/perl/Test_perl.ts +3 -0
  73. package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +67 -5
  74. package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +13 -1
  75. package/project/.sdk/src/cmp/php/PrepareAuth_php.ts +3 -0
  76. package/project/.sdk/src/cmp/php/TestClean_php.ts +809 -0
  77. package/project/.sdk/src/cmp/php/Test_php.ts +2 -0
  78. package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +96 -55
  79. package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +15 -2
  80. package/project/.sdk/src/cmp/py/PrepareAuth_py.ts +3 -0
  81. package/project/.sdk/src/cmp/py/TestClean_py.ts +549 -0
  82. package/project/.sdk/src/cmp/py/Test_py.ts +3 -0
  83. package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +83 -55
  84. package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +19 -3
  85. package/project/.sdk/src/cmp/rb/PrepareAuth_rb.ts +3 -0
  86. package/project/.sdk/src/cmp/rb/TestClean_rb.ts +535 -0
  87. package/project/.sdk/src/cmp/rb/Test_rb.ts +3 -0
  88. package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +108 -46
  89. package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +12 -1
  90. package/project/.sdk/src/cmp/rust/PrepareAuth_rust.ts +9 -45
  91. package/project/.sdk/src/cmp/rust/TestClean_rust.ts +881 -0
  92. package/project/.sdk/src/cmp/rust/Test_rust.ts +3 -0
  93. package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +14 -6
  94. package/project/.sdk/src/cmp/rust/fragment/Main.fragment.rs +17 -1
  95. package/project/.sdk/src/cmp/rust/fragment/SdkError.fragment.rs +34 -2
  96. package/project/.sdk/src/cmp/scala/PrepareAuth_scala.ts +3 -0
  97. package/project/.sdk/src/cmp/scala/TestClean_scala.ts +608 -0
  98. package/project/.sdk/src/cmp/scala/Test_scala.ts +3 -0
  99. package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +58 -6
  100. package/project/.sdk/src/cmp/swift/PrepareAuth_swift.ts +3 -0
  101. package/project/.sdk/src/cmp/swift/TestClean_swift.ts +671 -0
  102. package/project/.sdk/src/cmp/swift/Test_swift.ts +3 -0
  103. package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +10 -0
  104. package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +16 -2
  105. package/project/.sdk/src/cmp/swift/fragment/SdkError.fragment.swift +47 -3
  106. package/project/.sdk/src/cmp/ts/PrepareAuth_ts.ts +3 -0
  107. package/project/.sdk/src/cmp/ts/TestClean_ts.ts +465 -0
  108. package/project/.sdk/src/cmp/ts/Test_ts.ts +2 -0
  109. package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +5 -4
  110. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +7 -1
  111. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +7 -1
  112. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +7 -1
  113. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +7 -1
  114. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +7 -1
  115. package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +8 -2
  116. package/project/.sdk/src/cmp/ts/fragment/SdkError.fragment.ts +20 -2
  117. package/project/.sdk/src/cmp/zig/PrepareAuth_zig.ts +3 -0
  118. package/project/.sdk/src/cmp/zig/TestClean_zig.ts +791 -0
  119. package/project/.sdk/src/cmp/zig/Test_zig.ts +5 -0
  120. package/project/.sdk/src/cmp/zig/fragment/Build.fragment.zig +19 -0
  121. package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +14 -5
  122. package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +1 -1
  123. package/project/.sdk/tm/c/core/context.c +25 -0
  124. package/project/.sdk/tm/c/core/error.c +16 -0
  125. package/project/.sdk/tm/c/core/sdk.h +22 -0
  126. package/project/.sdk/tm/c/feature/audit.c +2 -0
  127. package/project/.sdk/tm/c/feature/cost.c +1 -0
  128. package/project/.sdk/tm/c/feature/debug.c +19 -29
  129. package/project/.sdk/tm/c/feature/log.c +21 -2
  130. package/project/.sdk/tm/c/feature/proxy.c +55 -3
  131. package/project/.sdk/tm/c/feature/secrets.c +7 -0
  132. package/project/.sdk/tm/c/feature/telemetry.c +2 -0
  133. package/project/.sdk/tm/c/tests/feature_test.c +2 -2
  134. package/project/.sdk/tm/c/utility/clean.c +530 -8
  135. package/project/.sdk/tm/c/utility/done.c +28 -12
  136. package/project/.sdk/tm/c/utility/make_error.c +4 -3
  137. package/project/.sdk/tm/c/utility/make_options.c +71 -45
  138. package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +15 -0
  139. package/project/.sdk/tm/clojure/src/sdk/client.clj +20 -4
  140. package/project/.sdk/tm/clojure/src/sdk/core.clj +319 -35
  141. package/project/.sdk/tm/clojure/src/sdk/features.clj +68 -30
  142. package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +4 -2
  143. package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +47 -20
  144. package/project/.sdk/tm/clojure/test/sdk/test_runner.clj +4 -0
  145. package/project/.sdk/tm/cpp/core/types.hpp +93 -3
  146. package/project/.sdk/tm/cpp/feature/audit.hpp +1 -0
  147. package/project/.sdk/tm/cpp/feature/cost.hpp +1 -0
  148. package/project/.sdk/tm/cpp/feature/debug.hpp +20 -12
  149. package/project/.sdk/tm/cpp/feature/log.hpp +31 -9
  150. package/project/.sdk/tm/cpp/feature/proxy.hpp +52 -6
  151. package/project/.sdk/tm/cpp/feature/secrets.hpp +13 -0
  152. package/project/.sdk/tm/cpp/feature/telemetry.hpp +4 -2
  153. package/project/.sdk/tm/cpp/test/feature_test.cpp +2 -2
  154. package/project/.sdk/tm/cpp/utility/pipeline.hpp +426 -51
  155. package/project/.sdk/tm/csharp/core/Context.cs +32 -0
  156. package/project/.sdk/tm/csharp/core/Utility.cs +2 -0
  157. package/project/.sdk/tm/csharp/feature/AuditFeature.cs +1 -0
  158. package/project/.sdk/tm/csharp/feature/CostFeature.cs +7 -5
  159. package/project/.sdk/tm/csharp/feature/DebugFeature.cs +19 -16
  160. package/project/.sdk/tm/csharp/feature/FeatureOptions.cs +16 -0
  161. package/project/.sdk/tm/csharp/feature/LogFeature.cs +4 -1
  162. package/project/.sdk/tm/csharp/feature/ProxyFeature.cs +26 -5
  163. package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +16 -0
  164. package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +4 -2
  165. package/project/.sdk/tm/csharp/test/FeatureTest.cs +2 -2
  166. package/project/.sdk/tm/csharp/utility/Clean.cs +440 -2
  167. package/project/.sdk/tm/csharp/utility/Done.cs +27 -11
  168. package/project/.sdk/tm/csharp/utility/MakeError.cs +19 -8
  169. package/project/.sdk/tm/csharp/utility/MakeOptions.cs +119 -29
  170. package/project/.sdk/tm/csharp/utility/MakeResponse.cs +21 -11
  171. package/project/.sdk/tm/csharp/utility/Register.cs +1 -0
  172. package/project/.sdk/tm/elixir/lib/projectname/context.ex +19 -0
  173. package/project/.sdk/tm/elixir/lib/projectname/entity_base.ex +22 -1
  174. package/project/.sdk/tm/elixir/lib/projectname/error.ex +24 -0
  175. package/project/.sdk/tm/elixir/lib/projectname/feature/audit.ex +2 -2
  176. package/project/.sdk/tm/elixir/lib/projectname/feature/cost.ex +2 -2
  177. package/project/.sdk/tm/elixir/lib/projectname/feature/debug.ex +13 -13
  178. package/project/.sdk/tm/elixir/lib/projectname/feature/log.ex +18 -5
  179. package/project/.sdk/tm/elixir/lib/projectname/feature/proxy.ex +19 -1
  180. package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +15 -0
  181. package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +4 -2
  182. package/project/.sdk/tm/elixir/lib/projectname/feature.ex +22 -0
  183. package/project/.sdk/tm/elixir/lib/projectname/utility.ex +464 -41
  184. package/project/.sdk/tm/elixir/test/feature_test.exs +3 -2
  185. package/project/.sdk/tm/go/core/context.go +42 -0
  186. package/project/.sdk/tm/go/core/error.go +30 -10
  187. package/project/.sdk/tm/go/core/utility_type.go +2 -0
  188. package/project/.sdk/tm/go/feature/audit_feature.go +1 -0
  189. package/project/.sdk/tm/go/feature/base_feature.go +12 -0
  190. package/project/.sdk/tm/go/feature/cost_feature.go +2 -2
  191. package/project/.sdk/tm/go/feature/debug_feature.go +14 -12
  192. package/project/.sdk/tm/go/feature/log_feature.go +13 -8
  193. package/project/.sdk/tm/go/feature/proxy_feature.go +26 -6
  194. package/project/.sdk/tm/go/feature/secrets_feature.go +19 -0
  195. package/project/.sdk/tm/go/feature/telemetry_feature.go +4 -2
  196. package/project/.sdk/tm/go/test/feature_test.go +2 -2
  197. package/project/.sdk/tm/go/utility/clean.go +585 -2
  198. package/project/.sdk/tm/go/utility/done.go +29 -9
  199. package/project/.sdk/tm/go/utility/make_error.go +51 -16
  200. package/project/.sdk/tm/go/utility/make_options.go +77 -36
  201. package/project/.sdk/tm/go/utility/register.go +12 -0
  202. package/project/.sdk/tm/java/core/Context.java +29 -0
  203. package/project/.sdk/tm/java/core/SdkClient.java +4 -2
  204. package/project/.sdk/tm/java/core/Utility.java +7 -0
  205. package/project/.sdk/tm/java/feature/AuditFeature.java +6 -0
  206. package/project/.sdk/tm/java/feature/CostFeature.java +5 -0
  207. package/project/.sdk/tm/java/feature/DebugFeature.java +25 -14
  208. package/project/.sdk/tm/java/feature/LogFeature.java +11 -4
  209. package/project/.sdk/tm/java/feature/ProxyFeature.java +41 -6
  210. package/project/.sdk/tm/java/feature/SecretsFeature.java +18 -0
  211. package/project/.sdk/tm/java/feature/TelemetryFeature.java +8 -2
  212. package/project/.sdk/tm/java/test/FeatureTest.java +2 -2
  213. package/project/.sdk/tm/java/utility/Clean.java +519 -1
  214. package/project/.sdk/tm/java/utility/Done.java +1 -1
  215. package/project/.sdk/tm/java/utility/MakeError.java +5 -1
  216. package/project/.sdk/tm/java/utility/MakeOptions.java +55 -31
  217. package/project/.sdk/tm/java/utility/Register.java +4 -0
  218. package/project/.sdk/tm/js/src/Context.js +5 -1
  219. package/project/.sdk/tm/js/src/feature/audit/AuditFeature.js +2 -2
  220. package/project/.sdk/tm/js/src/feature/cost/CostFeature.js +2 -2
  221. package/project/.sdk/tm/js/src/feature/debug/DebugFeature.js +13 -7
  222. package/project/.sdk/tm/js/src/feature/log/LogFeature.js +9 -5
  223. package/project/.sdk/tm/js/src/feature/proxy/ProxyFeature.js +19 -1
  224. package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +14 -0
  225. package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +4 -2
  226. package/project/.sdk/tm/js/src/utility/CleanUtility.js +294 -21
  227. package/project/.sdk/tm/js/src/utility/DoneUtility.js +17 -5
  228. package/project/.sdk/tm/js/src/utility/MakeErrorUtility.js +18 -2
  229. package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +39 -15
  230. package/project/.sdk/tm/js/src/utility/Utility.js +4 -2
  231. package/project/.sdk/tm/js/test/feature/harness.js +11 -1
  232. package/project/.sdk/tm/js/test/feature.test.js +9 -2
  233. package/project/.sdk/tm/kotlin/core/Context.kt +19 -0
  234. package/project/.sdk/tm/kotlin/core/SdkClient.kt +9 -2
  235. package/project/.sdk/tm/kotlin/core/Utility.kt +2 -0
  236. package/project/.sdk/tm/kotlin/feature/AuditFeature.kt +11 -9
  237. package/project/.sdk/tm/kotlin/feature/CostFeature.kt +8 -5
  238. package/project/.sdk/tm/kotlin/feature/DebugFeature.kt +15 -22
  239. package/project/.sdk/tm/kotlin/feature/LogFeature.kt +8 -4
  240. package/project/.sdk/tm/kotlin/feature/ProxyFeature.kt +26 -2
  241. package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +11 -0
  242. package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +4 -2
  243. package/project/.sdk/tm/kotlin/test/FeatureTest.kt +2 -2
  244. package/project/.sdk/tm/kotlin/utility/CoreUtil.kt +447 -11
  245. package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +38 -31
  246. package/project/.sdk/tm/kotlin/utility/Register.kt +1 -0
  247. package/project/.sdk/tm/lua/core/context.lua +43 -0
  248. package/project/.sdk/tm/lua/core/error.lua +36 -1
  249. package/project/.sdk/tm/lua/core/utility_type.lua +4 -0
  250. package/project/.sdk/tm/lua/feature/audit_feature.lua +2 -2
  251. package/project/.sdk/tm/lua/feature/cost_feature.lua +2 -2
  252. package/project/.sdk/tm/lua/feature/debug_feature.lua +21 -17
  253. package/project/.sdk/tm/lua/feature/log_feature.lua +2 -1
  254. package/project/.sdk/tm/lua/feature/proxy_feature.lua +23 -1
  255. package/project/.sdk/tm/lua/feature/secrets_feature.lua +18 -0
  256. package/project/.sdk/tm/lua/feature/telemetry_feature.lua +4 -2
  257. package/project/.sdk/tm/lua/test/feature/secrets/secrets_feature_test.lua +3 -2
  258. package/project/.sdk/tm/lua/test/feature_test.lua +10 -3
  259. package/project/.sdk/tm/lua/utility/clean.lua +426 -2
  260. package/project/.sdk/tm/lua/utility/clean_explain.lua +34 -0
  261. package/project/.sdk/tm/lua/utility/done.lua +1 -7
  262. package/project/.sdk/tm/lua/utility/make_error.lua +3 -1
  263. package/project/.sdk/tm/lua/utility/make_options.lua +76 -30
  264. package/project/.sdk/tm/lua/utility/register.lua +4 -1
  265. package/project/.sdk/tm/ocaml/Makefile +5 -1
  266. package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +12 -1
  267. package/project/.sdk/tm/ocaml/sdk_features.ml +78 -18
  268. package/project/.sdk/tm/ocaml/sdk_helpers.ml +27 -0
  269. package/project/.sdk/tm/ocaml/sdk_runtime.ml +304 -26
  270. package/project/.sdk/tm/ocaml/sdk_types.ml +1 -0
  271. package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +3 -1
  272. package/project/.sdk/tm/ocaml/test/t_feature.ml +2 -2
  273. package/project/.sdk/tm/perl/core/context.pm +27 -0
  274. package/project/.sdk/tm/perl/core/error.pm +52 -5
  275. package/project/.sdk/tm/perl/feature/audit_feature.pm +2 -2
  276. package/project/.sdk/tm/perl/feature/cost_feature.pm +2 -2
  277. package/project/.sdk/tm/perl/feature/debug_feature.pm +17 -13
  278. package/project/.sdk/tm/perl/feature/log_feature.pm +3 -1
  279. package/project/.sdk/tm/perl/feature/proxy_feature.pm +21 -1
  280. package/project/.sdk/tm/perl/feature/secrets_feature.pm +20 -1
  281. package/project/.sdk/tm/perl/feature/telemetry_feature.pm +4 -2
  282. package/project/.sdk/tm/perl/t/feature.t +4 -2
  283. package/project/.sdk/tm/perl/utility/clean.pm +345 -1
  284. package/project/.sdk/tm/perl/utility/done.pm +24 -6
  285. package/project/.sdk/tm/perl/utility/make_error.pm +17 -4
  286. package/project/.sdk/tm/perl/utility/make_options.pm +33 -14
  287. package/project/.sdk/tm/php/core/Context.php +24 -1
  288. package/project/.sdk/tm/php/core/Error.php +34 -3
  289. package/project/.sdk/tm/php/core/UtilityType.php +4 -0
  290. package/project/.sdk/tm/php/feature/AuditFeature.php +2 -2
  291. package/project/.sdk/tm/php/feature/CostFeature.php +2 -2
  292. package/project/.sdk/tm/php/feature/DebugFeature.php +18 -9
  293. package/project/.sdk/tm/php/feature/LogFeature.php +5 -2
  294. package/project/.sdk/tm/php/feature/ProxyFeature.php +20 -1
  295. package/project/.sdk/tm/php/feature/SecretsFeature.php +18 -0
  296. package/project/.sdk/tm/php/feature/TelemetryFeature.php +4 -2
  297. package/project/.sdk/tm/php/test/FeatureTest.php +2 -2
  298. package/project/.sdk/tm/php/utility/Clean.php +438 -2
  299. package/project/.sdk/tm/php/utility/Done.php +14 -7
  300. package/project/.sdk/tm/php/utility/MakeError.php +9 -7
  301. package/project/.sdk/tm/php/utility/MakeOptions.php +62 -38
  302. package/project/.sdk/tm/php/utility/Register.php +2 -0
  303. package/project/.sdk/tm/py/pkg/core/context.py +17 -0
  304. package/project/.sdk/tm/py/pkg/core/error.py +42 -1
  305. package/project/.sdk/tm/py/pkg/core/utility_type.py +4 -0
  306. package/project/.sdk/tm/py/pkg/feature/audit_feature.py +2 -2
  307. package/project/.sdk/tm/py/pkg/feature/cost_feature.py +2 -2
  308. package/project/.sdk/tm/py/pkg/feature/debug_feature.py +17 -12
  309. package/project/.sdk/tm/py/pkg/feature/log_feature.py +2 -1
  310. package/project/.sdk/tm/py/pkg/feature/proxy_feature.py +18 -1
  311. package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +12 -0
  312. package/project/.sdk/tm/py/pkg/feature/telemetry_feature.py +4 -2
  313. package/project/.sdk/tm/py/pkg/utility/clean.py +311 -1
  314. package/project/.sdk/tm/py/pkg/utility/done.py +18 -5
  315. package/project/.sdk/tm/py/pkg/utility/make_error.py +9 -6
  316. package/project/.sdk/tm/py/pkg/utility/make_options.py +64 -25
  317. package/project/.sdk/tm/py/pkg/utility/make_response.py +19 -13
  318. package/project/.sdk/tm/py/pkg/utility/register.py +4 -2
  319. package/project/.sdk/tm/py/test/feature_harness.py +4 -0
  320. package/project/.sdk/tm/py/test/test_feature.py +2 -2
  321. package/project/.sdk/tm/py/test/test_primary_utility.py +1 -0
  322. package/project/.sdk/tm/rb/core/context.rb +28 -0
  323. package/project/.sdk/tm/rb/core/error.rb +30 -0
  324. package/project/.sdk/tm/rb/core/utility_type.rb +1 -1
  325. package/project/.sdk/tm/rb/feature/audit_feature.rb +2 -2
  326. package/project/.sdk/tm/rb/feature/cost_feature.rb +2 -2
  327. package/project/.sdk/tm/rb/feature/debug_feature.rb +15 -12
  328. package/project/.sdk/tm/rb/feature/log_feature.rb +3 -1
  329. package/project/.sdk/tm/rb/feature/proxy_feature.rb +25 -1
  330. package/project/.sdk/tm/rb/feature/secrets_feature.rb +17 -0
  331. package/project/.sdk/tm/rb/feature/telemetry_feature.rb +4 -2
  332. package/project/.sdk/tm/rb/test/feature_test.rb +4 -2
  333. package/project/.sdk/tm/rb/utility/clean.rb +312 -1
  334. package/project/.sdk/tm/rb/utility/done.rb +15 -5
  335. package/project/.sdk/tm/rb/utility/make_error.rb +13 -4
  336. package/project/.sdk/tm/rb/utility/make_options.rb +31 -12
  337. package/project/.sdk/tm/rb/utility/register.rb +2 -0
  338. package/project/.sdk/tm/rust/core/context.rs +55 -0
  339. package/project/.sdk/tm/rust/core/utility_type.rs +17 -0
  340. package/project/.sdk/tm/rust/feature/audit.rs +2 -0
  341. package/project/.sdk/tm/rust/feature/cost.rs +3 -2
  342. package/project/.sdk/tm/rust/feature/debug.rs +16 -16
  343. package/project/.sdk/tm/rust/feature/log.rs +42 -7
  344. package/project/.sdk/tm/rust/feature/proxy.rs +48 -2
  345. package/project/.sdk/tm/rust/feature/secrets.rs +12 -0
  346. package/project/.sdk/tm/rust/feature/telemetry.rs +2 -0
  347. package/project/.sdk/tm/rust/tests/feature_test.rs +2 -2
  348. package/project/.sdk/tm/rust/utility/clean.rs +446 -5
  349. package/project/.sdk/tm/rust/utility/done.rs +22 -12
  350. package/project/.sdk/tm/rust/utility/make_error.rs +4 -1
  351. package/project/.sdk/tm/rust/utility/make_options.rs +73 -19
  352. package/project/.sdk/tm/scala/Makefile +3 -1
  353. package/project/.sdk/tm/scala/core/Context.scala +16 -0
  354. package/project/.sdk/tm/scala/core/SdkClient.scala +14 -4
  355. package/project/.sdk/tm/scala/core/SdkError.scala +28 -0
  356. package/project/.sdk/tm/scala/core/Types.scala +3 -0
  357. package/project/.sdk/tm/scala/core/Utility.scala +2 -0
  358. package/project/.sdk/tm/scala/feature/AuditFeature.scala +16 -10
  359. package/project/.sdk/tm/scala/feature/CostFeature.scala +10 -5
  360. package/project/.sdk/tm/scala/feature/DebugFeature.scala +24 -21
  361. package/project/.sdk/tm/scala/feature/LogFeature.scala +9 -4
  362. package/project/.sdk/tm/scala/feature/ProxyFeature.scala +23 -2
  363. package/project/.sdk/tm/scala/feature/SecretsFeature.scala +14 -0
  364. package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +9 -2
  365. package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +2 -2
  366. package/project/.sdk/tm/scala/utility/Make.scala +63 -20
  367. package/project/.sdk/tm/scala/utility/Misc.scala +358 -5
  368. package/project/.sdk/tm/scala/utility/Register.scala +1 -0
  369. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Context.swift +29 -0
  370. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Utility.swift +2 -0
  371. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +10 -9
  372. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CostFeature.swift +7 -5
  373. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/DebugFeature.swift +19 -15
  374. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/FeatureOptions.swift +16 -0
  375. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/LogFeature.swift +4 -1
  376. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/ProxyFeature.swift +20 -5
  377. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +13 -0
  378. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +4 -2
  379. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeError.swift +15 -5
  380. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +58 -19
  381. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Register.swift +1 -0
  382. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/ResultUtil.swift +391 -4
  383. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +2 -2
  384. package/project/.sdk/tm/ts/src/Context.ts +5 -1
  385. package/project/.sdk/tm/ts/src/feature/audit/AuditFeature.ts +2 -2
  386. package/project/.sdk/tm/ts/src/feature/cost/CostFeature.ts +2 -2
  387. package/project/.sdk/tm/ts/src/feature/debug/DebugFeature.ts +13 -7
  388. package/project/.sdk/tm/ts/src/feature/log/LogFeature.ts +9 -5
  389. package/project/.sdk/tm/ts/src/feature/proxy/ProxyFeature.ts +19 -1
  390. package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +12 -0
  391. package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +4 -2
  392. package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +287 -9
  393. package/project/.sdk/tm/ts/src/utility/DoneUtility.ts +18 -5
  394. package/project/.sdk/tm/ts/src/utility/MakeErrorUtility.ts +18 -8
  395. package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +38 -16
  396. package/project/.sdk/tm/ts/src/utility/Utility.ts +4 -2
  397. package/project/.sdk/tm/ts/test/feature/harness.ts +11 -1
  398. package/project/.sdk/tm/ts/test/feature.test.ts +9 -2
  399. package/project/.sdk/tm/zig/core/context.zig +34 -0
  400. package/project/.sdk/tm/zig/core/error.zig +22 -1
  401. package/project/.sdk/tm/zig/core/utility.zig +403 -39
  402. package/project/.sdk/tm/zig/feature/audit.zig +4 -2
  403. package/project/.sdk/tm/zig/feature/cost.zig +3 -2
  404. package/project/.sdk/tm/zig/feature/debug.zig +20 -25
  405. package/project/.sdk/tm/zig/feature/log.zig +3 -1
  406. package/project/.sdk/tm/zig/feature/proxy.zig +47 -6
  407. package/project/.sdk/tm/zig/feature/secrets.zig +7 -0
  408. package/project/.sdk/tm/zig/feature/telemetry.zig +4 -2
  409. package/project/.sdk/tm/zig/test/feature_test.zig +2 -2
  410. package/project/sdkgen-package.json +1 -1
  411. package/src/helpers/naming.ts +1 -1
@@ -1,31 +1,304 @@
1
1
 
2
- const {
3
- walk, size, pad, slice, clone
4
- } = require('./StructUtility')
2
+ const { OPTSPEC } = require('../Schema')
5
3
 
6
- // Clean request data by partially hiding sensitive values.
4
+
5
+ // Everything that leaves the pipeline passes through clean: the error, the
6
+ // explain record, the serialised context, and whatever a feature emits.
7
+ // Two layers: every registered secret VALUE (and its encoded forms) is
8
+ // replaced wherever it appears in a string, and every value under a
9
+ // sensitive KEY name is masked whatever it holds. Inside the pipeline data
10
+ // stays raw, so a hook can still read the header it must add to.
11
+
12
+ const MAXDEPTH = 32
13
+ const CIRCULAR = '[circular]'
14
+
15
+
16
+ function normkey(key) {
17
+ return String(key).toLowerCase().replace(/[-_]/g, '')
18
+ }
19
+
20
+
21
+ function splitkeys(keys) {
22
+ return String(null == keys ? '' : keys)
23
+ .split(/\s*,\s*/)
24
+ .map(normkey)
25
+ .filter((k) => '' !== k)
26
+ }
27
+
28
+
29
+ // The comma-separated literal values a caller registers; a list is taken
30
+ // as-is for a caller that has one.
31
+ function splitvalues(values) {
32
+ if (Array.isArray(values)) {
33
+ return values.filter((v) => 'string' === typeof v)
34
+ }
35
+ return String(null == values ? '' : values)
36
+ .split(/\s*,\s*/)
37
+ .filter((v) => '' !== v)
38
+ }
39
+
40
+
41
+ // The spec carries numbers as strings, so every target reads it alike.
42
+ function count(val, dflt) {
43
+ const n = Math.floor(Number(val))
44
+ return Number.isFinite(n) && 0 <= n ? n : dflt
45
+ }
46
+
47
+
48
+ // The derived block makeOptions builds; a context without options (makeError
49
+ // is reached with a bare one) falls back to the schema defaults, so nothing
50
+ // leaves raw for want of a constructor.
51
+ function cleanConfig(ctx) {
52
+ const derived = ctx?.options?.__derived__?.clean
53
+ if (null != derived) {
54
+ return derived
55
+ }
56
+ return makeCleanConfig(OPTSPEC?.clean)
57
+ }
58
+
59
+
60
+ function makeCleanConfig(cleanopts) {
61
+ const opts = cleanopts || {}
62
+ return {
63
+ active: false !== opts.active,
64
+ keys: splitkeys(opts.keys),
65
+ values: [],
66
+ mask: 'string' === typeof opts.mask ? opts.mask : '[redacted]',
67
+ hint: count(opts.hint, 0),
68
+ min: Math.max(1, count(opts.min, 4)),
69
+ }
70
+ }
71
+
72
+
73
+ // The encoded forms a value travels in: Basic and Bearer both carry base64,
74
+ // a query credential is percent-encoded, and a JSON dump escapes it.
75
+ function forms(value) {
76
+ const out = [value]
77
+ const add = (s) => { if ('' !== s && !out.includes(s)) out.push(s) }
78
+ try { add(Buffer.from(value, 'utf8').toString('base64')) } catch (_e) { }
79
+ try { add(encodeURIComponent(value)) } catch (_e) { }
80
+ try { add(JSON.stringify(value).slice(1, -1)) } catch (_e) { }
81
+ return out
82
+ }
83
+
84
+
85
+ // Register a secret value. Idempotent; shorter than `min` is not a secret
86
+ // the SDK can mask without blanking ordinary text.
87
+ function cleanAdd(ctx, value) {
88
+ const cfg = cleanConfig(ctx)
89
+ if ('string' !== typeof value || value.length < cfg.min) {
90
+ return
91
+ }
92
+ let changed = false
93
+ for (const form of forms(value)) {
94
+ if (form.length >= cfg.min && !cfg.values.includes(form)) {
95
+ cfg.values.push(form)
96
+ changed = true
97
+ }
98
+ }
99
+ if (changed) {
100
+ cfg.values.sort((a, b) => b.length - a.length)
101
+ }
102
+ }
103
+
104
+
105
+ function maskValue(cfg, value) {
106
+ if (0 < cfg.hint && value.length > 2 * cfg.hint) {
107
+ return cfg.mask + value.slice(-cfg.hint)
108
+ }
109
+ return cfg.mask
110
+ }
111
+
112
+
113
+ function cleanString(cfg, text) {
114
+ let out = text
115
+ for (const value of cfg.values) {
116
+ if (out.includes(value)) {
117
+ out = out.split(value).join(maskValue(cfg, value))
118
+ }
119
+ }
120
+ return out
121
+ }
122
+
123
+
124
+ function sensitiveKey(cfg, key) {
125
+ if (null == key || 'number' === typeof key) {
126
+ return false
127
+ }
128
+ const nk = normkey(key)
129
+ for (const k of cfg.keys) {
130
+ if (nk.includes(k)) {
131
+ return true
132
+ }
133
+ }
134
+ return false
135
+ }
136
+
137
+
138
+ // A plain-data copy of what is about to leave: toJSON is honoured (an entity
139
+ // serialises as its data, a context as its record), functions are dropped,
140
+ // cycles are cut, and no live object is shared with the copy - masking the
141
+ // copy must never mask the pipeline's own spec.
142
+ function snapshot(cfg, val, key, depth, seen) {
143
+ if (null == val) {
144
+ return val
145
+ }
146
+
147
+ const t = typeof val
148
+
149
+ if ('string' === t) {
150
+ return sensitiveKey(cfg, key) ? maskValue(cfg, val) : cleanString(cfg, val)
151
+ }
152
+
153
+ if ('function' === t) {
154
+ return undefined
155
+ }
156
+
157
+ if ('object' !== t) {
158
+ return sensitiveKey(cfg, key) ? cfg.mask : val
159
+ }
160
+
161
+ if (MAXDEPTH <= depth || seen.includes(val)) {
162
+ return CIRCULAR
163
+ }
164
+
165
+ if (sensitiveKey(cfg, key)) {
166
+ return cfg.mask
167
+ }
168
+
169
+ seen.push(val)
170
+ try {
171
+ if (Array.isArray(val)) {
172
+ const out = []
173
+ for (let i = 0; i < val.length; i++) {
174
+ out.push(snapshot(cfg, val[i], i, depth + 1, seen))
175
+ }
176
+ return out
177
+ }
178
+
179
+ if (val instanceof Error) {
180
+ const out = {
181
+ message: cleanString(cfg, String(val.message)),
182
+ stack: cleanString(cfg, String(val.stack || '')),
183
+ }
184
+ for (const k of Object.keys(val)) {
185
+ const v = snapshot(cfg, val[k], k, depth + 1, seen)
186
+ if (undefined !== v) out[k] = v
187
+ }
188
+ return out
189
+ }
190
+
191
+ if ('function' === typeof val.toJSON) {
192
+ const json = val.toJSON()
193
+ return json === val ? plain(cfg, val, depth, seen) : snapshot(cfg, json, key, depth + 1, seen)
194
+ }
195
+
196
+ return plain(cfg, val, depth, seen)
197
+ }
198
+ finally {
199
+ seen.pop()
200
+ }
201
+ }
202
+
203
+
204
+ function plain(cfg, val, depth, seen) {
205
+ const out = {}
206
+ for (const k of Object.keys(val)) {
207
+ const v = snapshot(cfg, val[k], k, depth + 1, seen)
208
+ if (undefined !== v) out[cleanName(cfg, out, k)] = v
209
+ }
210
+ return out
211
+ }
212
+
213
+
214
+ // A registered value used as a property name is masked like any other
215
+ // string; names that mask alike take a counter, so none is lost.
216
+ function cleanName(cfg, out, key) {
217
+ const name = cleanString(cfg, key)
218
+ if (name === key || !Object.prototype.hasOwnProperty.call(out, name)) {
219
+ return name
220
+ }
221
+ let i = 1
222
+ while (Object.prototype.hasOwnProperty.call(out, name + '#' + i)) i++
223
+ return name + '#' + i
224
+ }
225
+
226
+
227
+ // Clean a value on its way out. A string is redacted; an Error is redacted
228
+ // IN PLACE (it is about to be thrown, and its identity matters to the
229
+ // caller); anything else comes back as a masked plain-data copy.
7
230
  function clean(ctx, val) {
8
- const options = ctx.options
9
-
10
- const cleankeyre = options?.__derived__?.clean?.keyre
11
- const hintsize = 4
12
-
13
- /*
14
- if (null != cleankeyre) {
15
- val = walk(clone(val), (key, subval) => {
16
- if (cleankeyre.exec(key) && 'string' === typeof subval) {
17
- const len = size(subval)
18
- const hint = (hintsize * 4) < len ? slice(subval, 0, hintsize) : ''
19
- subval = pad(hint, len, '*')
231
+ const cfg = cleanConfig(ctx)
232
+
233
+ if (false === cfg.active) {
234
+ return val
235
+ }
236
+
237
+ if ('string' === typeof val) {
238
+ return cleanString(cfg, val)
239
+ }
240
+
241
+ if (val instanceof Error) {
242
+ val.message = cleanString(cfg, String(val.message))
243
+ if ('string' === typeof val.stack) {
244
+ val.stack = cleanString(cfg, val.stack)
245
+ }
246
+ for (const k of Object.keys(val)) {
247
+ let v = val[k]
248
+ if ('string' === typeof v) {
249
+ v = sensitiveKey(cfg, k) ? maskValue(cfg, v) : cleanString(cfg, v)
250
+ }
251
+ else if (null != v && 'object' === typeof v) {
252
+ v = snapshot(cfg, v, k, 1, [])
20
253
  }
21
- return subval
22
- })
254
+ const name = cleanString(cfg, k)
255
+ if (name !== k) {
256
+ delete val[k]
257
+ }
258
+ val[name === k ? k : cleanName(cfg, val, k)] = v
259
+ }
260
+ return val
23
261
  }
24
- */
25
262
 
26
- return val
263
+ return snapshot(cfg, val, undefined, 0, [])
264
+ }
265
+
266
+
267
+ // Is this key name sensitive under the context's clean configuration?
268
+ function cleanKey(ctx, key) {
269
+ return sensitiveKey(cleanConfig(ctx), key)
270
+ }
271
+
272
+
273
+ // Every scalar under a sensitive name, at any depth and of any shape: a
274
+ // credential mistyped as an object or a number is still a credential, and
275
+ // the validation error that rejects it quotes it.
276
+ function cleanAddSensitive(ctx, val, under = false, depth = 0, seen = [], parent) {
277
+ if (null == val || MAXDEPTH <= depth) {
278
+ return
279
+ }
280
+ const t = typeof val
281
+ if ('string' === t || 'number' === t || 'bigint' === t) {
282
+ if (under) cleanAdd(ctx, String(val))
283
+ return
284
+ }
285
+ if ('object' !== t || seen.includes(val)) {
286
+ return
287
+ }
288
+ seen.push(val)
289
+ // The keys under `feature` name features, not fields: `secrets` is no secret.
290
+ const named = !(1 === depth && 'feature' === parent)
291
+ for (const k of Object.keys(val)) {
292
+ cleanAddSensitive(ctx, val[k], under || (named && cleanKey(ctx, k)), depth + 1, seen, k)
293
+ }
27
294
  }
28
295
 
296
+
29
297
  module.exports = {
30
- clean
298
+ clean,
299
+ cleanAdd,
300
+ cleanAddSensitive,
301
+ cleanKey,
302
+ makeCleanConfig,
303
+ splitvalues,
31
304
  }
@@ -3,12 +3,8 @@ const { clean } = require('./CleanUtility')
3
3
 
4
4
  function done(ctx) {
5
5
  const error = ctx.utility.makeError
6
- const delprop = ctx.utility.struct.delprop
7
6
 
8
- if (ctx.ctrl.explain) {
9
- ctx.ctrl.explain = clean(ctx, ctx.ctrl.explain)
10
- delprop(ctx.ctrl.explain.result, 'err')
11
- }
7
+ cleanExplain(ctx)
12
8
 
13
9
  if (ctx.result && ctx.result.ok) {
14
10
  return ctx.result.resdata
@@ -17,6 +13,22 @@ function done(ctx) {
17
13
  return error(ctx)
18
14
  }
19
15
 
16
+ // In place: the caller may hold the record, and a stream copies only its ctrl.
17
+ function cleanExplain(ctx) {
18
+ const explain = ctx.ctrl.explain
19
+ if (null == explain || 'object' !== typeof explain) {
20
+ return
21
+ }
22
+ const cleaned = clean(ctx, explain)
23
+ if (cleaned !== explain) {
24
+ for (const k of Object.keys(explain)) delete explain[k]
25
+ Object.assign(explain, cleaned)
26
+ }
27
+ // With clean off, explain.result is the live result makeError reads.
28
+ if (null != explain.result) explain.result = ctx.utility.struct.delprop({ ...explain.result }, 'err')
29
+ }
30
+
20
31
  module.exports = {
32
+ cleanExplain,
21
33
  done
22
34
  }
@@ -18,9 +18,25 @@ function makeError(ctx, err) {
18
18
  err = undefined === err ? reserr : err
19
19
  err = err || ctx.error('unknown', 'unknown error')
20
20
 
21
+ // A hook or fetcher may reject with a plain value; clean returns a masked
22
+ // copy of that rather than changing it, so the copy is what leaves.
23
+ if (!(err instanceof Error)) {
24
+ const copy = clean(ctx, err)
25
+ const text = 'string' === typeof copy ? copy : String(copy?.message ?? 'unknown error')
26
+ err = Object.assign(new Error(text), 'object' === typeof copy ? copy : {})
27
+ }
28
+
21
29
  const errmsg = err.message || 'unknown error'
22
- const msg = 'ProjectNameSDK: ' + op.name + ': ' + errmsg
23
- err.message = clean(ctx, msg)
30
+ err.message = 'ProjectNameSDK: ' + op.name + ': ' + errmsg
31
+
32
+ // The context stays reachable for a debugger, but not for a serialiser:
33
+ // a transport error carries none, and a pipeline error's is enumerable
34
+ // only until here.
35
+ if (null != err.ctx) {
36
+ Object.defineProperty(err, 'ctx', { value: err.ctx, enumerable: false, writable: true })
37
+ }
38
+
39
+ clean(ctx, err)
24
40
 
25
41
  if (result.err) {
26
42
  delprop(result, 'err')
@@ -1,6 +1,8 @@
1
1
 
2
2
  const { OPTSPEC } = require('../Schema')
3
3
 
4
+ const { clean, cleanAdd, cleanAddSensitive, makeCleanConfig, splitvalues } = require('./CleanUtility')
5
+
4
6
 
5
7
  function makeOptions(ctx) {
6
8
  const utility = ctx.utility
@@ -10,7 +12,6 @@ function makeOptions(ctx) {
10
12
  const setprop = struct.setprop
11
13
  const merge = struct.merge
12
14
  const validate = struct.validate
13
- const escre = struct.escre
14
15
 
15
16
  // `auth: null` is the documented way to disable auth outright, and
16
17
  // prepareAuth honours it before it ever reads the apikey. But it cannot
@@ -33,6 +34,21 @@ function makeOptions(ctx) {
33
34
  delete opts.auth
34
35
  }
35
36
 
37
+ // The secret registry exists BEFORE validation, fed from the raw input, so
38
+ // the constructor's own rejection of a mistyped credential is clean too.
39
+ let config = ctx.config || {}
40
+ let cfgopts = config.options || {}
41
+
42
+ // An absent block is left out, or merge would erase the defaults.
43
+ const layer = (b) => null != b && 'object' === typeof b && !Array.isArray(b) ? b : {}
44
+ const cleancfg = makeCleanConfig(merge([{}, OPTSPEC.clean,
45
+ struct.clone(layer(cfgopts.clean)), layer(opts.clean)]))
46
+ const cleanctx = { options: { __derived__: { clean: cleancfg } } }
47
+ cleanAddSensitive(cleanctx, settings(opts))
48
+ for (const raw of [...splitvalues(cfgopts.clean?.values), ...splitvalues(opts.clean?.values)]) {
49
+ cleanAdd(cleanctx, raw)
50
+ }
51
+
36
52
  // Feature add-order. `options.feature` may be given as an ordered ARRAY of
37
53
  // { name, active, ...opts } entries (the array position IS the order in
38
54
  // which features are added), or as a { name: {opts} } map. Normalize an
@@ -57,8 +73,6 @@ function makeOptions(ctx) {
57
73
  setprop(utility, key, val)
58
74
  }
59
75
 
60
- let config = ctx.config || {}
61
- let cfgopts = config.options || {}
62
76
 
63
77
  // THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
64
78
  //
@@ -80,7 +94,12 @@ function makeOptions(ctx) {
80
94
  // contaminate every instance constructed after it.
81
95
  opts = merge([{}, struct.clone(cfgopts), opts])
82
96
 
83
- opts = validate(opts, optspec)
97
+ try {
98
+ opts = validate(opts, optspec)
99
+ }
100
+ catch (err) {
101
+ throw clean(cleanctx, err)
102
+ }
84
103
 
85
104
  // The platform fetch, supplied AFTER validate rather than as a spec
86
105
  // default. `system.fetch` is declared `$ANY`, which passes a caller's own
@@ -147,24 +166,29 @@ function makeOptions(ctx) {
147
166
  }
148
167
 
149
168
  opts.__derived__ = {
150
- clean: {
151
- keyre: undefined
152
- },
169
+ clean: cleancfg,
153
170
  featureorder,
154
171
  }
155
172
 
156
- const keyre = opts.clean.keys
157
- .split(/\s*,\s*/)
158
- .filter((s) => null != s && '' !== s)
159
- .map((key) => escre(key)).join('|')
160
-
161
- if ('' != keyre) {
162
- opts.__derived__.clean.keyre = keyre
163
- }
173
+ // Again over the merged result: the config's own defaults can carry one.
174
+ cleanAddSensitive({ options: opts }, settings(opts))
164
175
 
165
176
  return opts
166
177
  }
167
178
 
179
+ // Registration skips entity blocks: entity settings and seed records hold no credential.
180
+ function settings(opts) {
181
+ const noent = (b) => null != b && 'object' === typeof b && !Array.isArray(b)
182
+ ? { ...b, entity: undefined } : b
183
+ const feature = Array.isArray(opts.feature) ? opts.feature.map(noent)
184
+ : null != opts.feature && 'object' === typeof opts.feature
185
+ ? Object.fromEntries(Object.entries(opts.feature).map(([k, v]) => [k, noent(v)]))
186
+ : opts.feature
187
+ return { ...opts, clean: undefined, __derived__: undefined, entity: undefined,
188
+ test: noent(opts.test), feature }
189
+ }
190
+
191
+
168
192
  module.exports = {
169
193
  makeOptions
170
194
  }
@@ -1,7 +1,7 @@
1
1
 
2
2
 
3
- const { clean } = require('./CleanUtility')
4
- const { done } = require('./DoneUtility')
3
+ const { clean, cleanAdd } = require('./CleanUtility')
4
+ const { cleanExplain, done } = require('./DoneUtility')
5
5
  const { makeError } = require('./MakeErrorUtility')
6
6
  const { featureAdd } = require('./FeatureAddUtility')
7
7
  const { featureHook } = require('./FeatureHookUtility')
@@ -37,6 +37,8 @@ const { StructUtility } = require('./StructUtility')
37
37
  class Utility {
38
38
 
39
39
  clean = clean
40
+ cleanAdd = cleanAdd
41
+ cleanExplain = cleanExplain
40
42
  done = done
41
43
  makeError = makeError
42
44
  featureAdd = featureAdd
@@ -80,6 +80,9 @@ function makeClient(spec) {
80
80
 
81
81
  const utility = {
82
82
  struct,
83
+ // Features pass every record they emit through the SDK's own clean.
84
+ clean: stdutil.clean,
85
+ cleanAdd: stdutil.cleanAdd,
83
86
  fetcher: server,
84
87
  param: (ctx, name) => {
85
88
  const p = (ctx.spec && ctx.spec.params) || {}
@@ -88,10 +91,16 @@ function makeClient(spec) {
88
91
  },
89
92
  }
90
93
 
94
+ // One clean registry per client, as makeOptions gives a real one, so a value
95
+ // a feature registers with cleanAdd is masked by every clean after it.
96
+ const derived = stdutil.makeOptions({
97
+ utility, options: { feature: { test: { active: true } } }, config: {},
98
+ }).__derived__
99
+
91
100
  const client = {
92
101
  _mode: spec.mode || 'test',
93
102
  _features: [],
94
- _options: { base, headers: spec.headers || {}, feature: {} },
103
+ _options: { base, headers: spec.headers || {}, feature: {}, __derived__: derived },
95
104
  options() { return this._options },
96
105
  utility() { return utility },
97
106
  }
@@ -111,6 +120,7 @@ function makeClient(spec) {
111
120
  id: 'C' + idseq,
112
121
  client,
113
122
  utility,
123
+ options: client._options,
114
124
  out: {},
115
125
  ctrl: over.ctrl || {},
116
126
  meta: {},
@@ -384,7 +384,7 @@ describe('feature', () => {
384
384
  const entries = h.client._debug.entries
385
385
  strictEqual(entries.length, 1) // ring buffer capped at max
386
386
  strictEqual(seen.length, 2)
387
- strictEqual(seen[0].headers.authorization, '<redacted>')
387
+ strictEqual(seen[0].headers.authorization, '[redacted]')
388
388
  })
389
389
 
390
390
  test('captures failures', { skip: skipWithout('netsim') }, async () => {
@@ -518,6 +518,13 @@ describe('feature', () => {
518
518
  await h.op({ op: 'load' })
519
519
  strictEqual(rec.calls[0].fetchdef.proxy, undefined)
520
520
  })
521
+
522
+ test('masks the credentials in the URL it reports', async () => {
523
+ const h = makeClient({ features: [{ name: 'proxy', options: { url: 'http://pxuser:pxs3cret@proxy:8080' } }] })
524
+ await h.op({ op: 'load' })
525
+ strictEqual(h.client._proxy.url.includes('pxs3cret'), false)
526
+ strictEqual(h.client._proxy.url.includes('pxuser'), false)
527
+ })
521
528
  })
522
529
 
523
530
 
@@ -763,7 +770,7 @@ describe('feature', () => {
763
770
  const h = makeClient({ features: [{ name: 'debug', options: { now: () => 7, redact: ['x-secret'] } }] })
764
771
  await h.op({ op: 'load', headers: { 'x-secret': 'hide', 'x-ok': 'show' } })
765
772
  const e = h.client._debug.entries[0]
766
- strictEqual(e.headers['x-secret'], '<redacted>')
773
+ strictEqual(e.headers['x-secret'], '[redacted]')
767
774
  strictEqual(e.headers['x-ok'], 'show')
768
775
  })
769
776
 
@@ -244,4 +244,23 @@ class Context(ctxmap: MutableMap<String, Any?>?, basectx: Context?) {
244
244
  fun makeError(code: String, msg: String): SdkError {
245
245
  return SdkError(code, msg, this)
246
246
  }
247
+
248
+ // The serialised context leaves the pipeline (a logger, an error dump), so
249
+ // it is cleaned; the live fields stay raw for the pipeline's own use.
250
+ fun toMap(): Any? {
251
+ val record = linkedMapOf<String, Any?>()
252
+ record["id"] = this.id
253
+ record["op"] = this.op
254
+ record["spec"] = this.spec
255
+ record["entity"] = this.entity
256
+ record["result"] = this.result
257
+ record["response"] = this.response
258
+ record["meta"] = this.meta
259
+ val u = this.utility ?: return record
260
+ return u.clean(this, record)
261
+ }
262
+
263
+ override fun toString(): String {
264
+ return "Context " + Struct.jsonify(this.toMap())
265
+ }
247
266
  }
@@ -81,6 +81,11 @@ abstract class SdkClient(sdkopts: MutableMap<String, Any?>?) {
81
81
  this.util.featureHook(this.rootctx, "PostConstruct")
82
82
  }
83
83
 
84
+ // The options hold the credential; a printed client shows only its name.
85
+ override fun toString(): String {
86
+ return this.javaClass.simpleName + "(mode=" + this.mode + ")"
87
+ }
88
+
84
89
  fun optionsMap(): MutableMap<String, Any?> {
85
90
  val out = Struct.clone(this.options)
86
91
  if (out is MutableMap<*, *>) {
@@ -262,12 +267,14 @@ abstract class SdkClient(sdkopts: MutableMap<String, Any?>?) {
262
267
 
263
268
  val out = linkedMapOf<String, Any?>()
264
269
 
270
+ // A raw request returns its failure rather than passing it through
271
+ // makeError, so it is cleaned here.
265
272
  val fetchdef: MutableMap<String, Any?>
266
273
  try {
267
274
  fetchdef = this.prepare(fetchargs)
268
275
  } catch (err: RuntimeException) {
269
276
  out["ok"] = false
270
- out["err"] = err
277
+ out["err"] = utility.clean(ctx, err)
271
278
  return out
272
279
  }
273
280
 
@@ -277,7 +284,7 @@ abstract class SdkClient(sdkopts: MutableMap<String, Any?>?) {
277
284
  fetched = utility.fetcher(ctx, if (url is String) url else "", fetchdef)
278
285
  } catch (err: RuntimeException) {
279
286
  out["ok"] = false
280
- out["err"] = err
287
+ out["err"] = utility.clean(ctx, err)
281
288
  return out
282
289
  }
283
290
 
@@ -14,6 +14,7 @@ typealias FetcherFn = (Context, String, MutableMap<String, Any?>) -> Any?
14
14
  class Utility private constructor(register: Boolean) {
15
15
 
16
16
  lateinit var clean: (Context, Any?) -> Any?
17
+ lateinit var cleanAdd: (Context, Any?) -> Unit
17
18
  lateinit var done: (Context) -> Any?
18
19
  lateinit var makeError: (Context, RuntimeException?) -> Any?
19
20
  lateinit var featureAdd: (Context, Feature) -> Unit
@@ -59,6 +60,7 @@ class Utility private constructor(register: Boolean) {
59
60
  val u = Utility(false)
60
61
 
61
62
  u.clean = this.clean
63
+ u.cleanAdd = this.cleanAdd
62
64
  u.done = this.done
63
65
  u.makeError = this.makeError
64
66
  u.featureAdd = this.featureAdd
@@ -3,6 +3,7 @@ package KOTLINPACKAGE.feature
3
3
  import java.util.function.Consumer
4
4
 
5
5
  import KOTLINPACKAGE.core.Context
6
+ import KOTLINPACKAGE.core.Helpers
6
7
  import KOTLINPACKAGE.core.SdkClient
7
8
 
8
9
  // Audit trail. Emits a structured record for every operation — who (actor),
@@ -65,18 +66,19 @@ class AuditFeature : BaseFeature("audit", "0.0.1", true) {
65
66
  val entity = ctx.op.entity
66
67
  val opname = ctx.op.name
67
68
 
68
- val record = linkedMapOf<String, Any?>()
69
- record["seq"] = this.seq
70
- record["ts"] = FeatureOptions.foptNow(this.options).getAsLong()
71
- record["actor"] = actor
72
- record["entity"] = entity
73
- record["op"] = opname
74
- record["outcome"] = outcome
75
- record["correlationId"] = ctx.id
69
+ val raw = linkedMapOf<String, Any?>()
70
+ raw["seq"] = this.seq
71
+ raw["ts"] = FeatureOptions.foptNow(this.options).getAsLong()
72
+ raw["actor"] = actor
73
+ raw["entity"] = entity
74
+ raw["op"] = opname
75
+ raw["outcome"] = outcome
76
+ raw["correlationId"] = ctx.id
76
77
  val result = ctx.result
77
78
  if (result != null) {
78
- record["status"] = result.status
79
+ raw["status"] = result.status
79
80
  }
81
+ val record = Helpers.toMapAny(ctx.utility?.clean?.invoke(ctx, raw)) ?: raw
80
82
 
81
83
  this.records.add(record)
82
84
  val max = FeatureOptions.foptInt(this.options, "max", 1000)