@distrohelena/canton-typescript-sdk 0.1.52 → 0.1.53

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.
@@ -98,6 +98,19 @@ es256_runtime_dir() {
98
98
  printf '%s\n' "${START_LOCAL_ES256_RUNTIME_DIR:-$REPO_ROOT/.generated/localnet-es256}"
99
99
  }
100
100
 
101
+ resolve_no_auth_enabled() {
102
+ local value="${LOCALNET_NO_AUTH:-0}"
103
+ if [[ "$value" != "0" && "$value" != "1" ]]; then
104
+ echo "LOCALNET_NO_AUTH must be 0 or 1." >&2
105
+ return 1
106
+ fi
107
+ printf '%s\n' "$value"
108
+ }
109
+
110
+ no_auth_runtime_dir() {
111
+ printf '%s\n' "${START_LOCAL_NO_AUTH_RUNTIME_DIR:-$REPO_ROOT/.generated/localnet-no-auth}"
112
+ }
113
+
101
114
  resolve_tls_enabled() {
102
115
  local value="${LOCALNET_TLS:-0}"
103
116
  if [[ "$value" != "0" && "$value" != "1" ]]; then
@@ -447,6 +460,66 @@ EOF
447
460
  export LOCALNET_ES256_TOKEN_PATH="$token_path"
448
461
  }
449
462
 
