@distrohelena/canton-typescript-sdk 0.1.19 → 0.1.21

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.
@@ -107,6 +107,14 @@ resolve_tls_enabled() {
107
107
  printf '%s\n' "$value"
108
108
  }
109
109
 
110
+ localnet_http_scheme() {
111
+ if [[ "$(resolve_tls_enabled)" == "1" ]]; then
112
+ printf 'https\n'
113
+ else
114
+ printf 'http\n'
115
+ fi
116
+ }
117
+
110
118
  resolve_tls_rotate() {
111
119
  local value="${LOCALNET_TLS_ROTATE:-0}"
112
120
  if [[ "$value" != "0" && "$value" != "1" ]]; then
@@ -136,6 +144,8 @@ prepare_tls_runtime_files() {
136
144
  local compose_file="$runtime_dir/compose-localnet.yaml"
137
145
  local tls_fragment_file="$runtime_dir/canton-tls.conf"
138
146
  local canton_config_file="$runtime_dir/canton-localnet.conf"
147
+ local onboarding_utils_source="$MODULES_DIR/splice-onboarding/docker/utils.sh"
148
+ local onboarding_utils_file="$runtime_dir/splice-onboarding-utils.sh"
139
149
  local supplied_count=0
140
150
 
141
151
  [[ -n "${LOCALNET_TLS_CERT_CHAIN_PATH:-}" ]] && ((supplied_count += 1))
@@ -207,6 +217,15 @@ EOF
207
217
  fi
208
218
  fi
209
219
 
220
+ if [[ ! -r "$onboarding_utils_source" ]]; then
221
+ echo "Unable to read Splice onboarding utilities at $onboarding_utils_source." >&2
222
+ return 1
223
+ fi
224
+ sed \
225
+ -e 's#http://\$participant#${LOCALNET_HTTP_SCHEME:-http}://$participant#g' \
226
+ -e 's#http://\$validator#${LOCALNET_HTTP_SCHEME:-http}://$validator#g' \
227
+ "$onboarding_utils_source" > "$onboarding_utils_file"
228
+
210
229
  : > "$tls_fragment_file"
211
230
  local participant profile
212
231
  for participant in app-provider app-user sv; do
@@ -244,6 +263,69 @@ services:
244
263
  - "$server_certificate_path:/app/localnet-tls/server.crt:ro"
245
264
  - "$server_key_path:/app/localnet-tls/server.key:ro"
246
265
  - "$ca_certificate_path:/app/localnet-tls/ca.crt:ro"
266
+ splice:
267
+ volumes:
268
+ - "$ca_certificate_path:/app/localnet-tls/ca.crt:ro"
269
+ environment:
270
+ - |
271
+ ADDITIONAL_CONFIG_LOCALNET_TLS=
272
+ splice-onboarding:
273
+ volumes:
274
+ - "$ca_certificate_path:/app/localnet-tls/ca.crt:ro"
275
+ - "$onboarding_utils_file:/app/utils.sh:ro"
276
+ environment:
277
+ - LOCALNET_HTTP_SCHEME=https
278
+ - CURL_CA_BUNDLE=/app/localnet-tls/ca.crt
279
+ EOF
280
+ for participant in app-provider app-user sv; do
281
+ case "$participant" in
282
+ app-provider) profile="$APP_PROVIDER_PROFILE" ;;
283
+ app-user) profile="$APP_USER_PROFILE" ;;
284
+ sv) profile="$SV_PROFILE" ;;
285
+ esac
286
+ if [[ "$profile" == "off" ]]; then
287
+ continue
288
+ fi
289
+ if [[ "$participant" == "sv" ]]; then
290
+ cat >> "$compose_file" <<'EOF'
291
+ canton.validator-apps.sv-validator_backend.participant-client {
292
+ admin-api.tls.trust-collection-file = "/app/localnet-tls/ca.crt"
293
+ ledger-api.client-config.tls.trust-collection-file = "/app/localnet-tls/ca.crt"
294
+ }
295
+ canton.scan-apps.scan-app.participant-client {
296
+ admin-api.tls.trust-collection-file = "/app/localnet-tls/ca.crt"
297
+ ledger-api.client-config.tls.trust-collection-file = "/app/localnet-tls/ca.crt"
298
+ }
299
+ canton.sv-apps.sv.participant-client {
300
+ admin-api.tls.trust-collection-file = "/app/localnet-tls/ca.crt"
301
+ ledger-api.client-config.tls.trust-collection-file = "/app/localnet-tls/ca.crt"
302
+ }
303
+ EOF
304
+ else
305
+ cat >> "$compose_file" <<EOF
306
+ canton.validator-apps.${participant}-validator_backend.participant-client {
307
+ admin-api.tls.trust-collection-file = "/app/localnet-tls/ca.crt"
308
+ ledger-api.client-config.tls.trust-collection-file = "/app/localnet-tls/ca.crt"
309
+ }
310
+ EOF
311
+ fi
312
+ done
313
+ cat >> "$compose_file" <<EOF
314
+ pqs-app-provider:
315
+ environment:
316
+ SCRIBE_SOURCE_LEDGER_TLS_CAFILE: /app/localnet-tls/ca.crt
317
+ volumes:
318
+ - "$ca_certificate_path:/app/localnet-tls/ca.crt:ro"
319
+ pqs-app-user:
320
+ environment:
321
+ SCRIBE_SOURCE_LEDGER_TLS_CAFILE: /app/localnet-tls/ca.crt
322
+ volumes:
323
+ - "$ca_certificate_path:/app/localnet-tls/ca.crt:ro"
324
+ pqs-sv:
325
+ environment:
326
+ SCRIBE_SOURCE_LEDGER_TLS_CAFILE: /app/localnet-tls/ca.crt
327
+ volumes:
328
+ - "$ca_certificate_path:/app/localnet-tls/ca.crt:ro"
247
329
  EOF
