@auth-craft/aws-cf-stack 1.5.0 → 1.6.1

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.
@@ -10,11 +10,16 @@ create_admin() {
10
10
  local email="${LAMBDA_SUPER_ADMIN_EMAIL:-}"
11
11
  local password="${LAMBDA_SUPER_ADMIN_PASSWORD:-}"
12
12
  local name="${LAMBDA_SUPER_ADMIN_NAME:-Super Admin}"
13
- local setup_token="${LAMBDA_AUTH_SETUP_TOKEN:-${AUTH_SETUP_TOKEN:-}}"
14
13
 
15
- if [[ -z "$email" || -z "$password" || -z "$setup_token" ]]; then
16
- warn "Super-admin creds not configured — skipping."
17
- info "Set LAMBDA_SUPER_ADMIN_EMAIL, LAMBDA_SUPER_ADMIN_PASSWORD, LAMBDA_AUTH_SETUP_TOKEN to enable."
14
+ # Email + password are required to bootstrap the super-admin. Report exactly which are
15
+ # missing so a partial config isn't confusing. (The CLI is idempotent: if an active
16
+ # owner already exists in the system tenant it's a no-op, so re-runs are safe.)
17
+ local -a missing=()
18
+ [[ -z "$email" ]] && missing+=("LAMBDA_SUPER_ADMIN_EMAIL")
19
+ [[ -z "$password" ]] && missing+=("LAMBDA_SUPER_ADMIN_PASSWORD")
20
+ if [[ ${#missing[@]} -gt 0 ]]; then
21
+ warn "Super-admin skipped — missing: ${missing[*]}"
22
+ info "Set LAMBDA_SUPER_ADMIN_EMAIL and LAMBDA_SUPER_ADMIN_PASSWORD to enable."
18
23
  SUPER_ADMIN_STATUS="skipped"
19
24
  export SUPER_ADMIN_STATUS
20
25
  return 0
@@ -30,23 +35,24 @@ create_admin() {
30
35
 
31
36
  local output status
32
37
  set +e
33
- output="$(AUTH_SETUP_TOKEN="$setup_token" node "$entry" create-super-admin \
38
+ output="$(node "$entry" create-super-admin \
34
39
  --database-type dynamodb \
35
40
  --dynamodb-table "$DYNAMODB_TABLE" \
36
41
  --dynamodb-region "$AWS_REGION" \
37
42
  --email "$email" \
38
43
  --password "$password" \
39
- --name "$name" \
40
- --setup-token "$setup_token" 2>&1)"
44
+ --name "$name" 2>&1)"
41
45
  status=$?
42
46
  set -e
43
47
 
44
48
  echo "$output"
45
49
 
50
+ # Match the exact error CODE, not a loose substring: EXISTENCE_CHECK_FAILED's message
51
+ # also contains "already exists" and must NOT be mistaken for success.
46
52
  if [[ $status -eq 0 ]]; then
47
53
  success "Super admin created"
48
54
  SUPER_ADMIN_STATUS="created"
49
- elif echo "$output" | grep -qi "SUPER_ADMIN_EXISTS\|already exists"; then
55
+ elif echo "$output" | grep -qE '\[SUPER_ADMIN_EXISTS\]|SUPER_ADMIN_EXISTS'; then
50
56
  info "Super admin already exists (no action needed)"
51
57
  SUPER_ADMIN_STATUS="exists"
52
58
  else
@@ -151,6 +151,11 @@ deploy_one_worker() {
151
151
  config_file="$WRANGLER_DIR/wrangler.toml"
152
152
  if [[ -n "$cors_kv_id" || -n "$disable_public_url" ]]; then
153
153
  config_file="$(mktemp "${TMPDIR:-/tmp}/wrangler-${label}.XXXXXX.toml")"
154
+ # `main` in the shipped toml is RELATIVE to the toml's own dir (../assets/...). A temp
155
+ # config lives elsewhere (e.g. /tmp), so that relative path would resolve wrong and
156
+ # wrangler can't find the worker bundle. Rewrite it to the absolute asset path. This
157
+ # runs for BOTH branches below (disable-public-url and plain copy).
158
+ local abs_main="$GATEWAY_ASSET_DIR/worker.js"
154
159
  if [[ -n "$disable_public_url" ]]; then
155
160
  # Turn off the workers.dev URL *and* the per-version preview URLs in a single
156
161
  # deploy (no REST API round-trip; CF won't drop preview URLs just for workers_dev
@@ -158,8 +163,9 @@ deploy_one_worker() {
158
163
  # any [table] header or TOML scopes them under it (e.g. [build]). We drop the
159
164
  # shipped `workers_dev = true` (TOML forbids duplicate keys) and inject both flags
160
165
  # immediately after the first root key (`name = …`), before [build].
161
- awk '
162
- /^[[:space:]]*workers_dev[[:space:]]*=/ { next } # drop original (anywhere)
166
+ awk -v abs_main="$abs_main" '
167
+ /^[[:space:]]*workers_dev[[:space:]]*=/ { next } # drop original (anywhere)
168
+ /^[[:space:]]*main[[:space:]]*=/ { print "main = \"" abs_main "\""; next } # absolutize
163
169
  { print }
164
170
  !injected && /^[[:space:]]*name[[:space:]]*=/ {
165
171
  print "workers_dev = false"; print "preview_urls = false"; injected = 1
@@ -167,7 +173,10 @@ deploy_one_worker() {
167
173
  ' "$WRANGLER_DIR/wrangler.toml" >"$config_file"
168
174
  info " public URL disabled: workers.dev + preview URLs off (Pages-proxy / Service Binding only)"
169
175
  else
170
- cat "$WRANGLER_DIR/wrangler.toml" >"$config_file"
176
+ awk -v abs_main="$abs_main" '
177
+ /^[[:space:]]*main[[:space:]]*=/ { print "main = \"" abs_main "\""; next } # absolutize
178
+ { print }
179
+ ' "$WRANGLER_DIR/wrangler.toml" >"$config_file"
171
180
  fi
172
181
  if [[ -n "$cors_kv_id" ]]; then
173
182
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth-craft/aws-cf-stack",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "description": "Self-contained, versioned distribution of the Auth Craft AWS (DynamoDB + Lambda) + Cloudflare gateway stack. Bundles prebuilt Lambda/worker artifacts + CDK app so consumers deploy without cloning auth-craft.",
5
5
  "type": "module",
6
6
  "bin": {