Skip to content

Commit 76e4d34

Browse files
committed
fix(bindings): regenerate python bindings for create_and_sign string API and issuer_signed_b64
- create_and_sign now accepts dict[str, dict[str, str]] (JSON strings) - issuer_signed_b64() is now exposed in Python bindings - Regenerated from compiled Rust via maturin develop Signed-off-by: Adam Burdett <burdettadam@gmail.com>
1 parent 84743f7 commit 76e4d34

File tree

1 file changed

+88
-8
lines changed

1 file changed

+88
-8
lines changed

python/isomdl_uniffi/isomdl_uniffi.py

Lines changed: 88 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ def _uniffi_check_api_checksums(lib):
492492
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
493493
if lib.uniffi_isomdl_uniffi_checksum_method_mdoc_id() != 45880:
494494
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
495+
if lib.uniffi_isomdl_uniffi_checksum_method_mdoc_issuer_signed_b64() != 28958:
496+
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
495497
if lib.uniffi_isomdl_uniffi_checksum_method_mdoc_json() != 1636:
496498
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
497499
if lib.uniffi_isomdl_uniffi_checksum_method_mdoc_key_alias() != 9235:
@@ -506,7 +508,7 @@ def _uniffi_check_api_checksums(lib):
506508
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
507509
if lib.uniffi_isomdl_uniffi_checksum_constructor_mdlpresentationsession_new() != 1270:
508510
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
509-
if lib.uniffi_isomdl_uniffi_checksum_constructor_mdoc_create_and_sign() != 3320:
511+
if lib.uniffi_isomdl_uniffi_checksum_constructor_mdoc_create_and_sign() != 347:
510512
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
511513
if lib.uniffi_isomdl_uniffi_checksum_constructor_mdoc_create_and_sign_mdl() != 21814:
512514
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
@@ -761,6 +763,11 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure):
761763
ctypes.POINTER(_UniffiRustCallStatus),
762764
)
763765
_UniffiLib.uniffi_isomdl_uniffi_fn_method_mdoc_id.restype = _UniffiRustBuffer
766+
_UniffiLib.uniffi_isomdl_uniffi_fn_method_mdoc_issuer_signed_b64.argtypes = (
767+
ctypes.c_void_p,
768+
ctypes.POINTER(_UniffiRustCallStatus),
769+
)
770+
_UniffiLib.uniffi_isomdl_uniffi_fn_method_mdoc_issuer_signed_b64.restype = _UniffiRustBuffer
764771
_UniffiLib.uniffi_isomdl_uniffi_fn_method_mdoc_json.argtypes = (
765772
ctypes.c_void_p,
766773
ctypes.POINTER(_UniffiRustCallStatus),
@@ -1167,6 +1174,9 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure):
11671174
_UniffiLib.uniffi_isomdl_uniffi_checksum_method_mdoc_id.argtypes = (
11681175
)
11691176
_UniffiLib.uniffi_isomdl_uniffi_checksum_method_mdoc_id.restype = ctypes.c_uint16
1177+
_UniffiLib.uniffi_isomdl_uniffi_checksum_method_mdoc_issuer_signed_b64.argtypes = (
1178+
)
1179+
_UniffiLib.uniffi_isomdl_uniffi_checksum_method_mdoc_issuer_signed_b64.restype = ctypes.c_uint16
11701180
_UniffiLib.uniffi_isomdl_uniffi_checksum_method_mdoc_json.argtypes = (
11711181
)
11721182
_UniffiLib.uniffi_isomdl_uniffi_checksum_method_mdoc_json.restype = ctypes.c_uint16
@@ -1666,6 +1676,21 @@ def id(self, ):
16661676
The local ID of this credential.
16671677
"""
16681678

1679+
raise NotImplementedError
1680+
def issuer_signed_b64(self, ):
1681+
"""
1682+
Serialize as an ISO 18013-5 §8.3 compliant IssuerSigned structure (base64url, no padding).
1683+
1684+
Unlike [`Mdoc::stringify`], which serializes the internal `Document` struct
1685+
with snake_case CBOR keys (`issuer_auth`, `namespaces`), this method
1686+
serializes an [`IssuerSigned`] value using the camelCase keys required
1687+
by ISO 18013-5 §8.3 (`issuerAuth`, `nameSpaces`) and the correct
1688+
map-of-lists namespace representation (`NonEmptyVec<IssuerSignedItemBytes>`).
1689+
1690+
This is the correct format for use in OpenID4VCI mso_mdoc credential issuance
1691+
and ISO 18013-5 presentation.
1692+
"""
1693+
16691694
raise NotImplementedError
16701695
def json(self, ):
16711696
"""
@@ -1730,10 +1755,10 @@ def _make_instance_(cls, pointer):
17301755
inst._pointer = pointer
17311756
return inst
17321757
@classmethod
1733-
def create_and_sign(cls, doc_type: "str",namespaces: "dict[str, dict[str, bytes]]",holder_jwk: "str",iaca_cert_perm: "str",iaca_key_perm: "str"):
1758+
def create_and_sign(cls, doc_type: "str",namespaces: "dict[str, dict[str, str]]",holder_jwk: "str",iaca_cert_perm: "str",iaca_key_perm: "str"):
17341759
_UniffiConverterString.check_lower(doc_type)
17351760

