@voxgig/sdkgen 4.48.0 → 4.49.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 (174) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/tsconfig.tsbuildinfo +1 -1
  3. package/dist/utility.js +9 -1
  4. package/dist/utility.js.map +1 -1
  5. package/package.json +1 -1
  6. package/project/.sdk/model/feature/secrets.aontu +3 -0
  7. package/project/.sdk/src/cmp/c/Config_c.ts +6 -1
  8. package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +0 -10
  9. package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +0 -9
  10. package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +0 -11
  11. package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +0 -7
  12. package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +0 -10
  13. package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +2 -11
  14. package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +0 -10
  15. package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +0 -11
  16. package/project/.sdk/src/cmp/ocaml/Entity_ocaml.ts +2 -10
  17. package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +0 -13
  18. package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +0 -10
  19. package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +0 -10
  20. package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +0 -10
  21. package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +0 -12
  22. package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +0 -10
  23. package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +0 -9
  24. package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +0 -7
  25. package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +1 -14
  26. package/project/.sdk/tm/c/feature/cache.c +16 -1
  27. package/project/.sdk/tm/c/feature/secrets.c +149 -18
  28. package/project/.sdk/tm/c/tests/feature/secrets/secrets_test.c +319 -70
  29. package/project/.sdk/tm/c/tests/feature_test.c +31 -0
  30. package/project/.sdk/tm/c/utility/make_spec.c +1 -1
  31. package/project/.sdk/tm/c/utility/prepare_body.c +64 -1
  32. package/project/.sdk/tm/c/utility/prepare_query.c +11 -6
  33. package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +74 -29
  34. package/project/.sdk/tm/clojure/src/sdk/core.clj +48 -10
  35. package/project/.sdk/tm/clojure/src/sdk/features.clj +16 -2
  36. package/project/.sdk/tm/clojure/test/sdk/test/feature/secrets.clj +191 -48
  37. package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +16 -0
  38. package/project/.sdk/tm/cpp/core/types.hpp +1 -11
  39. package/project/.sdk/tm/cpp/feature/cache.hpp +14 -1
  40. package/project/.sdk/tm/cpp/feature/secrets.hpp +133 -18
  41. package/project/.sdk/tm/cpp/test/feature/secrets/secrets_test.cpp +175 -8
  42. package/project/.sdk/tm/cpp/test/feature_test.cpp +27 -0
  43. package/project/.sdk/tm/cpp/utility/pipeline.hpp +52 -4
  44. package/project/.sdk/tm/csharp/core/Control.cs +0 -5
  45. package/project/.sdk/tm/csharp/core/Point.cs +6 -0
  46. package/project/.sdk/tm/csharp/feature/CacheFeature.cs +16 -0
  47. package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +77 -38
  48. package/project/.sdk/tm/csharp/test/FeatureTest.cs +29 -0
  49. package/project/.sdk/tm/csharp/test/feature/secrets/SecretsFeatureTest.cs +315 -68
  50. package/project/.sdk/tm/csharp/utility/MakeSpec.cs +2 -2
  51. package/project/.sdk/tm/csharp/utility/PrepareBody.cs +42 -0
  52. package/project/.sdk/tm/csharp/utility/PrepareQuery.cs +13 -2
  53. package/project/.sdk/tm/elixir/lib/projectname/entity_base.ex +0 -13
  54. package/project/.sdk/tm/elixir/lib/projectname/feature/cache.ex +32 -10
  55. package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +78 -22
  56. package/project/.sdk/tm/elixir/lib/projectname/utility.ex +62 -6
  57. package/project/.sdk/tm/elixir/test/feature/secrets/secrets_test.exs +178 -19
  58. package/project/.sdk/tm/elixir/test/feature_test.exs +20 -0
  59. package/project/.sdk/tm/go/core/target.go +8 -0
  60. package/project/.sdk/tm/go/feature/cache_feature.go +14 -1
  61. package/project/.sdk/tm/go/feature/secrets_feature.go +110 -15
  62. package/project/.sdk/tm/go/test/feature/secrets/secrets_feature_test.go +373 -87
  63. package/project/.sdk/tm/go/test/feature_test.go +32 -0
  64. package/project/.sdk/tm/go/utility/media.go +2 -2
  65. package/project/.sdk/tm/go/utility/prepare_body.go +37 -1
  66. package/project/.sdk/tm/go/utility/prepare_query.go +10 -1
  67. package/project/.sdk/tm/java/core/Control.java +0 -5
  68. package/project/.sdk/tm/java/core/Point.java +7 -0
  69. package/project/.sdk/tm/java/feature/CacheFeature.java +12 -0
  70. package/project/.sdk/tm/java/feature/SecretsFeature.java +104 -34
  71. package/project/.sdk/tm/java/test/FeatureTest.java +25 -0
  72. package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +39 -0
  73. package/project/.sdk/tm/java/test/feature/secrets/SecretsFeatureTest.java +267 -53
  74. package/project/.sdk/tm/java/utility/Fetcher.java +18 -2
  75. package/project/.sdk/tm/java/utility/MakeSpec.java +1 -1
  76. package/project/.sdk/tm/java/utility/Media.java +2 -2
  77. package/project/.sdk/tm/java/utility/PrepareBody.java +50 -0
  78. package/project/.sdk/tm/java/utility/PrepareQuery.java +11 -1
  79. package/project/.sdk/tm/js/src/Point.js +2 -0
  80. package/project/.sdk/tm/js/src/feature/cache/CacheFeature.js +13 -0
  81. package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +79 -29
  82. package/project/.sdk/tm/js/src/utility/MakeSpecUtility.js +1 -1
  83. package/project/.sdk/tm/js/src/utility/PrepareBodyUtility.js +29 -0
  84. package/project/.sdk/tm/js/src/utility/PrepareQueryUtility.js +5 -3
  85. package/project/.sdk/tm/js/test/feature/secrets/Secrets.test.js +282 -93
  86. package/project/.sdk/tm/js/test/feature.test.js +17 -0
  87. package/project/.sdk/tm/kotlin/core/Control.kt +0 -5
  88. package/project/.sdk/tm/kotlin/core/Point.kt +7 -0
  89. package/project/.sdk/tm/kotlin/feature/CacheFeature.kt +12 -0
  90. package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +84 -24
  91. package/project/.sdk/tm/kotlin/test/FeatureTest.kt +24 -0
  92. package/project/.sdk/tm/kotlin/test/PrimaryUtilityTest.kt +35 -0
  93. package/project/.sdk/tm/kotlin/test/feature/secrets/SecretsTest.kt +236 -54
  94. package/project/.sdk/tm/kotlin/utility/Fetcher.kt +13 -1
  95. package/project/.sdk/tm/kotlin/utility/MakeSpecUrl.kt +1 -1
  96. package/project/.sdk/tm/kotlin/utility/Prepare.kt +40 -10
  97. package/project/.sdk/tm/lua/feature/cache_feature.lua +20 -0
  98. package/project/.sdk/tm/lua/feature/secrets_feature.lua +92 -15
  99. package/project/.sdk/tm/lua/test/feature/secrets/secrets_feature_test.lua +208 -43
  100. package/project/.sdk/tm/lua/test/feature_test.lua +18 -0
  101. package/project/.sdk/tm/lua/utility/clean.lua +1 -0
  102. package/project/.sdk/tm/lua/utility/make_spec.lua +1 -1
  103. package/project/.sdk/tm/lua/utility/prepare_body.lua +40 -0
  104. package/project/.sdk/tm/lua/utility/prepare_query.lua +11 -1
  105. package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +100 -14
  106. package/project/.sdk/tm/ocaml/sdk_features.ml +7 -1
  107. package/project/.sdk/tm/ocaml/sdk_runtime.ml +40 -5
  108. package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +143 -7
  109. package/project/.sdk/tm/ocaml/test/t_feature.ml +15 -0
  110. package/project/.sdk/tm/perl/feature/cache_feature.pm +13 -0
  111. package/project/.sdk/tm/perl/feature/secrets_feature.pm +87 -32
  112. package/project/.sdk/tm/perl/t/feature/secrets/secrets.t +177 -24
  113. package/project/.sdk/tm/perl/t/feature.t +24 -0
  114. package/project/.sdk/tm/perl/utility/make_spec.pm +1 -1
  115. package/project/.sdk/tm/perl/utility/prepare_body.pm +38 -4
  116. package/project/.sdk/tm/perl/utility/prepare_query.pm +7 -1
  117. package/project/.sdk/tm/php/feature/CacheFeature.php +13 -0
  118. package/project/.sdk/tm/php/feature/SecretsFeature.php +79 -23
  119. package/project/.sdk/tm/php/test/FeatureTest.php +23 -0
  120. package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +258 -48
  121. package/project/.sdk/tm/php/utility/MakeSpec.php +2 -2
  122. package/project/.sdk/tm/php/utility/PrepareBody.php +31 -0
  123. package/project/.sdk/tm/php/utility/PrepareQuery.php +9 -2
  124. package/project/.sdk/tm/py/pkg/feature/cache_feature.py +7 -1
  125. package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +90 -29
  126. package/project/.sdk/tm/py/pkg/utility/make_spec.py +1 -1
  127. package/project/.sdk/tm/py/pkg/utility/prepare_body.py +26 -0
  128. package/project/.sdk/tm/py/pkg/utility/prepare_query.py +7 -2
  129. package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +313 -80
  130. package/project/.sdk/tm/py/test/test_feature.py +18 -0
  131. package/project/.sdk/tm/rb/feature/cache_feature.rb +12 -0
  132. package/project/.sdk/tm/rb/feature/secrets_feature.rb +68 -21
  133. package/project/.sdk/tm/rb/test/feature/secrets/secrets_feature_test.rb +214 -43
  134. package/project/.sdk/tm/rb/test/feature_test.rb +20 -0
  135. package/project/.sdk/tm/rb/utility/make_spec.rb +1 -1
  136. package/project/.sdk/tm/rb/utility/prepare_body.rb +31 -3
  137. package/project/.sdk/tm/rb/utility/prepare_query.rb +7 -1
  138. package/project/.sdk/tm/rust/feature/cache.rs +15 -1
  139. package/project/.sdk/tm/rust/feature/secrets.rs +103 -23
  140. package/project/.sdk/tm/rust/tests/feature/secrets/main.rs +357 -67
  141. package/project/.sdk/tm/rust/tests/feature_test.rs +41 -0
  142. package/project/.sdk/tm/rust/utility/prepare_body.rs +51 -0
  143. package/project/.sdk/tm/rust/utility/prepare_query.rs +12 -4
  144. package/project/.sdk/tm/scala/core/Control.scala +0 -5
  145. package/project/.sdk/tm/scala/core/Point.scala +3 -0
  146. package/project/.sdk/tm/scala/feature/CacheFeature.scala +12 -0
  147. package/project/.sdk/tm/scala/feature/SecretsFeature.scala +88 -22
  148. package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +61 -1
  149. package/project/.sdk/tm/scala/sdktest/feature/secrets/SecretsTestMain.scala +230 -73
  150. package/project/.sdk/tm/scala/utility/Fetcher.scala +13 -1
  151. package/project/.sdk/tm/scala/utility/MakeSpec.scala +1 -1
  152. package/project/.sdk/tm/scala/utility/Prepare.scala +53 -12
  153. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Control.swift +0 -5
  154. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Point.swift +3 -0
  155. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CacheFeature.swift +11 -0
  156. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +76 -16
  157. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Make.swift +1 -1
  158. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Prepare.swift +36 -1
  159. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +21 -0
  160. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/feature/secrets/SecretsFeatureTest.swift +257 -73
  161. package/project/.sdk/tm/ts/src/Point.ts +3 -0
  162. package/project/.sdk/tm/ts/src/feature/cache/CacheFeature.ts +13 -0
  163. package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +77 -17
  164. package/project/.sdk/tm/ts/src/utility/PrepareBodyUtility.ts +29 -0
  165. package/project/.sdk/tm/ts/src/utility/PrepareQueryUtility.ts +5 -3
  166. package/project/.sdk/tm/ts/test/feature/secrets/Secrets.test.ts +282 -87
  167. package/project/.sdk/tm/ts/test/feature.test.ts +17 -0
  168. package/project/.sdk/tm/zig/core/utility.zig +47 -4
  169. package/project/.sdk/tm/zig/feature/cache.zig +15 -1
  170. package/project/.sdk/tm/zig/feature/secrets.zig +109 -32
  171. package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +232 -9
  172. package/project/.sdk/tm/zig/test/feature_test.zig +33 -0
  173. package/project/sdkgen-package.json +1 -1
  174. package/src/utility.ts +12 -1
