Skip to content

Commit c496b27

Browse files
author
Sneha Edula
committed
Update to use the new date fields and date format in YYYY-MM-DD format
1 parent b9b06f6 commit c496b27

7 files changed

Lines changed: 154 additions & 72 deletions

File tree

‎README.md‎

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,98 +3,97 @@
33
A command-line tool for managing Credential Engine platform resources.
44

55
## Requirements
6-
6+
77
- Python 3.10 or later
88
- `pip`
9+
910
## Installation
10-
11+
1112
> **Recommended:** install inside a virtual environment. This avoids file-permission errors, PATH conflicts, and "invalid distribution" warnings from previous installs.
12-
13+
1314
### Option 1: Install from source with a virtual environment (recommended)
14-
15+
1516
**macOS / Linux:**
16-
17+
1718
```bash
1819
git clone https://github.com/CredentialEngine/ce-cli.git
1920
cd ce-cli
20-
21+
2122
python3 -m venv .venv
2223
source .venv/bin/activate
23-
24+
2425
pip install -e .
2526
```
26-
27+
2728
**Windows (PowerShell):**
28-
29+
2930
```powershell
3031
git clone https://github.com/CredentialEngine/ce-cli.git
3132
cd ce-cli
32-
33+
3334
python -m venv .venv
3435
.venv\Scripts\activate
35-
36+
3637
pip install -e .
3738
```
38-
39+
3940
When the venv is active you'll see `(.venv)` in your prompt, and `ce` is automatically on `PATH`. To leave the venv, run `deactivate`. To re-enter it next time, run the activate command above from the project folder.
40-
41+
4142
### Option 2: Install from a release
42-
43+
4344
1. Download the `.whl` from the [Releases page](https://github.com/CredentialEngine/ce-cli/releases).
4445
2. Install it (inside a venv is still recommended):
4546
```bash
4647
pip install ce_cli-<version>-py3-none-any.whl
4748
```
4849

49-
### Upgrading
50-
50+
### Upgrading
51+
5152
From a release `.whl`:
52-
53+
5354
```bash
5455
pip install --upgrade ce_cli-<version>-py3-none-any.whl
5556
```
56-
57+
5758
From source: `git pull` and re-run `pip install -e .` inside your venv.
58-
59+
5960
### Option 3: Install from source without a venv
60-
61+
6162
```bash
6263
git clone https://github.com/CredentialEngine/ce-cli.git
6364
cd ce-cli
6465
pip install -e .
6566
```
66-
67+
6768
This puts the `ce` command on your `$PATH`. On Windows, see the [Windows PATH note](#windows-path-note) below if `ce` isn't found.
68-
69+
6970
### Verify the installation
70-
71+
7172
```bash
7273
ce --help
7374
```
74-
75+
7576
You should see the top-level command list.
76-
77+
7778
### Windows PATH note
78-
79+
7980
When you install on Windows without a venv, pip often drops ce.exe into your user Scripts folder, which Windows doesn't put on PATH by default:
80-
81+
8182
```
8283
C:\Users\<you>\AppData\Roaming\Python\Python310\Scripts
8384
```
84-
85+
8586
If `ce --help` fails after install, either use a venv (recommended) or add that folder to your User PATH:
86-
87+
8788
```powershell
8889
[Environment]::SetEnvironmentVariable(
8990
"Path",
9091
$env:Path + ";C:\Users\$env:USERNAME\AppData\Roaming\Python\Python310\Scripts",
9192
"User"
9293
)
9394
```
94-
95-
Then **close and reopen PowerShell** existing windows won't pick up the new PATH.
96-
9795

96+
Then **close and reopen PowerShell** existing windows won't pick up the new PATH.
9897

9998
## Quick start
10099

@@ -210,8 +209,8 @@ Verifies the JWT signatures and publishes each issuer to the IIR. Pass `--yes`/`
210209
| `VerificationMethod` | Yes | Full verification method ID (e.g., `did:key:z6Mk...#z6Mk...`) |
211210
| `Algorithm` | For did:key | `Ed25519`, `secp256k1`, `P-256`, or `X25519` |
212211
| `PrivateKey` | Yes | Multibase-encoded private key for signing |
213-
| `ValidFrom` | No | Date when the issuer becomes valid (MM/DD/YYYY) |
214-
| `ValidUntil` | No | Date when the issuer expires (MM/DD/YYYY) |
212+
| `ValidFrom` | No | Date when the issuer becomes valid (YYYY-MM-DD) |
213+
| `ValidUntil` | No | Date when the issuer expires (YYYY-MM-DD) |
215214

216215
Example:
217216

‎ce/commands/iir.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def bulk_sign(csv_path: str, output_path: str | None, errors_path: str | None) -
9191
9292
\b
9393
Input CSV columns (optional):
94-
ValidFrom, ValidUntil (format: MM/DD/YYYY)
94+
ValidFrom, ValidUntil (format: YYYY-MM-DD)
9595
9696
\b
9797
Produces two files:

‎ce/iir/api/iir_client/models/pub_issuer_dto.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class PubIssuerDTO:
3636
logo_uri (str | Unset):
3737
valid_from (datetime.datetime | Unset):
3838
valid_until (datetime.datetime | Unset):
39+
date_valid_from (datetime.datetime | Unset):
40+
date_valid_until (datetime.datetime | Unset):
3941
"""
4042

4143
ctid: str | Unset = UNSET
@@ -48,6 +50,8 @@ class PubIssuerDTO:
4850
logo_uri: str | Unset = UNSET
4951
valid_from: datetime.datetime | Unset = UNSET
5052
valid_until: datetime.datetime | Unset = UNSET
53+
date_valid_from: datetime.datetime | Unset = UNSET
54+
date_valid_until: datetime.datetime | Unset = UNSET
5155
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
5256

5357

@@ -79,6 +83,14 @@ def to_dict(self) -> dict[str, Any]:
7983
if not isinstance(self.valid_until, Unset):
8084
valid_until = self.valid_until.isoformat()
8185

86+
date_valid_from: str | Unset = UNSET
87+
if not isinstance(self.date_valid_from, Unset):
88+
date_valid_from = self.date_valid_from.isoformat()
89+
90+
date_valid_until: str | Unset = UNSET
91+
if not isinstance(self.date_valid_until, Unset):
92+
date_valid_until = self.date_valid_until.isoformat()
93+
8294

8395
field_dict: dict[str, Any] = {}
8496
field_dict.update(self.additional_properties)
@@ -104,6 +116,10 @@ def to_dict(self) -> dict[str, Any]:
104116
field_dict["ValidFrom"] = valid_from
105117
if valid_until is not UNSET:
106118
field_dict["ValidUntil"] = valid_until
119+
if date_valid_from is not UNSET:
120+
field_dict["DateValidFrom"] = date_valid_from
121+
if date_valid_until is not UNSET:
122+
field_dict["DateValidUntil"] = date_valid_until
107123

108124
return field_dict
109125

@@ -148,6 +164,26 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
148164

149165

150166

167+
_date_valid_from = d.pop("DateValidFrom", UNSET)
168+
date_valid_from: datetime.datetime | Unset
169+
if isinstance(_date_valid_from, Unset):
170+
date_valid_from = UNSET
171+
else:
172+
date_valid_from = isoparse(_date_valid_from)
173+
174+
175+
176+
177+
_date_valid_until = d.pop("DateValidUntil", UNSET)
178+
date_valid_until: datetime.datetime | Unset
179+
if isinstance(_date_valid_until, Unset):
180+
date_valid_until = UNSET
181+
else:
182+
date_valid_until = isoparse(_date_valid_until)
183+
184+
185+
186+
151187
pub_issuer_dto = cls(
152188
ctid=ctid,
153189
did=did,
@@ -159,6 +195,8 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
159195
logo_uri=logo_uri,
160196
valid_from=valid_from,
161197
valid_until=valid_until,
198+
date_valid_from=date_valid_from,
199+
date_valid_until=date_valid_until,
162200
)
163201

164202

‎ce/iir/did_ops.py‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import base64
6+
from datetime import timezone
67
import json
78
import re
89
from functools import lru_cache
@@ -88,12 +89,12 @@ def validate_date(value: str, field_name: str) -> tuple[bool, str, str]:
8889
return True, "", ""
8990
from datetime import datetime, timezone
9091
try:
91-
parsed = datetime.strptime(value, "%m/%d/%Y")
92-
utc_dt = parsed.replace(tzinfo=timezone.utc)
92+
parsed = datetime.strptime(value, "%Y-%m-%d")
93+
utc_dt = parsed.replace(hour=0, minute=0, second=0, tzinfo=timezone.utc)
9394
iso_value = utc_dt.strftime("%Y-%m-%dT%H:%M:%SZ")
9495
return True, "", iso_value
9596
except ValueError:
96-
return False, f"{field_name} must be in MM/DD/YYYY format, got '{value}'", ""
97+
return False, f"{field_name} must be in YYYY-MM-DD format, got '{value}'", ""
9798

9899

99100
def validate_date_range(valid_from: str, valid_until: str) -> tuple[bool, str]:
@@ -433,16 +434,18 @@ def call_submit_to_iir(
433434
) -> tuple[bool, str]:
434435
from datetime import datetime
435436

436-
def _to_dt_or_unset(value: str):
437+
def _to_iso_z(value: str) -> str:
437438
if not value:
438-
return UNSET
439+
return ""
439440
try:
440-
return datetime.fromisoformat(value.replace("Z", "+00:00"))
441+
dt = datetime.fromisoformat(value.replace("Z", "+00:00"))
441442
except ValueError:
442443
try:
443-
return datetime.strptime(value, "%Y-%m-%d")
444+
dt = datetime.strptime(value, "%Y-%m-%d")
444445
except ValueError:
445-
return UNSET
446+
return ""
447+
local_midnight = datetime(dt.year, dt.month, dt.day).astimezone()
448+
return local_midnight.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
446449

447450
try:
448451
client = _client(token, publisher_base, ssl_verify)
@@ -456,10 +459,15 @@ def _to_dt_or_unset(value: str):
456459
subject_web_page=subject_web_page,
457460
logo_base_64=logo_base64 if logo_base64 else UNSET,
458461
logo_uri=logo_uri if logo_uri else UNSET,
459-
valid_from=_to_dt_or_unset(valid_from),
460-
valid_until=_to_dt_or_unset(valid_until),
461462
)
462463

464+
df = _to_iso_z(valid_from)
465+
du = _to_iso_z(valid_until)
466+
if df:
467+
body.additional_properties["DateValidFrom"] = df
468+
if du:
469+
body.additional_properties["DateValidUntil"] = du
470+
463471
response = submit_to_iir_sync(client=client, body=body)
464472

465473
if response.status_code == 409:

‎ce/iir/openapi.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,14 @@
977977
"ValidUntil": {
978978
"format": "date-time",
979979
"type": "string"
980+
},
981+
"DateValidFrom": {
982+
"format": "date-time",
983+
"type": "string"
984+
},
985+
"DateValidUntil": {
986+
"format": "date-time",
987+
"type": "string"
980988
}
981989
}
982990
}

‎ce/iir/swagger.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,14 @@
706706
"ValidUntil": {
707707
"format": "date-time",
708708
"type": "string"
709+
},
710+
"DateValidFrom": {
711+
"format": "date-time",
712+
"type": "string"
713+
},
714+
"DateValidUntil": {
715+
"format": "date-time",
716+
"type": "string"
709717
}
710718
}
711719
}

0 commit comments

Comments
 (0)