@whook/oauth2 12.1.0 → 13.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -10
- package/dist/handlers/getOAuth2Authorize.d.ts +2 -3
- package/dist/handlers/getOAuth2Authorize.js.map +1 -1
- package/dist/handlers/getOAuth2Authorize.test.js +1 -0
- package/dist/handlers/getOAuth2Authorize.test.js.map +1 -1
- package/dist/handlers/postAuthLogin.d.ts +2 -2
- package/dist/handlers/postAuthLogin.test.js +1 -0
- package/dist/handlers/postAuthLogin.test.js.map +1 -1
- package/dist/handlers/postAuthRefresh.d.ts +2 -2
- package/dist/handlers/postAuthRefresh.test.js +1 -0
- package/dist/handlers/postAuthRefresh.test.js.map +1 -1
- package/dist/handlers/postOAuth2Acknowledge.d.ts +1 -1
- package/dist/handlers/postOAuth2Acknowledge.js.map +1 -1
- package/dist/handlers/postOAuth2Token.d.ts +4 -4
- package/dist/handlers/postOAuth2Token.js.map +1 -1
- package/dist/index.test.js +222 -152
- package/dist/index.test.js.map +1 -1
- package/dist/services/oAuth2ClientCredentialsGranter.d.ts +2 -2
- package/dist/services/oAuth2CodeGranter.d.ts +1 -1
- package/dist/services/oAuth2Granters.js +0 -1
- package/dist/services/oAuth2Granters.js.map +1 -1
- package/dist/services/oAuth2PasswordGranter.d.ts +1 -1
- package/dist/services/oAuth2RefreshTokenGranter.d.ts +1 -1
- package/dist/services/oAuth2TokenGranter.d.ts +1 -1
- package/package.json +42 -40
- package/src/handlers/getOAuth2Authorize.test.ts +1 -0
- package/src/handlers/getOAuth2Authorize.ts +1 -1
- package/src/handlers/postAuthLogin.test.ts +1 -0
- package/src/handlers/postAuthRefresh.test.ts +1 -0
- package/src/handlers/postOAuth2Acknowledge.ts +1 -1
- package/src/handlers/postOAuth2Token.ts +1 -1
- package/src/index.test.ts +234 -164
- package/src/services/oAuth2ClientCredentialsGranter.ts +1 -1
- package/src/services/oAuth2Granters.ts +0 -1
package/src/index.test.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import {
|
|
2
3
|
describe,
|
|
3
4
|
it,
|
|
@@ -12,13 +13,14 @@ import {
|
|
|
12
13
|
prepareServer,
|
|
13
14
|
prepareEnvironment as basePrepareEnvironment,
|
|
14
15
|
DEFAULT_ERRORS_DESCRIPTORS,
|
|
16
|
+
initWrappers,
|
|
17
|
+
initHandlers,
|
|
15
18
|
} from '@whook/whook';
|
|
16
19
|
import {
|
|
17
20
|
AUTHORIZATION_ERRORS_DESCRIPTORS,
|
|
18
|
-
|
|
19
|
-
wrapHandlerWithAuthorization,
|
|
21
|
+
initWrapHandlerWithAuthorization,
|
|
20
22
|
} from '@whook/authorization';
|
|
21
|
-
import { constant, initializer } from 'knifecycle';
|
|
23
|
+
import { alsoInject, constant, initializer } from 'knifecycle';
|
|
22
24
|
import axios from 'axios';
|
|
23
25
|
import { YError } from 'yerror';
|
|
24
26
|
import {
|
|
@@ -61,7 +63,10 @@ import type {
|
|
|
61
63
|
import type { Knifecycle } from 'knifecycle';
|
|
62
64
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
63
65
|
import type { Logger } from 'common-services';
|
|
64
|
-
import type {
|
|
66
|
+
import type {
|
|
67
|
+
AuthenticationService,
|
|
68
|
+
BaseAuthenticationData,
|
|
69
|
+
} from '@whook/authorization';
|
|
65
70
|
|
|
66
71
|
type CustomAuthenticationData = BaseAuthenticationData & {
|
|
67
72
|
userId: string;
|
|
@@ -198,16 +203,26 @@ describe('OAuth2 server', () => {
|
|
|
198
203
|
);
|
|
199
204
|
$.register(constant('BASE_PATH', BASE_PATH));
|
|
200
205
|
$.register(constant('API', API));
|
|
201
|
-
$.register(constant('
|
|
202
|
-
$.register(
|
|
206
|
+
$.register(constant('APP_ENV', 'local'));
|
|
207
|
+
$.register(
|
|
208
|
+
constant('ENV', {
|
|
209
|
+
NODE_ENV: 'test',
|
|
210
|
+
}),
|
|
211
|
+
);
|
|
203
212
|
$.register(constant('PORT', PORT));
|
|
204
213
|
$.register(constant('HOST', HOST));
|
|
205
214
|
$.register(constant('DEBUG_NODE_ENVS', []));
|
|
206
|
-
$.register(constant('NODE_ENVS', ['test']));
|
|
207
215
|
$.register(constant('MECHANISMS', [BEARER_MECHANISM, BASIC_MECHANISM]));
|
|
208
216
|
$.register(constant('logger', logger as Logger));
|
|
209
217
|
$.register(constant('time', time));
|
|
210
218
|
|
|
219
|
+
// Auth
|
|
220
|
+
const HANDLERS_WRAPPERS = ['wrapHandlerWithAuthorization'];
|
|
221
|
+
|
|
222
|
+
$.register(initWrapHandlerWithAuthorization);
|
|
223
|
+
$.register(alsoInject(HANDLERS_WRAPPERS, initWrappers));
|
|
224
|
+
$.register(constant('HANDLERS_WRAPPERS', HANDLERS_WRAPPERS));
|
|
225
|
+
|
|
211
226
|
// OAuth2 Specifics
|
|
212
227
|
$.register(constant('OAUTH2', OAUTH2));
|
|
213
228
|
$.register(
|
|
@@ -218,18 +233,9 @@ describe('OAuth2 server', () => {
|
|
|
218
233
|
}),
|
|
219
234
|
);
|
|
220
235
|
$.register(
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
type: 'service',
|
|
225
|
-
inject: [
|
|
226
|
-
'getOAuth2Authorize',
|
|
227
|
-
'postOAuth2Acknowledge',
|
|
228
|
-
'postOAuth2Token',
|
|
229
|
-
],
|
|
230
|
-
singleton: true,
|
|
231
|
-
},
|
|
232
|
-
async (services) => services,
|
|
236
|
+
alsoInject(
|
|
237
|
+
['getOAuth2Authorize', 'postOAuth2Acknowledge', 'postOAuth2Token'],
|
|
238
|
+
initHandlers,
|
|
233
239
|
),
|
|
234
240
|
);
|
|
235
241
|
$.register(constant('authentication', authentication));
|
|
@@ -240,15 +246,15 @@ describe('OAuth2 server', () => {
|
|
|
240
246
|
$.register(constant('oAuth2Password', oAuth2Password));
|
|
241
247
|
[
|
|
242
248
|
initGetOAuth2Authorize,
|
|
243
|
-
|
|
244
|
-
|
|
249
|
+
initPostOAuth2Acknowledge,
|
|
250
|
+
initPostOAuth2Token,
|
|
245
251
|
initOAuth2Granters,
|
|
246
252
|
initOAuth2ClientCredentialsGranter,
|
|
247
253
|
initOAuth2CodeGranter,
|
|
248
254
|
initOAuth2PasswordGranter,
|
|
249
255
|
initOAuth2RefreshTokenGranter,
|
|
250
256
|
initOAuth2TokenGranter,
|
|
251
|
-
].forEach((handlerInitializer) => $.register(handlerInitializer));
|
|
257
|
+
].forEach((handlerInitializer) => $.register(handlerInitializer as any));
|
|
252
258
|
|
|
253
259
|
return $;
|
|
254
260
|
}
|
|
@@ -352,31 +358,39 @@ describe('OAuth2 server', () => {
|
|
|
352
358
|
...headers,
|
|
353
359
|
// Erasing the Date header that may be added by Axios :/
|
|
354
360
|
date: undefined,
|
|
361
|
+
etag: undefined,
|
|
362
|
+
'last-modified': undefined,
|
|
363
|
+
server: undefined,
|
|
364
|
+
connection: undefined,
|
|
365
|
+
'keep-alive': undefined,
|
|
355
366
|
},
|
|
356
|
-
|
|
357
367
|
data,
|
|
358
368
|
}).toMatchInlineSnapshot(`
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
369
|
+
{
|
|
370
|
+
"data": {
|
|
371
|
+
"access_token": "an_access_token",
|
|
372
|
+
"expiration_date": "2010-03-07T00:00:00.000Z",
|
|
373
|
+
"expires_in": 86400,
|
|
374
|
+
"refresh_token": "a_refresh_token",
|
|
375
|
+
"refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
|
|
376
|
+
"refresh_token_expires_in": 5364748800,
|
|
377
|
+
"token_type": "bearer",
|
|
378
|
+
},
|
|
379
|
+
"headers": {
|
|
380
|
+
"connection": undefined,
|
|
381
|
+
"content-type": "application/json",
|
|
382
|
+
"date": undefined,
|
|
383
|
+
"etag": undefined,
|
|
384
|
+
"keep-alive": undefined,
|
|
385
|
+
"last-modified": undefined,
|
|
386
|
+
"server": undefined,
|
|
387
|
+
"transaction-id": "0",
|
|
388
|
+
"transfer-encoding": "chunked",
|
|
389
|
+
"x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
|
|
390
|
+
},
|
|
391
|
+
"status": 200,
|
|
392
|
+
}
|
|
393
|
+
`);
|
|
380
394
|
expect({
|
|
381
395
|
checkApplicationCalls: checkApplication.mock.calls,
|
|
382
396
|
authenticationCheckCalls: authentication.check.mock.calls,
|
|
@@ -449,31 +463,39 @@ describe('OAuth2 server', () => {
|
|
|
449
463
|
...headers,
|
|
450
464
|
// Erasing the Date header that may be added by Axios :/
|
|
451
465
|
date: undefined,
|
|
466
|
+
etag: undefined,
|
|
467
|
+
'last-modified': undefined,
|
|
468
|
+
server: undefined,
|
|
469
|
+
connection: undefined,
|
|
470
|
+
'keep-alive': undefined,
|
|
452
471
|
},
|
|
453
|
-
|
|
454
472
|
data,
|
|
455
473
|
}).toMatchInlineSnapshot(`
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
474
|
+
{
|
|
475
|
+
"data": {
|
|
476
|
+
"access_token": "an_access_token",
|
|
477
|
+
"expiration_date": "2010-03-07T00:00:00.000Z",
|
|
478
|
+
"expires_in": 86400,
|
|
479
|
+
"refresh_token": "a_refresh_token",
|
|
480
|
+
"refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
|
|
481
|
+
"refresh_token_expires_in": 5364748800,
|
|
482
|
+
"token_type": "bearer",
|
|
483
|
+
},
|
|
484
|
+
"headers": {
|
|
485
|
+
"connection": undefined,
|
|
486
|
+
"content-type": "application/json",
|
|
487
|
+
"date": undefined,
|
|
488
|
+
"etag": undefined,
|
|
489
|
+
"keep-alive": undefined,
|
|
490
|
+
"last-modified": undefined,
|
|
491
|
+
"server": undefined,
|
|
492
|
+
"transaction-id": "1",
|
|
493
|
+
"transfer-encoding": "chunked",
|
|
494
|
+
"x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
|
|
495
|
+
},
|
|
496
|
+
"status": 200,
|
|
497
|
+
}
|
|
498
|
+
`);
|
|
477
499
|
expect({
|
|
478
500
|
checkApplicationCalls: checkApplication.mock.calls,
|
|
479
501
|
authenticationCheckCalls: authentication.check.mock.calls,
|
|
@@ -541,31 +563,39 @@ describe('OAuth2 server', () => {
|
|
|
541
563
|
...headers,
|
|
542
564
|
// Erasing the Date header that may be added by Axios :/
|
|
543
565
|
date: undefined,
|
|
566
|
+
etag: undefined,
|
|
567
|
+
'last-modified': undefined,
|
|
568
|
+
server: undefined,
|
|
569
|
+
connection: undefined,
|
|
570
|
+
'keep-alive': undefined,
|
|
544
571
|
},
|
|
545
|
-
|
|
546
572
|
data,
|
|
547
573
|
}).toMatchInlineSnapshot(`
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
574
|
+
{
|
|
575
|
+
"data": {
|
|
576
|
+
"access_token": "an_access_token",
|
|
577
|
+
"expiration_date": "2010-03-07T00:00:00.000Z",
|
|
578
|
+
"expires_in": 86400,
|
|
579
|
+
"refresh_token": "a_refresh_token",
|
|
580
|
+
"refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
|
|
581
|
+
"refresh_token_expires_in": 5364748800,
|
|
582
|
+
"token_type": "bearer",
|
|
583
|
+
},
|
|
584
|
+
"headers": {
|
|
585
|
+
"connection": undefined,
|
|
586
|
+
"content-type": "application/json",
|
|
587
|
+
"date": undefined,
|
|
588
|
+
"etag": undefined,
|
|
589
|
+
"keep-alive": undefined,
|
|
590
|
+
"last-modified": undefined,
|
|
591
|
+
"server": undefined,
|
|
592
|
+
"transaction-id": "2",
|
|
593
|
+
"transfer-encoding": "chunked",
|
|
594
|
+
"x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
|
|
595
|
+
},
|
|
596
|
+
"status": 200,
|
|
597
|
+
}
|
|
598
|
+
`);
|
|
569
599
|
expect({
|
|
570
600
|
checkApplicationCalls: checkApplication.mock.calls,
|
|
571
601
|
authenticationCheckCalls: authentication.check.mock.calls,
|
|
@@ -624,22 +654,30 @@ describe('OAuth2 server', () => {
|
|
|
624
654
|
...headers,
|
|
625
655
|
// Erasing the Date header that may be added by Axios :/
|
|
626
656
|
date: undefined,
|
|
657
|
+
etag: undefined,
|
|
658
|
+
'last-modified': undefined,
|
|
659
|
+
server: undefined,
|
|
660
|
+
connection: undefined,
|
|
661
|
+
'keep-alive': undefined,
|
|
627
662
|
},
|
|
628
|
-
|
|
629
663
|
data,
|
|
630
664
|
}).toMatchInlineSnapshot(`
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
665
|
+
{
|
|
666
|
+
"data": "",
|
|
667
|
+
"headers": {
|
|
668
|
+
"connection": undefined,
|
|
669
|
+
"date": undefined,
|
|
670
|
+
"etag": undefined,
|
|
671
|
+
"keep-alive": undefined,
|
|
672
|
+
"last-modified": undefined,
|
|
673
|
+
"location": "https://auth.example.com/sign_in?type=code&redirect_uri=https%3A%2F%2Fexample.com%2Foauth2%2Fcallback%3Fa_param%3Da_param_value&scope=user&client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&state=xyz",
|
|
674
|
+
"server": undefined,
|
|
675
|
+
"transaction-id": "3",
|
|
676
|
+
"transfer-encoding": "chunked",
|
|
677
|
+
},
|
|
678
|
+
"status": 302,
|
|
679
|
+
}
|
|
680
|
+
`);
|
|
643
681
|
expect({
|
|
644
682
|
checkApplicationCalls: checkApplication.mock.calls,
|
|
645
683
|
authenticationCheckCalls: authentication.check.mock.calls,
|
|
@@ -702,23 +740,31 @@ describe('OAuth2 server', () => {
|
|
|
702
740
|
...headers,
|
|
703
741
|
// Erasing the Date header that may be added by Axios :/
|
|
704
742
|
date: undefined,
|
|
743
|
+
etag: undefined,
|
|
744
|
+
'last-modified': undefined,
|
|
745
|
+
server: undefined,
|
|
746
|
+
connection: undefined,
|
|
747
|
+
'keep-alive': undefined,
|
|
705
748
|
},
|
|
706
|
-
|
|
707
749
|
data,
|
|
708
750
|
}).toMatchInlineSnapshot(`
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
751
|
+
{
|
|
752
|
+
"data": "",
|
|
753
|
+
"headers": {
|
|
754
|
+
"connection": undefined,
|
|
755
|
+
"date": undefined,
|
|
756
|
+
"etag": undefined,
|
|
757
|
+
"keep-alive": undefined,
|
|
758
|
+
"last-modified": undefined,
|
|
759
|
+
"location": "http://redirect.example.com/yolo?a_param=a_value&client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&scope=user&state=xyz&redirect_uri=http%3A%2F%2Fredirect.example.com%2Fyolo%3Fa_param%3Da_value&code=a_code",
|
|
760
|
+
"server": undefined,
|
|
761
|
+
"transaction-id": "4",
|
|
762
|
+
"transfer-encoding": "chunked",
|
|
763
|
+
"x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
|
|
764
|
+
},
|
|
765
|
+
"status": 302,
|
|
766
|
+
}
|
|
767
|
+
`);
|
|
722
768
|
expect({
|
|
723
769
|
checkApplicationCalls: checkApplication.mock.calls,
|
|
724
770
|
authenticationCheckCalls: authentication.check.mock.calls,
|
|
@@ -789,31 +835,39 @@ describe('OAuth2 server', () => {
|
|
|
789
835
|
...headers,
|
|
790
836
|
// Erasing the Date header that may be added by Axios :/
|
|
791
837
|
date: undefined,
|
|
838
|
+
etag: undefined,
|
|
839
|
+
'last-modified': undefined,
|
|
840
|
+
server: undefined,
|
|
841
|
+
connection: undefined,
|
|
842
|
+
'keep-alive': undefined,
|
|
792
843
|
},
|
|
793
|
-
|
|
794
844
|
data,
|
|
795
845
|
}).toMatchInlineSnapshot(`
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
846
|
+
{
|
|
847
|
+
"data": {
|
|
848
|
+
"access_token": "an_access_token",
|
|
849
|
+
"expiration_date": "2010-03-07T00:00:00.000Z",
|
|
850
|
+
"expires_in": 86400,
|
|
851
|
+
"refresh_token": "a_refresh_token",
|
|
852
|
+
"refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
|
|
853
|
+
"refresh_token_expires_in": 5364748800,
|
|
854
|
+
"token_type": "bearer",
|
|
855
|
+
},
|
|
856
|
+
"headers": {
|
|
857
|
+
"connection": undefined,
|
|
858
|
+
"content-type": "application/json",
|
|
859
|
+
"date": undefined,
|
|
860
|
+
"etag": undefined,
|
|
861
|
+
"keep-alive": undefined,
|
|
862
|
+
"last-modified": undefined,
|
|
863
|
+
"server": undefined,
|
|
864
|
+
"transaction-id": "5",
|
|
865
|
+
"transfer-encoding": "chunked",
|
|
866
|
+
"x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
|
|
867
|
+
},
|
|
868
|
+
"status": 200,
|
|
869
|
+
}
|
|
870
|
+
`);
|
|
817
871
|
expect({
|
|
818
872
|
checkApplicationCalls: checkApplication.mock.calls,
|
|
819
873
|
authenticationCheckCalls: authentication.check.mock.calls,
|
|
@@ -870,22 +924,30 @@ describe('OAuth2 server', () => {
|
|
|
870
924
|
...headers,
|
|
871
925
|
// Erasing the Date header that may be added by Axios :/
|
|
872
926
|
date: undefined,
|
|
927
|
+
etag: undefined,
|
|
928
|
+
'last-modified': undefined,
|
|
929
|
+
server: undefined,
|
|
930
|
+
connection: undefined,
|
|
931
|
+
'keep-alive': undefined,
|
|
873
932
|
},
|
|
874
|
-
|
|
875
933
|
data,
|
|
876
934
|
}).toMatchInlineSnapshot(`
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
935
|
+
{
|
|
936
|
+
"data": "",
|
|
937
|
+
"headers": {
|
|
938
|
+
"connection": undefined,
|
|
939
|
+
"date": undefined,
|
|
940
|
+
"etag": undefined,
|
|
941
|
+
"keep-alive": undefined,
|
|
942
|
+
"last-modified": undefined,
|
|
943
|
+
"location": "https://auth.example.com/sign_in?type=token&redirect_uri=http%3A%2F%2Fredirect.example.com%2Fyolo&scope=user&client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&state=xyz",
|
|
944
|
+
"server": undefined,
|
|
945
|
+
"transaction-id": "6",
|
|
946
|
+
"transfer-encoding": "chunked",
|
|
947
|
+
},
|
|
948
|
+
"status": 302,
|
|
949
|
+
}
|
|
950
|
+
`);
|
|
889
951
|
expect({
|
|
890
952
|
checkApplicationCalls: checkApplication.mock.calls,
|
|
891
953
|
authenticationCheckCalls: authentication.check.mock.calls,
|
|
@@ -957,23 +1019,31 @@ describe('OAuth2 server', () => {
|
|
|
957
1019
|
...headers,
|
|
958
1020
|
// Erasing the Date header that may be added by Axios :/
|
|
959
1021
|
date: undefined,
|
|
1022
|
+
etag: undefined,
|
|
1023
|
+
'last-modified': undefined,
|
|
1024
|
+
server: undefined,
|
|
1025
|
+
connection: undefined,
|
|
1026
|
+
'keep-alive': undefined,
|
|
960
1027
|
},
|
|
961
|
-
|
|
962
1028
|
data,
|
|
963
1029
|
}).toMatchInlineSnapshot(`
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1030
|
+
{
|
|
1031
|
+
"data": "",
|
|
1032
|
+
"headers": {
|
|
1033
|
+
"connection": undefined,
|
|
1034
|
+
"date": undefined,
|
|
1035
|
+
"etag": undefined,
|
|
1036
|
+
"keep-alive": undefined,
|
|
1037
|
+
"last-modified": undefined,
|
|
1038
|
+
"location": "http://redirect.example.com/yolo?a_param=a_value&client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&scope=user&state=xyz&redirect_uri=http%3A%2F%2Fredirect.example.com%2Fyolo&access_token=an_access_token&token_type=bearer&expires_in=86400",
|
|
1039
|
+
"server": undefined,
|
|
1040
|
+
"transaction-id": "7",
|
|
1041
|
+
"transfer-encoding": "chunked",
|
|
1042
|
+
"x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
|
|
1043
|
+
},
|
|
1044
|
+
"status": 302,
|
|
1045
|
+
}
|
|
1046
|
+
`);
|
|
977
1047
|
expect({
|
|
978
1048
|
checkApplicationCalls: checkApplication.mock.calls,
|
|
979
1049
|
authenticationCheckCalls: authentication.check.mock.calls,
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
CheckApplicationService,
|
|
8
8
|
} from './oAuth2Granters.js';
|
|
9
9
|
import type { BaseAuthenticationData } from '@whook/authorization';
|
|
10
|
-
import type { OAuth2Options } from '../
|
|
10
|
+
import type { OAuth2Options } from '../services/oAuth2Granters.js';
|
|
11
11
|
|
|
12
12
|
export type OAuth2ClientCredentialsGranterDependencies = {
|
|
13
13
|
OAUTH2: OAuth2Options;
|