@whook/oauth2 24.1.1 → 25.0.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.
Files changed (64) hide show
  1. package/README.md +12 -10
  2. package/dist/index.d.ts +7 -6
  3. package/dist/index.js +5 -4
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.test.js +173 -168
  6. package/dist/index.test.js.map +1 -1
  7. package/dist/routes/getOAuth2Authorize.d.ts +39 -2
  8. package/dist/routes/getOAuth2Authorize.js +53 -2
  9. package/dist/routes/getOAuth2Authorize.js.map +1 -1
  10. package/dist/routes/getOAuth2WellKnown.d.ts +239 -0
  11. package/dist/routes/getOAuth2WellKnown.js +299 -0
  12. package/dist/routes/getOAuth2WellKnown.js.map +1 -0
  13. package/dist/routes/getOAuth2WellKnown.test.d.ts +1 -0
  14. package/dist/routes/getOAuth2WellKnown.test.js +100 -0
  15. package/dist/routes/getOAuth2WellKnown.test.js.map +1 -0
  16. package/dist/routes/postOAuth2Acknowledge.d.ts +1 -1
  17. package/dist/routes/postOAuth2Acknowledge.js +12 -10
  18. package/dist/routes/postOAuth2Acknowledge.js.map +1 -1
  19. package/dist/routes/postOAuth2Acknowledge.test.js +26 -21
  20. package/dist/routes/postOAuth2Acknowledge.test.js.map +1 -1
  21. package/dist/routes/postOAuth2Token.d.ts +10 -0
  22. package/dist/routes/postOAuth2Token.js +10 -0
  23. package/dist/routes/postOAuth2Token.js.map +1 -1
  24. package/dist/services/authCookies.d.ts +10 -9
  25. package/dist/services/authCookies.js.map +1 -1
  26. package/dist/services/authCookies.test.js.map +1 -1
  27. package/dist/services/oAuth2ClientCredentialsGranter.d.ts +5 -5
  28. package/dist/services/oAuth2ClientCredentialsGranter.js.map +1 -1
  29. package/dist/services/oAuth2CodeGranter.d.ts +31 -6
  30. package/dist/services/oAuth2CodeGranter.js +37 -9
  31. package/dist/services/oAuth2CodeGranter.js.map +1 -1
  32. package/dist/services/oAuth2CodeGranter.test.js +56 -20
  33. package/dist/services/oAuth2CodeGranter.test.js.map +1 -1
  34. package/dist/services/oAuth2Granters.d.ts +30 -26
  35. package/dist/services/oAuth2Granters.js +14 -0
  36. package/dist/services/oAuth2Granters.js.map +1 -1
  37. package/dist/services/oAuth2PasswordGranter.d.ts +5 -5
  38. package/dist/services/oAuth2PasswordGranter.js.map +1 -1
  39. package/dist/services/oAuth2RefreshTokenGranter.d.ts +5 -5
  40. package/dist/services/oAuth2RefreshTokenGranter.js.map +1 -1
  41. package/dist/services/oAuth2TokenGranter.d.ts +13 -5
  42. package/dist/services/oAuth2TokenGranter.js +11 -7
  43. package/dist/services/oAuth2TokenGranter.js.map +1 -1
  44. package/package.json +9 -9
  45. package/src/__snapshots__/index.test.ts.snap +3 -0
  46. package/src/index.test.ts +177 -167
  47. package/src/index.ts +34 -2
  48. package/src/routes/__snapshots__/getOAuth2Authorize.test.ts.snap +1 -2
  49. package/src/routes/getOAuth2Authorize.ts +67 -2
  50. package/src/routes/getOAuth2WellKnown.test.ts +132 -0
  51. package/src/routes/getOAuth2WellKnown.ts +335 -0
  52. package/src/routes/postOAuth2Acknowledge.test.ts +26 -21
  53. package/src/routes/postOAuth2Acknowledge.ts +19 -18
  54. package/src/routes/postOAuth2Token.ts +12 -1
  55. package/src/services/__snapshots__/oAuth2CodeGranter.test.ts.snap +3 -0
  56. package/src/services/authCookies.test.ts +5 -5
  57. package/src/services/authCookies.ts +13 -9
  58. package/src/services/oAuth2ClientCredentialsGranter.ts +5 -4
  59. package/src/services/oAuth2CodeGranter.test.ts +97 -30
  60. package/src/services/oAuth2CodeGranter.ts +89 -15
  61. package/src/services/oAuth2Granters.ts +60 -64
  62. package/src/services/oAuth2PasswordGranter.ts +5 -4
  63. package/src/services/oAuth2RefreshTokenGranter.ts +5 -4
  64. package/src/services/oAuth2TokenGranter.ts +27 -15