@@ -1,10 +1,12 @@
1
1
  package feature
2
2
 
3
3
  import (
4
+ "encoding/base64"
4
5
  "encoding/json"
5
6
  "fmt"
6
7
  "io"
7
8
  "net/http"
9
+ neturl "net/url"
8
10
  "strconv"
9
11
  "strings"
10
12
  "sync"
@@ -21,6 +23,8 @@ type SecretsFeature struct {
21
23
  options map[string]any
22
24
 
23
25
  liveopts map[string]any
26
+ declared bool
27
+ basic bool
24
28
 
25
29
  secretname string
26
30
  cache bool
@@ -44,6 +48,7 @@ type secretsExchange struct {
44
48
  response string
45
49
  statuses []int
46
50
  retries int
51
+ redirect string
47
52
  }
48
53
 
49
54
  type secretsCall struct {
@@ -81,6 +86,12 @@ func (f *SecretsFeature) Init(ctx *core.Context, options map[string]any) {
81
86
  f.liveopts = ctx.Options
82
87
  f.Active = foptBool(options, "active", false)
83
88
 
89
+ // PrepareAuth's generation inputs: auth where it places, Basic where it composes.
90
+ configopts, _ := ctx.Config["options"].(map[string]any)
91
+ declared, _ := configopts["auth"].(map[string]any)
92
+ f.declared = nil != declared
93
+ f.basic, _ = declared["basic"].(bool)
94
+
84
95
  if !f.Active {
85
96
  return
86
97
  }
@@ -107,6 +118,10 @@ func (f *SecretsFeature) Init(ctx *core.Context, options map[string]any) {
107
118
  response: foptStr(xopts, "response", "access_token"),
108
119
  statuses: statuses,
109
120
  retries: foptInt(xopts, "retries", 1),
121
+ redirect: "refuse",
122
+ }
123
+ if "same-origin" == foptStr(xopts, "redirect", "refuse") {
124
+ f.exchange.redirect = "same-origin"
110
125
  }
111
126
  }
112
127
 
@@ -184,6 +199,11 @@ func (f *SecretsFeature) Init(ctx *core.Context, options map[string]any) {
184
199
  }
185
200
  }
186
201
 
202
+ // authon is PrepareAuth's decision: declared auth, not suppressed by `auth: nil`.
203
+ func (f *SecretsFeature) authon() bool {
204
+ return f.declared && nil != f.liveopts["auth"]
205
+ }
206
+
187
207
  // Every value this feature resolves or buys is a secret the SDK handles,
188
208
  // and none arrives under an option key the intake registration saw.
189
209
  func (f *SecretsFeature) register(value string) {
@@ -228,7 +248,7 @@ func (f *SecretsFeature) resolve() error {
228
248
  // That bool is the whole of what resolve() needs to tell a cacheable HIT
229
249
  // from a miss it must not retain.
230
250
  func (f *SecretsFeature) resolveonce() (bool, error) {
231
- if nil == f.sek {
251
+ if nil == f.sek || !f.authon() {
232
252
  return false, nil
233
253
  }
234
254
 
@@ -273,10 +293,6 @@ func (f *SecretsFeature) resolveonce() (bool, error) {
273
293
  return true, nil
274
294
  }
275
295
 
276
- if nil == f.liveopts["auth"] {
277
- return false, nil
278
- }
279
-
280
296
  _, err = f.buy()
281
297
  return nil == err, err
282
298
  }
@@ -310,7 +326,7 @@ func (f *SecretsFeature) transport(ctx *core.Context, url string,
310
326
  func (f *SecretsFeature) withrefresh(ctx *core.Context, url string,
311
327
  fetchdef map[string]any, inner core.FetcherFunc) (any, error) {
312
328
 
313
- if nil == f.liveopts["auth"] {
329
+ if !f.authon() {
314
330
  return inner(ctx, url, fetchdef)
315
331
  }
316
332
 
@@ -386,9 +402,8 @@ func (f *SecretsFeature) reauth(fetchdef map[string]any, token string) {
386
402
  return
387
403
  }
388
404
 
389
- rawauth := f.liveopts["auth"]
390
- auth, _ := rawauth.(map[string]any)
391
- if nil == rawauth || nil == auth {
405
+ auth, _ := f.liveopts["auth"].(map[string]any)
406
+ if !f.authon() || nil == auth {
392
407
  delete(headers, "authorization")
393
408
  return
394
409
  }
@@ -400,14 +415,27 @@ func (f *SecretsFeature) reauth(fetchdef map[string]any, token string) {
400
415
  }
401
416
  name = strings.ToLower(name)
402
417
 
418
+ value := token
419
+ if basic, _ := auth["basic"].(bool); f.basic && basic {
420
+ value = f.pair(token)
421
+ }
422
+
403
423
  prefix, _ := auth["prefix"].(string)
404
424
  if "" == prefix {
405
- headers[name] = token
425
+ headers[name] = value
406
426
  } else {
407
- headers[name] = prefix + " " + token
427
+ headers[name] = prefix + " " + value
408
428
  }
409
429
  }
410
430
 
431
+ // pair is prepareAuth's Basic pair, with the token as its key half.
432
+ func (f *SecretsFeature) pair(token string) string {
433
+ secret, _ := f.liveopts["secret"].(string)
434
+ pair := base64.StdEncoding.EncodeToString([]byte(token + ":" + secret))
435
+ f.register(pair)
436
+ return pair
437
+ }
438
+
411
439
  // buy an access token with the refresh token. Concurrent callers share the
412
440
  // ONE in-flight purchase; the slot is cleared once settled, so the next
413
441
  // expiry buys a fresh token rather than replaying this result.
@@ -476,17 +504,33 @@ func (f *SecretsFeature) buyonce() (string, error) {
476
504
  return "", err
477
505
  }
478
506
 
479
- res, err := fetch(url, map[string]any{
507
+ fetchdef := map[string]any{
480
508
  "method": x.method,
481
509
  "headers": map[string]any{"content-type": "application/json"},
482
510
  "body": string(bodybytes),
483
- // Never followed: a redirect would carry the refresh token on.
511
+ // Never followed by the client: a redirect would carry the refresh token on.
484
512
  "redirect": "manual",
485
- })
513
+ }
514
+
515
+ res, err := fetch(url, fetchdef)
486
516
  if nil != err {
487
517
  return "", err
488
518
  }
489
519
 
520
+ // By option alone, and only while the exchange stays on its own origin.
521
+ at := url
522
+ for hops := 0; "same-origin" == x.redirect && hops < secretsRedirectMax; hops++ {
523
+ next := secretsMoved(url, at, res)
524
+ if "" == next {
525
+ break
526
+ }
527
+ at = next
528
+ res, err = fetch(at, fetchdef)
529
+ if nil != err {
530
+ return "", err
531
+ }
532
+ }
533
+
490
534
  status := core.ToInt(res["status"])
491
535
  if 200 > status || 300 <= status {
492
536
  return "", sekreto.Fail(
@@ -515,6 +559,51 @@ func (f *SecretsFeature) buyonce() (string, error) {
515
559
  return token, nil
516
560
  }
517
561
 
562
+ const secretsRedirectMax = 5
563
+
564
+ // secretsMoved says where a body-keeping redirect points, when that is on
565
+ // the exchange's own origin. Any other redirect would drop the body or leave it.
566
+ func secretsMoved(url string, at string, res map[string]any) string {
567
+ status := core.ToInt(res["status"])
568
+ if 307 != status && 308 != status {
569
+ return ""
570
+ }
571
+
572
+ headers, _ := res["headers"].(map[string]any)
573
+ location, _ := headers["location"].(string)
574
+ if "" == location {
575
+ return ""
576
+ }
577
+
578
+ from, err := neturl.Parse(at)
579
+ if nil != err {
580
+ return ""
581
+ }
582
+ loc, err := neturl.Parse(location)
583
+ if nil != err {
584
+ return ""
585
+ }
586
+ own, err := neturl.Parse(url)
587
+ if nil != err {
588
+ return ""
589
+ }
590
+
591
+ next := from.ResolveReference(loc)
592
+ if secretsOrigin(next) != secretsOrigin(own) {
593
+ return ""
594
+ }
595
+ return next.String()
596
+ }
597
+
598
+ func secretsOrigin(u *neturl.URL) string {
599
+ scheme := strings.ToLower(u.Scheme)
600
+ port := u.Port()
601
+ if "" == port {
602
+ port = map[string]string{"http": "80", "https": "443"}[scheme]
603
+ }
604
+ return scheme + "://" + strings.ToLower(u.Hostname()) + ":" + port
605
+ }
606
+
518
607
  // rawExchangeFetch is the token-exchange transport of last resort: plain
519
608
  // net/http, same result shape the system.fetch seam promises ("status" +
520
609
  // "json"). It exists so an exchange works with ordinary SDK options -
@@ -560,8 +649,14 @@ func rawExchangeFetch(fullurl string, fetchdef map[string]any) (map[string]any,
560
649
  return nil, err
561
650
  }
562
651
 
652
+ headers := map[string]any{}
653
+ for k := range res.Header {
654
+ headers[strings.ToLower(k)] = res.Header.Get(k)
655
+ }
656
+
563
657
  return map[string]any{
564
- "status": res.StatusCode,
658
+ "status": res.StatusCode,
659
+ "headers": headers,
565
660
  "json": func() any {
566
661
  var out any
567
662
  if nil != json.Unmarshal(raw, &out) {