@voxgig/sdkgen 4.10.0 → 4.11.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/secrets.aon +330 -0
- package/project/.sdk/model/target/c.aon +15 -2
- package/project/.sdk/model/target/cpp.aon +18 -0
- package/project/.sdk/model/target/lua.aon +17 -0
- package/project/.sdk/model/target/ocaml.aon +48 -5
- package/project/.sdk/model/target/zig.aon +30 -4
- package/project/.sdk/src/cmp/c/Config_c.ts +338 -1
- package/project/.sdk/src/cmp/c/Main_c.ts +57 -2
- package/project/.sdk/src/cmp/c/Package_c.ts +12 -2
- package/project/.sdk/src/cmp/cpp/Config_cpp.ts +324 -2
- package/project/.sdk/src/cmp/cpp/Gitignore_cpp.ts +2 -0
- package/project/.sdk/src/cmp/cpp/Main_cpp.ts +62 -4
- package/project/.sdk/src/cmp/cpp/Package_cpp.ts +10 -0
- package/project/.sdk/src/cmp/lua/Config_lua.ts +88 -0
- package/project/.sdk/src/cmp/lua/Gitignore_lua.ts +4 -0
- package/project/.sdk/src/cmp/lua/Main_lua.ts +93 -3
- package/project/.sdk/src/cmp/lua/Package_lua.ts +60 -0
- package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +10 -0
- package/project/.sdk/src/cmp/ocaml/Config_ocaml.ts +183 -5
- package/project/.sdk/src/cmp/ocaml/Main_ocaml.ts +160 -3
- package/project/.sdk/src/cmp/ocaml/Package_ocaml.ts +25 -1
- package/project/.sdk/src/cmp/zig/Config_zig.ts +130 -9
- package/project/.sdk/src/cmp/zig/Main_zig.ts +208 -4
- package/project/.sdk/{tm/zig/build.zig → src/cmp/zig/fragment/Build.fragment.zig} +7 -0
- package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +25 -0
- package/project/.sdk/{tm/zig/root.zig → src/cmp/zig/fragment/Root.fragment.zig} +9 -0
- package/project/.sdk/tm/c/Makefile +58 -9
- package/project/.sdk/tm/c/core/sdk.h +10 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/capability.c +133 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/capability.h +39 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/catalog.c +83 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/catalog.h +48 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/config.c +413 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/config.h +24 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/depend.c +264 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/depend.h +29 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/env.c +220 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/env.h +19 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/export.c +97 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/export.h +19 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/graph.c +237 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/graph.h +17 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/host.c +1494 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/host.h +135 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/order.c +288 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/order.h +18 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/point.c +141 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/point.h +80 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/ref.c +170 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/ref.h +52 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/resolve.c +98 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/resolve.h +18 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/types.c +150 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/types.h +104 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/value.c +649 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/value.h +135 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/version.c +151 -0
- package/project/.sdk/tm/c/feature/secrets/plugin/version.h +34 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/aws.c +281 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/azuresecrets.c +207 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/boru.c +164 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/clock.c +75 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/doppler.c +141 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/encode.c +144 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/gcpsecrets.c +177 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/hashicorp.c +239 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/httpjson.c +599 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/infisical.c +165 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/onepassword.c +194 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/proc.c +233 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/secretspec.c +125 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/sekretoplugins.h +125 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/sha256.c +270 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/sigv4.c +382 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/support.h +153 -0
- package/project/.sdk/tm/c/feature/secrets/plugins/tls.c +420 -0
- package/project/.sdk/tm/c/feature/secrets/sekreto/internal.h +86 -0
- package/project/.sdk/tm/c/feature/secrets/sekreto/json.c +721 -0
- package/project/.sdk/tm/c/feature/secrets/sekreto/providers.c +813 -0
- package/project/.sdk/tm/c/feature/secrets/sekreto/sekreto.c +944 -0
- package/project/.sdk/tm/c/feature/secrets/sekreto/sekreto.h +490 -0
- package/project/.sdk/tm/c/feature/secrets/sekreto/util.c +442 -0
- package/project/.sdk/tm/c/feature/secrets.c +797 -0
- package/project/.sdk/tm/c/feature/secrets.h +46 -0
- package/project/.sdk/tm/c/src/feature/secrets/.gitkeep +0 -0
- package/project/.sdk/tm/c/tests/feature/secrets/secrets_test.c +802 -0
- package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +38 -11
- package/project/.sdk/tm/clojure/test/sdk/test/feature/secrets.clj +40 -6
- package/project/.sdk/tm/cpp/Makefile +48 -4
- package/project/.sdk/tm/cpp/feature/secrets/plugin/capability.cpp +121 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/capability.hpp +41 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/catalog.cpp +60 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/catalog.hpp +66 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/config.cpp +376 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/config.hpp +29 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/depend.cpp +230 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/depend.hpp +31 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/env.cpp +205 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/env.hpp +25 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/export.cpp +84 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/export.hpp +24 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/graph.cpp +222 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/graph.hpp +21 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/host.cpp +1200 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/host.hpp +250 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/order.cpp +250 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/order.hpp +22 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/point.cpp +110 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/point.hpp +79 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/ref.cpp +136 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/ref.hpp +60 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/resolve.cpp +82 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/resolve.hpp +25 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/types.cpp +90 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/types.hpp +65 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/value.cpp +491 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/value.hpp +120 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/version.cpp +143 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugin/version.hpp +36 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Aws.cpp +248 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Aws.hpp +30 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Azuresecrets.cpp +149 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Azuresecrets.hpp +23 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Boru.cpp +117 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Boru.hpp +27 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Crypto.cpp +180 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Crypto.hpp +52 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Doppler.cpp +87 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Doppler.hpp +23 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Gcpsecrets.cpp +121 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Gcpsecrets.hpp +23 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Hashicorp.cpp +153 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Hashicorp.hpp +23 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Httpjson.cpp +666 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Httpjson.hpp +160 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Infisical.cpp +123 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Infisical.hpp +23 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Onepassword.cpp +125 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Onepassword.hpp +23 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Proc.cpp +223 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Proc.hpp +47 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Secretspec.cpp +104 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Secretspec.hpp +27 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Sigv4.cpp +242 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Sigv4.hpp +58 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Tls.cpp +260 -0
- package/project/.sdk/tm/cpp/feature/secrets/plugins/Tls.hpp +47 -0
- package/project/.sdk/tm/cpp/feature/secrets/sekreto/Json.cpp +476 -0
- package/project/.sdk/tm/cpp/feature/secrets/sekreto/Json.hpp +89 -0
- package/project/.sdk/tm/cpp/feature/secrets/sekreto/Provider.cpp +312 -0
- package/project/.sdk/tm/cpp/feature/secrets/sekreto/Provider.hpp +263 -0
- package/project/.sdk/tm/cpp/feature/secrets/sekreto/Providers.cpp +354 -0
- package/project/.sdk/tm/cpp/feature/secrets/sekreto/Providers.hpp +111 -0
- package/project/.sdk/tm/cpp/feature/secrets/sekreto/Sekreto.cpp +613 -0
- package/project/.sdk/tm/cpp/feature/secrets/sekreto/Sekreto.hpp +227 -0
- package/project/.sdk/tm/cpp/feature/secrets.hpp +745 -0
- package/project/.sdk/tm/cpp/src/feature/secrets/.gitkeep +0 -0
- package/project/.sdk/tm/cpp/test/feature/secrets/secrets_test.cpp +808 -0
- package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +34 -8
- package/project/.sdk/tm/csharp/test/feature/secrets/SecretsFeatureTest.cs +85 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +17 -2
- package/project/.sdk/tm/elixir/test/feature/secrets/secrets_test.exs +41 -0
- package/project/.sdk/tm/go/feature/secrets_feature.go +32 -10
- package/project/.sdk/tm/go/test/feature/secrets/secrets_feature_test.go +116 -0
- package/project/.sdk/tm/java/feature/SecretsFeature.java +33 -8
- package/project/.sdk/tm/java/test/feature/secrets/SecretsFeatureTest.java +64 -0
- package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +34 -11
- package/project/.sdk/tm/js/test/feature/secrets/Secrets.test.js +73 -0
- package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +32 -7
- package/project/.sdk/tm/kotlin/test/feature/secrets/SecretsTest.kt +69 -0
- package/project/.sdk/tm/lua/Makefile +15 -4
- package/project/.sdk/tm/lua/feature/secrets/native/sekretonet.c +806 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/capability.lua +135 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/catalog.lua +63 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/config.lua +361 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/depend.lua +232 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/env.lua +168 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/export.lua +66 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/graph.lua +194 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/host.lua +1190 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/json.lua +169 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/order.lua +207 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/point.lua +106 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/ref.lua +115 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/resolve.lua +78 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/types.lua +275 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin/version.lua +131 -0
- package/project/.sdk/tm/lua/feature/secrets/plugin.lua +76 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/addr.lua +124 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/err.lua +47 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/name.lua +315 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/aws.lua +228 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/azuresecrets.lua +137 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/boru.lua +124 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/crypto.lua +212 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/doppler.lua +89 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/gcpsecrets.lua +129 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/hashicorp.lua +154 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/httpjson.lua +248 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/infisical.lua +113 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/json.lua +449 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/net.lua +198 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/onepassword.lua +126 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/secretspec.lua +93 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/sigv4.lua +269 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/plugins/support.lua +146 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto/providers.lua +346 -0
- package/project/.sdk/tm/lua/feature/secrets/sekreto.lua +479 -0
- package/project/.sdk/tm/lua/feature/secrets_feature.lua +690 -0
- package/project/.sdk/tm/lua/src/feature/secrets/.gitkeep +0 -0
- package/project/.sdk/tm/lua/test/extend_test.lua +105 -0
- package/project/.sdk/tm/lua/test/feature/secrets/secrets_feature_test.lua +862 -0
- package/project/.sdk/tm/ocaml/Makefile +52 -8
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/capability.ml +106 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/catalog.ml +43 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/config.ml +349 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/defs.ml +143 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/depend.ml +217 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/env.ml +197 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/export.ml +89 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/graph.ml +227 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/host.ml +1112 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/order.ml +202 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/point.ml +138 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/ref.ml +126 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/resolve.ml +62 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/types.ml +97 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/value.ml +387 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugin/version.ml +139 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/aws.ml +171 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/azuresecrets.ml +116 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/boru.ml +95 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/crypto.ml +149 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/doppler.ml +61 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/gcpsecrets.ml +93 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/hashicorp.ml +120 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/http.ml +421 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/httpjson.ml +66 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/infisical.ml +85 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/onepassword.ml +112 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/runcmd.ml +97 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/secretspec.ml +68 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/sigv4.ml +259 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/tls.ml +44 -0
- package/project/.sdk/tm/ocaml/feature/secrets/plugins/tls_stubs.c +358 -0
- package/project/.sdk/tm/ocaml/feature/secrets/sekreto/json.ml +376 -0
- package/project/.sdk/tm/ocaml/feature/secrets/sekreto/provider.ml +647 -0
- package/project/.sdk/tm/ocaml/feature/secrets/sekreto/secret.ml +299 -0
- package/project/.sdk/tm/ocaml/feature/secrets/sekreto/sekreto.ml +347 -0
- package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +453 -0
- package/project/.sdk/tm/ocaml/src/feature/secrets/.gitkeep +0 -0
- package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +670 -0
- package/project/.sdk/tm/perl/feature/secrets_feature.pm +33 -12
- package/project/.sdk/tm/perl/t/feature/secrets/secrets.t +47 -0
- package/project/.sdk/tm/php/feature/SecretsFeature.php +30 -6
- package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +98 -0
- package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +28 -6
- package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +114 -0
- package/project/.sdk/tm/rb/feature/secrets_feature.rb +28 -6
- package/project/.sdk/tm/rb/test/feature/secrets/secrets_feature_test.rb +93 -0
- package/project/.sdk/tm/rust/feature/secrets.rs +33 -10
- package/project/.sdk/tm/rust/tests/feature/secrets/main.rs +96 -0
- package/project/.sdk/tm/scala/feature/SecretsFeature.scala +29 -7
- package/project/.sdk/tm/scala/sdktest/feature/secrets/SecretsTestMain.scala +71 -0
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +35 -12
- package/project/.sdk/tm/ts/test/feature/secrets/Secrets.test.ts +73 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/capability.zig +137 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/catalog.zig +90 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/config.zig +346 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/depend.zig +244 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/env.zig +201 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/export.zig +83 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/graph.zig +212 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/host.zig +1224 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/inst.zig +126 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/order.zig +228 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/plugin.zig +34 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/point.zig +166 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/ref.zig +147 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/resolve.zig +74 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/types.zig +140 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/value.zig +662 -0
- package/project/.sdk/tm/zig/feature/secrets/plugin/version.zig +139 -0
- package/project/.sdk/tm/zig/feature/secrets/plugins/aws.zig +294 -0
- package/project/.sdk/tm/zig/feature/secrets/plugins/azuresecrets.zig +222 -0
- package/project/.sdk/tm/zig/feature/secrets/plugins/boru.zig +188 -0
- package/project/.sdk/tm/zig/feature/secrets/plugins/doppler.zig +135 -0
- package/project/.sdk/tm/zig/feature/secrets/plugins/gcpsecrets.zig +170 -0
- package/project/.sdk/tm/zig/feature/secrets/plugins/hashicorp.zig +242 -0
- package/project/.sdk/tm/zig/feature/secrets/plugins/httpjson.zig +535 -0
- package/project/.sdk/tm/zig/feature/secrets/plugins/infisical.zig +167 -0
- package/project/.sdk/tm/zig/feature/secrets/plugins/onepassword.zig +202 -0
- package/project/.sdk/tm/zig/feature/secrets/plugins/secretspec.zig +160 -0
- package/project/.sdk/tm/zig/feature/secrets/plugins/sigv4.zig +336 -0
- package/project/.sdk/tm/zig/feature/secrets/sekreto/addr.zig +148 -0
- package/project/.sdk/tm/zig/feature/secrets/sekreto/builtins.zig +259 -0
- package/project/.sdk/tm/zig/feature/secrets/sekreto/provider.zig +440 -0
- package/project/.sdk/tm/zig/feature/secrets/sekreto/sekreto.zig +944 -0
- package/project/.sdk/tm/zig/feature/secrets.zig +854 -0
- package/project/.sdk/tm/zig/src/feature/secrets/.gitkeep +0 -0
- package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +891 -0
- package/project/sdkgen-package.json +1 -1
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
// VENDORED: @voxgig/sekreto sdk-20260908-1556-0 (c/src/json.c)
|
|
2
|
+
// Source: https://github.com/voxgig/sekreto @ 1267ee2e5f49566bc92695bc9eb3a60ef4924998 [tag: sdk-20260908-1556-0]
|
|
3
|
+
// License: MIT (c) voxgig - see repository LICENSE. Do not edit: resync from upstream.
|
|
4
|
+
/* sekreto's own JSON.
|
|
5
|
+
*
|
|
6
|
+
* There is no JSON in the C standard library and there is no third-party
|
|
7
|
+
* dependency to reach for, so this is the whole of it: a six-case value
|
|
8
|
+
* model, a recursive-descent parser, and a compact writer.
|
|
9
|
+
*
|
|
10
|
+
* Two properties are load-bearing and neither is incidental.
|
|
11
|
+
*
|
|
12
|
+
* A PARSE FAILURE IS NOT `null`. sek_json_parse answers NULL for text
|
|
13
|
+
* that is not JSON and a SEK_JSON_NULL node for the literal `null`;
|
|
14
|
+
* fetchjson needs exactly that difference, because only the first means
|
|
15
|
+
* the store could not answer coherently.
|
|
16
|
+
*
|
|
17
|
+
* OBJECTS ARE INSERTION-ORDERED. A payload's field order is signed by
|
|
18
|
+
* SigV4, and the shared spec compares whole maps, so a re-ordering
|
|
19
|
+
* container would fail both.
|
|
20
|
+
*
|
|
21
|
+
* A port of typescript/src/Json.ts, which is canonical.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#define _POSIX_C_SOURCE 200809L
|
|
25
|
+
|
|
26
|
+
#include <math.h>
|
|
27
|
+
#include <stdarg.h>
|
|
28
|
+
#include <stdio.h>
|
|
29
|
+
#include <stdlib.h>
|
|
30
|
+
#include <string.h>
|
|
31
|
+
|
|
32
|
+
#include "internal.h"
|
|
33
|
+
|
|
34
|
+
/* A response body arrives before any trust check has been made, so
|
|
35
|
+
* `[[[[[...` must not be able to overflow the stack. */
|
|
36
|
+
#define MAXDEPTH 128
|
|
37
|
+
|
|
38
|
+
sek_json *sek_json_null(sek_pool *pool) {
|
|
39
|
+
sek_json *val = (sek_json *)sek_alloc(pool, sizeof(sek_json));
|
|
40
|
+
val->type = SEK_JSON_NULL;
|
|
41
|
+
return val;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
sek_json *sek_json_bool(sek_pool *pool, int flag) {
|
|
45
|
+
sek_json *val = (sek_json *)sek_alloc(pool, sizeof(sek_json));
|
|
46
|
+
val->type = SEK_JSON_BOOL;
|
|
47
|
+
val->boolval = 0 != flag;
|
|
48
|
+
return val;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
sek_json *sek_json_num(sek_pool *pool, double num) {
|
|
52
|
+
sek_json *val = (sek_json *)sek_alloc(pool, sizeof(sek_json));
|
|
53
|
+
val->type = SEK_JSON_NUM;
|
|
54
|
+
val->numval = num;
|
|
55
|
+
return val;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
sek_json *sek_json_str(sek_pool *pool, const char *text) {
|
|
59
|
+
sek_json *val = (sek_json *)sek_alloc(pool, sizeof(sek_json));
|
|
60
|
+
val->type = SEK_JSON_STR;
|
|
61
|
+
val->strval = sek_strdup(pool, NULL == text ? "" : text);
|
|
62
|
+
return val;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
sek_json *sek_json_arr(sek_pool *pool) {
|
|
66
|
+
sek_json *val = (sek_json *)sek_alloc(pool, sizeof(sek_json));
|
|
67
|
+
val->type = SEK_JSON_ARR;
|
|
68
|
+
val->itemcap = 8;
|
|
69
|
+
val->items = (sek_json **)sek_alloc(pool, val->itemcap * sizeof(sek_json *));
|
|
70
|
+
return val;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
sek_json *sek_json_obj(sek_pool *pool) {
|
|
74
|
+
sek_json *val = (sek_json *)sek_alloc(pool, sizeof(sek_json));
|
|
75
|
+
val->type = SEK_JSON_OBJ;
|
|
76
|
+
val->mapcap = 8;
|
|
77
|
+
val->keys = (char **)sek_alloc(pool, val->mapcap * sizeof(char *));
|
|
78
|
+
val->vals = (sek_json **)sek_alloc(pool, val->mapcap * sizeof(sek_json *));
|
|
79
|
+
return val;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* The pool a node was made from is not recorded on the node, so growth
|
|
83
|
+
* needs one handed in; every call site has it. */
|
|
84
|
+
static void pushitem(sek_pool *pool, sek_json *arr, sek_json *item) {
|
|
85
|
+
if (arr->itemlen == arr->itemcap) {
|
|
86
|
+
size_t cap = arr->itemcap * 2;
|
|
87
|
+
sek_json **items = (sek_json **)sek_alloc(pool, cap * sizeof(sek_json *));
|
|
88
|
+
memcpy(items, arr->items, arr->itemlen * sizeof(sek_json *));
|
|
89
|
+
arr->items = items;
|
|
90
|
+
arr->itemcap = cap;
|
|
91
|
+
}
|
|
92
|
+
arr->items[arr->itemlen] = item;
|
|
93
|
+
arr->itemlen++;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static void setkey(sek_pool *pool, sek_json *obj, const char *key, sek_json *val) {
|
|
97
|
+
size_t index;
|
|
98
|
+
|
|
99
|
+
for (index = 0; index < obj->maplen; index++) {
|
|
100
|
+
if (0 == strcmp(obj->keys[index], key)) {
|
|
101
|
+
obj->vals[index] = val;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (obj->maplen == obj->mapcap) {
|
|
107
|
+
size_t cap = obj->mapcap * 2;
|
|
108
|
+
char **keys = (char **)sek_alloc(pool, cap * sizeof(char *));
|
|
109
|
+
sek_json **vals = (sek_json **)sek_alloc(pool, cap * sizeof(sek_json *));
|
|
110
|
+
memcpy(keys, obj->keys, obj->maplen * sizeof(char *));
|
|
111
|
+
memcpy(vals, obj->vals, obj->maplen * sizeof(sek_json *));
|
|
112
|
+
obj->keys = keys;
|
|
113
|
+
obj->vals = vals;
|
|
114
|
+
obj->mapcap = cap;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
obj->keys[obj->maplen] = sek_strdup(pool, key);
|
|
118
|
+
obj->vals[obj->maplen] = val;
|
|
119
|
+
obj->maplen++;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* The pool is passed rather than stored on every node: a node is 100-odd
|
|
123
|
+
* bytes and there are a lot of them in a Doppler config download, and a
|
|
124
|
+
* hidden global would make two Sekretos in two threads share a pool they
|
|
125
|
+
* never agreed to share. */
|
|
126
|
+
void sek_json_push(sek_pool *pool, sek_json *arr, sek_json *item) {
|
|
127
|
+
pushitem(pool, arr, item);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
void sek_json_set(sek_pool *pool, sek_json *obj, const char *key, sek_json *val) {
|
|
131
|
+
setkey(pool, obj, key, val);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* ---- reads --------------------------------------------------------- */
|
|
135
|
+
|
|
136
|
+
const char *sek_json_asstr(const sek_json *val) {
|
|
137
|
+
if (NULL == val || SEK_JSON_STR != val->type) {
|
|
138
|
+
return NULL;
|
|
139
|
+
}
|
|
140
|
+
return val->strval;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const sek_json *sek_json_asarr(const sek_json *val) {
|
|
144
|
+
if (NULL == val || SEK_JSON_ARR != val->type) {
|
|
145
|
+
return NULL;
|
|
146
|
+
}
|
|
147
|
+
return val;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const sek_json *sek_json_asobj(const sek_json *val) {
|
|
151
|
+
if (NULL == val || SEK_JSON_OBJ != val->type) {
|
|
152
|
+
return NULL;
|
|
153
|
+
}
|
|
154
|
+
return val;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
static sek_json *getkey(const sek_json *obj, const char *key) {
|
|
158
|
+
size_t index;
|
|
159
|
+
|
|
160
|
+
if (NULL == obj || SEK_JSON_OBJ != obj->type) {
|
|
161
|
+
return NULL;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
for (index = 0; index < obj->maplen; index++) {
|
|
165
|
+
if (0 == strcmp(obj->keys[index], key)) {
|
|
166
|
+
return obj->vals[index];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return NULL;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
sek_json *sek_json_dig(sek_json *val, ...) {
|
|
174
|
+
va_list keys;
|
|
175
|
+
sek_json *at = val;
|
|
176
|
+
|
|
177
|
+
va_start(keys, val);
|
|
178
|
+
|
|
179
|
+
for (;;) {
|
|
180
|
+
const char *key = va_arg(keys, const char *);
|
|
181
|
+
if (NULL == key) {
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
at = getkey(at, key);
|
|
185
|
+
if (NULL == at) {
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
va_end(keys);
|
|
191
|
+
|
|
192
|
+
return at;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const char *sek_json_text(sek_pool *pool, const sek_json *val) {
|
|
196
|
+
if (NULL == val) {
|
|
197
|
+
return NULL;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
switch (val->type) {
|
|
201
|
+
case SEK_JSON_STR:
|
|
202
|
+
return val->strval;
|
|
203
|
+
case SEK_JSON_NUM:
|
|
204
|
+
return sek_numstr(pool, val->numval);
|
|
205
|
+
case SEK_JSON_BOOL:
|
|
206
|
+
return val->boolval ? "true" : "false";
|
|
207
|
+
/* A JSON null is the absence of a value, so it must not become the
|
|
208
|
+
* string "null" - a null field in a vault response is a MISS. */
|
|
209
|
+
case SEK_JSON_NULL:
|
|
210
|
+
default:
|
|
211
|
+
return NULL;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* ---- numbers ------------------------------------------------------- */
|
|
216
|
+
|
|
217
|
+
char *sek_numstr(sek_pool *pool, double val) {
|
|
218
|
+
char buf[64];
|
|
219
|
+
|
|
220
|
+
/* JSON has no infinity and no NaN; a non-finite value can only have
|
|
221
|
+
* come from arithmetic this library should not have done. */
|
|
222
|
+
if (isnan(val) || isinf(val)) {
|
|
223
|
+
return sek_strdup(pool, "null");
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* An integral value prints as an integer, so a JSON `1` round-trips as
|
|
227
|
+
* `1` rather than `1.0` - the CLI's output line and the spec's map
|
|
228
|
+
* comparisons both depend on it. */
|
|
229
|
+
if (val == (double)(long long)val && 9007199254740992.0 > (val < 0 ? -val : val)) {
|
|
230
|
+
snprintf(buf, sizeof(buf), "%lld", (long long)val);
|
|
231
|
+
return sek_strdup(pool, buf);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
snprintf(buf, sizeof(buf), "%.17g", val);
|
|
235
|
+
return sek_strdup(pool, buf);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* ---- writer -------------------------------------------------------- */
|
|
239
|
+
|
|
240
|
+
char *sek_json_quote(sek_pool *pool, const char *text) {
|
|
241
|
+
sek_buf out;
|
|
242
|
+
size_t index;
|
|
243
|
+
|
|
244
|
+
sek_buf_init(&out, pool);
|
|
245
|
+
sek_buf_addch(&out, '"');
|
|
246
|
+
|
|
247
|
+
for (index = 0; NULL != text && '\0' != text[index]; index++) {
|
|
248
|
+
unsigned char ch = (unsigned char)text[index];
|
|
249
|
+
|
|
250
|
+
switch (ch) {
|
|
251
|
+
case '"':
|
|
252
|
+
sek_buf_add(&out, "\\\"");
|
|
253
|
+
break;
|
|
254
|
+
case '\\':
|
|
255
|
+
sek_buf_add(&out, "\\\\");
|
|
256
|
+
break;
|
|
257
|
+
case '\n':
|
|
258
|
+
sek_buf_add(&out, "\\n");
|
|
259
|
+
break;
|
|
260
|
+
case '\r':
|
|
261
|
+
sek_buf_add(&out, "\\r");
|
|
262
|
+
break;
|
|
263
|
+
case '\t':
|
|
264
|
+
sek_buf_add(&out, "\\t");
|
|
265
|
+
break;
|
|
266
|
+
default:
|
|
267
|
+
if (0x20 > ch) {
|
|
268
|
+
sek_buf_addfmt(&out, "\\u%04x", (unsigned)ch);
|
|
269
|
+
} else {
|
|
270
|
+
/* Non-ASCII is not escaped: the bytes are already UTF-8 and
|
|
271
|
+
* escaping them would need surrogate arithmetic no port does. */
|
|
272
|
+
sek_buf_addch(&out, (char)ch);
|
|
273
|
+
}
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
sek_buf_addch(&out, '"');
|
|
279
|
+
|
|
280
|
+
return out.data;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
static void writeval(sek_buf *out, const sek_json *val) {
|
|
284
|
+
size_t index;
|
|
285
|
+
|
|
286
|
+
if (NULL == val) {
|
|
287
|
+
sek_buf_add(out, "null");
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
switch (val->type) {
|
|
292
|
+
case SEK_JSON_NULL:
|
|
293
|
+
sek_buf_add(out, "null");
|
|
294
|
+
break;
|
|
295
|
+
case SEK_JSON_BOOL:
|
|
296
|
+
sek_buf_add(out, val->boolval ? "true" : "false");
|
|
297
|
+
break;
|
|
298
|
+
case SEK_JSON_NUM:
|
|
299
|
+
sek_buf_add(out, sek_numstr(out->pool, val->numval));
|
|
300
|
+
break;
|
|
301
|
+
case SEK_JSON_STR:
|
|
302
|
+
sek_buf_add(out, sek_json_quote(out->pool, val->strval));
|
|
303
|
+
break;
|
|
304
|
+
case SEK_JSON_ARR:
|
|
305
|
+
sek_buf_addch(out, '[');
|
|
306
|
+
for (index = 0; index < val->itemlen; index++) {
|
|
307
|
+
if (0 < index) {
|
|
308
|
+
sek_buf_addch(out, ',');
|
|
309
|
+
}
|
|
310
|
+
writeval(out, val->items[index]);
|
|
311
|
+
}
|
|
312
|
+
sek_buf_addch(out, ']');
|
|
313
|
+
break;
|
|
314
|
+
case SEK_JSON_OBJ:
|
|
315
|
+
sek_buf_addch(out, '{');
|
|
316
|
+
for (index = 0; index < val->maplen; index++) {
|
|
317
|
+
if (0 < index) {
|
|
318
|
+
sek_buf_addch(out, ',');
|
|
319
|
+
}
|
|
320
|
+
sek_buf_add(out, sek_json_quote(out->pool, val->keys[index]));
|
|
321
|
+
sek_buf_addch(out, ':');
|
|
322
|
+
writeval(out, val->vals[index]);
|
|
323
|
+
}
|
|
324
|
+
sek_buf_addch(out, '}');
|
|
325
|
+
break;
|
|
326
|
+
default:
|
|
327
|
+
sek_buf_add(out, "null");
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
char *sek_json_stringify(sek_pool *pool, const sek_json *val) {
|
|
333
|
+
sek_buf out;
|
|
334
|
+
sek_buf_init(&out, pool);
|
|
335
|
+
writeval(&out, val);
|
|
336
|
+
return out.data;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/* ---- parser -------------------------------------------------------- */
|
|
340
|
+
|
|
341
|
+
typedef struct {
|
|
342
|
+
sek_pool *pool;
|
|
343
|
+
const char *text;
|
|
344
|
+
size_t len;
|
|
345
|
+
size_t at;
|
|
346
|
+
int bad;
|
|
347
|
+
int depth;
|
|
348
|
+
} reader;
|
|
349
|
+
|
|
350
|
+
static sek_json *readvalue(reader *rd);
|
|
351
|
+
|
|
352
|
+
static void skipspace(reader *rd) {
|
|
353
|
+
while (rd->at < rd->len) {
|
|
354
|
+
char ch = rd->text[rd->at];
|
|
355
|
+
if (' ' == ch || '\t' == ch || '\n' == ch || '\r' == ch) {
|
|
356
|
+
rd->at++;
|
|
357
|
+
} else {
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/* A word matched WHOLE, not by its first letter: `nullish` is not null. */
|
|
364
|
+
static int readword(reader *rd, const char *word) {
|
|
365
|
+
size_t len = strlen(word);
|
|
366
|
+
|
|
367
|
+
if (rd->len - rd->at < len) {
|
|
368
|
+
return 0;
|
|
369
|
+
}
|
|
370
|
+
if (0 != strncmp(rd->text + rd->at, word, len)) {
|
|
371
|
+
return 0;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
rd->at += len;
|
|
375
|
+
return 1;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/* One UTF-16 code unit as UTF-8. No surrogate-pair recombination, in this
|
|
379
|
+
* port or any other: a lone surrogate is written as-is, which keeps every
|
|
380
|
+
* port byte-identical on an input none of them should ever see. */
|
|
381
|
+
static void addunit(sek_buf *out, unsigned code) {
|
|
382
|
+
if (0x80 > code) {
|
|
383
|
+
sek_buf_addch(out, (char)code);
|
|
384
|
+
} else if (0x800 > code) {
|
|
385
|
+
sek_buf_addch(out, (char)(0xC0 | (code >> 6)));
|
|
386
|
+
sek_buf_addch(out, (char)(0x80 | (code & 0x3F)));
|
|
387
|
+
} else {
|
|
388
|
+
sek_buf_addch(out, (char)(0xE0 | (code >> 12)));
|
|
389
|
+
sek_buf_addch(out, (char)(0x80 | ((code >> 6) & 0x3F)));
|
|
390
|
+
sek_buf_addch(out, (char)(0x80 | (code & 0x3F)));
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
static int hexdigit(char ch) {
|
|
395
|
+
if ('0' <= ch && '9' >= ch) {
|
|
396
|
+
return ch - '0';
|
|
397
|
+
}
|
|
398
|
+
if ('a' <= ch && 'f' >= ch) {
|
|
399
|
+
return ch - 'a' + 10;
|
|
400
|
+
}
|
|
401
|
+
if ('A' <= ch && 'F' >= ch) {
|
|
402
|
+
return ch - 'A' + 10;
|
|
403
|
+
}
|
|
404
|
+
return -1;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
static char *readstring(reader *rd) {
|
|
408
|
+
sek_buf out;
|
|
409
|
+
|
|
410
|
+
if (rd->at >= rd->len || '"' != rd->text[rd->at]) {
|
|
411
|
+
rd->bad = 1;
|
|
412
|
+
return NULL;
|
|
413
|
+
}
|
|
414
|
+
rd->at++;
|
|
415
|
+
|
|
416
|
+
sek_buf_init(&out, rd->pool);
|
|
417
|
+
|
|
418
|
+
while (rd->at < rd->len) {
|
|
419
|
+
char ch = rd->text[rd->at];
|
|
420
|
+
|
|
421
|
+
if ('"' == ch) {
|
|
422
|
+
rd->at++;
|
|
423
|
+
return out.data;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if ('\\' == ch) {
|
|
427
|
+
rd->at++;
|
|
428
|
+
if (rd->at >= rd->len) {
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
ch = rd->text[rd->at];
|
|
432
|
+
rd->at++;
|
|
433
|
+
|
|
434
|
+
switch (ch) {
|
|
435
|
+
case '"':
|
|
436
|
+
sek_buf_addch(&out, '"');
|
|
437
|
+
break;
|
|
438
|
+
case '\\':
|
|
439
|
+
sek_buf_addch(&out, '\\');
|
|
440
|
+
break;
|
|
441
|
+
case '/':
|
|
442
|
+
sek_buf_addch(&out, '/');
|
|
443
|
+
break;
|
|
444
|
+
case 'b':
|
|
445
|
+
sek_buf_addch(&out, '\b');
|
|
446
|
+
break;
|
|
447
|
+
case 'f':
|
|
448
|
+
sek_buf_addch(&out, '\f');
|
|
449
|
+
break;
|
|
450
|
+
case 'n':
|
|
451
|
+
sek_buf_addch(&out, '\n');
|
|
452
|
+
break;
|
|
453
|
+
case 'r':
|
|
454
|
+
sek_buf_addch(&out, '\r');
|
|
455
|
+
break;
|
|
456
|
+
case 't':
|
|
457
|
+
sek_buf_addch(&out, '\t');
|
|
458
|
+
break;
|
|
459
|
+
case 'u': {
|
|
460
|
+
unsigned code = 0;
|
|
461
|
+
int step;
|
|
462
|
+
if (rd->len - rd->at < 4) {
|
|
463
|
+
rd->bad = 1;
|
|
464
|
+
return NULL;
|
|
465
|
+
}
|
|
466
|
+
for (step = 0; step < 4; step++) {
|
|
467
|
+
int digit = hexdigit(rd->text[rd->at + (size_t)step]);
|
|
468
|
+
if (0 > digit) {
|
|
469
|
+
rd->bad = 1;
|
|
470
|
+
return NULL;
|
|
471
|
+
}
|
|
472
|
+
code = (code << 4) | (unsigned)digit;
|
|
473
|
+
}
|
|
474
|
+
rd->at += 4;
|
|
475
|
+
addunit(&out, code);
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
default:
|
|
479
|
+
rd->bad = 1;
|
|
480
|
+
return NULL;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
sek_buf_addch(&out, ch);
|
|
487
|
+
rd->at++;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
rd->bad = 1;
|
|
491
|
+
return NULL;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
static sek_json *readnumber(reader *rd) {
|
|
495
|
+
size_t start = rd->at;
|
|
496
|
+
char *span;
|
|
497
|
+
char *stop = NULL;
|
|
498
|
+
double num;
|
|
499
|
+
|
|
500
|
+
if (rd->at < rd->len && '-' == rd->text[rd->at]) {
|
|
501
|
+
rd->at++;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
while (rd->at < rd->len) {
|
|
505
|
+
char ch = rd->text[rd->at];
|
|
506
|
+
if (('0' <= ch && '9' >= ch) || '.' == ch || 'e' == ch || 'E' == ch || '+' == ch ||
|
|
507
|
+
'-' == ch) {
|
|
508
|
+
rd->at++;
|
|
509
|
+
} else {
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (start == rd->at) {
|
|
515
|
+
rd->bad = 1;
|
|
516
|
+
return NULL;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
span = sek_strndup(rd->pool, rd->text + start, rd->at - start);
|
|
520
|
+
num = strtod(span, &stop);
|
|
521
|
+
|
|
522
|
+
if (NULL == stop || '\0' != *stop) {
|
|
523
|
+
rd->bad = 1;
|
|
524
|
+
return NULL;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/* `1e999` parses to infinity, which JSON cannot express and which would
|
|
528
|
+
* later blow up a token-expiry computation. */
|
|
529
|
+
if (isnan(num) || isinf(num)) {
|
|
530
|
+
rd->bad = 1;
|
|
531
|
+
return NULL;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
return sek_json_num(rd->pool, num);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
static sek_json *readarray(reader *rd) {
|
|
538
|
+
sek_json *out = sek_json_arr(rd->pool);
|
|
539
|
+
|
|
540
|
+
rd->at++; /* [ */
|
|
541
|
+
skipspace(rd);
|
|
542
|
+
|
|
543
|
+
if (rd->at < rd->len && ']' == rd->text[rd->at]) {
|
|
544
|
+
rd->at++;
|
|
545
|
+
return out;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
for (;;) {
|
|
549
|
+
sek_json *item = readvalue(rd);
|
|
550
|
+
if (rd->bad) {
|
|
551
|
+
return NULL;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
pushitem(rd->pool, out, item);
|
|
555
|
+
skipspace(rd);
|
|
556
|
+
|
|
557
|
+
if (rd->at >= rd->len) {
|
|
558
|
+
rd->bad = 1;
|
|
559
|
+
return NULL;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
if (',' == rd->text[rd->at]) {
|
|
563
|
+
rd->at++;
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (']' == rd->text[rd->at]) {
|
|
568
|
+
rd->at++;
|
|
569
|
+
return out;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
rd->bad = 1;
|
|
573
|
+
return NULL;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
static sek_json *readobject(reader *rd) {
|
|
578
|
+
sek_json *out = sek_json_obj(rd->pool);
|
|
579
|
+
|
|
580
|
+
rd->at++; /* { */
|
|
581
|
+
skipspace(rd);
|
|
582
|
+
|
|
583
|
+
if (rd->at < rd->len && '}' == rd->text[rd->at]) {
|
|
584
|
+
rd->at++;
|
|
585
|
+
return out;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
for (;;) {
|
|
589
|
+
char *key;
|
|
590
|
+
sek_json *val;
|
|
591
|
+
|
|
592
|
+
skipspace(rd);
|
|
593
|
+
key = readstring(rd);
|
|
594
|
+
if (rd->bad) {
|
|
595
|
+
return NULL;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
skipspace(rd);
|
|
599
|
+
if (rd->at >= rd->len || ':' != rd->text[rd->at]) {
|
|
600
|
+
rd->bad = 1;
|
|
601
|
+
return NULL;
|
|
602
|
+
}
|
|
603
|
+
rd->at++;
|
|
604
|
+
|
|
605
|
+
val = readvalue(rd);
|
|
606
|
+
if (rd->bad) {
|
|
607
|
+
return NULL;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
setkey(rd->pool, out, key, val);
|
|
611
|
+
skipspace(rd);
|
|
612
|
+
|
|
613
|
+
if (rd->at >= rd->len) {
|
|
614
|
+
rd->bad = 1;
|
|
615
|
+
return NULL;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
if (',' == rd->text[rd->at]) {
|
|
619
|
+
rd->at++;
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
if ('}' == rd->text[rd->at]) {
|
|
624
|
+
rd->at++;
|
|
625
|
+
return out;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
rd->bad = 1;
|
|
629
|
+
return NULL;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
static sek_json *readvalue(reader *rd) {
|
|
634
|
+
char head;
|
|
635
|
+
|
|
636
|
+
if (MAXDEPTH < rd->depth) {
|
|
637
|
+
rd->bad = 1;
|
|
638
|
+
return NULL;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
skipspace(rd);
|
|
642
|
+
|
|
643
|
+
if (rd->at >= rd->len) {
|
|
644
|
+
rd->bad = 1;
|
|
645
|
+
return NULL;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
head = rd->text[rd->at];
|
|
649
|
+
|
|
650
|
+
if ('{' == head || '[' == head) {
|
|
651
|
+
sek_json *out;
|
|
652
|
+
rd->depth++;
|
|
653
|
+
out = '{' == head ? readobject(rd) : readarray(rd);
|
|
654
|
+
rd->depth--;
|
|
655
|
+
return out;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
if ('"' == head) {
|
|
659
|
+
char *text = readstring(rd);
|
|
660
|
+
if (rd->bad) {
|
|
661
|
+
return NULL;
|
|
662
|
+
}
|
|
663
|
+
return sek_json_str(rd->pool, text);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
if ('t' == head) {
|
|
667
|
+
if (readword(rd, "true")) {
|
|
668
|
+
return sek_json_bool(rd->pool, 1);
|
|
669
|
+
}
|
|
670
|
+
rd->bad = 1;
|
|
671
|
+
return NULL;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if ('f' == head) {
|
|
675
|
+
if (readword(rd, "false")) {
|
|
676
|
+
return sek_json_bool(rd->pool, 0);
|
|
677
|
+
}
|
|
678
|
+
rd->bad = 1;
|
|
679
|
+
return NULL;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
if ('n' == head) {
|
|
683
|
+
if (readword(rd, "null")) {
|
|
684
|
+
return sek_json_null(rd->pool);
|
|
685
|
+
}
|
|
686
|
+
rd->bad = 1;
|
|
687
|
+
return NULL;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
return readnumber(rd);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
sek_json *sek_json_parse(sek_pool *pool, const char *text) {
|
|
694
|
+
reader rd;
|
|
695
|
+
sek_json *out;
|
|
696
|
+
|
|
697
|
+
if (NULL == text) {
|
|
698
|
+
return NULL;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
rd.pool = pool;
|
|
702
|
+
rd.text = text;
|
|
703
|
+
rd.len = strlen(text);
|
|
704
|
+
rd.at = 0;
|
|
705
|
+
rd.bad = 0;
|
|
706
|
+
rd.depth = 0;
|
|
707
|
+
|
|
708
|
+
out = readvalue(&rd);
|
|
709
|
+
|
|
710
|
+
if (rd.bad) {
|
|
711
|
+
return NULL;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/* Trailing content after the top-level value is not JSON. */
|
|
715
|
+
skipspace(&rd);
|
|
716
|
+
if (rd.at != rd.len) {
|
|
717
|
+
return NULL;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
return out;
|
|
721
|
+
}
|