248
330
  export LOCALNET_TLS_COMPOSE_FILE="$compose_file"
249
331
  export LOCALNET_TLS_FRAGMENT_FILE="$tls_fragment_file"
@@ -642,6 +724,19 @@ EOF
642
724
  done
643
725
  } > "$splice_config_file"
644
726
 
727
+ if [[ "$(resolve_tls_enabled)" == "1" ]]; then
728
+ local index
729
+ for ((index = 1; index <= count; index++)); do
730
+ cat >> "$splice_config_file" <<EOF
731
+ canton.validator-apps.extra-${index}-validator_backend.participant-client {
732
+ admin-api.tls.trust-collection-file = "/app/localnet-tls/ca.crt"
733
+ ledger-api.client-config.tls.trust-collection-file = "/app/localnet-tls/ca.crt"
734
+ }
735
+
736
+ EOF
737
+ done
738
+ fi
739
+
645
740
  {
646
741
  cat <<'EOF'
647
742
  volumes:
@@ -731,8 +826,20 @@ EOF
731
826
  SCRIBE_TARGET_POSTGRES_USERNAME: \${DB_USER}
732
827
  SCRIBE_TARGET_POSTGRES_PASSWORD: \${DB_PASSWORD}
733
828
  SCRIBE_CONFIG: /onboarding/extra-${index}-pqs.conf
829
+ EOF
830
+ if [[ "$(resolve_tls_enabled)" == "1" ]]; then
831
+ cat <<'EOF'
832
+ SCRIBE_SOURCE_LEDGER_TLS_CAFILE: /app/localnet-tls/ca.crt
833
+ EOF
834
+ fi
835
+ cat <<EOF
734
836
  volumes:
735
837
  - onboarding:/onboarding
838
+ EOF
839
+ if [[ "$(resolve_tls_enabled)" == "1" ]]; then
840
+ printf ' - "%s:/app/localnet-tls/ca.crt:ro"\n' "${LOCALNET_TLS_CA_CERT_PATH}"
841
+ fi
842
+ cat <<'EOF'
736
843
  command:
737
844
  - pipeline
738
845
  - ledger
@@ -865,6 +972,7 @@ provision_extra_pqs() {
865
972
  -e EXTRA_PARTICIPANT_PARTY_HINT="extra_${index}_${PARTY_HINT_BASE}" \
866
973
  -e EXTRA_PQS_USER_NAME="${name}-pqs-user" \
867
974
  -e EXTRA_PQS_CONFIG_FILE="${name}-pqs.conf" \
975
+ -e LOCALNET_HTTP_SCHEME="$(localnet_http_scheme)" \
868
976
  splice-onboarding \
869
977
  bash -lc '
870
978
  set -euo pipefail
@@ -898,6 +1006,7 @@ grant_validator_read_as_any_party_right() {
898
1006
  -e VALIDATOR_USER_NAME="$validator_user_name" \
899
1007
  -e VALIDATOR_AUTH_AUDIENCE="$auth_audience" \
900
1008
  -e PARTICIPANT_JSON_API_PORT="$participant_json_port" \
1009
+ -e LOCALNET_HTTP_SCHEME="$(localnet_http_scheme)" \
901
1010
  splice-onboarding \
902
1011
  bash -lc '
903
1012
  set -euo pipefail
@@ -914,7 +1023,7 @@ payload="$(cat <<EOF
914
1023
  }
915
1024
  EOF
916
1025
  )"
917
- curl_check "http://$participant/v2/users/$VALIDATOR_USER_NAME/rights" "$validator_token" "application/json" \
1026
+ curl_check "${LOCALNET_HTTP_SCHEME:-http}://$participant/v2/users/$VALIDATOR_USER_NAME/rights" "$validator_token" "application/json" \
918
1027
  --data-raw "$payload" >/dev/null
919
1028
  '
920
1029
  }