package/README.md CHANGED
@@ -13,8 +13,8 @@
13
13
  [//]: # (::contents:start)
14
14
 
15
15
  This module is aimed to allow you to easily bring OAuth2 to your
16
- [Whook](https://github.com/nfroidure/whook) server. It must be used with a
17
- server side rendered frontend that brings the UI that allows users to
16
+ [Whook](https://github.com/nfroidure/whook) server. To use the code flow, it
17
+ requires a server side rendered frontend that brings the UI that allows users to
18
18
  authenticate and allow client applications to act on behalf of them.
19
19
 
20
20
  ![Code Flow Overview](./code_flow_overview.svg)
@@ -41,7 +41,8 @@ This module requires you to implement some services it relies on:
41
41
  - `oAuth2ClientCredentialsService` aimed to check the `client_credential` grant
42
42
  type with your own logic (if you use it),
43
43
  - `OAuth2CodeService` aimed to check the `code` grant type with your own logic
44
- (if you use it).
44
+ (if you use it). Note that it is your responsibility to implement the PKCE
45
+ logic in it.
45
46
 
46
47
  ## Quick setup
47
48
 
@@ -221,8 +222,8 @@ async function initOAuth2VerifyTokenGranter({
221
222
 
222
223
  ## Additional routes/helpers
223
224
 
224
- For internal use, you may prefer use cookies based auth routes like
225
- `postLogin`, `postLogout` and `postRefresh`.
225
+ For internal use, you may prefer use cookies based auth routes like `postLogin`,
226
+ `postLogout` and `postRefresh`.
226
227
 
227
228
  To do so, configure the `ROOT_AUTHENTICATION_DATA` and `COOKIES` configurations:
228
229
 
@@ -237,10 +238,10 @@ To do so, configure the `ROOT_AUTHENTICATION_DATA` and `COOKIES` configurations:
237
238
  + },
238
239
  ```
239
240
 
240
- Than import the `postLogin`, `postLogout` and `postRefresh` routes like so:
241
+ Then import the `postLogin`, `postLogout` and `postRefresh` routes like so:
241
242
 
242
243
  ```ts
243
- // src/routes/postRefresh.ts
244
+ // src/routes/postAuthRefresh.ts
244
245
  import {
245
246
  initPostAuthRefresh,
246
247
  postAuthRefreshDefinition,
@@ -263,7 +264,7 @@ export const definition: WhookRouteDefinition = {
263
264
  export default initPostAuthRefresh;
264
265
  ```
265
266
 
266
- Additionnaly, you could create any handler in the `/auth` path in order to
267
+ Additionally, you could create any handler in the `/auth` path in order to
267
268
  receive the auth cookies. For example, you may want to serve user profiles
268
269
  there.
269
270
 
@@ -328,10 +329,11 @@ export const definition: WhookRouteDefinition = {
328
329
  ```
329
330
 
330
331
  You will probably need to also protect the `postOAuth2Token` endpoint with your
331
- own security mecanism:
332
+ own security mechanism:
332
333
 
333
334
  ```ts
334
- // In a `src/routes/postOAuth2Token.ts` fileimport {
335
+ // In a `src/routes/postOAuth2Token.ts` file
336
+ import {
335
337
  initPostOAuth2Token,
336
338
  postOAuth2TokenDefinition,
337
339
  postOAuth2TokenAuthorizationCodeTokenRequestBodySchema,
package/dist/index.d.ts CHANGED
@@ -1,22 +1,23 @@
1
- import initGetOAuth2Authorize, { definition as getOAuth2AuthorizeDefinition, responseTypeParameter as getOAuth2AuthorizeResponseTypeParameter, clientIdParameter as getOAuth2AuthorizeClientIdParameter, redirectURIParameter as getOAuth2AuthorizeRedirectURIParameter, scopeParameter as getOAuth2AuthorizeScopeParameter, stateParameter as getOAuth2AuthorizeStateParameter } from './routes/getOAuth2Authorize.js';
1
+ import initGetOAuth2Authorize, { definition as getOAuth2AuthorizeDefinition, responseTypeParameter as getOAuth2AuthorizeResponseTypeParameter, clientIdParameter as getOAuth2AuthorizeClientIdParameter, redirectURIParameter as getOAuth2AuthorizeRedirectURIParameter, scopeParameter as getOAuth2AuthorizeScopeParameter, stateParameter as getOAuth2AuthorizeStateParameter, codeChallengeSchema as getOAuth2AuthorizeCodeChallengeSchema, codeChallengeParameter as getOAuth2AuthorizeCodeChallengeParameter, codeChallengeMethodSchema as getOAuth2AuthorizeCodeChallengeMethodSchema, codeChallengeMethodParameter as getOAuth2AuthorizeCodeChallengeMethodParameter } from './routes/getOAuth2Authorize.js';
2
2
  import initPostOAuth2Acknowledge, { definition as postOAuth2AcknowledgeDefinition } from './routes/postOAuth2Acknowledge.js';
3
- import initPostOAuth2Token, { definition as postOAuth2TokenDefinition, authorizationCodeTokenRequestBodySchema as postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, passwordTokenRequestBodySchema as postOAuth2TokenPasswordTokenRequestBodySchema, clientCredentialsTokenRequestBodySchema as postOAuth2TokenClientCredentialsTokenRequestBodySchema, refreshTokenRequestBodySchema as postOAuth2TokenRefreshTokenRequestBodySchema, tokenBodySchema as postOAuth2TokenTokenBodySchema } from './routes/postOAuth2Token.js';
3
+ import initPostOAuth2Token, { definition as postOAuth2TokenDefinition, codeVerifierSchema as postOAuth2TokenCodeVerifierSchema, authorizationCodeTokenRequestBodySchema as postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, passwordTokenRequestBodySchema as postOAuth2TokenPasswordTokenRequestBodySchema, clientCredentialsTokenRequestBodySchema as postOAuth2TokenClientCredentialsTokenRequestBodySchema, refreshTokenRequestBodySchema as postOAuth2TokenRefreshTokenRequestBodySchema, tokenBodySchema as postOAuth2TokenTokenBodySchema } from './routes/postOAuth2Token.js';
4
+ import initGetOAuth2WellKnown, { definition as getOAuth2WellKnownDefinition, endpointAuthenticationMethodsSchema as getOAuth2WellKnownEndpointAuthenticationMethodsSchema, jsonWebAlgorithmsSchema as getOAuth2WellKnownJsonWebAlgorithmsSchema, jsonWebEncryptionsSchema as getOAuth2WellKnownJsonWebEncryptionsSchema, httpsProtocolURISchema as getOAuth2WellKnownHTTPSProtocolURISchema, oAuth2MetadataSchema as getOAuth2WellKnownOAuth2MetadataSchema } from './routes/getOAuth2WellKnown.js';
4
5
  import initOAuth2Granters, { type OAuth2YErrorRegistry, OAUTH2_ERRORS_DESCRIPTORS } from './services/oAuth2Granters.js';
5
6
  import initOAuth2ClientCredentialsGranter from './services/oAuth2ClientCredentialsGranter.js';
6
- import initOAuth2CodeGranter from './services/oAuth2CodeGranter.js';
7
7
  import initOAuth2PasswordGranter from './services/oAuth2PasswordGranter.js';
8
8
  import initOAuth2RefreshTokenGranter from './services/oAuth2RefreshTokenGranter.js';
9
9
  import initOAuth2TokenGranter from './services/oAuth2TokenGranter.js';
10
- import { type OAuth2CodeService, type OAuth2PasswordService, type OAuth2AccessTokenService, type OAuth2RefreshTokenService, type CheckApplicationService, type OAuth2GranterService, type OAuth2Options, type OAuth2Config } from './services/oAuth2Granters.js';
10
+ import { type OAuth2PasswordService, type OAuth2AccessTokenService, type OAuth2RefreshTokenService, type CheckApplicationService, type OAuth2GranterService, type OAuth2Options, type OAuth2Config } from './services/oAuth2Granters.js';
11
11
  import initPostAuthLogin, { definition as postAuthLoginDefinition } from './routes/postAuthLogin.js';
12
12
  import initPostAuthLogout, { definition as postAuthLogoutDefinition } from './routes/postAuthLogout.js';
13
13
  import initPostAuthRefresh, { authCookieHeaderParameter, definition as postAuthRefreshDefinition } from './routes/postAuthRefresh.js';
14
14
  import initAuthCookiesService, { AUTH_API_PREFIX } from './services/authCookies.js';
15
15
  import { type AuthCookiesConfig, type AuthCookiesService, type AuthCookiesData, type AuthHandlersConfig } from './services/authCookies.js';
16
+ import initOAuth2CodeGranter, { base64UrlEncode, hashCodeVerifier, type CodeChallengeMethod, type OAuth2CodeService } from './services/oAuth2CodeGranter.js';
16
17
  declare module 'yerror' {
17
18
  interface YErrorRegistry extends OAuth2YErrorRegistry {
18
19
  E_UNEXPECTED: unknown[];
19
20
  }
20
21
  }
21
- export type { OAuth2YErrorRegistry, OAuth2CodeService, OAuth2PasswordService, OAuth2AccessTokenService, OAuth2RefreshTokenService, CheckApplicationService, OAuth2GranterService, OAuth2Options, OAuth2Config, AuthCookiesConfig, AuthCookiesService, AuthCookiesData, AuthHandlersConfig, };
22
- export { initGetOAuth2Authorize, getOAuth2AuthorizeDefinition, getOAuth2AuthorizeResponseTypeParameter, getOAuth2AuthorizeClientIdParameter, getOAuth2AuthorizeRedirectURIParameter, getOAuth2AuthorizeScopeParameter, getOAuth2AuthorizeStateParameter, initPostOAuth2Acknowledge, postOAuth2AcknowledgeDefinition, initPostOAuth2Token, postOAuth2TokenDefinition, postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, postOAuth2TokenPasswordTokenRequestBodySchema, postOAuth2TokenClientCredentialsTokenRequestBodySchema, postOAuth2TokenRefreshTokenRequestBodySchema, postOAuth2TokenTokenBodySchema, OAUTH2_ERRORS_DESCRIPTORS, initOAuth2Granters, initOAuth2ClientCredentialsGranter, initOAuth2CodeGranter, initOAuth2PasswordGranter, initOAuth2RefreshTokenGranter, initOAuth2TokenGranter, AUTH_API_PREFIX, authCookieHeaderParameter, initPostAuthLogin, postAuthLoginDefinition, initPostAuthLogout, postAuthLogoutDefinition, initPostAuthRefresh, postAuthRefreshDefinition, initAuthCookiesService, };
22
+ export type { OAuth2YErrorRegistry, CodeChallengeMethod, OAuth2CodeService, OAuth2PasswordService, OAuth2AccessTokenService, OAuth2RefreshTokenService, CheckApplicationService, OAuth2GranterService, OAuth2Options, OAuth2Config, AuthCookiesConfig, AuthCookiesService, AuthCookiesData, AuthHandlersConfig, };
23
+ export { initGetOAuth2Authorize, getOAuth2AuthorizeDefinition, getOAuth2AuthorizeResponseTypeParameter, getOAuth2AuthorizeClientIdParameter, getOAuth2AuthorizeRedirectURIParameter, getOAuth2AuthorizeScopeParameter, getOAuth2AuthorizeStateParameter, getOAuth2AuthorizeCodeChallengeSchema, getOAuth2AuthorizeCodeChallengeMethodSchema, getOAuth2AuthorizeCodeChallengeParameter, getOAuth2AuthorizeCodeChallengeMethodParameter, initGetOAuth2WellKnown, getOAuth2WellKnownDefinition, getOAuth2WellKnownEndpointAuthenticationMethodsSchema, getOAuth2WellKnownJsonWebAlgorithmsSchema, getOAuth2WellKnownJsonWebEncryptionsSchema, getOAuth2WellKnownHTTPSProtocolURISchema, getOAuth2WellKnownOAuth2MetadataSchema, base64UrlEncode, hashCodeVerifier, initPostOAuth2Acknowledge, postOAuth2AcknowledgeDefinition, initPostOAuth2Token, postOAuth2TokenDefinition, postOAuth2TokenCodeVerifierSchema, postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, postOAuth2TokenPasswordTokenRequestBodySchema, postOAuth2TokenClientCredentialsTokenRequestBodySchema, postOAuth2TokenRefreshTokenRequestBodySchema, postOAuth2TokenTokenBodySchema, OAUTH2_ERRORS_DESCRIPTORS, initOAuth2Granters, initOAuth2ClientCredentialsGranter, initOAuth2CodeGranter, initOAuth2PasswordGranter, initOAuth2RefreshTokenGranter, initOAuth2TokenGranter, AUTH_API_PREFIX, authCookieHeaderParameter, initPostAuthLogin, postAuthLoginDefinition, initPostAuthLogout, postAuthLogoutDefinition, initPostAuthRefresh, postAuthRefreshDefinition, initAuthCookiesService, };
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import initGetOAuth2Authorize, { definition as getOAuth2AuthorizeDefinition, responseTypeParameter as getOAuth2AuthorizeResponseTypeParameter, clientIdParameter as getOAuth2AuthorizeClientIdParameter, redirectURIParameter as getOAuth2AuthorizeRedirectURIParameter, scopeParameter as getOAuth2AuthorizeScopeParameter, stateParameter as getOAuth2AuthorizeStateParameter, } from './routes/getOAuth2Authorize.js';
1
+ import initGetOAuth2Authorize, { definition as getOAuth2AuthorizeDefinition, responseTypeParameter as getOAuth2AuthorizeResponseTypeParameter, clientIdParameter as getOAuth2AuthorizeClientIdParameter, redirectURIParameter as getOAuth2AuthorizeRedirectURIParameter, scopeParameter as getOAuth2AuthorizeScopeParameter, stateParameter as getOAuth2AuthorizeStateParameter, codeChallengeSchema as getOAuth2AuthorizeCodeChallengeSchema, codeChallengeParameter as getOAuth2AuthorizeCodeChallengeParameter, codeChallengeMethodSchema as getOAuth2AuthorizeCodeChallengeMethodSchema, codeChallengeMethodParameter as getOAuth2AuthorizeCodeChallengeMethodParameter, } from './routes/getOAuth2Authorize.js';
2
2
  import initPostOAuth2Acknowledge, { definition as postOAuth2AcknowledgeDefinition, } from './routes/postOAuth2Acknowledge.js';
3
- import initPostOAuth2Token, { definition as postOAuth2TokenDefinition, authorizationCodeTokenRequestBodySchema as postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, passwordTokenRequestBodySchema as postOAuth2TokenPasswordTokenRequestBodySchema, clientCredentialsTokenRequestBodySchema as postOAuth2TokenClientCredentialsTokenRequestBodySchema, refreshTokenRequestBodySchema as postOAuth2TokenRefreshTokenRequestBodySchema, tokenBodySchema as postOAuth2TokenTokenBodySchema, } from './routes/postOAuth2Token.js';
3
+ import initPostOAuth2Token, { definition as postOAuth2TokenDefinition, codeVerifierSchema as postOAuth2TokenCodeVerifierSchema, authorizationCodeTokenRequestBodySchema as postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, passwordTokenRequestBodySchema as postOAuth2TokenPasswordTokenRequestBodySchema, clientCredentialsTokenRequestBodySchema as postOAuth2TokenClientCredentialsTokenRequestBodySchema, refreshTokenRequestBodySchema as postOAuth2TokenRefreshTokenRequestBodySchema, tokenBodySchema as postOAuth2TokenTokenBodySchema, } from './routes/postOAuth2Token.js';
4
+ import initGetOAuth2WellKnown, { definition as getOAuth2WellKnownDefinition, endpointAuthenticationMethodsSchema as getOAuth2WellKnownEndpointAuthenticationMethodsSchema, jsonWebAlgorithmsSchema as getOAuth2WellKnownJsonWebAlgorithmsSchema, jsonWebEncryptionsSchema as getOAuth2WellKnownJsonWebEncryptionsSchema, httpsProtocolURISchema as getOAuth2WellKnownHTTPSProtocolURISchema, oAuth2MetadataSchema as getOAuth2WellKnownOAuth2MetadataSchema, } from './routes/getOAuth2WellKnown.js';
4
5
  import initOAuth2Granters, { OAUTH2_ERRORS_DESCRIPTORS, } from './services/oAuth2Granters.js';
5
6
  import initOAuth2ClientCredentialsGranter from './services/oAuth2ClientCredentialsGranter.js';
6
- import initOAuth2CodeGranter from './services/oAuth2CodeGranter.js';
7
7
  import initOAuth2PasswordGranter from './services/oAuth2PasswordGranter.js';
8
8
  import initOAuth2RefreshTokenGranter from './services/oAuth2RefreshTokenGranter.js';
9
9
  import initOAuth2TokenGranter from './services/oAuth2TokenGranter.js';
@@ -11,5 +11,6 @@ import initPostAuthLogin, { definition as postAuthLoginDefinition, } from './rou
11
11
  import initPostAuthLogout, { definition as postAuthLogoutDefinition, } from './routes/postAuthLogout.js';
12
12
  import initPostAuthRefresh, { authCookieHeaderParameter, definition as postAuthRefreshDefinition, } from './routes/postAuthRefresh.js';
13
13
  import initAuthCookiesService, { AUTH_API_PREFIX, } from './services/authCookies.js';
14
- export { initGetOAuth2Authorize, getOAuth2AuthorizeDefinition, getOAuth2AuthorizeResponseTypeParameter, getOAuth2AuthorizeClientIdParameter, getOAuth2AuthorizeRedirectURIParameter, getOAuth2AuthorizeScopeParameter, getOAuth2AuthorizeStateParameter, initPostOAuth2Acknowledge, postOAuth2AcknowledgeDefinition, initPostOAuth2Token, postOAuth2TokenDefinition, postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, postOAuth2TokenPasswordTokenRequestBodySchema, postOAuth2TokenClientCredentialsTokenRequestBodySchema, postOAuth2TokenRefreshTokenRequestBodySchema, postOAuth2TokenTokenBodySchema, OAUTH2_ERRORS_DESCRIPTORS, initOAuth2Granters, initOAuth2ClientCredentialsGranter, initOAuth2CodeGranter, initOAuth2PasswordGranter, initOAuth2RefreshTokenGranter, initOAuth2TokenGranter, AUTH_API_PREFIX, authCookieHeaderParameter, initPostAuthLogin, postAuthLoginDefinition, initPostAuthLogout, postAuthLogoutDefinition, initPostAuthRefresh, postAuthRefreshDefinition, initAuthCookiesService, };
14
+ import initOAuth2CodeGranter, { base64UrlEncode, hashCodeVerifier, } from './services/oAuth2CodeGranter.js';
15
+ export { initGetOAuth2Authorize, getOAuth2AuthorizeDefinition, getOAuth2AuthorizeResponseTypeParameter, getOAuth2AuthorizeClientIdParameter, getOAuth2AuthorizeRedirectURIParameter, getOAuth2AuthorizeScopeParameter, getOAuth2AuthorizeStateParameter, getOAuth2AuthorizeCodeChallengeSchema, getOAuth2AuthorizeCodeChallengeMethodSchema, getOAuth2AuthorizeCodeChallengeParameter, getOAuth2AuthorizeCodeChallengeMethodParameter, initGetOAuth2WellKnown, getOAuth2WellKnownDefinition, getOAuth2WellKnownEndpointAuthenticationMethodsSchema, getOAuth2WellKnownJsonWebAlgorithmsSchema, getOAuth2WellKnownJsonWebEncryptionsSchema, getOAuth2WellKnownHTTPSProtocolURISchema, getOAuth2WellKnownOAuth2MetadataSchema, base64UrlEncode, hashCodeVerifier, initPostOAuth2Acknowledge, postOAuth2AcknowledgeDefinition, initPostOAuth2Token, postOAuth2TokenDefinition, postOAuth2TokenCodeVerifierSchema, postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, postOAuth2TokenPasswordTokenRequestBodySchema, postOAuth2TokenClientCredentialsTokenRequestBodySchema, postOAuth2TokenRefreshTokenRequestBodySchema, postOAuth2TokenTokenBodySchema, OAUTH2_ERRORS_DESCRIPTORS, initOAuth2Granters, initOAuth2ClientCredentialsGranter, initOAuth2CodeGranter, initOAuth2PasswordGranter, initOAuth2RefreshTokenGranter, initOAuth2TokenGranter, AUTH_API_PREFIX, authCookieHeaderParameter, initPostAuthLogin, postAuthLoginDefinition, initPostAuthLogout, postAuthLogoutDefinition, initPostAuthRefresh, postAuthRefreshDefinition, initAuthCookiesService, };
15
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,EAAE,EAC7B,UAAU,IAAI,4BAA4B,EAC1C,qBAAqB,IAAI,uCAAuC,EAChE,iBAAiB,IAAI,mCAAmC,EACxD,oBAAoB,IAAI,sCAAsC,EAC9D,cAAc,IAAI,gCAAgC,EAClD,cAAc,IAAI,gCAAgC,GACnD,MAAM,gCAAgC,CAAC;AACxC,OAAO,yBAAyB,EAAE,EAChC,UAAU,IAAI,+BAA+B,GAC9C,MAAM,mCAAmC,CAAC;AAC3C,OAAO,mBAAmB,EAAE,EAC1B,UAAU,IAAI,yBAAyB,EACvC,uCAAuC,IAAI,sDAAsD,EACjG,8BAA8B,IAAI,6CAA6C,EAC/E,uCAAuC,IAAI,sDAAsD,EACjG,6BAA6B,IAAI,4CAA4C,EAC7E,eAAe,IAAI,8BAA8B,GAClD,MAAM,6BAA6B,CAAC;AACrC,OAAO,kBAAkB,EAAE,EAEzB,yBAAyB,GAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,kCAAkC,MAAM,8CAA8C,CAAC;AAC9F,OAAO,qBAAqB,MAAM,iCAAiC,CAAC;AACpE,OAAO,yBAAyB,MAAM,qCAAqC,CAAC;AAC5E,OAAO,6BAA6B,MAAM,yCAAyC,CAAC;AACpF,OAAO,sBAAsB,MAAM,kCAAkC,CAAC;AAWtE,OAAO,iBAAiB,EAAE,EACxB,UAAU,IAAI,uBAAuB,GACtC,MAAM,2BAA2B,CAAC;AACnC,OAAO,kBAAkB,EAAE,EACzB,UAAU,IAAI,wBAAwB,GACvC,MAAM,4BAA4B,CAAC;AACpC,OAAO,mBAAmB,EAAE,EAC1B,yBAAyB,EACzB,UAAU,IAAI,yBAAyB,GACxC,MAAM,6BAA6B,CAAC;AACrC,OAAO,sBAAsB,EAAE,EAC7B,eAAe,GAChB,MAAM,2BAA2B,CAAC;AA6BnC,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,uCAAuC,EACvC,mCAAmC,EACnC,sCAAsC,EACtC,gCAAgC,EAChC,gCAAgC,EAChC,yBAAyB,EACzB,+BAA+B,EAC/B,mBAAmB,EACnB,yBAAyB,EACzB,sDAAsD,EACtD,6CAA6C,EAC7C,sDAAsD,EACtD,4CAA4C,EAC5C,8BAA8B,EAC9B,yBAAyB,EACzB,kBAAkB,EAClB,kCAAkC,EAClC,qBAAqB,EACrB,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,eAAe,EACf,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,GACvB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,EAAE,EAC7B,UAAU,IAAI,4BAA4B,EAC1C,qBAAqB,IAAI,uCAAuC,EAChE,iBAAiB,IAAI,mCAAmC,EACxD,oBAAoB,IAAI,sCAAsC,EAC9D,cAAc,IAAI,gCAAgC,EAClD,cAAc,IAAI,gCAAgC,EAClD,mBAAmB,IAAI,qCAAqC,EAC5D,sBAAsB,IAAI,wCAAwC,EAClE,yBAAyB,IAAI,2CAA2C,EACxE,4BAA4B,IAAI,8CAA8C,GAC/E,MAAM,gCAAgC,CAAC;AACxC,OAAO,yBAAyB,EAAE,EAChC,UAAU,IAAI,+BAA+B,GAC9C,MAAM,mCAAmC,CAAC;AAC3C,OAAO,mBAAmB,EAAE,EAC1B,UAAU,IAAI,yBAAyB,EACvC,kBAAkB,IAAI,iCAAiC,EACvD,uCAAuC,IAAI,sDAAsD,EACjG,8BAA8B,IAAI,6CAA6C,EAC/E,uCAAuC,IAAI,sDAAsD,EACjG,6BAA6B,IAAI,4CAA4C,EAC7E,eAAe,IAAI,8BAA8B,GAClD,MAAM,6BAA6B,CAAC;AACrC,OAAO,sBAAsB,EAAE,EAC7B,UAAU,IAAI,4BAA4B,EAC1C,mCAAmC,IAAI,qDAAqD,EAC5F,uBAAuB,IAAI,yCAAyC,EACpE,wBAAwB,IAAI,0CAA0C,EACtE,sBAAsB,IAAI,wCAAwC,EAClE,oBAAoB,IAAI,sCAAsC,GAC/D,MAAM,gCAAgC,CAAC;AACxC,OAAO,kBAAkB,EAAE,EAEzB,yBAAyB,GAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,kCAAkC,MAAM,8CAA8C,CAAC;AAC9F,OAAO,yBAAyB,MAAM,qCAAqC,CAAC;AAC5E,OAAO,6BAA6B,MAAM,yCAAyC,CAAC;AACpF,OAAO,sBAAsB,MAAM,kCAAkC,CAAC;AAUtE,OAAO,iBAAiB,EAAE,EACxB,UAAU,IAAI,uBAAuB,GACtC,MAAM,2BAA2B,CAAC;AACnC,OAAO,kBAAkB,EAAE,EACzB,UAAU,IAAI,wBAAwB,GACvC,MAAM,4BAA4B,CAAC;AACpC,OAAO,mBAAmB,EAAE,EAC1B,yBAAyB,EACzB,UAAU,IAAI,yBAAyB,GACxC,MAAM,6BAA6B,CAAC;AACrC,OAAO,sBAAsB,EAAE,EAC7B,eAAe,GAChB,MAAM,2BAA2B,CAAC;AAOnC,OAAO,qBAAqB,EAAE,EAC5B,eAAe,EACf,gBAAgB,GAGjB,MAAM,iCAAiC,CAAC;AAwBzC,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,uCAAuC,EACvC,mCAAmC,EACnC,sCAAsC,EACtC,gCAAgC,EAChC,gCAAgC,EAChC,qCAAqC,EACrC,2CAA2C,EAC3C,wCAAwC,EACxC,8CAA8C,EAC9C,sBAAsB,EACtB,4BAA4B,EAC5B,qDAAqD,EACrD,yCAAyC,EACzC,0CAA0C,EAC1C,wCAAwC,EACxC,sCAAsC,EACtC,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EACzB,+BAA+B,EAC/B,mBAAmB,EACnB,yBAAyB,EACzB,iCAAiC,EACjC,sDAAsD,EACtD,6CAA6C,EAC7C,sDAAsD,EACtD,4CAA4C,EAC5C,8BAA8B,EAC9B,yBAAyB,EACzB,kBAAkB,EAClB,kCAAkC,EAClC,qBAAqB,EACrB,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,eAAe,EACf,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,GACvB,CAAC"}
@@ -6,7 +6,7 @@ import { alsoInject, constant, initializer } from 'knifecycle';
6
6
  import axios from 'axios';
7
7
  import { YError } from 'yerror';
8
8
  import { BEARER as BEARER_MECHANISM, BASIC as BASIC_MECHANISM, } from 'http-auth-utils';
9
- import { initGetOAuth2Authorize, getOAuth2AuthorizeDefinition, getOAuth2AuthorizeResponseTypeParameter, getOAuth2AuthorizeClientIdParameter, getOAuth2AuthorizeRedirectURIParameter, getOAuth2AuthorizeScopeParameter, getOAuth2AuthorizeStateParameter, initPostOAuth2Acknowledge, postOAuth2AcknowledgeDefinition, initPostOAuth2Token, postOAuth2TokenDefinition, OAUTH2_ERRORS_DESCRIPTORS, initOAuth2CodeGranter, initOAuth2PasswordGranter, initOAuth2RefreshTokenGranter, initOAuth2Granters, initOAuth2ClientCredentialsGranter, initOAuth2TokenGranter, postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, postOAuth2TokenPasswordTokenRequestBodySchema, postOAuth2TokenClientCredentialsTokenRequestBodySchema, postOAuth2TokenTokenBodySchema, postOAuth2TokenRefreshTokenRequestBodySchema, } from './index.js';
9
+ import { initGetOAuth2Authorize, getOAuth2AuthorizeDefinition, getOAuth2AuthorizeResponseTypeParameter, getOAuth2AuthorizeClientIdParameter, getOAuth2AuthorizeRedirectURIParameter, getOAuth2AuthorizeScopeParameter, getOAuth2AuthorizeStateParameter, getOAuth2AuthorizeCodeChallengeSchema, getOAuth2AuthorizeCodeChallengeParameter, getOAuth2AuthorizeCodeChallengeMethodSchema, getOAuth2AuthorizeCodeChallengeMethodParameter, initPostOAuth2Acknowledge, postOAuth2AcknowledgeDefinition, initPostOAuth2Token, postOAuth2TokenCodeVerifierSchema, postOAuth2TokenDefinition, OAUTH2_ERRORS_DESCRIPTORS, initOAuth2CodeGranter, initOAuth2PasswordGranter, initOAuth2RefreshTokenGranter, initOAuth2Granters, initOAuth2ClientCredentialsGranter, initOAuth2TokenGranter, postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, postOAuth2TokenPasswordTokenRequestBodySchema, postOAuth2TokenClientCredentialsTokenRequestBodySchema, postOAuth2TokenTokenBodySchema, postOAuth2TokenRefreshTokenRequestBodySchema, } from './index.js';
10
10
  describe('OAuth2 server', () => {
11
11
  const BASE_PATH = '/v1';
12
12
  const PORT = 4444;
@@ -69,6 +69,8 @@ describe('OAuth2 server', () => {
69
69
  getOAuth2AuthorizeRedirectURIParameter,
70
70
  getOAuth2AuthorizeScopeParameter,
71
71
  getOAuth2AuthorizeStateParameter,
72
+ getOAuth2AuthorizeCodeChallengeParameter,
73
+ getOAuth2AuthorizeCodeChallengeMethodParameter,
72
74
  ].reduce((parametersHash, { name, parameter }) => ({
73
75
  ...parametersHash,
74
76
  [name]: parameter,
@@ -79,6 +81,9 @@ describe('OAuth2 server', () => {
79
81
  postOAuth2TokenClientCredentialsTokenRequestBodySchema,
80
82
  postOAuth2TokenRefreshTokenRequestBodySchema,
81
83
  postOAuth2TokenTokenBodySchema,
84
+ getOAuth2AuthorizeCodeChallengeSchema,
85
+ getOAuth2AuthorizeCodeChallengeMethodSchema,
86
+ postOAuth2TokenCodeVerifierSchema,
82
87
  ].reduce((schemasHash, { name, schema }) => ({
83
88
  ...schemasHash,
84
89
  [name]: schema,
@@ -255,31 +260,31 @@ describe('OAuth2 server', () => {
255
260
  },
256
261
  data,
257
262
  }).toMatchInlineSnapshot(`
258
- {
259
- "data": {
260
- "access_token": "an_access_token",
261
- "expiration_date": "2010-03-07T00:00:00.000Z",
262
- "expires_in": 86400,
263
- "refresh_token": "a_refresh_token",
264
- "refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
265
- "refresh_token_expires_in": 5364748800,
266
- "token_type": "bearer",
267
- },
268
- "headers": {
269
- "connection": undefined,
270
- "content-type": "application/json",
271
- "date": undefined,
272
- "etag": undefined,
273
- "keep-alive": undefined,
274
- "last-modified": undefined,
275
- "server": undefined,
276
- "transaction-id": "0",
277
- "transfer-encoding": "chunked",
278
- "x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
279
- },
280
- "status": 200,
281
- }
282
- `);
263
+ {
264
+ "data": {
265
+ "access_token": "an_access_token",
266
+ "expiration_date": "2010-03-07T00:00:00.000Z",
267
+ "expires_in": 86400,
268
+ "refresh_token": "a_refresh_token",
269
+ "refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
270
+ "refresh_token_expires_in": 5364748800,
271
+ "token_type": "bearer",
272
+ },
273
+ "headers": {
274
+ "connection": undefined,
275
+ "content-type": "application/json",
276
+ "date": undefined,
277
+ "etag": undefined,
278
+ "keep-alive": undefined,
279
+ "last-modified": undefined,
280
+ "server": undefined,
281
+ "transaction-id": "0",
282
+ "transfer-encoding": "chunked",
283
+ "x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
284
+ },
285
+ "status": 200,
286
+ }
287
+ `);
283
288
  expect({
284
289
  checkApplicationCalls: checkApplication.mock.calls,
285
290
  authenticationCheckCalls: authentication.check.mock.calls,
@@ -353,31 +358,31 @@ describe('OAuth2 server', () => {
353
358
  },
354
359
  data,
355
360
  }).toMatchInlineSnapshot(`
356
- {
357
- "data": {
358
- "access_token": "an_access_token",
359
- "expiration_date": "2010-03-07T00:00:00.000Z",
360
- "expires_in": 86400,
361
- "refresh_token": "a_refresh_token",
362
- "refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
363
- "refresh_token_expires_in": 5364748800,
364
- "token_type": "bearer",
365
- },
366
- "headers": {
367
- "connection": undefined,
368
- "content-type": "application/json",
369
- "date": undefined,
370
- "etag": undefined,
371
- "keep-alive": undefined,
372
- "last-modified": undefined,
373
- "server": undefined,
374
- "transaction-id": "1",
375
- "transfer-encoding": "chunked",
376
- "x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
377
- },
378
- "status": 200,
379
- }
380
- `);
361
+ {
362
+ "data": {
363
+ "access_token": "an_access_token",
364
+ "expiration_date": "2010-03-07T00:00:00.000Z",
365
+ "expires_in": 86400,
366
+ "refresh_token": "a_refresh_token",
367
+ "refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
368
+ "refresh_token_expires_in": 5364748800,
369
+ "token_type": "bearer",
370
+ },
371
+ "headers": {
372
+ "connection": undefined,
373
+ "content-type": "application/json",
374
+ "date": undefined,
375
+ "etag": undefined,
376
+ "keep-alive": undefined,
377
+ "last-modified": undefined,
378
+ "server": undefined,
379
+ "transaction-id": "1",
380
+ "transfer-encoding": "chunked",
381
+ "x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
382
+ },
383
+ "status": 200,
384
+ }
385
+ `);
381
386
  expect({
382
387
  checkApplicationCalls: checkApplication.mock.calls,
383
388
  authenticationCheckCalls: authentication.check.mock.calls,
@@ -446,31 +451,31 @@ describe('OAuth2 server', () => {
446
451
  },
447
452
  data,
448
453
  }).toMatchInlineSnapshot(`
449
- {
450
- "data": {
451
- "access_token": "an_access_token",
452
- "expiration_date": "2010-03-07T00:00:00.000Z",
453
- "expires_in": 86400,
454
- "refresh_token": "a_refresh_token",
455
- "refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
456
- "refresh_token_expires_in": 5364748800,
457
- "token_type": "bearer",
458
- },
459
- "headers": {
460
- "connection": undefined,
461
- "content-type": "application/json",
462
- "date": undefined,
463
- "etag": undefined,
464
- "keep-alive": undefined,
465
- "last-modified": undefined,
466
- "server": undefined,
467
- "transaction-id": "2",
468
- "transfer-encoding": "chunked",
469
- "x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
470
- },
471
- "status": 200,
472
- }
473
- `);
454
+ {
455
+ "data": {
456
+ "access_token": "an_access_token",
457
+ "expiration_date": "2010-03-07T00:00:00.000Z",
458
+ "expires_in": 86400,
459
+ "refresh_token": "a_refresh_token",
460
+ "refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
461
+ "refresh_token_expires_in": 5364748800,
462
+ "token_type": "bearer",
463
+ },
464
+ "headers": {
465
+ "connection": undefined,
466
+ "content-type": "application/json",
467
+ "date": undefined,
468
+ "etag": undefined,
469
+ "keep-alive": undefined,
470
+ "last-modified": undefined,
471
+ "server": undefined,
472
+ "transaction-id": "2",
473
+ "transfer-encoding": "chunked",
474
+ "x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
475
+ },
476
+ "status": 200,
477
+ }
478
+ `);
474
479
  expect({
475
480
  checkApplicationCalls: checkApplication.mock.calls,
476
481
  authenticationCheckCalls: authentication.check.mock.calls,
@@ -501,7 +506,7 @@ describe('OAuth2 server', () => {
501
506
  type: 'code',
502
507
  applicationId: 'acdc41ce-acdc-41ce-acdc-41ceacdc41ce',
503
508
  scope: 'user,oauth',
504
- redirectURI: 'https://example.com/oauth2/callback?a_param=a_param_value',
509
+ redirectURI: 'https://redirect.example.com/oauth2/callback?a_param=a_param_value',
505
510
  });
506
511
  const { status, headers, data } = await axios({
507
512
  method: 'get',
@@ -530,22 +535,22 @@ describe('OAuth2 server', () => {
530
535
  },
531
536
  data,
532
537
  }).toMatchInlineSnapshot(`
533
- {
534
- "data": "",
535
- "headers": {
536
- "connection": undefined,
537
- "date": undefined,
538
- "etag": undefined,
539
- "keep-alive": undefined,
540
- "last-modified": undefined,
541
- "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",
542
- "server": undefined,
543
- "transaction-id": "3",
544
- "transfer-encoding": "chunked",
545
- },
546
- "status": 302,
547
- }
548
- `);
538
+ {
539
+ "data": "",
540
+ "headers": {
541
+ "connection": undefined,
542
+ "date": undefined,
543
+ "etag": undefined,
544
+ "keep-alive": undefined,
545
+ "last-modified": undefined,
546
+ "location": "https://auth.example.com/sign_in?type=code&redirect_uri=https%3A%2F%2Fredirect.example.com%2Foauth2%2Fcallback%3Fa_param%3Da_param_value&scope=user&client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&state=xyz",
547
+ "server": undefined,
548
+ "transaction-id": "3",
549
+ "transfer-encoding": "chunked",
550
+ },
551
+ "status": 302,
552
+ }
553
+ `);
549
554
  expect({
550
555
  checkApplicationCalls: checkApplication.mock.calls,
551
556
  authenticationCheckCalls: authentication.check.mock.calls,
@@ -611,23 +616,23 @@ describe('OAuth2 server', () => {
611
616
  },
612
617
  data,
613
618
  }).toMatchInlineSnapshot(`
614
- {
615
- "data": "",
616
- "headers": {
617
- "connection": undefined,
618
- "date": undefined,
619
- "etag": undefined,
620
- "keep-alive": undefined,
621
- "last-modified": undefined,
622
- "location": "http://redirect.example.com/yolo?a_param=a_value&client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&scope=user&state=xyz&user_id=2&redirect_uri=http%3A%2F%2Fredirect.example.com%2Fyolo%3Fa_param%3Da_value&code=a_code",
623
- "server": undefined,
624
- "transaction-id": "4",
625
- "transfer-encoding": "chunked",
626
- "x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
627
- },
628
- "status": 302,
629
- }
630
- `);
619
+ {
620
+ "data": "",
621
+ "headers": {
622
+ "connection": undefined,
623
+ "date": undefined,
624
+ "etag": undefined,
625
+ "keep-alive": undefined,
626
+ "last-modified": undefined,
627
+ "location": "http://redirect.example.com/yolo?a_param=a_value&client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&scope=user&state=xyz&code=a_code",
628
+ "server": undefined,
629
+ "transaction-id": "4",
630
+ "transfer-encoding": "chunked",
631
+ "x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
632
+ },
633
+ "status": 302,
634
+ }
635
+ `);
631
636
  expect({
632
637
  checkApplicationCalls: checkApplication.mock.calls,
633
638
  authenticationCheckCalls: authentication.check.mock.calls,
@@ -699,31 +704,31 @@ describe('OAuth2 server', () => {
699
704
  },
700
705
  data,
701
706
  }).toMatchInlineSnapshot(`
702
- {
703
- "data": {
704
- "access_token": "an_access_token",
705
- "expiration_date": "2010-03-07T00:00:00.000Z",
706
- "expires_in": 86400,
707
- "refresh_token": "a_refresh_token",
708
- "refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
709
- "refresh_token_expires_in": 5364748800,
710
- "token_type": "bearer",
711
- },
712
- "headers": {
713
- "connection": undefined,
714
- "content-type": "application/json",
715
- "date": undefined,
716
- "etag": undefined,
717
- "keep-alive": undefined,
718
- "last-modified": undefined,
719
- "server": undefined,
720
- "transaction-id": "5",
721
- "transfer-encoding": "chunked",
722
- "x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
723
- },
724
- "status": 200,
725
- }
726
- `);
707
+ {
708
+ "data": {
709
+ "access_token": "an_access_token",
710
+ "expiration_date": "2010-03-07T00:00:00.000Z",
711
+ "expires_in": 86400,
712
+ "refresh_token": "a_refresh_token",
713
+ "refresh_token_expiration_date": "2180-03-06T00:00:00.000Z",
714
+ "refresh_token_expires_in": 5364748800,
715
+ "token_type": "bearer",
716
+ },
717
+ "headers": {
718
+ "connection": undefined,
719
+ "content-type": "application/json",
720
+ "date": undefined,
721
+ "etag": undefined,
722
+ "keep-alive": undefined,
723
+ "last-modified": undefined,
724
+ "server": undefined,
725
+ "transaction-id": "5",
726
+ "transfer-encoding": "chunked",
727
+ "x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
728
+ },
729
+ "status": 200,
730
+ }
731
+ `);
727
732
  expect({
728
733
  checkApplicationCalls: checkApplication.mock.calls,
729
734
  authenticationCheckCalls: authentication.check.mock.calls,
@@ -783,22 +788,22 @@ describe('OAuth2 server', () => {
783
788
  },
784
789
  data,
785
790
  }).toMatchInlineSnapshot(`
786
- {
787
- "data": "",
788
- "headers": {
789
- "connection": undefined,
790
- "date": undefined,
791
- "etag": undefined,
792
- "keep-alive": undefined,
793
- "last-modified": undefined,
794
- "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",
795
- "server": undefined,
796
- "transaction-id": "6",
797
- "transfer-encoding": "chunked",
798
- },
799
- "status": 302,
800
- }
801
- `);
791
+ {
792
+ "data": "",
793
+ "headers": {
794
+ "connection": undefined,
795
+ "date": undefined,
796
+ "etag": undefined,
797
+ "keep-alive": undefined,
798
+ "last-modified": undefined,
799
+ "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",
800
+ "server": undefined,
801
+ "transaction-id": "6",
802
+ "transfer-encoding": "chunked",
803
+ },
804
+ "status": 302,
805
+ }
806
+ `);
802
807
  expect({
803
808
  checkApplicationCalls: checkApplication.mock.calls,
804
809
  authenticationCheckCalls: authentication.check.mock.calls,
@@ -873,23 +878,23 @@ describe('OAuth2 server', () => {
873
878
  },
874
879
  data,
875
880
  }).toMatchInlineSnapshot(`
876
- {
877
- "data": "",
878
- "headers": {
879
- "connection": undefined,
880
- "date": undefined,
881
- "etag": undefined,
882
- "keep-alive": undefined,
883
- "last-modified": undefined,
884
- "location": "http://redirect.example.com/yolo?a_param=a_value&client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&scope=user&state=xyz&user_id=2&redirect_uri=http%3A%2F%2Fredirect.example.com%2Fyolo&access_token=an_access_token&token_type=bearer&expires_in=86400",
885
- "server": undefined,
886
- "transaction-id": "7",
887
- "transfer-encoding": "chunked",
888
- "x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
889
- },
890
- "status": 302,
891
- }
892
- `);
881
+ {
882
+ "data": "",
883
+ "headers": {
884
+ "connection": undefined,
885
+ "date": undefined,
886
+ "etag": undefined,
887
+ "keep-alive": undefined,
888
+ "last-modified": undefined,
889
+ "location": "http://redirect.example.com/yolo?client_id=acdc41ce-acdc-41ce-acdc-41ceacdc41ce&scope=user&state=xyz&access_token=an_access_token&token_type=bearer&expires_in=86400",
890
+ "server": undefined,
891
+ "transaction-id": "7",
892
+ "transfer-encoding": "chunked",
893
+ "x-authenticated": "{"applicationId":"acdc41ce-acdc-41ce-acdc-41ceacdc41ce","scope":"user,oauth","userId":"2"}",
894
+ },
895
+ "status": 302,
896
+ }
897
+ `);
893
898
  expect({
894
899
  checkApplicationCalls: checkApplication.mock.calls,
895
900
  authenticationCheckCalls: authentication.check.mock.calls,