463
+ prepare_no_auth_runtime_files() {
464
+ if [[ "$(resolve_no_auth_enabled)" != "1" ]]; then
465
+ return 0
466
+ fi
467
+
468
+ local runtime_dir
469
+ runtime_dir="$(no_auth_runtime_dir)"
470
+ local compose_file="$runtime_dir/compose-no-auth.yaml"
471
+ local canton_config_file="$runtime_dir/canton-no-auth.conf"
472
+ mkdir -p "$runtime_dir"
473
+
474
+ cat > "$canton_config_file" <<EOF
475
+ include file("/app/base-app.conf")
476
+
477
+ $(if [[ "$(resolve_tls_enabled)" == "1" ]]; then printf 'include file("/app/localnet-tls.conf")\n'; fi)
478
+
479
+ EOF
480
+ local participant profile
481
+ for participant in app-provider app-user sv; do
482
+ case "$participant" in
483
+ app-provider) profile="$APP_PROVIDER_PROFILE" ;;
484
+ app-user) profile="$APP_USER_PROFILE" ;;
485
+ sv) profile="$SV_PROFILE" ;;
486
+ esac
487
+ if [[ "$profile" != "off" ]]; then
488
+ cat >> "$canton_config_file" <<EOF
489
+ canton.participants.${participant}.ledger-api.auth-services = []
490
+ EOF
491
+ fi
492
+ done
493
+
494
+ cat > "$compose_file" <<EOF
495
+ services:
496
+ canton:
497
+ volumes:
498
+ - "${LOCALNET_DIR}/conf/canton/app.conf:/app/base-app.conf:ro"
499
+ - "$canton_config_file:/app/app.conf:ro"
500
+ pqs-app-provider:
501
+ environment:
502
+ SCRIBE_SOURCE_LEDGER_AUTH: NoAuth
503
+ pqs-app-user:
504
+ environment:
505
+ SCRIBE_SOURCE_LEDGER_AUTH: NoAuth
506
+ pqs-sv:
507
+ environment:
508
+ SCRIBE_SOURCE_LEDGER_AUTH: NoAuth
509
+ EOF
510
+ export LOCALNET_NO_AUTH_COMPOSE_FILE="$compose_file"
511
+ }
512
+
513
+ append_no_auth_args() {
514
+ local -n compose_args_ref="$1"
515
+ if [[ "$(resolve_no_auth_enabled)" == "1" ]]; then
516
+ local compose_file="$(no_auth_runtime_dir)/compose-no-auth.yaml"
517
+ if [[ -f "$compose_file" ]]; then
518
+ compose_args_ref+=( -f "$compose_file" )
519
+ fi
520
+ fi
521
+ }
522
+
450
523
  append_es256_args() {
451
524
  local -n compose_args_ref="$1"
452
525
  if [[ "$(resolve_es256_enabled)" == "1" ]]; then
@@ -485,6 +558,23 @@ docker_compose() {
485
558
  "${DOCKER_COMPOSE_CMD[@]}" "$@"
486
559
  }
487
560
 
561
+ resolve_extra_participant_auth() {
562
+ local index="$1"
563
+ local var="EXTRA_PARTICIPANT_${index}_AUTH"
564
+ local value="${!var:-}"
565
+ if [[ -z "$value" ]]; then
566
+ if [[ "$(resolve_no_auth_enabled)" == "1" ]]; then value="none"; else value="jwt"; fi
567
+ fi
568
+ case "$value" in
569
+ jwt|none) ;;
570
+ *)
571
+ echo "EXTRA_PARTICIPANT_${index}_AUTH must be 'jwt' or 'none'." >&2
572
+ return 1
573
+ ;;
574
+ esac
575
+ printf '%s\n' "$value"
576
+ }
577
+
488
578
  resolve_extra_participants() {
489
579
  local value="${EXTRA_PARTICIPANTS:-0}"
490
580
  if [[ ! "$value" =~ ^[0-9]+$ ]]; then
@@ -684,6 +774,16 @@ EOF
684
774
  done
685
775
  fi
686
776
 
777
+ local no_auth_index
778
+ for ((no_auth_index = 1; no_auth_index <= count; no_auth_index++)); do
779
+ if [[ "$(resolve_extra_participant_auth "$no_auth_index")" == "none" ]]; then
780
+ cat >> "$canton_config_file" <<EOF
781
+ canton.participants.extra-${no_auth_index}.ledger-api.auth-services = []
782
+
783
+ EOF
784
+ fi
785
+ done
786
+
687
787
  if [[ "$(resolve_tls_enabled)" == "1" ]]; then
688
788
  local index
689
789
  for ((index = 1; index <= count; index++)); do
@@ -842,7 +942,7 @@ EOF
842
942
  environment:
843
943
  SCRIBE_SOURCE_LEDGER_HOST: canton
844
944
  SCRIBE_SOURCE_LEDGER_PORT: \${EXTRA_PARTICIPANT_${index}_LEDGER_API_PORT}
845
- SCRIBE_SOURCE_LEDGER_AUTH: OAuth
945
+ SCRIBE_SOURCE_LEDGER_AUTH: $(if [[ "$(resolve_extra_participant_auth "$index")" == "none" ]]; then printf 'NoAuth'; else printf 'OAuth'; fi)
846
946
  SCRIBE_TARGET_POSTGRES_HOST: postgres-pqs-extra-${index}
847
947
  SCRIBE_TARGET_POSTGRES_PORT: 5432
848
948
  SCRIBE_TARGET_POSTGRES_DATABASE: \${EXTRA_PQS_${index}_POSTGRES_DB}
@@ -1218,8 +1318,9 @@ start_ledger_stack() {
1218
1318
  load_localnet_common_env "$localnet_dir/env/common.env"
1219
1319
  prepare_tls_runtime_files
1220
1320
  prepare_es256_runtime_files
1321
+ prepare_no_auth_runtime_files
1221
1322
  local extra_participants
1222
- extra_participants="$(resolve_extra_participants)"
1323
+ extra_participants="$(resolve_extra_participants)"
1223
1324
  if (( extra_participants > 0 )) && [[ "$auth_mode" != "shared-secret" ]]; then
1224
1325
  echo "EXTRA_PARTICIPANTS with extra PQS currently supports AUTH_MODE=shared-secret only." >&2
1225
1326
  return 1
@@ -1252,6 +1353,7 @@ start_ledger_stack() {
1252
1353
  append_extra_participant_args "$extra_participants" "$auth_mode" compose_args
1253
1354
  append_tls_args compose_args
1254
1355
  append_es256_args compose_args
1356
+ append_no_auth_args compose_args
1255
1357
  docker_compose "${compose_args[@]}" down -v --remove-orphans
1256
1358
  mapfile -t startup_services < <(prerequisite_services "$auth_mode")
1257
1359
  mapfile -t followup_services < <(dependent_services)
@@ -1289,17 +1391,22 @@ load_repo_root_env
1289
1391
  QUICKSTART_DIR="$(resolve_quickstart_dir)"
1290
1392
  cd "$QUICKSTART_DIR"
1291
1393
 
1394
+ if [[ "$(resolve_no_auth_enabled)" == "1" && "$(resolve_es256_enabled)" == "1" ]]; then
1395
+ echo "LOCALNET_NO_AUTH=1 conflicts with LOCALNET_ES256_JWT=1: pick one auth mode." >&2
1396
+ exit 1
1397
+ fi
1398
+
1292
1399
  if [[ ! -f .env.local ]]; then
1293
1400
  echo ".env.local not found. Bootstrapping Quickstart with 'make setup'."
1294
1401
  make setup
1295
1402
  fi
1296
1403
 
1297
- if [[ "$(resolve_es256_enabled)" != "1" && "$(resolve_tls_enabled)" != "1" ]] && make_target_exists start-local-ledger; then
1404
+ if [[ "$(resolve_es256_enabled)" != "1" && "$(resolve_tls_enabled)" != "1" && "$(resolve_no_auth_enabled)" != "1" ]] && make_target_exists start-local-ledger; then
1298
1405
  make start-local-ledger
1299
1406
  else
1300
1407
  auth_mode="$(read_env_value AUTH_MODE || true)"
1301
1408
  auth_mode="${auth_mode:-shared-secret}"
1302
- if [[ "$(resolve_es256_enabled)" == "1" || "$(resolve_tls_enabled)" == "1" ]]; then
1409
+ if [[ "$(resolve_es256_enabled)" == "1" || "$(resolve_tls_enabled)" == "1" || "$(resolve_no_auth_enabled)" == "1" ]]; then
1303
1410
  echo "Generated localnet transport overlay enabled. Starting ledger-only compose stack directly."
1304
1411
  else
1305
1412
  echo "start-local-ledger target not found. Starting ledger-only compose stack directly."
@@ -92,6 +92,19 @@ es256_runtime_dir() {
92
92
  printf '%s\n' "${START_LOCAL_ES256_RUNTIME_DIR:-$REPO_ROOT/.generated/localnet-es256}"
93
93
  }
94
94
 
95
+ resolve_no_auth_enabled() {
96
+ local value="${LOCALNET_NO_AUTH:-0}"
97
+ if [[ "$value" != "0" && "$value" != "1" ]]; then
98
+ echo "LOCALNET_NO_AUTH must be 0 or 1." >&2
99
+ return 1
100
+ fi
101
+ printf '%s\n' "$value"
102
+ }
103
+
104
+ no_auth_runtime_dir() {
105
+ printf '%s\n' "${START_LOCAL_NO_AUTH_RUNTIME_DIR:-$REPO_ROOT/.generated/localnet-no-auth}"
106
+ }
107
+
95
108
  resolve_tls_enabled() {
96
109
  local value="${LOCALNET_TLS:-0}"
97
110
  if [[ "$value" != "0" && "$value" != "1" ]]; then
@@ -125,6 +138,16 @@ append_tls_args() {
125
138
  fi
126
139
  }
127
140
 
141
+ append_no_auth_args() {
142
+ local -n compose_args_ref="$1"
143
+ if [[ "$(resolve_no_auth_enabled)" == "1" ]]; then
144
+ local compose_file="$(no_auth_runtime_dir)/compose-no-auth.yaml"
145
+ if [[ -f "$compose_file" ]]; then
146
+ compose_args_ref+=( -f "$compose_file" )
147
+ fi
148
+ fi
149
+ }
150
+
128
151
  resolve_docker_compose_cmd() {
129
152
  if (( ${#DOCKER_COMPOSE_CMD[@]} > 0 )); then
130
153
  return 0
@@ -203,6 +226,7 @@ stop_ledger_stack() {
203
226
  append_existing_extra_participant_args compose_args
204
227
  append_tls_args compose_args
205
228
  append_es256_args compose_args
229
+ append_no_auth_args compose_args
206
230
  docker_compose "${compose_args[@]}" down -v --remove-orphans
207
231
  }
208
232
 
@@ -215,7 +239,7 @@ if [[ ! -f .env.local ]]; then
215
239
  exit 0
216
240
  fi
217
241
 
218
- if [[ "$(resolve_es256_enabled)" != "1" && "$(resolve_tls_enabled)" != "1" ]] && make_target_exists stop-local-ledger; then
242
+ if [[ "$(resolve_es256_enabled)" != "1" && "$(resolve_tls_enabled)" != "1" && "$(resolve_no_auth_enabled)" != "1" ]] && make_target_exists stop-local-ledger; then
219
243
  make stop-local-ledger
220
244
  else
221
245
  auth_mode="$(read_env_value AUTH_MODE || true)"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distrohelena/canton-typescript-sdk",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",