@@ -928,6 +1037,7 @@ grant_user_read_as_any_party_right() {
928
1037
  -e TARGET_USER_NAME="$user_name" \
929
1038
  -e TARGET_AUTH_AUDIENCE="$auth_audience" \
930
1039
  -e PARTICIPANT_JSON_API_PORT="$participant_json_port" \
1040
+ -e LOCALNET_HTTP_SCHEME="$(localnet_http_scheme)" \
931
1041
  splice-onboarding \
932
1042
  bash -lc '
933
1043
  set -euo pipefail
@@ -944,7 +1054,7 @@ payload="$(cat <<EOF
944
1054
  }
945
1055
  EOF
946
1056
  )"
947
- curl_check "http://$participant/v2/users/$TARGET_USER_NAME/rights" "$admin_token" "application/json" \
1057
+ curl_check "${LOCALNET_HTTP_SCHEME:-http}://$participant/v2/users/$TARGET_USER_NAME/rights" "$admin_token" "application/json" \
948
1058
  --data-raw "$payload" >/dev/null
949
1059
  '
950
1060
  }
@@ -62,6 +62,13 @@ run_case() {
62
62
  : > "$quickstart_dir/docker/modules/pqs/compose.yaml"
63
63
  : > "$quickstart_dir/docker/modules/pqs/compose.env"
64
64
  : > "$quickstart_dir/docker/modules/splice-onboarding/compose.yaml"
65
+ printf '%s\n' \
66
+ 'curl_check "http://$participant/v2/users"' \
67
+ 'curl_check "http://$validator/api/validator/v0/scan-proxy/dso-party-id"' \
68
+ > "$quickstart_dir/docker/modules/splice-onboarding/docker-utils.sh"
69
+ mkdir -p "$quickstart_dir/docker/modules/splice-onboarding/docker"
70
+ mv "$quickstart_dir/docker/modules/splice-onboarding/docker-utils.sh" \
71
+ "$quickstart_dir/docker/modules/splice-onboarding/docker/utils.sh"
65
72
  : > "$quickstart_dir/docker/modules/keycloak/compose.yaml"
66
73
  : > "$quickstart_dir/docker/modules/keycloak/compose.env"
67
74
 
@@ -412,11 +419,27 @@ if grep -Fq 'canton.participants.app-user.ledger-api.tls {' "$tmpdir/tls/canton-
412
419
  fi
413
420
  assert_file_contains_text "$tmpdir/tls/compose-localnet.yaml" '/app/localnet-tls/server.key:ro'
414
421
  assert_file_contains_text "$tmpdir/tls/compose-localnet.yaml" '/app/localnet-tls/ca.crt:ro'
422
+ assert_file_contains_text "$tmpdir/tls/compose-localnet.yaml" 'ADDITIONAL_CONFIG_LOCALNET_TLS='
423
+ assert_file_contains_text "$tmpdir/tls/compose-localnet.yaml" 'LOCALNET_HTTP_SCHEME=https'
424
+ assert_file_contains_text "$tmpdir/tls/compose-localnet.yaml" 'CURL_CA_BUNDLE=/app/localnet-tls/ca.crt'
425
+ assert_file_contains_text "$tmpdir/tls/compose-localnet.yaml" "$tmpdir/tls/splice-onboarding-utils.sh:/app/utils.sh:ro"
426
+ assert_file_contains_text "$tmpdir/tls/compose-localnet.yaml" 'admin-api.tls.trust-collection-file = "/app/localnet-tls/ca.crt"'
427
+ assert_file_contains_text "$tmpdir/tls/compose-localnet.yaml" 'ledger-api.client-config.tls.trust-collection-file = "/app/localnet-tls/ca.crt"'
428
+ assert_file_contains_text "$tmpdir/tls/compose-localnet.yaml" 'SCRIBE_SOURCE_LEDGER_TLS_CAFILE: /app/localnet-tls/ca.crt'
429
+ assert_file_contains_text "$tmpdir/tls/splice-onboarding-utils.sh" '${LOCALNET_HTTP_SCHEME:-http}://$participant/v2/users'
430
+ assert_file_contains_text "$tmpdir/tls/splice-onboarding-utils.sh" '${LOCALNET_HTTP_SCHEME:-http}://$validator/api/validator/v0/scan-proxy/dso-party-id'
431
+ if grep -Fq 'canton.validator-apps.app-user-validator_backend.participant-client' "$tmpdir/tls/compose-localnet.yaml"; then
432
+ echo "unexpected client TLS configuration for inactive app-user participant" >&2
433
+ exit 1
434
+ fi
415
435
  assert_file_mode "$tmpdir/tls/server.key" 600
416
436
  assert_file_mode "$tmpdir/tls/ca.key" 600
417
437
  run_case $'.PHONY: start\nstart:\n' 'stub docker compose -f compose.yaml -f '"$tmpdir"'/quickstart/docker/modules/localnet/compose.yaml -f '"$tmpdir"'/quickstart/docker/modules/splice-onboarding/compose.yaml -f '"$tmpdir"'/quickstart/docker/modules/pqs/compose.yaml --env-file .env --env-file .env.local --env-file '"$tmpdir"'/quickstart/docker/modules/localnet/compose.env --env-file '"$tmpdir"'/quickstart/docker/modules/localnet/env/common.env --env-file '"$tmpdir"'/quickstart/docker/modules/pqs/compose.env --profile app-provider --profile pqs-app-provider --profile pqs-sv -f '"$tmpdir"'/generated/compose-extra-participants.yaml --env-file '"$tmpdir"'/generated/extra-participants.env -f '"$tmpdir"'/tls/compose-localnet.yaml down -v --remove-orphans' shared-secret default 2 '' '' 0 1
418
438
  assert_file_contains_text "$tmpdir/generated/additional-config.extra-participants.conf" 'canton.participants.extra-1.ledger-api.tls {'
419
439
  assert_file_contains_text "$tmpdir/generated/additional-config.extra-participants.conf" 'canton.participants.extra-2.admin-api.tls {'
440
+ assert_file_contains_text "$tmpdir/generated/additional-config.extra-validators.conf" 'canton.validator-apps.extra-1-validator_backend.participant-client {'
441
+ assert_file_contains_text "$tmpdir/generated/additional-config.extra-validators.conf" 'admin-api.tls.trust-collection-file = "/app/localnet-tls/ca.crt"'
442
+ assert_file_contains_text "$tmpdir/generated/compose-extra-participants.yaml" 'SCRIBE_SOURCE_LEDGER_TLS_CAFILE: /app/localnet-tls/ca.crt'
420
443
 
421
444
  mkdir -p "$tmpdir/supplied"
422
445
  openssl genrsa -out "$tmpdir/supplied/ca.key" 2048 >/dev/null 2>&1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distrohelena/canton-typescript-sdk",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",