1- const { JWE , JWS , JWK } = require ( '@panva/ jose' )
1+ const { JWE , JWS , JWK } = require ( 'jose' )
22const data = require ( '../lib/data' )
33const { generateKey, toPublicKey } = require ( '../lib/crypto' )
44const { verify } = require ( '../lib/jwt' )
@@ -58,7 +58,7 @@ describe('data', () => {
5858 await write ( connectionId , { domain, area, data : payload } )
5959
6060 expect ( tokens . createWriteDataToken ) . toHaveBeenCalledWith (
61- connectionId , [ { domain, area, data : expect . any ( Object ) } ]
61+ connectionId , [ { domain, area, data : expect . any ( Object ) } ]
6262 )
6363 } )
6464 it ( 'creates a token with the correct arguments without domain' , async ( ) => {
@@ -109,22 +109,22 @@ describe('data', () => {
109109 tokens . send . mockResolvedValue ( 'read.response.token' )
110110 verify . mockImplementation ( ( ) => ( {
111111 payload : {
112- paths : [ { domain, area, data : createJWE ( data ) } ]
112+ paths : [ { domain, area, data : createJWE ( data ) } ]
113113 }
114114 } ) )
115115 } )
116116 it ( 'creates a token with the correct arguments' , async ( ) => {
117117 await read ( connectionId , { domain, area } )
118118
119119 expect ( tokens . createReadDataToken ) . toHaveBeenCalledWith (
120- connectionId , [ { domain, area } ]
120+ connectionId , [ { domain, area } ]
121121 )
122122 } )
123123 it ( 'creates a token with the correct arguments without domain' , async ( ) => {
124124 await read ( connectionId , { area } )
125125
126126 expect ( tokens . createReadDataToken ) . toHaveBeenCalledWith (
127- connectionId , [ { domain : config . clientId , area } ]
127+ connectionId , [ { domain : config . clientId , area } ]
128128 )
129129 } )
130130 it ( 'creates a token with the correct arguments with multiple paths' , async ( ) => {
@@ -166,22 +166,22 @@ describe('data', () => {
166166 tokens . send . mockResolvedValue ( 'read.response.token' )
167167 verify . mockImplementation ( ( ) => ( {
168168 payload : {
169- paths : [ { domain, area } ]
169+ paths : [ { domain, area } ]
170170 }
171171 } ) )
172172 } )
173173 it ( 'creates a token with the correct arguments' , async ( ) => {
174174 await read ( connectionId , { domain, area } )
175175
176176 expect ( tokens . createReadDataToken ) . toHaveBeenCalledWith (
177- connectionId , [ { domain, area } ]
177+ connectionId , [ { domain, area } ]
178178 )
179179 } )
180180 it ( 'creates a token with the correct arguments without domain' , async ( ) => {
181181 await read ( connectionId , { area } )
182182
183183 expect ( tokens . createReadDataToken ) . toHaveBeenCalledWith (
184- connectionId , [ { domain : config . clientId , area } ]
184+ connectionId , [ { domain : config . clientId , area } ]
185185 )
186186 } )
187187 it ( 'posts to operator' , async ( ) => {
@@ -215,14 +215,14 @@ describe('data', () => {
215215 await auth ( accessToken ) . write ( { domain, area, data : payload } )
216216
217217 expect ( tokens . createWriteDataToken ) . toHaveBeenCalledWith (
218- connectionId , [ { domain, area, data : expect . any ( Object ) } ]
218+ connectionId , [ { domain, area, data : expect . any ( Object ) } ]
219219 )
220220 } )
221221 it ( 'creates a token with the correct arguments without domain' , async ( ) => {
222222 await auth ( accessToken ) . write ( { area, data : payload } )
223223
224224 expect ( tokens . createWriteDataToken ) . toHaveBeenCalledWith (
225- connectionId , [ { domain : config . clientId , area, data : expect . any ( Object ) } ]
225+ connectionId , [ { domain : config . clientId , area, data : expect . any ( Object ) } ]
226226 )
227227 } )
228228 it ( 'posts to operator' , async ( ) => {
@@ -254,9 +254,11 @@ describe('data', () => {
254254 case 'access.token' :
255255 return { payload : { sub : connectionId } }
256256 case 'read.response.token' :
257- return { payload : {
258- paths : [ { domain, area, data : createJWE ( data ) } ]
259- } }
257+ return {
258+ payload : {
259+ paths : [ { domain, area, data : createJWE ( data ) } ]
260+ }
261+ }
260262 default :
261263 throw new Error ( 'Unmocked token' )
262264 }
@@ -271,14 +273,14 @@ describe('data', () => {
271273 await auth ( accessToken ) . read ( { domain, area } )
272274
273275 expect ( tokens . createReadDataToken ) . toHaveBeenCalledWith (
274- connectionId , [ { domain, area } ]
276+ connectionId , [ { domain, area } ]
275277 )
276278 } )
277279 it ( 'creates a token with the correct arguments without domain' , async ( ) => {
278280 await auth ( accessToken ) . read ( { area } )
279281
280282 expect ( tokens . createReadDataToken ) . toHaveBeenCalledWith (
281- connectionId , [ { domain : config . clientId , area } ]
283+ connectionId , [ { domain : config . clientId , area } ]
282284 )
283285 } )
284286 it ( 'posts to operator' , async ( ) => {
@@ -313,7 +315,7 @@ describe('data', () => {
313315 case 'access.token' :
314316 return { payload : { sub : connectionId } }
315317 case 'read.response.token' :
316- return { payload : { paths : [ { domain, area } ] } }
318+ return { payload : { paths : [ { domain, area } ] } }
317319 default :
318320 throw new Error ( 'Unmocked token' )
319321 }
@@ -328,14 +330,14 @@ describe('data', () => {
328330 await auth ( accessToken ) . read ( { domain, area } )
329331
330332 expect ( tokens . createReadDataToken ) . toHaveBeenCalledWith (
331- connectionId , [ { domain, area } ]
333+ connectionId , [ { domain, area } ]
332334 )
333335 } )
334336 it ( 'creates a token with the correct arguments without domain' , async ( ) => {
335337 await auth ( accessToken ) . read ( { area } )
336338
337339 expect ( tokens . createReadDataToken ) . toHaveBeenCalledWith (
338- connectionId , [ { domain : config . clientId , area } ]
340+ connectionId , [ { domain : config . clientId , area } ]
339341 )
340342 } )
341343 it ( 'posts to operator' , async ( ) => {
0 commit comments