@whook/oauth2 24.1.1 → 25.0.2
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 +12 -10
- package/dist/index.d.ts +7 -6
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +173 -168
- package/dist/index.test.js.map +1 -1
- package/dist/routes/getOAuth2Authorize.d.ts +39 -2
- package/dist/routes/getOAuth2Authorize.js +53 -2
- package/dist/routes/getOAuth2Authorize.js.map +1 -1
- package/dist/routes/getOAuth2WellKnownMetadata.d.ts +239 -0
- package/dist/routes/getOAuth2WellKnownMetadata.js +299 -0
- package/dist/routes/getOAuth2WellKnownMetadata.js.map +1 -0
- package/dist/routes/getOAuth2WellKnownMetadata.test.d.ts +1 -0
- package/dist/routes/getOAuth2WellKnownMetadata.test.js +100 -0
- package/dist/routes/getOAuth2WellKnownMetadata.test.js.map +1 -0
- package/dist/routes/postOAuth2Acknowledge.d.ts +1 -1
- package/dist/routes/postOAuth2Acknowledge.js +12 -10
- package/dist/routes/postOAuth2Acknowledge.js.map +1 -1
- package/dist/routes/postOAuth2Acknowledge.test.js +26 -21
- package/dist/routes/postOAuth2Acknowledge.test.js.map +1 -1
- package/dist/routes/postOAuth2Token.d.ts +10 -0
- package/dist/routes/postOAuth2Token.js +10 -0
- package/dist/routes/postOAuth2Token.js.map +1 -1
- package/dist/services/authCookies.d.ts +10 -9
- package/dist/services/authCookies.js.map +1 -1
- package/dist/services/authCookies.test.js.map +1 -1
- package/dist/services/oAuth2ClientCredentialsGranter.d.ts +5 -5
- package/dist/services/oAuth2ClientCredentialsGranter.js.map +1 -1
- package/dist/services/oAuth2CodeGranter.d.ts +31 -6
- package/dist/services/oAuth2CodeGranter.js +37 -9
- package/dist/services/oAuth2CodeGranter.js.map +1 -1
- package/dist/services/oAuth2CodeGranter.test.js +56 -20
- package/dist/services/oAuth2CodeGranter.test.js.map +1 -1
- package/dist/services/oAuth2Granters.d.ts +30 -26
- package/dist/services/oAuth2Granters.js +14 -0
- package/dist/services/oAuth2Granters.js.map +1 -1
- package/dist/services/oAuth2PasswordGranter.d.ts +5 -5
- package/dist/services/oAuth2PasswordGranter.js.map +1 -1
- package/dist/services/oAuth2RefreshTokenGranter.d.ts +5 -5
- package/dist/services/oAuth2RefreshTokenGranter.js.map +1 -1
- package/dist/services/oAuth2TokenGranter.d.ts +13 -5
- package/dist/services/oAuth2TokenGranter.js +11 -7
- package/dist/services/oAuth2TokenGranter.js.map +1 -1
- package/package.json +9 -9
- package/src/__snapshots__/index.test.ts.snap +3 -0
- package/src/index.test.ts +177 -167
- package/src/index.ts +34 -2
- package/src/routes/__snapshots__/getOAuth2Authorize.test.ts.snap +1 -2
- package/src/routes/getOAuth2Authorize.ts +67 -2
- package/src/routes/getOAuth2WellKnownMetadata.test.ts +132 -0
- package/src/routes/getOAuth2WellKnownMetadata.ts +335 -0
- package/src/routes/postOAuth2Acknowledge.test.ts +26 -21
- package/src/routes/postOAuth2Acknowledge.ts +19 -18
- package/src/routes/postOAuth2Token.ts +12 -1
- package/src/services/__snapshots__/oAuth2CodeGranter.test.ts.snap +3 -0
- package/src/services/authCookies.test.ts +5 -5
- package/src/services/authCookies.ts +13 -9
- package/src/services/oAuth2ClientCredentialsGranter.ts +5 -4
- package/src/services/oAuth2CodeGranter.test.ts +97 -30
- package/src/services/oAuth2CodeGranter.ts +89 -15
- package/src/services/oAuth2Granters.ts +60 -64
- package/src/services/oAuth2PasswordGranter.ts +5 -4
- package/src/services/oAuth2RefreshTokenGranter.ts +5 -4
- 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.
|
|
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
|

|
|
@@ -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
|
-
`
|
|
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
|
-
|
|
241
|
+
Then import the `postLogin`, `postLogout` and `postRefresh` routes like so:
|
|
241
242
|
|
|
242
243
|
```ts
|
|
243
|
-
// src/routes/
|
|
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
|
-
|
|
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
|
|
332
|
+
own security mechanism:
|
|
332
333
|
|
|
333
334
|
```ts
|
|
334
|
-
// In a `src/routes/postOAuth2Token.ts`
|
|
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/getOAuth2WellKnownMetadata.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
|
|
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/getOAuth2WellKnownMetadata.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
|
-
|
|
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,
|
|
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,wCAAwC,CAAC;AAChD,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"}
|
package/dist/index.test.js
CHANGED
|
@@ -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
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
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
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
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
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
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
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
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
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
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
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
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
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
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,
|