@@ -472,133 +472,6 @@ export class Credentials {
472
472
op,
473
473
} ;
474
474
}
475
-
476
- /**
477
- * Present a credential
478
- * @async
479
- * @param {string } name Name or alias of the identifier
480
- * @param {string } said SAID of the credential
481
- * @param {string } recipient Identifier prefix of the receiver of the presentation
482
- * @param {boolean } [include=true] Flag to indicate whether to stream credential alongside presentation exchange message
483
- * @returns {Promise<string> } A promise to the long-running operation
484
- */
485
- async present (
486
- name : string ,
487
- said : string ,
488
- recipient : string ,
489
- include : boolean = true
490
- ) : Promise < string > {
491
- const hab = await this . client . identifiers ( ) . get ( name ) ;
492
- const pre : string = hab . prefix ;
493
-
494
- const cred = await this . get ( said ) ;
495
- const data = {
496
- i : cred . sad . i ,
497
- s : cred . sad . s ,
498
- n : said ,
499
- } ;
500
-
501
- const vs = versify ( Ident . KERI , undefined , Serials . JSON , 0 ) ;
502
-
503
- const _sad = {
504
- v : vs ,
505
- t : Ilks . exn ,
506
- d : '' ,
507
- dt : new Date ( ) . toISOString ( ) . replace ( 'Z' , '000+00:00' ) ,
508
- r : '/presentation' ,
509
- q : { } ,
510
- a : data ,
511
- } ;
512
- const [ , sad ] = Saider . saidify ( _sad ) ;
513
- const exn = new Serder ( sad ) ;
514
-
515
- const keeper = this . client ! . manager ! . get ( hab ) ;
516
-
517
- const sig = await keeper . sign ( b ( exn . raw ) , true ) ;
518
-
519
- const siger = new Siger ( { qb64 : sig [ 0 ] } ) ;
520
- const seal = [ 'SealLast' , { i : pre } ] ;
521
- let ims = messagize ( exn , [ siger ] , seal , undefined , undefined , true ) ;
522
- ims = ims . slice ( JSON . stringify ( exn . ked ) . length ) ;
523
-
524
- const body = {
525
- exn : exn . ked ,
526
- sig : new TextDecoder ( ) . decode ( ims ) ,
527
- recipient : recipient ,
528
- include : include ,
529
- } ;
530
-
531
- const path = `/identifiers/${ name } /credentials/${ said } /presentations` ;
532
- const method = 'POST' ;
533
- const headers = new Headers ( {
534
- Accept : 'application/json+cesr' ,
535
- } ) ;
536
- const res = await this . client . fetch ( path , method , body , headers ) ;
537
- return await res . text ( ) ;
538
- }
539
-
540
- /**
541
- * Request a presentation of a credential
542
- * @async
543
- * @param {string } name Name or alias of the identifier
544
- * @param {string } recipient Identifier prefix of the receiver of the presentation
545
- * @param {string } schema SAID of the schema
546
- * @param {string } [issuer] Optional prefix of the issuer of the credential
547
- * @returns {Promise<string> } A promise to the long-running operation
548
- */
549
- async request (
550
- name : string ,
551
- recipient : string ,
552
- schema : string ,
553
- issuer ?: string
554
- ) : Promise < string > {
555
- const hab = await this . client . identifiers ( ) . get ( name ) ;
556
- const pre : string = hab . prefix ;
557
-
558
- const data : any = {
559
- s : schema ,
560
- } ;
561
- if ( issuer !== undefined ) {
562
- data [ 'i' ] = issuer ;
563
- }
564
-
565
- const vs = versify ( Ident . KERI , undefined , Serials . JSON , 0 ) ;
566
-
567
- const _sad = {
568
- v : vs ,
569
- t : Ilks . exn ,
570
- d : '' ,
571
- dt : new Date ( ) . toISOString ( ) . replace ( 'Z' , '000+00:00' ) ,
572
- r : '/presentation/request' ,
573
- q : { } ,
574
- a : data ,
575
- } ;
576
- const [ , sad ] = Saider . saidify ( _sad ) ;
577
- const exn = new Serder ( sad ) ;
578
-
579
- const keeper = this . client ! . manager ! . get ( hab ) ;
580
-
581
- const sig = await keeper . sign ( b ( exn . raw ) , true ) ;
582
-
583
- const siger = new Siger ( { qb64 : sig [ 0 ] } ) ;
584
- const seal = [ 'SealLast' , { i : pre } ] ;
585
- let ims = messagize ( exn , [ siger ] , seal , undefined , undefined , true ) ;
586
- ims = ims . slice ( JSON . stringify ( exn . ked ) . length ) ;
587
-
588
- const body = {
589
- exn : exn . ked ,
590
- sig : new TextDecoder ( ) . decode ( ims ) ,
591
- recipient : recipient ,
592
- } ;
593
-
594
- const path = `/identifiers/${ name } /requests` ;
595
- const method = 'POST' ;
596
- const headers = new Headers ( {
597
- Accept : 'application/json+cesr' ,
598
- } ) ;
599
- const res = await this . client . fetch ( path , method , body , headers ) ;
600
- return await res . text ( ) ;
601
- }
602
475
}
603
476
604
477
export interface CreateRegistryArgs {
0 commit comments