@@ -61,7 +61,7 @@ class OpenEnterpriseAPI: Ability {
61
61
return body
62
62
}
63
63
default :
64
- throw Error . WrongResponse
64
+ throw Error . WrongResponse ( response )
65
65
}
66
66
}
67
67
@@ -87,7 +87,7 @@ class OpenEnterpriseAPI: Ability {
87
87
return body
88
88
}
89
89
default :
90
- throw Error . WrongResponse
90
+ throw Error . WrongResponse ( response )
91
91
}
92
92
}
93
93
@@ -100,7 +100,7 @@ class OpenEnterpriseAPI: Ability {
100
100
return body
101
101
}
102
102
default :
103
- throw Error . WrongResponse
103
+ throw Error . WrongResponse ( response )
104
104
}
105
105
}
106
106
@@ -127,7 +127,7 @@ class OpenEnterpriseAPI: Ability {
127
127
return body
128
128
}
129
129
default :
130
- throw Error . WrongResponse
130
+ throw Error . WrongResponse ( response )
131
131
}
132
132
}
133
133
@@ -167,7 +167,7 @@ class OpenEnterpriseAPI: Ability {
167
167
return body
168
168
}
169
169
default :
170
- throw Error . WrongResponse
170
+ throw Error . WrongResponse ( response )
171
171
}
172
172
}
173
173
@@ -194,7 +194,7 @@ class OpenEnterpriseAPI: Ability {
194
194
return body
195
195
}
196
196
default :
197
- throw Error . WrongResponse
197
+ throw Error . WrongResponse ( response )
198
198
}
199
199
}
200
200
@@ -208,7 +208,8 @@ class OpenEnterpriseAPI: Ability {
208
208
" issuerId " : issuerId,
209
209
" attrNames " : [
210
210
" name " ,
211
- " age "
211
+ " age " ,
212
+ " gender "
212
213
]
213
214
]
214
215
@@ -230,7 +231,7 @@ class OpenEnterpriseAPI: Ability {
230
231
return body
231
232
}
232
233
default :
233
- throw Error . WrongResponse
234
+ throw Error . WrongResponse ( response )
234
235
}
235
236
}
236
237
@@ -244,7 +245,7 @@ class OpenEnterpriseAPI: Ability {
244
245
author: issuerId,
245
246
schemaId: " \( Config . agentUrl) /schema-registry/schemas/ \( anoncredSchemaGuid) /schema " ,
246
247
signatureType: " CL " ,
247
- supportRevocation: true
248
+ supportRevocation: false
248
249
)
249
250
250
251
let response = try await client!. createCredentialDefinition ( body: . json( anoncredDefinition) )
@@ -255,7 +256,7 @@ class OpenEnterpriseAPI: Ability {
255
256
return body
256
257
}
257
258
default :
258
- throw Error . WrongResponse
259
+ throw Error . WrongResponse ( response )
259
260
}
260
261
}
261
262
@@ -269,7 +270,7 @@ class OpenEnterpriseAPI: Ability {
269
270
return response
270
271
}
271
272
default :
272
- throw Error . WrongResponse
273
+ throw Error . WrongResponse ( response )
273
274
}
274
275
}
275
276
@@ -283,7 +284,7 @@ class OpenEnterpriseAPI: Ability {
283
284
return response
284
285
}
285
286
default :
286
- throw Error . WrongResponse
287
+ throw Error . WrongResponse ( response )
287
288
}
288
289
}
289
290
@@ -298,7 +299,7 @@ class OpenEnterpriseAPI: Ability {
298
299
return body
299
300
}
300
301
default :
301
- throw Error . WrongResponse
302
+ throw Error . WrongResponse ( response )
302
303
}
303
304
}
304
305
@@ -323,15 +324,16 @@ class OpenEnterpriseAPI: Ability {
323
324
return body
324
325
}
325
326
default :
326
- throw Error . WrongResponse
327
+ throw Error . WrongResponse ( response )
327
328
}
328
329
}
329
330
330
331
func offerAnonymousCredential( _ connectionId: String ) async throws -> Components . Schemas . IssueCredentialRecord {
331
332
var claims : OpenAPIValueContainer = try OpenAPIValueContainer ( )
332
333
claims. value = [
333
334
" name " : " automation " ,
334
- " age " : " 99 "
335
+ " age " : " 99 " ,
336
+ " gender " : " M "
335
337
]
336
338
337
339
let body = Components . Schemas. CreateIssueCredentialRecordRequest (
@@ -351,7 +353,7 @@ class OpenEnterpriseAPI: Ability {
351
353
return body
352
354
}
353
355
default :
354
- throw Error . WrongResponse
356
+ throw Error . WrongResponse ( response )
355
357
}
356
358
}
357
359
@@ -364,7 +366,7 @@ class OpenEnterpriseAPI: Ability {
364
366
return body
365
367
}
366
368
default :
367
- throw Error . WrongResponse
369
+ throw Error . WrongResponse ( response )
368
370
}
369
371
}
370
372
@@ -395,7 +397,55 @@ class OpenEnterpriseAPI: Ability {
395
397
return body
396
398
}
397
399
default :
398
- throw Error . WrongResponse
400
+ throw Error . WrongResponse ( response)
401
+ }
402
+ }
403
+
404
+ func requestAnonymousPresentProof( _ connectionId: String ) async throws -> Components . Schemas . PresentationStatus {
405
+ let credentialDefinitionUrl = Config . agentUrl + " /credential-definition-registry/definitions/ " + Config. anoncredDefinitionGuid + " /definition "
406
+ let anoncredPresentationRequest = Components . Schemas. AnoncredPresentationRequestV1 (
407
+ requested_attributes: . init( additionalProperties: [
408
+ " gender " : . init(
409
+ name: " gender " ,
410
+ restrictions: [
411
+ . init( additionalProperties: [
412
+ " attr::gender::value " : " M " ,
413
+ " cred_def_id " : credentialDefinitionUrl
414
+ ] )
415
+ ]
416
+ )
417
+ ] ) ,
418
+ requested_predicates: . init( additionalProperties: [
419
+ " age " : . init(
420
+ name: " age " ,
421
+ p_type: " > " ,
422
+ p_value: 18 ,
423
+ restrictions: [ ]
424
+ )
425
+ ] ) ,
426
+ name: " proof_req_1 " ,
427
+ nonce: Utils . generateNonce ( length: 25 ) ,
428
+ version: " 1.0 "
429
+ )
430
+
431
+ let body = Components . Schemas. RequestPresentationInput (
432
+ connectionId: connectionId,
433
+ options: nil ,
434
+ proofs: [ ] ,
435
+ anoncredPresentationRequest: anoncredPresentationRequest,
436
+ credentialFormat: " AnonCreds "
437
+ )
438
+
439
+ let response = try await client!. requestPresentation ( body: . json( body) )
440
+
441
+ switch ( response) {
442
+ case . created( let createdResponse) :
443
+ switch ( createdResponse. body) {
444
+ case . json( let body) :
445
+ return body
446
+ }
447
+ default :
448
+ throw Error . WrongResponse ( response)
399
449
}
400
450
}
401
451
@@ -408,12 +458,12 @@ class OpenEnterpriseAPI: Ability {
408
458
return body
409
459
}
410
460
default :
411
- throw Error . WrongResponse
461
+ throw Error . WrongResponse ( response )
412
462
}
413
463
}
414
464
415
- enum Error : Swift . Error , Equatable {
416
- case WrongResponse
465
+ enum Error : Swift . Error {
466
+ case WrongResponse( _ response : Any )
417
467
}
418
468
}
419
469
}
0 commit comments