codeimprint 0.5.0a28__tar.gz → 0.5.0a30__tar.gz

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.
Files changed (26) hide show
  1. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/CHANGELOG.md +22 -0
  2. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/PKG-INFO +1 -1
  3. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/pyproject.toml +1 -1
  4. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/__init__.py +1 -1
  5. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/api.py +6 -0
  6. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/cli.py +72 -0
  7. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/.gitignore +0 -0
  8. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/LICENSE +0 -0
  9. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/NOTICE +0 -0
  10. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/README.pypi.md +0 -0
  11. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint/__init__.py +0 -0
  12. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint/__main__.py +0 -0
  13. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/__main__.py +0 -0
  14. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/chainseal.py +0 -0
  15. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/config.py +0 -0
  16. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/gitrepo.py +0 -0
  17. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/imprint_file.py +0 -0
  18. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/linecount.py +0 -0
  19. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/ownership.py +0 -0
  20. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/project.py +0 -0
  21. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/receipt.py +0 -0
  22. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/records.py +0 -0
  23. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/timestamp.py +0 -0
  24. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/transparency.py +0 -0
  25. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/trust.py +0 -0
  26. {codeimprint-0.5.0a28 → codeimprint-0.5.0a30}/src/codeimprint_cli/tsa_roots.py +0 -0
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0a30 — `imprint github link` warns about sealing twice [CIM-BE-44-v1]
4
+
5
+ For engine 0.7.0a35 (works with any engine).
6
+
7
+ - **New warning in `imprint github link`:** when the repository also has
8
+ `.github/workflows/codeimprint.yml`, it says: "This repository also has
9
+ .github/workflows/codeimprint.yml, so each push is sealed twice. Delete that file to use
10
+ the GitHub App only." A warning only: the file is never deleted, and the exit code is
11
+ unchanged.
12
+ - No other change. Tests: `tests/test_github_link.py`.
13
+
14
+ ## 0.5.0a29 — `imprint plan` [CIM-BE-43-v1]
15
+
16
+ For engine 0.7.0a34.
17
+
18
+ - **New: `imprint plan`** (read-only): the plan, its status and period end, usage (active
19
+ projects of the plan's limit, with the 80% and 100% alerts, and whether the limit is
20
+ enforced), an open invoice request, an unpaid invoice, and the hub's billing page.
21
+ `--org <ID>` for an organisation you administer, `--json` for the server's answer. Plans
22
+ are bought and changed on the hub, never from the client.
23
+ - No other change. Tests: `tests/test_plan.py`.
24
+
3
25
  ## 0.5.0a28 — `imprint init` and the GitHub App [CIM-BE-41-v1]
4
26
 
5
27
  For engine 0.7.0a33.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: codeimprint
3
- Version: 0.5.0a28
3
+ Version: 0.5.0a30
4
4
  Summary: CodeImprint: seal your code with a CodeImprint server (tamper-evident, logged and timestamped) and verify seals offline.
5
5
  Project-URL: Homepage, https://codeimprint.ai
6
6
  Project-URL: Hub, https://app.codeimprint.ai
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
  # Published on PyPI as `codeimprint`. The import package stays `codeimprint_cli` and the
7
7
  # command `imprint`.
8
8
  name = "codeimprint"
9
- version = "0.5.0a28"
9
+ version = "0.5.0a30"
10
10
  description = "CodeImprint: seal your code with a CodeImprint server (tamper-evident, logged and timestamped) and verify seals offline."
11
11
  readme = "README.pypi.md"
12
12
  license = "Apache-2.0"
@@ -5,4 +5,4 @@ A thin client for a CodeImprint server: it zips a project, asks the server to se
5
5
  it, and verifies Imprint files offline. All analysis happens on the server.
