@@ -43,7 +43,8 @@ import {
43
43
NativeProver ,
44
44
VerifiableConstants ,
45
45
buildAccept ,
46
- AcceptProfile
46
+ AcceptProfile ,
47
+ createAuthorizationRequest
47
48
} from '../../src' ;
48
49
import { ProvingMethodAlg , Token } from '@iden3/js-jwz' ;
49
50
import { Blockchain , DID , DidMethod , NetworkId } from '@iden3/js-iden3-core' ;
@@ -172,23 +173,15 @@ describe('auth', () => {
172
173
circuits : [ AcceptAuthCircuits . AuthV2 ]
173
174
} ;
174
175
175
- const authReqBody : AuthorizationRequestMessageBody = {
176
- callbackUrl : 'http://localhost:8080/callback?id=1234442-123123-123123' ,
177
- reason : 'reason' ,
178
- message : 'message' ,
179
- accept : buildAccept ( [ profile ] ) ,
180
- scope : [ proofReq ]
181
- } ;
182
-
183
- const id = uuid . v4 ( ) ;
184
- const authReq : AuthorizationRequestMessage = {
185
- id,
186
- typ : PROTOCOL_CONSTANTS . MediaType . PlainMessage ,
187
- type : PROTOCOL_CONSTANTS . PROTOCOL_MESSAGE_TYPE . AUTHORIZATION_REQUEST_MESSAGE_TYPE ,
188
- thid : id ,
189
- body : authReqBody ,
190
- from : issuerDID . string ( )
191
- } ;
176
+ const authReq = createAuthorizationRequest (
177
+ 'reason' ,
178
+ issuerDID . string ( ) ,
179
+ 'http://localhost:8080/callback?id=1234442-123123-123123' ,
180
+ {
181
+ scope : [ proofReq ] ,
182
+ accept : buildAccept ( [ profile ] )
183
+ }
184
+ ) ;
192
185
193
186
const msgBytes = byteEncoder . encode ( JSON . stringify ( authReq ) ) ;
194
187
const authRes = await authHandler . handleAuthorizationRequest ( userDID , msgBytes ) ;
@@ -836,19 +829,6 @@ describe('auth', () => {
836
829
const userId = 'did:polygonid:polygon:mumbai:2qPDLXDaU1xa1ERTb1XKBfPCB3o2wA46q49neiXWwY' ;
837
830
const reason = 'test' ;
838
831
const message = 'message to sign' ;
839
- const request : AuthorizationRequestMessage = createAuthorizationRequestWithMessage (
840
- reason ,
841
- message ,
842
- sender ,
843
- callback
844
- ) ;
845
- expect ( request . body . scope . length ) . to . be . eq ( 0 ) ;
846
- expect ( request . body . callbackUrl ) . to . be . eq ( callback ) ;
847
- expect ( request . body . reason ) . to . be . eq ( reason ) ;
848
- expect ( request . from ) . to . be . eq ( sender ) ;
849
-
850
- request . thid = '7f38a193-0918-4a48-9fac-36adfdb8b542' ;
851
-
852
832
const proofRequest : ZeroKnowledgeProofRequest = {
853
833
id : 23 ,
854
834
circuitId : CircuitId . AtomicQueryMTPV2 ,
@@ -864,10 +844,20 @@ describe('auth', () => {
864
844
}
865
845
}
866
846
} ;
867
- request . body . scope . push ( proofRequest ) ;
868
-
847
+ const request : AuthorizationRequestMessage = createAuthorizationRequestWithMessage (
848
+ reason ,
849
+ message ,
850
+ sender ,
851
+ callback ,
852
+ {
853
+ scope : [ proofRequest ]
854
+ }
855
+ ) ;
869
856
expect ( request . body . scope . length ) . to . be . eq ( 1 ) ;
870
-
857
+ expect ( request . body . callbackUrl ) . to . be . eq ( callback ) ;
858
+ expect ( request . body . reason ) . to . be . eq ( reason ) ;
859
+ expect ( request . from ) . to . be . eq ( sender ) ;
860
+ request . thid = '7f38a193-0918-4a48-9fac-36adfdb8b542' ;
871
861
const mtpProof : ZeroKnowledgeProofResponse = {
872
862
id : proofRequest . id ,
873
863
circuitId : 'credentialAtomicQueryMTPV2' ,
0 commit comments