@voxgig/sdkgen 4.50.0 → 4.51.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.
- package/bin/voxgig-sdkgen +1 -1
- package/package.json +1 -1
- package/project/.sdk/model/feature/cache.aontu +6 -4
- package/project/.sdk/model/target/lua.aontu +6 -0
- package/project/.sdk/src/cmp/c/Config_c.ts +3 -134
- package/project/.sdk/src/cmp/c/TestClean_c.ts +14 -0
- package/project/.sdk/src/cmp/clojure/TestClean_clojure.ts +10 -5
- package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +13 -0
- package/project/.sdk/src/cmp/csharp/TestClean_csharp.ts +9 -0
- package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +11 -3
- package/project/.sdk/src/cmp/go/TestClean_go.ts +39 -3
- package/project/.sdk/src/cmp/java/TestClean_java.ts +8 -0
- package/project/.sdk/src/cmp/js/TestClean_js.ts +13 -5
- package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +22 -0
- package/project/.sdk/src/cmp/lua/TestClean_lua.ts +12 -3
- package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +18 -4
- package/project/.sdk/src/cmp/perl/TestClean_perl.ts +12 -3
- package/project/.sdk/src/cmp/php/TestClean_php.ts +10 -3
- package/project/.sdk/src/cmp/py/TestClean_py.ts +10 -3
- package/project/.sdk/src/cmp/rb/TestClean_rb.ts +10 -3
- package/project/.sdk/src/cmp/rust/TestClean_rust.ts +10 -0
- package/project/.sdk/src/cmp/scala/TestClean_scala.ts +34 -0
- package/project/.sdk/src/cmp/swift/TestClean_swift.ts +20 -10
- package/project/.sdk/src/cmp/ts/TestClean_ts.ts +13 -5
- package/project/.sdk/src/cmp/zig/TestClean_zig.ts +12 -0
- package/project/.sdk/tm/c/core/context.c +1 -0
- package/project/.sdk/tm/c/core/sdk.h +7 -4
- package/project/.sdk/tm/c/feature/cache.c +243 -13
- package/project/.sdk/tm/c/feature/secrets.c +27 -38
- package/project/.sdk/tm/c/tests/feature_test.c +104 -0
- package/project/.sdk/tm/c/utility/clean.c +26 -33
- package/project/.sdk/tm/c/utility/make_options.c +9 -8
- package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +14 -11
- package/project/.sdk/tm/clojure/src/sdk/client.clj +3 -1
- package/project/.sdk/tm/clojure/src/sdk/core.clj +19 -11
- package/project/.sdk/tm/clojure/src/sdk/features.clj +81 -10
- package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +33 -0
- package/project/.sdk/tm/clojure/test/sdk/test/pipeline.clj +1 -0
- package/project/.sdk/tm/cpp/Makefile +5 -0
- package/project/.sdk/tm/cpp/core/types.hpp +11 -4
- package/project/.sdk/tm/cpp/feature/audit.hpp +6 -7
- package/project/.sdk/tm/cpp/feature/cache.hpp +188 -9
- package/project/.sdk/tm/cpp/feature/secrets.hpp +12 -0
- package/project/.sdk/tm/cpp/test/feature_test.cpp +99 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +9 -7
- package/project/.sdk/tm/csharp/core/Context.cs +4 -0
- package/project/.sdk/tm/csharp/feature/CacheFeature.cs +126 -12
- package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +9 -27
- package/project/.sdk/tm/csharp/test/FeatureTest.cs +76 -0
- package/project/.sdk/tm/csharp/utility/Clean.cs +5 -10
- package/project/.sdk/tm/csharp/utility/Fetcher.cs +7 -1
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +5 -12
- package/project/.sdk/tm/elixir/lib/projectname/context.ex +2 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/cache.ex +146 -30
- package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +10 -56
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +18 -12
- package/project/.sdk/tm/elixir/test/feature_test.exs +61 -0
- package/project/.sdk/tm/go/core/context.go +6 -0
- package/project/.sdk/tm/go/feature/cache_feature.go +131 -4
- package/project/.sdk/tm/go/feature/secrets_feature.go +17 -71
- package/project/.sdk/tm/go/test/feature_corpus_test.go +150 -2
- package/project/.sdk/tm/go/test/feature_test.go +61 -0
- package/project/.sdk/tm/go/utility/clean.go +5 -7
- package/project/.sdk/tm/go/utility/fetcher.go +11 -0
- package/project/.sdk/tm/go/utility/make_options.go +5 -7
- package/project/.sdk/tm/java/core/Context.java +9 -0
- package/project/.sdk/tm/java/feature/CacheFeature.java +123 -17
- package/project/.sdk/tm/java/feature/SecretsFeature.java +9 -92
- package/project/.sdk/tm/java/test/FeatureCorpusTest.java +141 -2
- package/project/.sdk/tm/java/test/FeatureTest.java +60 -0
- package/project/.sdk/tm/java/utility/Clean.java +6 -10
- package/project/.sdk/tm/java/utility/Fetcher.java +5 -1
- package/project/.sdk/tm/java/utility/MakeOptions.java +3 -1
- package/project/.sdk/tm/js/src/Context.js +4 -0
- package/project/.sdk/tm/js/src/feature/cache/CacheFeature.js +118 -11
- package/project/.sdk/tm/js/src/feature/cost/CostFeature.js +3 -2
- package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +1 -1
- package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +4 -4
- package/project/.sdk/tm/js/src/feature/rbac/RbacFeature.js +4 -4
- package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +16 -6
- package/project/.sdk/tm/js/src/feature/validate/ValidateFeature.js +2 -1
- package/project/.sdk/tm/js/src/utility/CleanUtility.js +1 -1
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +6 -6
- package/project/.sdk/tm/js/test/feature/Corpus.test.js +100 -2
- package/project/.sdk/tm/js/test/feature/harness.js +3 -3
- package/project/.sdk/tm/js/test/pipeline.test.js +1 -1
- package/project/.sdk/tm/kotlin/core/Context.kt +3 -0
- package/project/.sdk/tm/kotlin/feature/CacheFeature.kt +102 -7
- package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +10 -20
- package/project/.sdk/tm/kotlin/test/FeatureTest.kt +59 -0
- package/project/.sdk/tm/kotlin/utility/CoreUtil.kt +5 -5
- package/project/.sdk/tm/kotlin/utility/Fetcher.kt +4 -0
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +3 -1
- package/project/.sdk/tm/lua/core/context.lua +6 -0
- package/project/.sdk/tm/lua/feature/cache_feature.lua +212 -15
- package/project/.sdk/tm/lua/feature/secrets_feature.lua +15 -80
- package/project/.sdk/tm/lua/test/feature_test.lua +81 -0
- package/project/.sdk/tm/lua/utility/clean.lua +6 -9
- package/project/.sdk/tm/lua/utility/fetcher.lua +9 -0
- package/project/.sdk/tm/lua/utility/make_options.lua +5 -5
- package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +21 -6
- package/project/.sdk/tm/ocaml/sdk_features.ml +106 -8
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +13 -10
- package/project/.sdk/tm/ocaml/sdk_types.ml +2 -0
- package/project/.sdk/tm/ocaml/test/t_feature.ml +35 -1
- package/project/.sdk/tm/perl/core/context.pm +3 -0
- package/project/.sdk/tm/perl/feature/audit_feature.pm +4 -7
- package/project/.sdk/tm/perl/feature/cache_feature.pm +111 -15
- package/project/.sdk/tm/perl/feature/secrets_feature.pm +13 -18
- package/project/.sdk/tm/perl/t/feature.t +66 -0
- package/project/.sdk/tm/perl/t/feature_corpus.t +80 -4
- package/project/.sdk/tm/perl/utility/clean.pm +6 -8
- package/project/.sdk/tm/perl/utility/fetcher.pm +4 -0
- package/project/.sdk/tm/perl/utility/make_options.pm +5 -5
- package/project/.sdk/tm/php/core/Context.php +4 -0
- package/project/.sdk/tm/php/feature/CacheFeature.php +98 -13
- package/project/.sdk/tm/php/feature/SecretsFeature.php +18 -15
- package/project/.sdk/tm/php/test/FeatureCorpusTest.php +113 -3
- package/project/.sdk/tm/php/test/FeatureTest.php +68 -0
- package/project/.sdk/tm/php/utility/Clean.php +3 -10
- package/project/.sdk/tm/php/utility/Fetcher.php +8 -3
- package/project/.sdk/tm/php/utility/MakeOptions.php +5 -7
- package/project/.sdk/tm/py/pkg/core/context.py +4 -0
- package/project/.sdk/tm/py/pkg/feature/cache_feature.py +79 -13
- package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +15 -66
- package/project/.sdk/tm/py/pkg/utility/clean.py +4 -10
- package/project/.sdk/tm/py/pkg/utility/make_options.py +8 -9
- package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +23 -9
- package/project/.sdk/tm/py/test/test_feature.py +50 -0
- package/project/.sdk/tm/py/test/test_feature_corpus.py +88 -3
- package/project/.sdk/tm/rb/core/context.rb +4 -1
- package/project/.sdk/tm/rb/feature/audit_feature.rb +6 -5
- package/project/.sdk/tm/rb/feature/cache_feature.rb +75 -11
- package/project/.sdk/tm/rb/feature/secrets_feature.rb +9 -64
- package/project/.sdk/tm/rb/test/feature_corpus_test.rb +85 -3
- package/project/.sdk/tm/rb/test/feature_test.rb +74 -0
- package/project/.sdk/tm/rb/utility/clean.rb +6 -7
- package/project/.sdk/tm/rb/utility/fetcher.rb +6 -0
- package/project/.sdk/tm/rb/utility/make_options.rb +5 -5
- package/project/.sdk/tm/rust/core/context.rs +8 -0
- package/project/.sdk/tm/rust/feature/cache.rs +120 -3
- package/project/.sdk/tm/rust/feature/secrets.rs +36 -98
- package/project/.sdk/tm/rust/tests/feature/secrets/main.rs +3 -3
- package/project/.sdk/tm/rust/tests/feature_test.rs +100 -0
- package/project/.sdk/tm/rust/utility/clean.rs +35 -43
- package/project/.sdk/tm/rust/utility/fetcher.rs +6 -0
- package/project/.sdk/tm/rust/utility/make_options.rs +8 -11
- package/project/.sdk/tm/scala/core/Context.scala +4 -0
- package/project/.sdk/tm/scala/feature/CacheFeature.scala +117 -11
- package/project/.sdk/tm/scala/feature/SecretsFeature.scala +11 -24
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +28 -0
- package/project/.sdk/tm/scala/utility/Fetcher.scala +5 -0
- package/project/.sdk/tm/scala/utility/Make.scala +3 -1
- package/project/.sdk/tm/scala/utility/Misc.scala +5 -8
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Context.swift +3 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CacheFeature.swift +122 -11
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +9 -13
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Fetcher.swift +4 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +5 -4
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/ResultUtil.swift +4 -5
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +55 -0
- package/project/.sdk/tm/ts/src/Context.ts +4 -0
- package/project/.sdk/tm/ts/src/feature/cache/CacheFeature.ts +115 -4
- package/project/.sdk/tm/ts/src/feature/cost/CostFeature.ts +3 -2
- package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +1 -1
- package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +4 -4
- package/project/.sdk/tm/ts/src/feature/rbac/RbacFeature.ts +4 -4
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +14 -2
- package/project/.sdk/tm/ts/src/feature/validate/ValidateFeature.ts +2 -1
- package/project/.sdk/tm/ts/src/utility/CleanUtility.ts +1 -1
- package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +6 -6
- package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +101 -2
- package/project/.sdk/tm/ts/test/feature/harness.ts +3 -3
- package/project/.sdk/tm/ts/test/pipeline.test.ts +1 -1
- package/project/.sdk/tm/zig/core/context.zig +5 -0
- package/project/.sdk/tm/zig/core/utility.zig +11 -9
- package/project/.sdk/tm/zig/feature/cache.zig +144 -13
- package/project/.sdk/tm/zig/feature/secrets.zig +6 -1
- package/project/.sdk/tm/zig/test/feature_test.zig +65 -0
- package/project/sdkgen-package.json +1 -1
|
@@ -472,6 +472,52 @@
|
|
|
472
472
|
;; cache
|
|
473
473
|
;; ---------------------------------------------------------------------------
|
|
474
474
|
|
|
475
|
+
(def ^:private cache-unstored #{"no-store" "private" "no-cache"})
|
|
476
|
+
|
|
477
|
+
(defn- cache-header-text [v]
|
|
478
|
+
(cond (nil? v) nil
|
|
479
|
+
(string? v) v
|
|
480
|
+
(and (number? v) (== v (Math/floor (double v)))) (str (long v))
|
|
481
|
+
:else (str v)))
|
|
482
|
+
|
|
483
|
+
(defn- cache-digest [^javax.crypto.spec.SecretKeySpec secret headers]
|
|
484
|
+
(let [pairs (if (instance? java.util.Map headers)
|
|
485
|
+
(sort (keep (fn [[k v]] (when-let [t (cache-header-text v)] [(str/lower-case (str k)) t]))
|
|
486
|
+
(seq ^java.util.Map headers)))
|
|
487
|
+
[])
|
|
488
|
+
mac (doto (javax.crypto.Mac/getInstance "HmacSHA256") (.init secret))]
|
|
489
|
+
(doseq [[k v] pairs]
|
|
490
|
+
(.update mac (.getBytes (str k ":" v "\n") "UTF-8")))
|
|
491
|
+
(apply str (map #(format "%02x" (bit-and (long %) 0xff)) (.doFinal mac)))))
|
|
492
|
+
|
|
493
|
+
;; The configured ttl capped by the response's Cache-Control; zero when the
|
|
494
|
+
;; response may not be stored.
|
|
495
|
+
(defn- cache-lifetime [headers ttl]
|
|
496
|
+
(let [control (str/lower-case (or (some (fn [[k v]] (when (= "cache-control" (str/lower-case (str k))) (cache-header-text v)))
|
|
497
|
+
(when (instance? java.util.Map headers) (seq ^java.util.Map headers)))
|
|
498
|
+
""))
|
|
499
|
+
directives (map str/trim (str/split control #","))]
|
|
500
|
+
(if (some cache-unstored directives)
|
|
501
|
+
0
|
|
502
|
+
(reduce (fn [life d]
|
|
503
|
+
(if-let [[_ secs] (re-matches #"max-age\s*=\s*\"?(\d+)\"?" d)]
|
|
504
|
+
(long (min life (*' 1000 (bigint secs))))
|
|
505
|
+
life))
|
|
506
|
+
(long ttl) directives))))
|
|
507
|
+
|
|
508
|
+
(defn- cache-scope [url]
|
|
509
|
+
(str/replace (first (str/split (str url) #"[?#]" 2)) #"/+$" ""))
|
|
510
|
+
|
|
511
|
+
(defn- cache-parent [scope]
|
|
512
|
+
(let [scheme (str/index-of scope "://")
|
|
513
|
+
root (if (nil? scheme) 0 (str/index-of scope "/" (+ scheme 3)))]
|
|
514
|
+
(if (nil? root)
|
|
515
|
+
scope
|
|
516
|
+
(subs scope 0 (max root (or (str/last-index-of scope "/") 0))))))
|
|
517
|
+
|
|
518
|
+
(defn- cache-under? [scope prefix]
|
|
519
|
+
(or (= scope prefix) (str/starts-with? scope (str prefix "/"))))
|
|
520
|
+
|
|
475
521
|
(defn cache-feature []
|
|
476
522
|
(let [fa (new-feature "cache" false "0.0.1")
|
|
477
523
|
track! (fn [kind]
|
|
@@ -506,12 +552,22 @@
|
|
|
506
552
|
(let [oldest (first (keys (:store @fa)))]
|
|
507
553
|
(if (nil? oldest) (swap! fa assoc :store {})
|
|
508
554
|
(swap! fa update :store dissoc oldest))))))
|
|
555
|
+
invalidate! (fn [url]
|
|
556
|
+
(let [path (cache-scope url)
|
|
557
|
+
collection (cache-parent path)]
|
|
558
|
+
(swap! fa update :store
|
|
559
|
+
(fn [store]
|
|
560
|
+
(into {} (remove (fn [[_ e]] (let [scope (mget e "scope")]
|
|
561
|
+
(or (cache-under? scope path)
|
|
562
|
+
(= scope collection))))
|
|
563
|
+
store))))))
|
|
509
564
|
through (fn [ctx url fetchdef inner]
|
|
510
565
|
(let [method (str/upper-case (str (or (and (vs/ismap fetchdef) (vs/getprop fetchdef "method")) "GET")))
|
|
511
566
|
methods (or (opt fa "methods") (vs/jt "GET"))]
|
|
512
|
-
(
|
|
513
|
-
(
|
|
514
|
-
(let [key (str method " " url
|
|
567
|
+
(cond
|
|
568
|
+
(some #(= % method) (vec methods))
|
|
569
|
+
(let [key (str method " " url " "
|
|
570
|
+
(cache-digest (:secret @fa) (when (vs/ismap fetchdef) (vs/getprop fetchdef "headers"))))
|
|
515
571
|
now (now-ms fa)
|
|
516
572
|
hit (get (:store @fa) key)]
|
|
517
573
|
(if (and (some? hit) (> (mget hit "expiry") now))
|
|
@@ -524,17 +580,32 @@
|
|
|
524
580
|
|
|
525
581
|
(and (nil? err) (cacheable? res))
|
|
526
582
|
(let [snap (snapshot res)
|
|
527
|
-
ttl (opt fa "ttl" 5000)]
|
|
528
|
-
(
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
583
|
+
ttl (cache-lifetime (mget snap "headers") (opt fa "ttl" 5000))]
|
|
584
|
+
(if (<= ttl 0)
|
|
585
|
+
(do (track! "bypass") [(replay snap) nil])
|
|
586
|
+
(do
|
|
587
|
+
(swap! fa update :store dissoc key)
|
|
588
|
+
(evict!)
|
|
589
|
+
(swap! fa update :store assoc key
|
|
590
|
+
(vs/jm "expiry" (+ now ttl) "scope" (cache-scope url) "snapshot" snap))
|
|
591
|
+
(track! "miss")
|
|
592
|
+
[(replay snap) nil])))
|
|
593
|
+
|
|
594
|
+
:else (do (track! "bypass") [res err])))))
|
|
595
|
+
|
|
596
|
+
(contains? #{"GET" "HEAD"} method)
|
|
597
|
+
(inner ctx url fetchdef)
|
|
532
598
|
|
|
533
|
-
|
|
599
|
+
:else
|
|
600
|
+
(try (inner ctx url fetchdef)
|
|
601
|
+
(finally (invalidate! url))))))]
|
|
534
602
|
(swap! fa assoc
|
|
535
603
|
"init" (fn [ctx options]
|
|
536
604
|
(swap! fa assoc :client (core/oget ctx :client)
|
|
537
|
-
:options (if (vs/ismap options) options (vs/jm)) :active (opts-active? options) :store {}
|
|
605
|
+
:options (if (vs/ismap options) options (vs/jm)) :active (opts-active? options) :store {}
|
|
606
|
+
:secret (let [bytes (byte-array 32)]
|
|
607
|
+
(.nextBytes (java.security.SecureRandom.) bytes)
|
|
608
|
+
(javax.crypto.spec.SecretKeySpec. bytes "HmacSHA256")))
|
|
538
609
|
(when (active? fa)
|
|
539
610
|
(wrap-fetcher! ctx (fn [fctx url fd inner] (through fctx url fd inner))))))
|
|
540
611
|
fa))
|
|
@@ -365,6 +365,39 @@
|
|
|
365
365
|
h (make-harness [(fspec "cache" "active" false)] :server server)]
|
|
366
366
|
(h-op h :path "/x") (h-op h :path "/x")
|
|
367
367
|
(t/is-eq (count @calls) 2 "two calls"))))
|
|
368
|
+
(check "cache-keys-on-request-headers" "cache"
|
|
369
|
+
(fn [] (let [[server calls] (recording-server nil)
|
|
370
|
+
h (make-harness [(fspec "cache" "ttl" 10000)] :server server)]
|
|
371
|
+
(h-op h :path "/w/1" :headers (vs/jm "x-tenant" "tenant-a"))
|
|
372
|
+
(h-op h :path "/w/1" :headers (vs/jm "X-Tenant" "tenant-b"))
|
|
373
|
+
(t/is-eq (count @calls) 2 "a second tenant was not served the first tenant's entry")
|
|
374
|
+
(h-op h :path "/w/1" :headers (vs/jm "x-tenant" "tenant-b"))
|
|
375
|
+
(t/is-eq (count @calls) 2 "the same headers share an entry"))))
|
|
376
|
+
(check "cache-a-write-drops-its-collection" "cache"
|
|
377
|
+
(fn [] (let [[server calls] (recording-server nil)
|
|
378
|
+
h (make-harness [(fspec "cache" "ttl" 10000)] :server server)
|
|
379
|
+
paths ["/w/1" "/w" "/w/1/part" "/other/1" "/w/2"]]
|
|
380
|
+
(doseq [p paths] (h-op h :path p))
|
|
381
|
+
(h-op h :opname "update" :method "PUT" :path "/w/1")
|
|
382
|
+
(doseq [p paths] (h-op h :path p))
|
|
383
|
+
(t/is-eq (count @calls) 9 "the collection refetched")
|
|
384
|
+
(t/is-eq (mget (h-track h "_cache") "hit") 2 "the other entity stayed cached"))))
|
|
385
|
+
(check "cache-control-prevents-storing" "cache"
|
|
386
|
+
(fn [] (doseq [control ["no-store" "private" "No-Cache" "max-age=60, private"]]
|
|
387
|
+
(let [[server calls] (recording-server
|
|
388
|
+
(fn [_n _fd] [(make-response 200 (vs/jm "ok" true) (vs/jm "Cache-Control" control)) nil]))
|
|
389
|
+
h (make-harness [(fspec "cache" "ttl" 10000)] :server server)]
|
|
390
|
+
(h-op h :path "/w") (h-op h :path "/w")
|
|
391
|
+
(t/is-eq (count @calls) 2 (str control " was not stored"))))))
|
|
392
|
+
(check "cache-max-age-caps-the-ttl" "cache"
|
|
393
|
+
(fn [] (let [c (make-clock)
|
|
394
|
+
[server calls] (recording-server
|
|
395
|
+
(fn [_n _fd] [(make-response 200 (vs/jm "ok" true) (vs/jm "cache-control" "max-age=1")) nil]))
|
|
396
|
+
h (make-harness [(fspec "cache" "ttl" 10000 "now" (clock-now c))] :server server)]
|
|
397
|
+
(h-op h :path "/w") (clock-advance c 500) (h-op h :path "/w")
|
|
398
|
+
(t/is-eq (count @calls) 1 "a hit inside max-age")
|
|
399
|
+
(clock-advance c 600) (h-op h :path "/w")
|
|
400
|
+
(t/is-eq (count @calls) 2 "max-age expired before the ttl"))))
|
|
368
401
|
|
|
369
402
|
;; ---- idempotency ----
|
|
370
403
|
(check "idempotency-adds-key-mutating" "idempotency"
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
(let [utility (core/get-utility sdk)
|
|
16
16
|
ctx (core/make-context (vs/jm "opname" opname "client" sdk "utility" utility) nil)]
|
|
17
17
|
(when (nil? (core/oget ctx :options)) (core/oset! ctx :options (core/client-options-map sdk)))
|
|
18
|
+
(core/oset! ctx :cleancfg (core/oget (core/client-root-ctx sdk) :cleancfg))
|
|
18
19
|
ctx))
|
|
19
20
|
|
|
20
21
|
(defn- set-points! [ctx pts] (swap! (core/oget ctx :op) assoc :points pts))
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
CXX ?= g++
|
|
12
12
|
CXXFLAGS ?= -std=c++17 -O0 -g -Wall -Wextra -Wno-unused-parameter -pthread
|
|
13
|
+
ifeq ($(OS),Windows_NT)
|
|
14
|
+
ifneq (,$(findstring g++,$(CXX)))
|
|
15
|
+
CXXFLAGS += -Wa,-mbig-obj
|
|
16
|
+
endif
|
|
17
|
+
endif
|
|
13
18
|
|
|
14
19
|
# ---- gated feature payloads (model/feature/<name>.aontu plugin groups) --------
|
|
15
20
|
#
|
|
@@ -460,6 +460,7 @@ struct CtxSpec {
|
|
|
460
460
|
|
|
461
461
|
Value config = Value::undef();
|
|
462
462
|
Value options = Value::undef();
|
|
463
|
+
Value cleancfg = Value::undef();
|
|
463
464
|
Value shared = Value::undef();
|
|
464
465
|
Value meta = Value::undef();
|
|
465
466
|
Value entopts = Value::undef();
|
|
@@ -491,6 +492,9 @@ struct CtxOut {
|
|
|
491
492
|
ResponsePtr request;
|
|
492
493
|
ResponsePtr response;
|
|
493
494
|
ResultPtr result;
|
|
495
|
+
// Per-call feature state that must end with the call (the c port's
|
|
496
|
+
// ctx_out_extra).
|
|
497
|
+
std::map<std::string, Value> extra;
|
|
494
498
|
};
|
|
495
499
|
|
|
496
500
|
// ---- Context ----------------------------------------------------------
|
|
@@ -508,6 +512,8 @@ public:
|
|
|
508
512
|
Value config = Value::undef();
|
|
509
513
|
Value entopts = Value::undef();
|
|
510
514
|
Value options = Value::undef();
|
|
515
|
+
// The clean registry, beside the options rather than in them.
|
|
516
|
+
Value cleancfg = Value::undef();
|
|
511
517
|
OpMapPtr opmap;
|
|
512
518
|
ResponsePtr response;
|
|
513
519
|
ResultPtr result;
|
|
@@ -630,9 +636,9 @@ public:
|
|
|
630
636
|
|
|
631
637
|
// ---- SdkClient --------------------------------------------------------
|
|
632
638
|
|
|
633
|
-
// A registration replaces the secret registry
|
|
634
|
-
//
|
|
635
|
-
//
|
|
639
|
+
// A registration replaces the secret registry's `values` slot while other
|
|
640
|
+
// threads clean: it holds this lock exclusively, and every read of that slot
|
|
641
|
+
// holds it shared.
|
|
636
642
|
inline std::shared_mutex& cleanRegistryLock() {
|
|
637
643
|
// winpthreads sets up a static rwlock on its first lock, failing threads
|
|
638
644
|
// that race it with EINVAL; that first lock runs in this static's
|
|
@@ -811,6 +817,8 @@ inline Context::Context(const CtxSpec& cs, const CtxPtr& basectx) {
|
|
|
811
817
|
// Options
|
|
812
818
|
if (cs.options.is_map()) options = cs.options;
|
|
813
819
|
if (options.is_undef() && basectx) options = basectx->options;
|
|
820
|
+
if (cs.cleancfg.is_map()) cleancfg = cs.cleancfg;
|
|
821
|
+
if (cleancfg.is_undef() && basectx) cleancfg = basectx->cleancfg;
|
|
814
822
|
|
|
815
823
|
// Entity
|
|
816
824
|
entity = cs.entity;
|
|
@@ -978,7 +986,6 @@ inline SdkClient::SdkClient(const Value& options_) {
|
|
|
978
986
|
}
|
|
979
987
|
|
|
980
988
|
inline Value SdkClient::optionsMap() {
|
|
981
|
-
std::shared_lock<std::shared_mutex> guard(cleanRegistryLock());
|
|
982
989
|
Value out = Struct::clone(options);
|
|
983
990
|
return out.is_map() ? out : vmap();
|
|
984
991
|
}
|
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
// on the feature (bounded by `max`, default 1000) and, when a `sink` callback
|
|
5
5
|
// is supplied, are pushed to it. The actor is the per-call ctrl actor,
|
|
6
6
|
// falling back to the options `actor`, then "anonymous". Each operation is
|
|
7
|
-
// audited exactly once (the per-context seen marker
|
|
8
|
-
//
|
|
7
|
+
// audited exactly once (the per-context seen marker, java's ctx.out, is kept
|
|
8
|
+
// in ctx->out.extra). Timestamps use the injectable `now` clock.
|
|
9
9
|
|
|
10
10
|
#ifndef SDK_FEATURE_AUDIT_HPP
|
|
11
11
|
#define SDK_FEATURE_AUDIT_HPP
|
|
12
12
|
|
|
13
|
-
#include <map>
|
|
14
13
|
#include <string>
|
|
15
14
|
|
|
16
15
|
#include "../core/types.hpp"
|
|
@@ -52,15 +51,15 @@ public:
|
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
private:
|
|
55
|
-
std::map<std::string, bool> seen;
|
|
56
|
-
|
|
57
54
|
void emit(CtxPtr ctx, const std::string& outcome) {
|
|
58
55
|
if (!active) return;
|
|
59
56
|
|
|
60
57
|
// One record per operation (PreDone + a following PreUnexpected on a
|
|
61
58
|
// failure must not double-log).
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
auto& extra = ctx->out.extra;
|
|
60
|
+
auto at = extra.find("audit_seen");
|
|
61
|
+
if (at != extra.end() && at->second.is_bool() && at->second.as_bool()) return;
|
|
62
|
+
extra["audit_seen"] = Value(true);
|
|
64
63
|
|
|
65
64
|
seq++;
|
|
66
65
|
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
// ProjectName SDK — cache feature (mirrors java feature/CacheFeature.java).
|
|
2
|
-
// Response caching for safe (read) requests
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// Bodies are snapshotted so both the current caller and later hits re-read
|
|
8
|
-
// the JSON body repeatedly.
|
|
2
|
+
// Response caching for safe (read) requests, per client: see the features
|
|
3
|
+
// reference for the key, the write invalidation and the Cache-Control rules.
|
|
4
|
+
// No HMAC in std: SipHash-2-4 under a random per-client key separates header
|
|
5
|
+
// sets within one store without holding a header value. It is not a
|
|
6
|
+
// cryptographic commitment.
|
|
9
7
|
|
|
10
8
|
#ifndef SDK_FEATURE_CACHE_HPP
|
|
11
9
|
#define SDK_FEATURE_CACHE_HPP
|
|
12
10
|
|
|
11
|
+
#include <algorithm>
|
|
13
12
|
#include <cctype>
|
|
13
|
+
#include <cstdint>
|
|
14
|
+
#include <cstdio>
|
|
14
15
|
#include <map>
|
|
16
|
+
#include <random>
|
|
15
17
|
#include <string>
|
|
18
|
+
#include <utility>
|
|
16
19
|
#include <vector>
|
|
17
20
|
|
|
18
21
|
#include "../core/types.hpp"
|
|
@@ -34,6 +37,46 @@ public:
|
|
|
34
37
|
|
|
35
38
|
CacheFeature() : BaseFeature("cache", "0.0.1", true) {}
|
|
36
39
|
|
|
40
|
+
static uint64_t le64(const uint8_t* p) {
|
|
41
|
+
uint64_t v = 0;
|
|
42
|
+
for (int i = 7; i >= 0; i--) v = (v << 8) | p[i];
|
|
43
|
+
return v;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static uint64_t rotl(uint64_t x, int b) { return (x << b) | (x >> (64 - b)); }
|
|
47
|
+
|
|
48
|
+
static void sipround(uint64_t& v0, uint64_t& v1, uint64_t& v2, uint64_t& v3) {
|
|
49
|
+
v0 += v1; v1 = rotl(v1, 13); v1 ^= v0; v0 = rotl(v0, 32);
|
|
50
|
+
v2 += v3; v3 = rotl(v3, 16); v3 ^= v2;
|
|
51
|
+
v0 += v3; v3 = rotl(v3, 21); v3 ^= v0;
|
|
52
|
+
v2 += v1; v1 = rotl(v1, 17); v1 ^= v2; v2 = rotl(v2, 32);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static uint64_t siphash24(const uint8_t key[16], const std::string& in) {
|
|
56
|
+
const uint8_t* p = reinterpret_cast<const uint8_t*>(in.data());
|
|
57
|
+
size_t len = in.size();
|
|
58
|
+
uint64_t k0 = le64(key), k1 = le64(key + 8);
|
|
59
|
+
uint64_t v0 = 0x736f6d6570736575ULL ^ k0, v1 = 0x646f72616e646f6dULL ^ k1;
|
|
60
|
+
uint64_t v2 = 0x6c7967656e657261ULL ^ k0, v3 = 0x7465646279746573ULL ^ k1;
|
|
61
|
+
size_t full = len - (len % 8);
|
|
62
|
+
for (size_t i = 0; i < full; i += 8) {
|
|
63
|
+
uint64_t m = le64(p + i);
|
|
64
|
+
v3 ^= m;
|
|
65
|
+
sipround(v0, v1, v2, v3);
|
|
66
|
+
sipround(v0, v1, v2, v3);
|
|
67
|
+
v0 ^= m;
|
|
68
|
+
}
|
|
69
|
+
uint64_t b = static_cast<uint64_t>(len) << 56;
|
|
70
|
+
for (size_t i = 0; i < len % 8; i++) b |= static_cast<uint64_t>(p[full + i]) << (8 * i);
|
|
71
|
+
v3 ^= b;
|
|
72
|
+
sipround(v0, v1, v2, v3);
|
|
73
|
+
sipround(v0, v1, v2, v3);
|
|
74
|
+
v0 ^= b;
|
|
75
|
+
v2 ^= 0xff;
|
|
76
|
+
for (int i = 0; i < 4; i++) sipround(v0, v1, v2, v3);
|
|
77
|
+
return v0 ^ v1 ^ v2 ^ v3;
|
|
78
|
+
}
|
|
79
|
+
|
|
37
80
|
void init(CtxPtr ctx, const Value& options_) override {
|
|
38
81
|
client = ctx->client;
|
|
39
82
|
options = options_;
|
|
@@ -42,6 +85,8 @@ public:
|
|
|
42
85
|
|
|
43
86
|
store.clear();
|
|
44
87
|
order.clear();
|
|
88
|
+
std::random_device rd;
|
|
89
|
+
for (auto& b : secret) b = static_cast<uint8_t>(rd() & 0xff);
|
|
45
90
|
|
|
46
91
|
auto inner = ctx->utility->fetcher;
|
|
47
92
|
ctx->utility->fetcher = [this, inner](CtxPtr ctx2, const std::string& url,
|
|
@@ -60,11 +105,13 @@ private:
|
|
|
60
105
|
|
|
61
106
|
struct CacheEntry {
|
|
62
107
|
long long expiry = 0;
|
|
108
|
+
std::string scope;
|
|
63
109
|
CacheSnapshot snapshot;
|
|
64
110
|
};
|
|
65
111
|
|
|
66
112
|
std::map<std::string, CacheEntry> store;
|
|
67
113
|
std::vector<std::string> order;
|
|
114
|
+
uint8_t secret[16] = {0};
|
|
68
115
|
|
|
69
116
|
static std::string upper(std::string s) {
|
|
70
117
|
for (auto& c : s) c = static_cast<char>(std::toupper((unsigned char)c));
|
|
@@ -91,10 +138,18 @@ private:
|
|
|
91
138
|
}
|
|
92
139
|
}
|
|
93
140
|
if (!cacheable) {
|
|
141
|
+
if (method == "GET" || method == "HEAD") {
|
|
142
|
+
return inner(ctx, url, fetchdef);
|
|
143
|
+
}
|
|
144
|
+
struct Invalidate {
|
|
145
|
+
CacheFeature* self;
|
|
146
|
+
const std::string& url;
|
|
147
|
+
~Invalidate() { self->invalidate(url); }
|
|
148
|
+
} after{this, url};
|
|
94
149
|
return inner(ctx, url, fetchdef);
|
|
95
150
|
}
|
|
96
151
|
|
|
97
|
-
std::string key = method + " " + url;
|
|
152
|
+
std::string key = method + " " + url + " " + digest(getp(fetchdef, "headers"));
|
|
98
153
|
long long now = fopt::foptNow(options)();
|
|
99
154
|
|
|
100
155
|
auto it = store.find(key);
|
|
@@ -113,10 +168,16 @@ private:
|
|
|
113
168
|
|
|
114
169
|
if (storable(res) && json(res)) {
|
|
115
170
|
CacheSnapshot snap = snapshot(res);
|
|
116
|
-
|
|
171
|
+
long long ttl = lifetime(snap.headers, fopt::foptInt(options, "ttl", 5000));
|
|
172
|
+
if (ttl <= 0) {
|
|
173
|
+
bypass++;
|
|
174
|
+
return replay(snap);
|
|
175
|
+
}
|
|
176
|
+
drop(key);
|
|
117
177
|
evict();
|
|
118
178
|
CacheEntry entry;
|
|
119
179
|
entry.expiry = now + ttl;
|
|
180
|
+
entry.scope = urlScope(url);
|
|
120
181
|
entry.snapshot = snap;
|
|
121
182
|
store[key] = entry;
|
|
122
183
|
order.push_back(key);
|
|
@@ -128,6 +189,124 @@ private:
|
|
|
128
189
|
return res;
|
|
129
190
|
}
|
|
130
191
|
|
|
192
|
+
static std::string lower(std::string s) {
|
|
193
|
+
for (auto& c : s) c = static_cast<char>(std::tolower((unsigned char)c));
|
|
194
|
+
return s;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
static bool headerText(const Value& v, std::string& out) {
|
|
198
|
+
if (v.is_string()) { out = v.as_string(); return true; }
|
|
199
|
+
if (v.is_int()) { out = std::to_string(v.as_int()); return true; }
|
|
200
|
+
if (v.is_double()) {
|
|
201
|
+
double d = v.as_double();
|
|
202
|
+
char buf[64];
|
|
203
|
+
if (d == static_cast<double>(static_cast<long long>(d))) {
|
|
204
|
+
std::snprintf(buf, sizeof(buf), "%lld", static_cast<long long>(d));
|
|
205
|
+
} else {
|
|
206
|
+
std::snprintf(buf, sizeof(buf), "%g", d);
|
|
207
|
+
}
|
|
208
|
+
out = buf;
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
if (v.is_bool()) { out = v.as_bool() ? "true" : "false"; return true; }
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
std::string digest(const Value& headers) {
|
|
216
|
+
std::vector<std::pair<std::string, std::string>> pairs;
|
|
217
|
+
if (headers.is_map()) {
|
|
218
|
+
for (const auto& kv : *headers.as_map()) {
|
|
219
|
+
std::string text;
|
|
220
|
+
if (headerText(kv.second, text)) pairs.emplace_back(lower(kv.first), text);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
std::sort(pairs.begin(), pairs.end());
|
|
224
|
+
std::string text;
|
|
225
|
+
for (const auto& p : pairs) text += p.first + ":" + p.second + "\n";
|
|
226
|
+
char hex[17];
|
|
227
|
+
std::snprintf(hex, sizeof(hex), "%016llx",
|
|
228
|
+
static_cast<unsigned long long>(siphash24(secret, text)));
|
|
229
|
+
return std::string(hex);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
void invalidate(const std::string& url) {
|
|
233
|
+
std::string path = urlScope(url);
|
|
234
|
+
std::string collection = urlParent(path);
|
|
235
|
+
std::vector<std::string> dropped;
|
|
236
|
+
for (const auto& kv : store) {
|
|
237
|
+
if (under(kv.second.scope, path) || kv.second.scope == collection) dropped.push_back(kv.first);
|
|
238
|
+
}
|
|
239
|
+
for (const auto& key : dropped) drop(key);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
void drop(const std::string& key) {
|
|
243
|
+
if (store.erase(key) > 0) {
|
|
244
|
+
order.erase(std::remove(order.begin(), order.end(), key), order.end());
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
static std::string trim(const std::string& s) {
|
|
249
|
+
size_t a = 0, b = s.size();
|
|
250
|
+
while (a < b && std::isspace((unsigned char)s[a])) a++;
|
|
251
|
+
while (b > a && std::isspace((unsigned char)s[b - 1])) b--;
|
|
252
|
+
return s.substr(a, b - a);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// The configured ttl capped by the response's Cache-Control; zero when the
|
|
256
|
+
// response may not be stored.
|
|
257
|
+
static long long lifetime(const Value& headers, long long ttl) {
|
|
258
|
+
std::string control;
|
|
259
|
+
if (headers.is_map()) {
|
|
260
|
+
for (const auto& kv : *headers.as_map()) {
|
|
261
|
+
std::string text;
|
|
262
|
+
if (lower(kv.first) == "cache-control" && headerText(kv.second, text)) control = lower(text);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
long long life = ttl;
|
|
266
|
+
size_t start = 0;
|
|
267
|
+
while (start <= control.size()) {
|
|
268
|
+
size_t comma = control.find(',', start);
|
|
269
|
+
std::string directive = trim(control.substr(start, comma == std::string::npos ? std::string::npos : comma - start));
|
|
270
|
+
if (directive == "no-store" || directive == "private" || directive == "no-cache") return 0;
|
|
271
|
+
if (directive.rfind("max-age", 0) == 0) {
|
|
272
|
+
std::string value = trim(directive.substr(7));
|
|
273
|
+
if (!value.empty() && value[0] == '=') {
|
|
274
|
+
value = trim(value.substr(1));
|
|
275
|
+
if (value.size() >= 2 && value.front() == '"' && value.back() == '"') value = value.substr(1, value.size() - 2);
|
|
276
|
+
if (!value.empty() && value.size() < 16 &&
|
|
277
|
+
std::all_of(value.begin(), value.end(), [](char c) { return std::isdigit((unsigned char)c); })) {
|
|
278
|
+
life = std::min(life, std::stoll(value) * 1000);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (comma == std::string::npos) break;
|
|
283
|
+
start = comma + 1;
|
|
284
|
+
}
|
|
285
|
+
return life;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
static std::string urlScope(const std::string& url) {
|
|
289
|
+
std::string out = url.substr(0, url.find_first_of("?#"));
|
|
290
|
+
while (!out.empty() && out.back() == '/') out.pop_back();
|
|
291
|
+
return out;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
static std::string urlParent(const std::string& scope) {
|
|
295
|
+
size_t root = 0;
|
|
296
|
+
size_t scheme = scope.find("://");
|
|
297
|
+
if (scheme != std::string::npos) {
|
|
298
|
+
root = scope.find('/', scheme + 3);
|
|
299
|
+
if (root == std::string::npos) return scope;
|
|
300
|
+
}
|
|
301
|
+
size_t cut = scope.rfind('/');
|
|
302
|
+
if (cut == std::string::npos || cut < root) cut = root;
|
|
303
|
+
return scope.substr(0, cut);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
static bool under(const std::string& scope, const std::string& prefix) {
|
|
307
|
+
return scope == prefix || scope.rfind(prefix + "/", 0) == 0;
|
|
308
|
+
}
|
|
309
|
+
|
|
131
310
|
// A body the transport could not read as JSON passes through, for the operation to report.
|
|
132
311
|
bool storable(const Value& res) {
|
|
133
312
|
int status = fopt::fresStatus(res);
|
|
@@ -425,6 +425,9 @@ private:
|
|
|
425
425
|
|
|
426
426
|
std::shared_ptr<Exchange> exchange_;
|
|
427
427
|
std::string refresh_;
|
|
428
|
+
// The transport's refusal of the last purchase, which the gate throws in
|
|
429
|
+
// place of a resolution error.
|
|
430
|
+
SdkErrorPtr refused_;
|
|
428
431
|
|
|
429
432
|
// The custom-provider slot table: the Injector each `custom` spec's slot
|
|
430
433
|
// ticket names.
|
|
@@ -567,6 +570,7 @@ private:
|
|
|
567
570
|
// message, or "" for success with the token in cred_. Called under mu_.
|
|
568
571
|
std::string buy() {
|
|
569
572
|
const Exchange& x = *exchange_;
|
|
573
|
+
refused_ = nullptr;
|
|
570
574
|
|
|
571
575
|
// TEST MODE BUYS NOTHING. The test feature replaces the transport so no
|
|
572
576
|
// request leaves the process; an exchange here would be the one HTTP
|
|
@@ -629,6 +633,10 @@ private:
|
|
|
629
633
|
}
|
|
630
634
|
return "";
|
|
631
635
|
}
|
|
636
|
+
// Not util::fetcher, as every other target does: the cpp core has no
|
|
637
|
+
// client of its own, so only the guard is applied before sekreto's.
|
|
638
|
+
refused_ = util::getOnlyRefusal(client->rootctx, at, fetchdef);
|
|
639
|
+
if (refused_) return refused_->msg;
|
|
632
640
|
std::vector<std::pair<std::string, std::string>> hdrs{{"content-type", "application/json"}};
|
|
633
641
|
SecretsRawResponse raw = secrets_rawfetch(x.method, at, hdrs, bodytext);
|
|
634
642
|
if (!raw.ok) return raw.err;
|
|
@@ -824,6 +832,9 @@ private:
|
|
|
824
832
|
std::string rerr = resolve();
|
|
825
833
|
if (!rerr.empty()) {
|
|
826
834
|
track_.refused++;
|
|
835
|
+
SdkErrorPtr refused = refused_;
|
|
836
|
+
refused_ = nullptr;
|
|
837
|
+
if (refused) throw refused;
|
|
827
838
|
throw ctx->makeError("secrets_resolve", rerr);
|
|
828
839
|
}
|
|
829
840
|
|
|
@@ -865,6 +876,7 @@ private:
|
|
|
865
876
|
// The purchase failed: answer with the API's own refusal rather
|
|
866
877
|
// than this one. The caller asked for data, and the refusal is
|
|
867
878
|
// the more useful of the two - the exchange error is a symptom.
|
|
879
|
+
refused_ = nullptr;
|
|
868
880
|
return out;
|
|
869
881
|
}
|
|
870
882
|
}
|