6
6
  """
7
7
 
8
- __version__ = "0.5.0a28"
8
+ __version__ = "0.5.0a30"
@@ -225,6 +225,12 @@ class Client:
225
225
  {"project": project, "days": days,
226
226
  **({"label": label} if label else {})})
227
227
 
228
+ def billing_status(self, org_id: str | None = None) -> dict:
229
+ """The signed-in account's (or an organisation's) plan, status and usage (read-only;
230
+ engine 0.7.0a34+)."""
231
+ path = "/api/v1/me/billing" + (f"?org_id={quote(org_id)}" if org_id else "")
232
+ return self._request("GET", path)
233
+
228
234
  def tokens(self) -> list[dict]:
229
235
  return self._request("GET", "/api/v1/me/tokens").get("items") or []
230
236
 
@@ -2301,6 +2301,58 @@ def cmd_key(args) -> int:
2301
2301
 
2302
2302
 
2303
2303
  # -- project names and the GitHub App (CIM-BE-19-v1) ---------------------------------------
2304
+ ALERTS = {"near_limit": "close to your plan's limit",
2305
+ "limit_reached": "your plan's limit is reached"}
2306
+
2307
+
2308
+ def cmd_plan(args) -> int:
2309
+ """`imprint plan`: the plan, its status and usage, read-only. Plans are bought and
2310
+ changed on the hub's billing page, never from here."""
2311
+ sc = _session_client(args)
2312
+ try:
2313
+ s = sc.billing_status(getattr(args, "org", None))
2314
+ except ApiError as exc:
2315
+ if exc.status == 404 and exc.code != "org_not_found":
2316
+ raise Abort(f"{sc.url} has no billing yet (engine 0.7.0a34 or later)") from exc
2317
+ raise Abort(_explain(sc, exc, "could not read the plan")) from exc
2318
+ except NetworkError as exc:
2319
+ raise Abort(f"could not read the plan: {exc}") from exc
2320
+ if getattr(args, "json", False):
2321
+ print(json.dumps(s, indent=2, sort_keys=True))
2322
+ return 0
2323
+ plan, sub, use = s["plan"], s.get("subscription"), s["usage"]
2324
+ limit = f"{plan['projects']} active projects" if plan.get("projects") else "custom limit"
2325
+ line = f"Plan {plan['name']} ({limit})"
2326
+ if sub and sub["plan"] == plan["key"]:
2327
+ until = (sub.get("period_end") or "")[:10]
2328
+ line += f" · {sub['status']}, {sub.get('interval') or 'yearly'}" + (
2329
+ f", until {until}" if until else "")
2330
+ elif sub and sub["status"] in ("pending", "lapsed", "canceled", "past_due"):
2331
+ line += f" · your {sub['plan']} plan is {sub['status']}"
2332
+ lines = [line]
2333
+ if use.get("limit"):
2334
+ usage = (f"Usage {use['active_projects']} of {use['limit']} active projects "
2335
+ f"({use['percent']}%)")
2336
+ if use.get("alert"):
2337
+ usage += f": {ALERTS[use['alert']]}"
2338
+ if not use.get("enforced"):
2339
+ usage += " (shown only: sealing is not limited)"
2340
+ lines.append(usage)
2341
+ else:
2342
+ lines.append(f"Usage {use['active_projects']} active projects")
2343
+ lines.append(" (active: sealed in the last 12 months, not archived)")
2344
+ req = s.get("invoice_request")
2345
+ if req:
2346
+ lines.append(f"Invoice request {req['id']} for {req['plan']} ({req['status']})")
2347
+ inv = s.get("latest_invoice")
2348
+ if inv and inv.get("status") not in (None, "paid"):
2349
+ lines.append(f"Invoice {inv.get('number') or inv['id']}: {inv['status']}"
2350
+ + (f", due {inv['due'][:10]}" if inv.get("due") else ""))
2351
+ lines.append(f"Manage {s.get('billing_page')}")
2352
+ _say(*lines)
2353
+ return 0
2354
+
2355
+
2304
2356
  def cmd_token(args) -> int:
2305
2357
  """`imprint token create | list | revoke`: CI tokens of the signed-in account. A token
2306
2358
  acts as the account for one project, on the sealing routes, until it expires."""
@@ -2687,6 +2739,7 @@ def cmd_github(args) -> int:
2687
2739
  _say(f"Repository {repository}", f"Project {prep['project_id']} (custody: "
2688
2740
  f"{prep.get('custody', 'owner')})", f"Already authorised by your key {fp} "
2689
2741
  f"({prep['authorisation']}): nothing to do.")
2742
+ _warn_workflow(root)
2690
2743
  return 0
2691
2744
  doc = prep["document"]
2692
2745
  if doc.get("authorised_by") != fp or doc.get("project") != prep["project_id"]:
@@ -2722,9 +2775,21 @@ def cmd_github(args) -> int:
2722
2775
  _say(f"Authorised {done['authorisation']} (log entry #{done['receipt']['log']['index']})",
2723
2776
  f"Custody {done['custody']}: your key {fp} controls the project's chain; the App "
2724
2777
  "seals each push with its own key, authorised by yours")
2778
+ _warn_workflow(root)
2725
2779
  return 0
2726
2780
 
2727
2781
 
2782
+ SEALED_TWICE = ("This repository also has .github/workflows/codeimprint.yml, so each push is "
2783
+ "sealed twice. Delete that file to use the GitHub App only.")
2784
+
2785
+
2786
+ def _warn_workflow(root: Path) -> None:
2787
+ """CIM-BE-44-v1: the App now seals every push; the Actions workflow `imprint init` wrote
2788
+ would seal each one again. Only a warning: the file is never deleted here."""
2789
+ if (root / ".github" / "workflows" / "codeimprint.yml").is_file():
2790
+ _warn(SEALED_TWICE)
2791
+
2792
+
2728
2793
  def _print_result(r: dict, fail_above: float) -> None:
2729
2794
  _say(f"Reference {r.get('reference')}",
2730
2795
  f"Suspect {r.get('suspect')}",
@@ -3185,6 +3250,13 @@ def build_parser() -> argparse.ArgumentParser:
3185
3250
  ky.add_argument("--url", help="server URL (overrides login and CODEIMPRINT_URL)")
3186
3251
  ky.set_defaults(func=cmd_key)
3187
3252
 
3253
+ pl = sub.add_parser("plan", help="your plan, its status and usage (read-only; buy or "
3254
+ "change it on the hub's billing page)")
3255
+ pl.add_argument("--org", help="an organisation you administer, by its ID")
3256
+ pl.add_argument("--json", action="store_true", help="the server's answer as JSON")
3257
+ pl.add_argument("--url", help="server URL (overrides login and CODEIMPRINT_URL)")
3258
+ pl.set_defaults(func=cmd_plan)
3259
+
3188
3260
  tk = sub.add_parser("token", help="CI tokens for automated builds (CODEIMPRINT_TOKEN): "
3189
3261
  "create, list, revoke")
3190
3262
  tk.add_argument("action", choices=["create", "list", "revoke"])
File without changes
File without changes