@le-space/rootfs 0.4.2 → 0.4.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/rootfs",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Shared rootfs contract parsing, reference profile assets, and build helpers.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -129,6 +129,21 @@ def signature_payload(chain: str, sender: str, message_type: str, item_hash: str
129
129
  return "\n".join([chain, sender, message_type, item_hash])
130
130
 
131
131
 
132
+ def registration_id_instance_item_hash(registration_id: str | None) -> str | None:
133
+ normalized = str(registration_id or "").strip()
134
+ if not normalized:
135
+ return None
136
+
137
+ parts = [part.strip() for part in normalized.split(":") if part.strip()]
138
+ if not parts:
139
+ return None
140
+
141
+ candidate = parts[-1]
142
+ if len(candidate) == 64 and all(char in "0123456789abcdefABCDEF" for char in candidate):
143
+ return candidate
144
+ return None
145
+
146
+
132
147
  def relay_authorization_payload(
133
148
  owner_address: str,
134
149
  publisher_address: str,
@@ -136,6 +151,7 @@ def relay_authorization_payload(
136
151
  registration_id: str | None,
137
152
  profile: str | None,
138
153
  version: str | None,
154
+ instance_item_hash: str | None,
139
155
  issued_at: int,
140
156
  ) -> dict[str, object]:
141
157
  return {
@@ -145,7 +161,7 @@ def relay_authorization_payload(
145
161
  "registrationId": registration_id,
146
162
  "profile": profile,
147
163
  "version": version,
148
- "instanceItemHash": None,
164
+ "instanceItemHash": instance_item_hash,
149
165
  "issuedAt": issued_at,
150
166
  "expiresAt": None,
151
167
  }
@@ -194,6 +210,7 @@ def load_owner_authorization(
194
210
  return None
195
211
 
196
212
  owner_address = address_from_private_key(owner_private_key)
213
+ instance_item_hash = registration_id_instance_item_hash(registration_id)
197
214
  payload = relay_authorization_payload(
198
215
  owner_address,
199
216
  publisher_address,
@@ -201,6 +218,7 @@ def load_owner_authorization(
201
218
  registration_id,
202
219
  profile,
203
220
  version,
221
+ instance_item_hash,
204
222
  issued_at,
205
223
  )
206
224
  return {
@@ -210,6 +228,28 @@ def load_owner_authorization(
210
228
  }
211
229
 
212
230
 
231
+ def resolve_owner_address(
232
+ env_values: dict[str, str],
233
+ owner_authorization: dict[str, object] | None,
234
+ ) -> str | None:
235
+ if isinstance(owner_authorization, dict):
236
+ payload = owner_authorization.get("payload")
237
+ if isinstance(payload, dict):
238
+ owner_address = str(payload.get("ownerAddress") or "").strip()
239
+ if owner_address:
240
+ return owner_address
241
+
242
+ owner_address = env_values.get("ALEPH_BOOTSTRAP_OWNER_ADDRESS", "").strip()
243
+ if owner_address:
244
+ return owner_address
245
+
246
+ owner_private_key = env_values.get("ALEPH_BOOTSTRAP_OWNER_PRIVATE_KEY", "").strip()
247
+ if owner_private_key:
248
+ return address_from_private_key(owner_private_key)
249
+
250
+ return None
251
+
252
+
213
253
  def post_json(url: str, body: dict[str, object]) -> tuple[int, dict]:
214
254
  data = json_dumps(body).encode("utf-8")
215
255
  request = urllib.request.Request(
@@ -243,6 +283,7 @@ def build_post_content(
243
283
  registration_id: str | None,
244
284
  profile: str | None,
245
285
  version: str | None,
286
+ owner_address: str | None,
246
287
  owner_authorization: dict[str, object] | None,
247
288
  relay_proof: dict[str, object],
248
289
  now_ms: int,
@@ -256,11 +297,7 @@ def build_post_content(
256
297
  "registrationId": registration_id,
257
298
  "profile": profile,
258
299
  "version": version,
259
- "ownerAddress": (
260
- owner_authorization.get("payload", {}).get("ownerAddress")
261
- if isinstance(owner_authorization, dict)
262
- else None
263
- ),
300
+ "ownerAddress": owner_address,
264
301
  "publisherAddress": sender,
265
302
  "authorization": owner_authorization,
266
303
  "relayProof": relay_proof,
@@ -508,6 +545,7 @@ def main() -> None:
508
545
  version,
509
546
  now_ms,
510
547
  )
548
+ owner_address = resolve_owner_address(env_values, owner_authorization)
511
549
 
512
550
  proof_payload = relay_proof_payload(
513
551
  peer_id,
@@ -531,6 +569,7 @@ def main() -> None:
531
569
  registration_id,
532
570
  profile,
533
571
  version,
572
+ owner_address,
534
573
  owner_authorization,
535
574
  relay_proof,
536
575
  now_ms,
@@ -26,6 +26,7 @@ UDP_PORT=""
26
26
  BOOTSTRAP_PUBLISHER_PRIVATE_KEY=""
27
27
  BOOTSTRAP_PUBLISHER_LIBP2P_IDENTITY_B64=""
28
28
  BOOTSTRAP_OWNER_PRIVATE_KEY=""
29
+ BOOTSTRAP_OWNER_ADDRESS=""
29
30
  BOOTSTRAP_OWNER_AUTHORIZATION_B64=""
30
31
  BOOTSTRAP_REGISTRATION_ID=""
31
32
  START_SERVICE=1
@@ -46,6 +47,7 @@ Usage:
46
47
  [--bootstrap-publisher-private-key <hex>] \
47
48
  [--bootstrap-publisher-libp2p-identity-b64 <base64>] \
48
49
  [--bootstrap-owner-private-key <hex>] \
50
+ [--bootstrap-owner-address <address>] \
49
51
  [--bootstrap-owner-authorization-b64 <base64>] \
50
52
  [--bootstrap-registration-id <id>] \
51
53
  [--no-start]
@@ -169,6 +171,10 @@ while [ "$#" -gt 0 ]; do
169
171
  BOOTSTRAP_OWNER_PRIVATE_KEY="${2:-}"
170
172
  shift 2
171
173
  ;;
174
+ --bootstrap-owner-address)
175
+ BOOTSTRAP_OWNER_ADDRESS="${2:-}"
176
+ shift 2
177
+ ;;
172
178
  --bootstrap-owner-authorization-b64)
173
179
  BOOTSTRAP_OWNER_AUTHORIZATION_B64="${2:-}"
174
180
  shift 2
@@ -275,6 +281,7 @@ fi
275
281
  if [ -n "${BOOTSTRAP_OWNER_PRIVATE_KEY}" ]; then
276
282
  write_env_var "ALEPH_BOOTSTRAP_OWNER_PRIVATE_KEY" "${BOOTSTRAP_OWNER_PRIVATE_KEY}"
277
283
  fi
284
+ write_env_var "ALEPH_BOOTSTRAP_OWNER_ADDRESS" "${BOOTSTRAP_OWNER_ADDRESS}"
278
285
  if [ -n "${BOOTSTRAP_OWNER_AUTHORIZATION_B64}" ]; then
279
286
  write_env_var "ALEPH_BOOTSTRAP_OWNER_AUTHORIZATION_B64" "${BOOTSTRAP_OWNER_AUTHORIZATION_B64}"
280
287
  fi
@@ -164,6 +164,9 @@ def _build_configure_args(record: dict) -> list[str]:
164
164
  registration_id = str(bootstrap.get("registrationId") or "").strip()
165
165
  if registration_id:
166
166
  args.extend(["--bootstrap-registration-id", registration_id])
167
+ owner_address = str(record.get("ownerAddress") or "").strip()
168
+ if owner_address:
169
+ args.extend(["--bootstrap-owner-address", owner_address])
167
170
  owner_auth = str(bootstrap.get("ownerAuthorizationBase64") or "").strip()
168
171
  if owner_auth:
169
172
  args.extend(["--bootstrap-owner-authorization-b64", owner_auth])
@@ -516,6 +519,7 @@ class Handler(BaseHTTPRequestHandler):
516
519
  "bootstrap_publisher_libp2p_identity_b64"
517
520
  )
518
521
  bootstrap_owner_private_key = payload.get("bootstrap_owner_private_key")
522
+ bootstrap_owner_address = payload.get("bootstrap_owner_address")
519
523
  bootstrap_owner_authorization_b64 = payload.get("bootstrap_owner_authorization_b64")
520
524
  bootstrap_registration_id = payload.get("bootstrap_registration_id")
521
525
  no_start = bool(payload.get("no_start"))
@@ -548,6 +552,8 @@ class Handler(BaseHTTPRequestHandler):
548
552
  )
549
553
  if bootstrap_owner_private_key is not None:
550
554
  args.extend(["--bootstrap-owner-private-key", str(bootstrap_owner_private_key)])
555
+ if bootstrap_owner_address is not None:
556
+ args.extend(["--bootstrap-owner-address", str(bootstrap_owner_address)])
551
557
  if bootstrap_owner_authorization_b64 is not None:
552
558
  args.extend(
553
559
  ["--bootstrap-owner-authorization-b64", str(bootstrap_owner_authorization_b64)]