@@ -2,13 +2,14 @@ import { vi, describe, it, expect, test, beforeEach, afterEach } from 'vitest';
2
2
import UUIDLib from "@stablelib/uuid" ;
3
3
import Agent from "../../../src/edge-agent/Agent" ;
4
4
import { AttachmentDescriptor , DID , MessageDirection , Seed } from "../../../src/domain" ;
5
- import { HandshakeRequest , OutOfBandInvitation , ProtocolType } from "../../../src" ;
5
+ import { HandshakeRequest , OfferCredential , OutOfBandInvitation , ProtocolType } from "../../../src" ;
6
6
import { InvitationIsInvalidError } from "../../../src/domain/models/errors/Agent" ;
7
7
import { mockPluto } from "../../fixtures/inmemory/factory" ;
8
8
import { mockTask } from "../../testFns" ;
9
9
import { StartMediator } from '../../../src/edge-agent/didcomm/StartMediator' ;
10
10
import { StartFetchingMessages } from '../../../src/edge-agent/didcomm/StartFetchingMessages' ;
11
11
import { MediatorConnection } from '../../../src/plugins/internal/didcomm' ;
12
+ import { CreateOOBOffer } from '../../../src/edge-agent/didcomm/CreateOOBOffer' ;
12
13
13
14
describe ( "Agent" , ( ) => {
14
15
let agent : Agent ;
@@ -64,6 +65,57 @@ describe("Agent", () => {
64
65
65
66
const encodeB64 = ( value : any ) => Buffer . from ( JSON . stringify ( value ) ) . toString ( "base64" ) ;
66
67
68
+ it ( "Should issue an oob invitation with a credential offer attachment" , async ( ) => {
69
+ const task = new CreateOOBOffer ( {
70
+ from : DID . fromString ( "did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjp7InVyaSI6Imh0dHA6Ly8xOTIuMTY4LjEuNDQ6ODA4MCIsImEiOlsiZGlkY29tbS92MiJdfX0.SeyJ0IjoiZG0iLCJzIjp7InVyaSI6IndzOi8vMTkyLjE2OC4xLjQ0OjgwODAvd3MiLCJhIjpbImRpZGNvbW0vdjIiXX19" ) ,
71
+ offer : new OfferCredential (
72
+ {
73
+ goal_code : "Offer Credential" ,
74
+ credential_preview : {
75
+ type : "https://didcomm.org/issue-credential/3.0/credential-credential" ,
76
+ body : {
77
+ attributes : [ { name : "familyName" , value : "Wonderland" } ] ,
78
+ } ,
79
+ } ,
80
+ } ,
81
+ [
82
+ new AttachmentDescriptor (
83
+ {
84
+ json : {
85
+ id : "8404678b-9a36-4989-af1d-0f445347e0e3" ,
86
+ media_type : "application/json" ,
87
+ data : {
88
+ json : {
89
+ options : {
90
+ challenge : "ad0f43ad-8538-41d4-9cb8-20967bc685bc" ,
91
+ domain : "domain" ,
92
+ } ,
93
+ presentation_definition : {
94
+ id : "748efa58-2bce-440d-921f-2520a8446663" ,
95
+ input_descriptors : [ ] ,
96
+ format : {
97
+ jwt : {
98
+ alg : [ "ES256K" ] ,
99
+ proof_type : [ ] ,
100
+ } ,
101
+ } ,
102
+ } ,
103
+ } ,
104
+ } ,
105
+ format : "prism/jwt" ,
106
+ } ,
107
+ } ,
108
+ "application/json" ,
109
+ )
110
+ ]
111
+ ) ,
112
+ } ) ;
113
+ const oob = await agent . runTask ( task ) ;
114
+ const url = `https://my.domain.com/path?_oob=${ oob } ` ;
115
+ const result = await agent . parseInvitation ( url ) ;
116
+ expect ( result ) . to . be . instanceOf ( OutOfBandInvitation ) ;
117
+ } ) ;
118
+
67
119
it ( "invitation - returns OutOfBandInvitation" , async ( ) => {
68
120
const oob = makeOOB ( ) ;
69
121
const url = `https://my.domain.com/path?_oob=${ encodeB64 ( oob ) } ` ;
0 commit comments