1736-
_UniffiConverterMapStringMapStringBytes.check_lower(namespaces)
1761+
_UniffiConverterMapStringMapStringString.check_lower(namespaces)
17371762

17381763
_UniffiConverterString.check_lower(holder_jwk)
17391764

@@ -1744,7 +1769,7 @@ def create_and_sign(cls, doc_type: "str",namespaces: "dict[str, dict[str, bytes]
17441769
# Call the (fallible) function before creating any half-baked object instances.
17451770
pointer = _uniffi_rust_call_with_error(_UniffiConverterTypeMdocInitError,_UniffiLib.uniffi_isomdl_uniffi_fn_constructor_mdoc_create_and_sign,
17461771
_UniffiConverterString.lower(doc_type),
1747-
_UniffiConverterMapStringMapStringBytes.lower(namespaces),
1772+
_UniffiConverterMapStringMapStringString.lower(namespaces),
17481773
_UniffiConverterString.lower(holder_jwk),
17491774
_UniffiConverterString.lower(iaca_cert_perm),
17501775
_UniffiConverterString.lower(iaca_key_perm))
@@ -1876,6 +1901,28 @@ def id(self, ) -> "Uuid":
18761901

18771902

18781903

1904+
def issuer_signed_b64(self, ) -> "str":
1905+
"""
1906+
Serialize as an ISO 18013-5 §8.3 compliant IssuerSigned structure (base64url, no padding).
1907+
1908+
Unlike [`Mdoc::stringify`], which serializes the internal `Document` struct
1909+
with snake_case CBOR keys (`issuer_auth`, `namespaces`), this method
1910+
serializes an [`IssuerSigned`] value using the camelCase keys required
1911+
by ISO 18013-5 §8.3 (`issuerAuth`, `nameSpaces`) and the correct
1912+
map-of-lists namespace representation (`NonEmptyVec<IssuerSignedItemBytes>`).
1913+
1914+
This is the correct format for use in OpenID4VCI mso_mdoc credential issuance
1915+
and ISO 18013-5 presentation.
1916+
"""
1917+
1918+
return _UniffiConverterString.lift(
1919+
_uniffi_rust_call_with_error(_UniffiConverterTypeMdocEncodingError,_UniffiLib.uniffi_isomdl_uniffi_fn_method_mdoc_issuer_signed_b64,self._uniffi_clone_pointer(),)
1920+
)
1921+
1922+
1923+
1924+
1925+
18791926
def json(self, ) -> "str":
18801927
"""
18811928
Serialize as JSON
@@ -3873,6 +3920,39 @@ def read(cls, buf):
38733920

38743921

38753922

3923+
class _UniffiConverterMapStringString(_UniffiConverterRustBuffer):
3924+
@classmethod
3925+
def check_lower(cls, items):
3926+
for (key, value) in items.items():
3927+
_UniffiConverterString.check_lower(key)
3928+
_UniffiConverterString.check_lower(value)
3929+
3930+
@classmethod
3931+
def write(cls, items, buf):
3932+
buf.write_i32(len(items))
3933+
for (key, value) in items.items():
3934+
_UniffiConverterString.write(key, buf)
3935+
_UniffiConverterString.write(value, buf)
3936+
3937+
@classmethod
3938+
def read(cls, buf):
3939+
count = buf.read_i32()
3940+
if count < 0:
3941+
raise InternalError("Unexpected negative map size")
3942+
3943+
# It would be nice to use a dict comprehension,
3944+
# but in Python 3.7 and before the evaluation order is not according to spec,
3945+
# so we we're reading the value before the key.
3946+
# This loop makes the order explicit: first reading the key, then the value.
3947+
d = {}
3948+
for i in range(count):
3949+
key = _UniffiConverterString.read(buf)
3950+
val = _UniffiConverterString.read(buf)
3951+
d[key] = val
3952+
return d
3953+
3954+
3955+
38763956
class _UniffiConverterMapStringBytes(_UniffiConverterRustBuffer):
38773957
@classmethod
38783958
def check_lower(cls, items):
@@ -4005,19 +4085,19 @@ def read(cls, buf):
40054085

40064086

40074087

4008-
class _UniffiConverterMapStringMapStringBytes(_UniffiConverterRustBuffer):
4088+
class _UniffiConverterMapStringMapStringString(_UniffiConverterRustBuffer):
40094089
@classmethod
40104090
def check_lower(cls, items):
40114091
for (key, value) in items.items():
40124092
_UniffiConverterString.check_lower(key)
4013-
_UniffiConverterMapStringBytes.check_lower(value)
4093+
_UniffiConverterMapStringString.check_lower(value)
40144094

40154095
@classmethod
40164096
def write(cls, items, buf):
40174097
buf.write_i32(len(items))
40184098
for (key, value) in items.items():
40194099
_UniffiConverterString.write(key, buf)
4020-
_UniffiConverterMapStringBytes.write(value, buf)
4100+
_UniffiConverterMapStringString.write(value, buf)
40214101

40224102
@classmethod
40234103
def read(cls, buf):
@@ -4032,7 +4112,7 @@ def read(cls, buf):
40324112
d = {}
40334113
for i in range(count):
40344114
key = _UniffiConverterString.read(buf)
4035-
val = _UniffiConverterMapStringBytes.read(buf)
4115+
val = _UniffiConverterMapStringString.read(buf)
40364116
d[key] = val
40374117
return d
40384118

0 commit comments

Comments
 (0)