@@ -356,257 +356,6 @@ const SerializedSignatureSchema = z
356
356
} )
357
357
. strict ( ) ;
358
358
359
- // Private Credentials: Node schemas
360
-
361
- type Node =
362
- | { type : "owner" }
363
- | { type : "issuer" ; credentialKey : string }
364
- | { type : "constant" ; data : z . infer < typeof SerializedValueSchema > }
365
- | { type : "root" }
366
- | { type : "property" ; key : string ; inner : Node }
367
- | { type : "record" ; data : Record < string , Node > }
368
- | { type : "equals" ; left : Node ; right : Node }
369
- | { type : "equalsOneOf" ; input : Node ; options : Node [ ] | Node }
370
- | { type : "lessThan" ; left : Node ; right : Node }
371
- | { type : "lessThanEq" ; left : Node ; right : Node }
372
- | { type : "add" ; left : Node ; right : Node }
373
- | { type : "sub" ; left : Node ; right : Node }
374
- | { type : "mul" ; left : Node ; right : Node }
375
- | { type : "div" ; left : Node ; right : Node }
376
- | { type : "and" ; inputs : Node [ ] }
377
- | { type : "or" ; left : Node ; right : Node }
378
- | { type : "not" ; inner : Node }
379
- | { type : "hash" ; inputs : Node [ ] ; prefix ?: string | null }
380
- | { type : "ifThenElse" ; condition : Node ; thenNode : Node ; elseNode : Node } ;
381
-
382
- const NodeSchema : z . ZodType < Node > = z . lazy ( ( ) =>
383
- z . discriminatedUnion ( "type" , [
384
- z
385
- . object ( {
386
- type : z . literal ( "owner" ) ,
387
- } )
388
- . strict ( ) ,
389
-
390
- z
391
- . object ( {
392
- type : z . literal ( "issuer" ) ,
393
- credentialKey : z . string ( ) ,
394
- } )
395
- . strict ( ) ,
396
-
397
- z
398
- . object ( {
399
- type : z . literal ( "constant" ) ,
400
- data : SerializedValueSchema ,
401
- } )
402
- . strict ( ) ,
403
-
404
- z
405
- . object ( {
406
- type : z . literal ( "root" ) ,
407
- } )
408
- . strict ( ) ,
409
-
410
- z
411
- . object ( {
412
- type : z . literal ( "property" ) ,
413
- key : z . string ( ) ,
414
- inner : NodeSchema ,
415
- } )
416
- . strict ( ) ,
417
-
418
- z
419
- . object ( {
420
- type : z . literal ( "record" ) ,
421
- data : z . record ( NodeSchema ) ,
422
- } )
423
- . strict ( ) ,
424
-
425
- z
426
- . object ( {
427
- type : z . literal ( "equals" ) ,
428
- left : NodeSchema ,
429
- right : NodeSchema ,
430
- } )
431
- . strict ( ) ,
432
-
433
- z
434
- . object ( {
435
- type : z . literal ( "equalsOneOf" ) ,
436
- input : NodeSchema ,
437
- options : z . union ( [
438
- z . array ( NodeSchema ) , // For array of nodes case
439
- NodeSchema ,
440
- ] ) ,
441
- } )
442
- . strict ( ) ,
443
-
444
- z
445
- . object ( {
446
- type : z . literal ( "lessThan" ) ,
447
- left : NodeSchema ,
448
- right : NodeSchema ,
449
- } )
450
- . strict ( ) ,
451
-
452
- z
453
- . object ( {
454
- type : z . literal ( "lessThanEq" ) ,
455
- left : NodeSchema ,
456
- right : NodeSchema ,
457
- } )
458
- . strict ( ) ,
459
-
460
- z
461
- . object ( {
462
- type : z . literal ( "add" ) ,
463
- left : NodeSchema ,
464
- right : NodeSchema ,
465
- } )
466
- . strict ( ) ,
467
-
468
- z
469
- . object ( {
470
- type : z . literal ( "sub" ) ,
471
- left : NodeSchema ,
472
- right : NodeSchema ,
473
- } )
474
- . strict ( ) ,
475
-
476
- z
477
- . object ( {
478
- type : z . literal ( "mul" ) ,
479
- left : NodeSchema ,
480
- right : NodeSchema ,
481
- } )
482
- . strict ( ) ,
483
-
484
- z
485
- . object ( {
486
- type : z . literal ( "div" ) ,
487
- left : NodeSchema ,
488
- right : NodeSchema ,
489
- } )
490
- . strict ( ) ,
491
-
492
- z
493
- . object ( {
494
- type : z . literal ( "and" ) ,
495
- inputs : z . array ( NodeSchema ) ,
496
- } )
497
- . strict ( ) ,
498
-
499
- z
500
- . object ( {
501
- type : z . literal ( "or" ) ,
502
- left : NodeSchema ,
503
- right : NodeSchema ,
504
- } )
505
- . strict ( ) ,
506
-
507
- z
508
- . object ( {
509
- type : z . literal ( "not" ) ,
510
- inner : NodeSchema ,
511
- } )
512
- . strict ( ) ,
513
-
514
- z
515
- . object ( {
516
- type : z . literal ( "hash" ) ,
517
- inputs : z . array ( NodeSchema ) ,
518
- prefix : z . union ( [ z . string ( ) , z . null ( ) ] ) . optional ( ) ,
519
- } )
520
- . strict ( ) ,
521
-
522
- z
523
- . object ( {
524
- type : z . literal ( "ifThenElse" ) ,
525
- condition : NodeSchema ,
526
- thenNode : NodeSchema ,
527
- elseNode : NodeSchema ,
528
- } )
529
- . strict ( ) ,
530
- ] ) ,
531
- ) ;
532
-
533
- // Private Credentials: Input Schema
534
-
535
- const InputSchema = z . discriminatedUnion ( "type" , [
536
- z
537
- . object ( {
538
- type : z . literal ( "credential" ) ,
539
- credentialType : z . union ( [
540
- z . literal ( "simple" ) ,
541
- z . literal ( "unsigned" ) ,
542
- z . literal ( "recursive" ) ,
543
- ] ) ,
544
- witness : z . union ( [ z . record ( SerializedTypeSchema ) , SerializedTypeSchema ] ) ,
545
- data : z . union ( [ z . record ( SerializedTypeSchema ) , SerializedTypeSchema ] ) ,
546
- } )
547
- . strict ( ) ,
548
-
549
- z
550
- . object ( {
551
- type : z . literal ( "constant" ) ,
552
- data : SerializedTypeSchema ,
553
- value : z . union ( [ z . string ( ) , z . record ( z . string ( ) ) ] ) ,
554
- } )
555
- . strict ( ) ,
556
-
557
- z
558
- . object ( {
559
- type : z . literal ( "claim" ) ,
560
- data : z . union ( [ z . record ( SerializedTypeSchema ) , SerializedTypeSchema ] ) ,
561
- } )
562
- . strict ( ) ,
563
- ] ) ;
564
-
565
- // Private Credentials: Context schemas
566
-
567
- const HttpsContextSchema = z
568
- . object ( {
569
- type : z . literal ( "https" ) ,
570
- action : z . string ( ) ,
571
- serverNonce : SerializedFieldSchema ,
572
- } )
573
- . strict ( ) ;
574
-
575
- const ZkAppContextSchema = z
576
- . object ( {
577
- type : z . literal ( "zk-app" ) ,
578
- action : SerializedFieldSchema ,
579
- serverNonce : SerializedFieldSchema ,
580
- } )
581
- . strict ( ) ;
582
-
583
- const ContextSchema = z . union ( [ HttpsContextSchema , ZkAppContextSchema ] ) ;
584
-
585
- // Private Credentials: PresentationRequestSchema
586
-
587
- export const PresentationRequestSchema = z
588
- . object ( {
589
- type : z . union ( [
590
- z . literal ( "no-context" ) ,
591
- z . literal ( "zk-app" ) ,
592
- z . literal ( "https" ) ,
593
- ] ) ,
594
- spec : z
595
- . object ( {
596
- inputs : z . record ( InputSchema ) ,
597
- logic : z
598
- . object ( {
599
- assert : NodeSchema ,
600
- outputClaim : NodeSchema ,
601
- } )
602
- . strict ( ) ,
603
- } )
604
- . strict ( ) ,
605
- claims : z . record ( SerializedValueSchema ) ,
606
- inputContext : z . union ( [ ContextSchema , z . null ( ) ] ) ,
607
- } )
608
- . strict ( ) ;
609
-
610
359
// Private Credentials: Witness Schemas
611
360
612
361
const SimpleWitnessSchema = z
0 commit comments