|
26 | 26 | from ..wallet.error import WalletNotFoundError |
27 | 27 | from .error_messages import ANONCREDS_PROFILE_REQUIRED_MSG |
28 | 28 | from .models.anoncreds_cred_def import CredDef |
| 29 | +from base58 import alphabet |
| 30 | + |
| 31 | +B58 = alphabet if isinstance(alphabet, str) else alphabet.decode("ascii") |
29 | 32 |
|
30 | 33 | LOGGER = logging.getLogger(__name__) |
31 | 34 |
|
@@ -143,8 +146,8 @@ async def create_credential_request( |
143 | 146 | ) = await asyncio.get_event_loop().run_in_executor( |
144 | 147 | None, |
145 | 148 | CredentialRequest.create, |
| 149 | + holder_did, # FIX ME PLEEEEASE |
146 | 150 | None, |
147 | | - holder_did, |
148 | 151 | credential_definition.to_native(), |
149 | 152 | secret, |
150 | 153 | AnonCredsHolder.MASTER_SECRET_ID, |
@@ -207,27 +210,53 @@ async def store_credential( |
207 | 210 |
|
208 | 211 | schema_id = cred_recvd.schema_id |
209 | 212 | schema_id_parts = re.match(r"^(\w+):2:([^:]+):([^:]+)$", schema_id) |
| 213 | + if 'indy2'in schema_id: |
| 214 | + INDY_SCHEMA_ID = rf"^(did:indy2)?:.+:[{B58}]{{21,22}}/anoncreds/v0/SCHEMA/.+/[0-9.]+$" |
| 215 | + schema_id_parts = re.match(INDY_SCHEMA_ID, schema_id) |
210 | 216 | if not schema_id_parts: |
211 | 217 | raise AnonCredsHolderError( |
212 | 218 | f"Error parsing credential schema ID: {schema_id}" |
213 | 219 | ) |
214 | | - cred_def_id = cred_recvd.cred_def_id |
215 | | - cdef_id_parts = re.match(r"^(\w+):3:CL:([^:]+):([^:]+)$", cred_def_id) |
| 220 | + cred_def_id = cred_recvd.cred_def_id |
| 221 | + cdef_id_parts = re.match(r"^(\w+):3:CL:([^:]+):([^:]+)$", cred_def_id) |
| 222 | + if 'indy2' in cred_def_id: |
| 223 | + INDY_CRED_DEF_ID = ( |
| 224 | + rf"^((did:indy2)?:.+:[{B58}]{{21,22}})" # issuer DID |
| 225 | + f"/anoncreds/v0/CLAIM_DEF/" # cred def id marker |
| 226 | + # f":CL" # sig alg |
| 227 | + rf"((did:indy2)?:.+:[{B58}]{{21,22}}/anoncreds/v0/SCHEMA/.+/[0-9.]+)" # schema txn / id |
| 228 | + f"/(.+)?$" # tag |
| 229 | + ) |
| 230 | + cdef_id_parts = re.match(INDY_CRED_DEF_ID, cred_def_id) |
216 | 231 | if not cdef_id_parts: |
217 | 232 | raise AnonCredsHolderError( |
218 | 233 | f"Error parsing credential definition ID: {cred_def_id}" |
219 | 234 | ) |
220 | 235 |
|
221 | 236 | credential_id = credential_id or str(uuid.uuid4()) |
222 | | - tags = { |
223 | | - "schema_id": schema_id, |
224 | | - "schema_issuer_did": schema_id_parts[1], |
225 | | - "schema_name": schema_id_parts[2], |
226 | | - "schema_version": schema_id_parts[3], |
227 | | - "issuer_did": cdef_id_parts[1], |
228 | | - "cred_def_id": cred_def_id, |
229 | | - "rev_reg_id": cred_recvd.rev_reg_id or "None", |
230 | | - } |
| 237 | + tags = {} |
| 238 | + if 'indy2' in cred_def_id and 'indy2' in schema_id: |
| 239 | + schema_id_parts = schema_id.split('/') |
| 240 | + cdef_id_parts = cred_def_id.split('/') |
| 241 | + tags = { |
| 242 | + "schema_id": schema_id, |
| 243 | + "schema_issuer_did": schema_id_parts[0], |
| 244 | + "schema_name": schema_id_parts[4], |
| 245 | + "schema_version": schema_id_parts[5], |
| 246 | + "issuer_did": cdef_id_parts[0], |
| 247 | + "cred_def_id": cred_def_id, |
| 248 | + "rev_reg_id": cred_recvd.rev_reg_id or "None", |
| 249 | + } |
| 250 | + else: |
| 251 | + tags = { |
| 252 | + "schema_id": schema_id, |
| 253 | + "schema_issuer_did": schema_id_parts[1], |
| 254 | + "schema_name": schema_id_parts[2], |
| 255 | + "schema_version": schema_id_parts[3], |
| 256 | + "issuer_did": cdef_id_parts[1], |
| 257 | + "cred_def_id": cred_def_id, |
| 258 | + "rev_reg_id": cred_recvd.rev_reg_id or "None", |
| 259 | + } |
231 | 260 |
|
232 | 261 | # FIXME - sdk has some special handling for fully qualified DIDs here |
233 | 262 |
|
|
0 commit comments