@whook/oauth2 25.2.1 → 26.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 +147 -98
- package/dist/index.d.ts +34 -11
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +1671 -393
- package/dist/index.test.js.map +1 -1
- package/dist/libs/authorizationRequests.d.ts +6 -0
- package/dist/libs/authorizationRequests.js +22 -0
- package/dist/libs/authorizationRequests.js.map +1 -0
- package/dist/libs/authorizationRequests.test.js +24 -0
- package/dist/libs/authorizationRequests.test.js.map +1 -0
- package/dist/libs/clients.d.ts +2 -0
- package/dist/libs/clients.js +13 -0
- package/dist/libs/clients.js.map +1 -0
- package/dist/libs/errors.d.ts +143 -0
- package/dist/libs/errors.js +227 -0
- package/dist/libs/errors.js.map +1 -0
- package/dist/libs/grants.d.ts +2 -0
- package/dist/libs/grants.js +10 -0
- package/dist/libs/grants.js.map +1 -0
- package/dist/libs/redirectURI.d.ts +8 -0
- package/dist/libs/redirectURI.js +94 -0
- package/dist/libs/redirectURI.js.map +1 -0
- package/dist/libs/schemas.d.ts +31 -0
- package/dist/libs/schemas.js +33 -0
- package/dist/libs/schemas.js.map +1 -0
- package/dist/libs/scopes.d.ts +16 -0
- package/dist/libs/scopes.js +37 -0
- package/dist/libs/scopes.js.map +1 -1
- package/dist/libs/utils.d.ts +2 -0
- package/dist/libs/utils.js +17 -0
- package/dist/libs/utils.js.map +1 -0
- package/dist/libs/verifier.d.ts +10 -0
- package/dist/libs/verifier.js +51 -0
- package/dist/libs/verifier.js.map +1 -0
- package/dist/libs/verifier.test.d.ts +1 -0
- package/dist/libs/verifier.test.js +21 -0
- package/dist/libs/verifier.test.js.map +1 -0
- package/dist/routes/getOAuth2Authorize.d.ts +38 -59
- package/dist/routes/getOAuth2Authorize.js +129 -93
- package/dist/routes/getOAuth2Authorize.js.map +1 -1
- package/dist/routes/getOAuth2Authorize.test.js +959 -73
- package/dist/routes/getOAuth2Authorize.test.js.map +1 -1
- package/dist/routes/getOAuth2WellKnownMetadata.d.ts +18 -11
- package/dist/routes/getOAuth2WellKnownMetadata.js +43 -11
- package/dist/routes/getOAuth2WellKnownMetadata.js.map +1 -1
- package/dist/routes/getOAuth2WellKnownMetadata.test.js +51 -49
- package/dist/routes/getOAuth2WellKnownMetadata.test.js.map +1 -1
- package/dist/routes/getOAuth2WellKnownProtectedResourceMetadata.d.ts +3 -6
- package/dist/routes/getOAuth2WellKnownProtectedResourceMetadata.js +3 -6
- package/dist/routes/getOAuth2WellKnownProtectedResourceMetadata.js.map +1 -1
- package/dist/routes/postAuthLogin.d.ts +14 -9
- package/dist/routes/postAuthLogin.js +10 -5
- package/dist/routes/postAuthLogin.js.map +1 -1
- package/dist/routes/postAuthLogin.test.js +79 -55
- package/dist/routes/postAuthLogin.test.js.map +1 -1
- package/dist/routes/postAuthLogout.d.ts +5 -2
- package/dist/routes/postAuthLogout.js +12 -7
- package/dist/routes/postAuthLogout.js.map +1 -1
- package/dist/routes/postAuthLogout.test.js +35 -17
- package/dist/routes/postAuthLogout.test.js.map +1 -1
- package/dist/routes/postAuthRefresh.d.ts +14 -9
- package/dist/routes/postAuthRefresh.js +10 -6
- package/dist/routes/postAuthRefresh.js.map +1 -1
- package/dist/routes/postAuthRefresh.test.js +90 -59
- package/dist/routes/postAuthRefresh.test.js.map +1 -1
- package/dist/routes/postOAuth2Acknowledge.d.ts +11 -10
- package/dist/routes/postOAuth2Acknowledge.js +43 -37
- package/dist/routes/postOAuth2Acknowledge.js.map +1 -1
- package/dist/routes/postOAuth2Acknowledge.test.js +135 -70
- package/dist/routes/postOAuth2Acknowledge.test.js.map +1 -1
- package/dist/routes/postOAuth2PushedAuthorizationRequest.d.ts +137 -0
- package/dist/routes/postOAuth2PushedAuthorizationRequest.js +187 -0
- package/dist/routes/postOAuth2PushedAuthorizationRequest.js.map +1 -0
- package/dist/routes/postOAuth2PushedAuthorizationRequest.test.d.ts +1 -0
- package/dist/routes/postOAuth2PushedAuthorizationRequest.test.js +554 -0
- package/dist/routes/postOAuth2PushedAuthorizationRequest.test.js.map +1 -0
- package/dist/routes/postOAuth2Revoke.d.ts +99 -0
- package/dist/routes/postOAuth2Revoke.js +102 -0
- package/dist/routes/postOAuth2Revoke.js.map +1 -0
- package/dist/routes/postOAuth2Revoke.test.d.ts +1 -0
- package/dist/routes/postOAuth2Revoke.test.js +161 -0
- package/dist/routes/postOAuth2Revoke.test.js.map +1 -0
- package/dist/routes/postOAuth2Token.d.ts +47 -108
- package/dist/routes/postOAuth2Token.js +65 -114
- package/dist/routes/postOAuth2Token.js.map +1 -1
- package/dist/routes/postOAuth2Token.test.js +493 -61
- package/dist/routes/postOAuth2Token.test.js.map +1 -1
- package/dist/services/authCookies.d.ts +9 -13
- package/dist/services/authCookies.js +9 -5
- package/dist/services/authCookies.js.map +1 -1
- package/dist/services/authCookies.test.js.map +1 -1
- package/dist/services/oAuth2AuthorizationCodeGranter.d.ts +124 -0
- package/dist/services/oAuth2AuthorizationCodeGranter.js +204 -0
- package/dist/services/oAuth2AuthorizationCodeGranter.js.map +1 -0
- package/dist/services/oAuth2AuthorizationCodeGranter.test.d.ts +1 -0
- package/dist/services/oAuth2AuthorizationCodeGranter.test.js +345 -0
- package/dist/services/oAuth2AuthorizationCodeGranter.test.js.map +1 -0
- package/dist/services/oAuth2AuthorizationRequests.d.ts +41 -0
- package/dist/services/oAuth2AuthorizationRequests.js +61 -0
- package/dist/services/oAuth2AuthorizationRequests.js.map +1 -0
- package/dist/services/oAuth2AuthorizationRequests.test.d.ts +1 -0
- package/dist/services/oAuth2AuthorizationRequests.test.js +249 -0
- package/dist/services/oAuth2AuthorizationRequests.test.js.map +1 -0
- package/dist/services/oAuth2ClientCredentialsGranter.d.ts +28 -12
- package/dist/services/oAuth2ClientCredentialsGranter.js +39 -21
- package/dist/services/oAuth2ClientCredentialsGranter.js.map +1 -1
- package/dist/services/oAuth2ClientCredentialsGranter.test.d.ts +1 -0
- package/dist/services/oAuth2ClientCredentialsGranter.test.js +265 -0
- package/dist/services/oAuth2ClientCredentialsGranter.test.js.map +1 -0
- package/dist/services/oAuth2Granters.d.ts +79 -86
- package/dist/services/oAuth2Granters.js +2 -67
- package/dist/services/oAuth2Granters.js.map +1 -1
- package/dist/services/oAuth2ImplicitGranter.d.ts +38 -0
- package/dist/services/oAuth2ImplicitGranter.js +61 -0
- package/dist/services/oAuth2ImplicitGranter.js.map +1 -0
- package/dist/services/oAuth2ImplicitGranter.test.d.ts +1 -0
- package/dist/services/oAuth2ImplicitGranter.test.js +589 -0
- package/dist/services/oAuth2ImplicitGranter.test.js.map +1 -0
- package/dist/services/oAuth2PasswordGranter.d.ts +43 -10
- package/dist/services/oAuth2PasswordGranter.js +53 -18
- package/dist/services/oAuth2PasswordGranter.js.map +1 -1
- package/dist/services/oAuth2PasswordGranter.test.d.ts +1 -0
- package/dist/services/oAuth2PasswordGranter.test.js +455 -0
- package/dist/services/oAuth2PasswordGranter.test.js.map +1 -0
- package/dist/services/oAuth2RefreshTokenGranter.d.ts +42 -9
- package/dist/services/oAuth2RefreshTokenGranter.js +60 -21
- package/dist/services/oAuth2RefreshTokenGranter.js.map +1 -1
- package/dist/services/oAuth2RefreshTokenGranter.test.d.ts +1 -0
- package/dist/services/oAuth2RefreshTokenGranter.test.js +403 -0
- package/dist/services/oAuth2RefreshTokenGranter.test.js.map +1 -0
- package/package.json +14 -13
- package/src/index.test.ts +1773 -407
- package/src/index.ts +63 -53
- package/src/libs/authorizationRequests.test.ts +40 -0
- package/src/libs/authorizationRequests.ts +42 -0
- package/src/libs/clients.ts +22 -0
- package/src/libs/errors.ts +411 -0
- package/src/libs/grants.ts +15 -0
- package/src/libs/redirectURI.ts +142 -0
- package/src/libs/schemas.ts +37 -0
- package/src/libs/scopes.ts +49 -0
- package/src/libs/utils.ts +24 -0
- package/src/libs/verifier.test.ts +37 -0
- package/src/libs/verifier.ts +75 -0
- package/src/routes/getOAuth2Authorize.test.ts +1102 -102
- package/src/routes/getOAuth2Authorize.ts +243 -151
- package/src/routes/getOAuth2WellKnownMetadata.test.ts +73 -74
- package/src/routes/getOAuth2WellKnownMetadata.ts +63 -16
- package/src/routes/getOAuth2WellKnownProtectedResourceMetadata.ts +4 -6
- package/src/routes/postAuthLogin.test.ts +86 -57
- package/src/routes/postAuthLogin.ts +24 -14
- package/src/routes/postAuthLogout.test.ts +42 -18
- package/src/routes/postAuthLogout.ts +22 -8
- package/src/routes/postAuthRefresh.test.ts +98 -61
- package/src/routes/postAuthRefresh.ts +25 -13
- package/src/routes/postOAuth2Acknowledge.test.ts +167 -108
- package/src/routes/postOAuth2Acknowledge.ts +90 -64
- package/src/routes/postOAuth2PushedAuthorizationRequest.test.ts +681 -0
- package/src/routes/postOAuth2PushedAuthorizationRequest.ts +292 -0
- package/src/routes/postOAuth2Revoke.test.ts +179 -0
- package/src/routes/postOAuth2Revoke.ts +156 -0
- package/src/routes/postOAuth2Token.test.ts +570 -108
- package/src/routes/postOAuth2Token.ts +104 -136
- package/src/services/authCookies.test.ts +5 -5
- package/src/services/authCookies.ts +24 -22
- package/src/services/oAuth2AuthorizationCodeGranter.test.ts +407 -0
- package/src/services/oAuth2AuthorizationCodeGranter.ts +365 -0
- package/src/services/oAuth2AuthorizationRequests.test.ts +282 -0
- package/src/services/oAuth2AuthorizationRequests.ts +141 -0
- package/src/services/oAuth2ClientCredentialsGranter.test.ts +303 -0
- package/src/services/oAuth2ClientCredentialsGranter.ts +68 -43
- package/src/services/oAuth2Granters.ts +100 -196
- package/src/services/oAuth2ImplicitGranter.test.ts +650 -0
- package/src/services/oAuth2ImplicitGranter.ts +147 -0
- package/src/services/oAuth2PasswordGranter.test.ts +493 -0
- package/src/services/oAuth2PasswordGranter.ts +116 -40
- package/src/services/oAuth2RefreshTokenGranter.test.ts +441 -0
- package/src/services/oAuth2RefreshTokenGranter.ts +118 -51
- package/src/types.d.ts +1 -0
- package/dist/services/oAuth2CodeGranter.d.ts +0 -41
- package/dist/services/oAuth2CodeGranter.js +0 -105
- package/dist/services/oAuth2CodeGranter.js.map +0 -1
- package/dist/services/oAuth2CodeGranter.test.js +0 -123
- package/dist/services/oAuth2CodeGranter.test.js.map +0 -1
- package/dist/services/oAuth2TokenGranter.d.ts +0 -22
- package/dist/services/oAuth2TokenGranter.js +0 -64
- package/dist/services/oAuth2TokenGranter.js.map +0 -1
- package/src/__snapshots__/index.test.ts.snap +0 -401
- package/src/routes/__snapshots__/getOAuth2Authorize.test.ts.snap +0 -37
- package/src/routes/__snapshots__/postOAuth2Acknowledge.test.ts.snap +0 -61
- package/src/routes/__snapshots__/postOAuth2Token.test.ts.snap +0 -52
- package/src/services/__snapshots__/oAuth2CodeGranter.test.ts.snap +0 -52
- package/src/services/oAuth2CodeGranter.test.ts +0 -176
- package/src/services/oAuth2CodeGranter.ts +0 -210
- package/src/services/oAuth2TokenGranter.ts +0 -119
- /package/dist/{services/oAuth2CodeGranter.test.d.ts → libs/authorizationRequests.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -13,17 +13,18 @@
|
|
|
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. To use the
|
|
17
|
-
requires a server side rendered frontend that
|
|
18
|
-
authenticate and allow client applications to
|
|
16
|
+
[Whook](https://github.com/nfroidure/whook) server. To use the implicit, code
|
|
17
|
+
and other user facing flows, it requires a server side rendered frontend that
|
|
18
|
+
brings the UI that allows users to authenticate and allow client applications to
|
|
19
|
+
act on behalf of them.
|
|
19
20
|
|
|
20
21
|

|
|
21
22
|
|
|
22
23
|
The module provides:
|
|
23
24
|
|
|
24
|
-
-
|
|
25
|
-
(`
|
|
26
|
-
applications,
|
|
25
|
+
- 3 OAuth2 routes definitions implementing the OAuth2 standard endpoints
|
|
26
|
+
(`getOAuth2Authorize`, `postOAuth2Token`, `postOAuth2Revoke`) to be used by
|
|
27
|
+
OAuth2 client applications,
|
|
27
28
|
- 4 authentication endpoints to be used by the authorization server directly to
|
|
28
29
|
authenticate users (`postAuthLogin`, `postAuthRefresh`, `postAuthLogout`) and
|
|
29
30
|
acknowledge the client requests (`postOAuth2Acknowledge`),
|
|
@@ -34,15 +35,13 @@ This module requires you to implement some services it relies on:
|
|
|
34
35
|
|
|
35
36
|
- `oAuth2AccessToken` that generates and checks the `access_token` and the
|
|
36
37
|
`oAuth2RefreshToken` for the `refresh_token`, both have the same interface,
|
|
37
|
-
- `
|
|
38
|
-
can be used or not for a given grant type, a given scope and redirect URI,
|
|
38
|
+
- `readClientGrants` service that returns the grants for a given client id,
|
|
39
39
|
- `oAuth2PasswordService` aimed to check the `password` grant type with your own
|
|
40
40
|
logic (if you use it),
|
|
41
41
|
- `oAuth2ClientCredentialsService` aimed to check the `client_credential` grant
|
|
42
42
|
type with your own logic (if you use it),
|
|
43
|
-
- `
|
|
44
|
-
(if you use it).
|
|
45
|
-
logic in it.
|
|
43
|
+
- `oAuth2AuthorizationCodeService` aimed to check the `code` grant type with
|
|
44
|
+
your own logic (if you use it).
|
|
46
45
|
|
|
47
46
|
## Quick setup
|
|
48
47
|
|
|
@@ -74,7 +73,7 @@ Declare this module types in your `src/whook.d.ts` type definitions:
|
|
|
74
73
|
|
|
75
74
|
```diff
|
|
76
75
|
+import {
|
|
77
|
-
+ type
|
|
76
|
+
+ type WhookOAuth2Config,
|
|
78
77
|
+} from '@whook/oauth2';
|
|
79
78
|
|
|
80
79
|
// ...
|
|
@@ -86,8 +85,7 @@ declare module 'application-services' {
|
|
|
86
85
|
export interface AppConfig
|
|
87
86
|
- extends WhookBaseConfigs {}
|
|
88
87
|
+ extends WhookBaseConfigs,
|
|
89
|
-
+
|
|
90
|
-
+ OAuth2Config {}
|
|
88
|
+
+ WhookOAuth2Config {}
|
|
91
89
|
|
|
92
90
|
// ...
|
|
93
91
|
|
|
@@ -100,7 +98,7 @@ Add the OAuth2 configuration to your config files:
|
|
|
100
98
|
// ...
|
|
101
99
|
+ import {
|
|
102
100
|
+ OAUTH2_ERRORS_DESCRIPTORS,
|
|
103
|
-
+
|
|
101
|
+
+ WhookOAuth2Config,
|
|
104
102
|
+ } from '@whook/oauth2';
|
|
105
103
|
import { type AppConfig } from 'application-services';
|
|
106
104
|
|
|
@@ -133,76 +131,87 @@ Here, for example a handler that implement a verify token mechanism in order to
|
|
|
133
131
|
validate a user subscription:
|
|
134
132
|
|
|
135
133
|
```ts
|
|
136
|
-
import { autoService } from 'knifecycle';
|
|
134
|
+
import { autoService, location } from 'knifecycle';
|
|
137
135
|
import { noop } from '@whook/whook';
|
|
138
136
|
import { type WhookAuthenticationData } from '@whook/authorization';
|
|
139
|
-
import { YError } from 'yerror';
|
|
137
|
+
import { YError, hasYErrorCode } from 'yerror';
|
|
140
138
|
import { type LogService } from 'common-services';
|
|
141
139
|
import {
|
|
142
|
-
type
|
|
143
|
-
type
|
|
140
|
+
type WhookOAuth2ReadClientGrantsService,
|
|
141
|
+
type WhookOAuth2GranterDefinitions,
|
|
142
|
+
type WhookOAuth2GranterService,
|
|
143
|
+
type WhookOAuth2Options,
|
|
144
144
|
} from '@whook/oauth2';
|
|
145
145
|
import { type JWTService } from 'jwt-service';
|
|
146
146
|
import { type PGService } from 'postgresql-service';
|
|
147
|
+
import sql from 'pgsqwell';
|
|
148
|
+
|
|
149
|
+
const VERIFY_USER_GRANTER_TYPE = 'verify_user';
|
|
147
150
|
|
|
148
151
|
export type OAuth2VerifyTokenGranterDependencies = {
|
|
149
|
-
|
|
152
|
+
OAUTH2: WhookOAuth2Options;
|
|
153
|
+
readClientGrants: WhookOAuth2ReadClientGrantsService;
|
|
150
154
|
jwtToken: JWTService<WhookAuthenticationData>;
|
|
151
155
|
pg: Pick<PGService, 'query'>;
|
|
152
156
|
log?: LogService;
|
|
153
157
|
};
|
|
154
|
-
export type OAuth2VerifyTokenGranterParameters = {
|
|
155
|
-
verifyToken: string;
|
|
156
|
-
};
|
|
157
|
-
export type OAuth2VerifyTokenGranterService = OAuth2GranterService<
|
|
158
|
-
unknown,
|
|
159
|
-
unknown,
|
|
160
|
-
OAuth2VerifyTokenGranterParameters,
|
|
161
|
-
WhookAuthenticationData
|
|
162
|
-
>;
|
|
163
|
-
|
|
164
|
-
export default autoService(initOAuth2VerifyTokenGranter);
|
|
165
158
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
159
|
+
export interface OAuth2VerifyTokenGranterDefinitions extends WhookOAuth2GranterDefinitions {
|
|
160
|
+
authenticateParameters: {
|
|
161
|
+
verifyToken: string;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
export type OAuth2VerifyTokenGranterService =
|
|
165
|
+
WhookOAuth2GranterService<OAuth2VerifyTokenGranterDefinitions>;
|
|
171
166
|
|
|
172
167
|
async function initOAuth2VerifyTokenGranter({
|
|
173
|
-
|
|
168
|
+
readClientGrants,
|
|
174
169
|
jwtToken,
|
|
175
170
|
pg,
|
|
176
171
|
log = noop,
|
|
177
172
|
}: OAuth2VerifyTokenGranterDependencies): Promise<OAuth2VerifyTokenGranterService> {
|
|
178
|
-
const authenticateWithVerifyToken: OAuth2VerifyTokenGranterService['
|
|
179
|
-
async ({ verifyToken },
|
|
173
|
+
const authenticateWithVerifyToken: OAuth2VerifyTokenGranterService['authenticate'] =
|
|
174
|
+
async ({ verifyToken }, optionalAuthenticationData) => {
|
|
180
175
|
try {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
176
|
+
const tokenAuthenticationData = await jwtToken.verify(verifyToken);
|
|
177
|
+
|
|
178
|
+
const grants = await readClientGrants(tokenAuthenticationData.clientId);
|
|
179
|
+
|
|
180
|
+
if (!grants.isPublicClient) {
|
|
181
|
+
if (!optionalAuthenticationData) {
|
|
182
|
+
throw new YError('E_UNAUTHORIZED');
|
|
183
|
+
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
if (
|
|
187
|
+
optionalAuthenticationData &&
|
|
188
|
+
optionalAuthenticationData.clientId !==
|
|
189
|
+
tokenAuthenticationData.clientId
|
|
190
|
+
) {
|
|
191
|
+
throw new YError('E_OAUTH2_CLIENT_MISMATCH', [
|
|
192
|
+
optionalAuthenticationData.clientId,
|
|
193
|
+
tokenAuthenticationData.clientId,
|
|
194
|
+
]);
|
|
195
|
+
}
|
|
187
196
|
|
|
188
|
-
|
|
189
|
-
applicationId: authenticationData.applicationId,
|
|
190
|
-
type: 'verify',
|
|
191
|
-
scope: newAuthenticationData.scope,
|
|
192
|
-
});
|
|
197
|
+
checkGrantType(grants.allowedGrantTypes, VERIFY_USER_GRANTER_TYPE);
|
|
193
198
|
|
|
194
|
-
const result = await pg.query(
|
|
195
|
-
|
|
196
|
-
|
|
199
|
+
const result = await pg.query(sql`
|
|
200
|
+
UPDATE users
|
|
201
|
+
SET roles = ARRAY['user'::role]
|
|
202
|
+
WHERE id = ${tokenAuthenticationData.userId}
|
|
203
|
+
`);
|
|
197
204
|
|
|
198
205
|
if (result.rowCount === 0) {
|
|
199
|
-
throw new YError('E_ALREADY_VERIFIED',
|
|
206
|
+
throw new YError('E_ALREADY_VERIFIED', [
|
|
207
|
+
tokenAuthenticationData.userId,
|
|
208
|
+
]);
|
|
200
209
|
}
|
|
201
210
|
|
|
202
|
-
return
|
|
211
|
+
return tokenAuthenticationData;
|
|
203
212
|
} catch (err) {
|
|
204
|
-
if (err
|
|
205
|
-
throw YError.wrap(err
|
|
213
|
+
if (hasYErrorCode(err, 'E_BAD_TOKEN')) {
|
|
214
|
+
throw YError.wrap(err, 'E_BAD_VERIFY_TOKEN');
|
|
206
215
|
}
|
|
207
216
|
throw err;
|
|
208
217
|
}
|
|
@@ -211,34 +220,59 @@ async function initOAuth2VerifyTokenGranter({
|
|
|
211
220
|
log('debug', '👫 - OAuth2VerifyTokenGranter Service Initialized!');
|
|
212
221
|
|
|
213
222
|
return {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
authenticate: authenticateWithVerifyToken,
|
|
218
|
-
},
|
|
223
|
+
grantType: VERIFY_USER_GRANTER_TYPE,
|
|
224
|
+
issuesRefreshToken: true,
|
|
225
|
+
authenticate: authenticateWithVerifyToken,
|
|
219
226
|
};
|
|
220
227
|
}
|
|
228
|
+
|
|
229
|
+
export default location(
|
|
230
|
+
autoService(initOAuth2VerifyTokenGranter),
|
|
231
|
+
import.meta.url,
|
|
232
|
+
);
|
|
221
233
|
```
|
|
222
234
|
|
|
223
235
|
## Additional routes/helpers
|
|
224
236
|
|
|
225
|
-
For internal use, you may prefer use cookies based auth routes like
|
|
226
|
-
`
|
|
237
|
+
For internal use, you may prefer use cookies based auth routes like
|
|
238
|
+
`postAuthLogin`, `postAuthLogout` and `postAuthRefresh`.
|
|
227
239
|
|
|
228
|
-
To do so, configure the `
|
|
240
|
+
To do so, configure the `COOKIES` configurations:
|
|
241
|
+
|
|
242
|
+
Declare this module types in your `src/whook.d.ts` type definitions:
|
|
243
|
+
|
|
244
|
+
```diff
|
|
245
|
+
// src/whook.d.ts
|
|
246
|
+
import {
|
|
247
|
+
type WhookOAuth2Config,
|
|
248
|
+
+ type WhookAuthCookiesConfig,
|
|
249
|
+
} from '@whook/oauth2';
|
|
250
|
+
|
|
251
|
+
// ...
|
|
252
|
+
|
|
253
|
+
declare module 'application-services' {
|
|
254
|
+
|
|
255
|
+
// (...)
|
|
256
|
+
|
|
257
|
+
export interface AppConfig
|
|
258
|
+
extends WhookBaseConfigs,
|
|
259
|
+
+ WhookAuthCookiesConfig,
|
|
260
|
+
WhookOAuth2Config {}
|
|
261
|
+
|
|
262
|
+
// ...
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
```
|
|
229
266
|
|
|
230
267
|
```diff
|
|
231
268
|
// src/production/config.ts
|
|
232
269
|
+ COOKIES: {
|
|
233
270
|
+ domain: 'example.org',
|
|
234
271
|
+ },
|
|
235
|
-
+ ROOT_AUTHENTICATION_DATA: {
|
|
236
|
-
+ applicationId: 'abbacaca-abba-caca-caca-abbacacacaca',
|
|
237
|
-
+ scope: 'user,admin',
|
|
238
|
-
+ },
|
|
239
272
|
```
|
|
240
273
|
|
|
241
|
-
Then import the `
|
|
274
|
+
Then import the `postAuthLogin`, `postAuthLogout` and `postAuthRefresh` routes
|
|
275
|
+
like so:
|
|
242
276
|
|
|
243
277
|
```ts
|
|
244
278
|
// src/routes/postAuthRefresh.ts
|
|
@@ -251,15 +285,14 @@ import { type WhookRouteDefinition } from '@whook/whook';
|
|
|
251
285
|
|
|
252
286
|
export { authCookieHeaderParameter };
|
|
253
287
|
|
|
254
|
-
export const definition
|
|
288
|
+
export const definition = {
|
|
255
289
|
...postAuthRefreshDefinition,
|
|
256
290
|
operation: {
|
|
257
291
|
...postAuthRefreshDefinition.operation,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
},
|
|
292
|
+
// Erase the default config that disables the endpoint
|
|
293
|
+
config: undefined,
|
|
261
294
|
},
|
|
262
|
-
};
|
|
295
|
+
} as const satisfies WhookRouteDefinition;
|
|
263
296
|
|
|
264
297
|
export default initPostAuthRefresh;
|
|
265
298
|
```
|
|
@@ -286,7 +319,7 @@ import { type WhookRouteDefinition } from '@whook/whook';
|
|
|
286
319
|
|
|
287
320
|
export default initPostOAuth2Acknowledge;
|
|
288
321
|
|
|
289
|
-
export const definition
|
|
322
|
+
export const definition = {
|
|
290
323
|
...postOAuth2AcknowledgeDefinition,
|
|
291
324
|
operation: {
|
|
292
325
|
...postOAuth2AcknowledgeDefinition.operation,
|
|
@@ -303,7 +336,7 @@ export const definition: WhookRouteDefinition = {
|
|
|
303
336
|
content: {
|
|
304
337
|
'application/json': {
|
|
305
338
|
schema: {
|
|
306
|
-
...postOAuth2AcknowledgeDefinition.operation.
|
|
339
|
+
...postOAuth2AcknowledgeDefinition.operation.requestBody.content[
|
|
307
340
|
'application/json'
|
|
308
341
|
].schema,
|
|
309
342
|
required: [
|
|
@@ -325,7 +358,7 @@ export const definition: WhookRouteDefinition = {
|
|
|
325
358
|
},
|
|
326
359
|
},
|
|
327
360
|
},
|
|
328
|
-
};
|
|
361
|
+
} as const satisfies WhookRouteDefinition;
|
|
329
362
|
```
|
|
330
363
|
|
|
331
364
|
You will probably need to also protect the `postOAuth2Token` endpoint with your
|
|
@@ -336,35 +369,41 @@ own security mechanism:
|
|
|
336
369
|
import {
|
|
337
370
|
initPostOAuth2Token,
|
|
338
371
|
postOAuth2TokenDefinition,
|
|
372
|
+
postOAuth2TokenTokenBodySchema,
|
|
339
373
|
postOAuth2TokenAuthorizationCodeTokenRequestBodySchema,
|
|
340
|
-
postOAuth2TokenPasswordTokenRequestBodySchema,
|
|
341
374
|
postOAuth2TokenClientCredentialsTokenRequestBodySchema,
|
|
375
|
+
postOAuth2TokenCodeVerifierSchema,
|
|
376
|
+
postOAuth2TokenPasswordTokenRequestBodySchema,
|
|
342
377
|
postOAuth2TokenRefreshTokenRequestBodySchema,
|
|
343
|
-
postOAuth2TokenTokenBodySchema,
|
|
344
378
|
} from '@whook/oauth2';
|
|
345
|
-
import {
|
|
346
|
-
|
|
347
|
-
|
|
379
|
+
import {
|
|
380
|
+
type WhookAPISchemaDefinition,
|
|
381
|
+
type WhookRouteDefinition,
|
|
382
|
+
refersTo,
|
|
383
|
+
} from '@whook/whook';
|
|
348
384
|
|
|
349
|
-
export const definition
|
|
385
|
+
export const definition = {
|
|
350
386
|
...postOAuth2TokenDefinition,
|
|
351
387
|
operation: {
|
|
352
388
|
...postOAuth2TokenDefinition.operation,
|
|
353
389
|
security: [
|
|
354
390
|
{
|
|
355
|
-
basicAuth: ['
|
|
391
|
+
basicAuth: ['oauth2'],
|
|
356
392
|
},
|
|
357
393
|
],
|
|
358
394
|
},
|
|
359
|
-
};
|
|
395
|
+
} as const satisfies WhookRouteDefinition;
|
|
360
396
|
|
|
361
397
|
export {
|
|
398
|
+
postOAuth2TokenTokenBodySchema,
|
|
362
399
|
postOAuth2TokenAuthorizationCodeTokenRequestBodySchema,
|
|
363
|
-
postOAuth2TokenPasswordTokenRequestBodySchema,
|
|
364
400
|
postOAuth2TokenClientCredentialsTokenRequestBodySchema,
|
|
401
|
+
postOAuth2TokenCodeVerifierSchema,
|
|
402
|
+
postOAuth2TokenPasswordTokenRequestBodySchema,
|
|
365
403
|
postOAuth2TokenRefreshTokenRequestBodySchema,
|
|
366
|
-
postOAuth2TokenTokenBodySchema,
|
|
367
404
|
};
|
|
405
|
+
|
|
406
|
+
export default initPostOAuth2Token;
|
|
368
407
|
```
|
|
369
408
|
|
|
370
409
|
Or you may want to reduce the OAuth2 grant types supported:
|
|
@@ -374,33 +413,43 @@ Or you may want to reduce the OAuth2 grant types supported:
|
|
|
374
413
|
import {
|
|
375
414
|
initGetOAuth2Authorize,
|
|
376
415
|
getOAuth2AuthorizeDefinition as definition,
|
|
377
|
-
getOAuth2AuthorizeResponseTypeParameter as baseResponseTypeParameter,
|
|
378
416
|
getOAuth2AuthorizeClientIdParameter as clientIdParameter,
|
|
417
|
+
getOAuth2AuthorizeCodeChallengeMethodParameter as codeChallengeMethodParameter,
|
|
418
|
+
getOAuth2AuthorizeCodeChallengeMethodSchema as codeChallengeMethodSchema,
|
|
419
|
+
getOAuth2AuthorizeCodeChallengeParameter as codeChallengeParameter,
|
|
420
|
+
getOAuth2AuthorizeCodeChallengeSchema as codeChallengeSchema,
|
|
379
421
|
getOAuth2AuthorizeRedirectURIParameter as redirectURIParameter,
|
|
422
|
+
getOAuth2AuthorizeResponseTypeParameter as baseResponseTypeParameter,
|
|
380
423
|
getOAuth2AuthorizeScopeParameter as scopeParameter,
|
|
424
|
+
getOAuth2AuthorizeScopeSchema as scopeSchema,
|
|
381
425
|
getOAuth2AuthorizeStateParameter as stateParameter,
|
|
382
426
|
} from '@whook/oauth2';
|
|
383
427
|
|
|
384
|
-
export default initGetOAuth2Authorize;
|
|
385
|
-
|
|
386
|
-
export {
|
|
387
|
-
definition,
|
|
388
|
-
clientIdParameter,
|
|
389
|
-
redirectURIParameter,
|
|
390
|
-
scopeParameter,
|
|
391
|
-
stateParameter,
|
|
392
|
-
};
|
|
393
|
-
|
|
394
428
|
export const responseTypeParameter = {
|
|
395
429
|
...baseResponseTypeParameter,
|
|
396
430
|
parameter: {
|
|
397
431
|
...baseResponseTypeParameter.parameter,
|
|
398
432
|
schema: {
|
|
399
433
|
...baseResponseTypeParameter.parameter.schema,
|
|
400
|
-
enum: ['code'], // Allow only the 'code'
|
|
434
|
+
enum: ['code'], // Allow only the 'code' response type
|
|
401
435
|
},
|
|
402
436
|
},
|
|
403
437
|
};
|
|
438
|
+
|
|
439
|
+
export {
|
|
440
|
+
definition,
|
|
441
|
+
codeChallengeSchema,
|
|
442
|
+
codeChallengeParameter,
|
|
443
|
+
codeChallengeMethodSchema,
|
|
444
|
+
codeChallengeMethodParameter,
|
|
445
|
+
clientIdParameter,
|
|
446
|
+
redirectURIParameter,
|
|
447
|
+
scopeParameter,
|
|
448
|
+
stateParameter,
|
|
449
|
+
scopeSchema,
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
export default initGetOAuth2Authorize;
|
|
404
453
|
```
|
|
405
454
|
|
|
406
455
|
[//]: # (::contents:end)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,48 @@
|
|
|
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';
|
|
1
|
+
import initGetOAuth2Authorize, { definition as getOAuth2AuthorizeDefinition, responseTypeParameter as getOAuth2AuthorizeResponseTypeParameter, clientIdParameter as getOAuth2AuthorizeClientIdParameter, redirectURIParameter as getOAuth2AuthorizeRedirectURIParameter, scopeParameter as getOAuth2AuthorizeScopeParameter, stateParameter as getOAuth2AuthorizeStateParameter, requestURIParameter as getOAuth2AuthorizeRequestURIParameter, codeChallengeSchema as getOAuth2AuthorizeCodeChallengeSchema, codeChallengeParameter as getOAuth2AuthorizeCodeChallengeParameter, codeChallengeMethodSchema as getOAuth2AuthorizeCodeChallengeMethodSchema, codeChallengeMethodParameter as getOAuth2AuthorizeCodeChallengeMethodParameter, requestURISchema as getOAuth2AuthorizeRequestURISchema, scopeSchema as getOAuth2AuthorizeScopeSchema } from './routes/getOAuth2Authorize.js';
|
|
2
2
|
import initPostOAuth2Acknowledge, { definition as postOAuth2AcknowledgeDefinition } from './routes/postOAuth2Acknowledge.js';
|
|
3
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
|
|
4
|
+
import initPostOAuth2PushedAuthorizationRequest, { definition as postOAuth2PushedAuthorizationRequestDefinition, pushedAuthorizationRequestBodySchema as postOAuth2PushedAuthorizationRequestBodySchema, requestURISchema as postOAuth2PushedAuthorizationRequestRequestURISchema } from './routes/postOAuth2PushedAuthorizationRequest.js';
|
|
5
|
+
import initGetOAuth2WellKnown, { definition as getOAuth2WellKnownDefinition, endpointAuthenticationMethodsSchema as getOAuth2WellKnownEndpointAuthenticationMethodsSchema, jsonWebAlgorithmsSchema as getOAuth2WellKnownJsonWebAlgorithmsSchema, jsonWebEncryptionsSchema as getOAuth2WellKnownJsonWebEncryptionsSchema, httpsProtocolURISchema as getOAuth2WellKnownHTTPSProtocolURISchema, oAuth2MetadataSchema as getOAuth2WellKnownOAuth2MetadataSchema, scopeTokenSchema as getOAuth2WellKnownScopeTokenSchema, scopeTokensSchema as getOAuth2WellKnownScopeTokensSchema } from './routes/getOAuth2WellKnownMetadata.js';
|
|
5
6
|
import initGetOAuth2WellKnownProtectedResource, { definition as getOAuth2WellKnownProtectedResourceDefinition, bearerMethodSchema as getOAuth2WellKnownProtectedResourceBearerMethodSchema, oAuth2ProtectedResourceMetadataSchema as getOAuth2WellKnownProtectedResourceSchema } from './routes/getOAuth2WellKnownProtectedResourceMetadata.js';
|
|
6
|
-
import
|
|
7
|
+
import initPostOAuth2Revoke, { definition as postOAuth2RevokeDefinition, tokenTypeHintSchema as postOAuth2RevokeTokenTypeHintSchema, revokeTokenRequestBodySchema as postOAuth2RevokeTokenRequestBodySchema } from './routes/postOAuth2Revoke.js';
|
|
8
|
+
export type * from './routes/postOAuth2Revoke.js';
|
|
9
|
+
import initOAuth2Granters from './services/oAuth2Granters.js';
|
|
10
|
+
export type * from './services/oAuth2Granters.js';
|
|
7
11
|
import initOAuth2ClientCredentialsGranter from './services/oAuth2ClientCredentialsGranter.js';
|
|
12
|
+
export type * from './services/oAuth2ClientCredentialsGranter.js';
|
|
8
13
|
import initOAuth2PasswordGranter from './services/oAuth2PasswordGranter.js';
|
|
14
|
+
export type * from './services/oAuth2PasswordGranter.js';
|
|
9
15
|
import initOAuth2RefreshTokenGranter from './services/oAuth2RefreshTokenGranter.js';
|
|
10
|
-
|
|
11
|
-
import
|
|
16
|
+
export type * from './services/oAuth2RefreshTokenGranter.js';
|
|
17
|
+
import initOAuth2ImplicitGranter from './services/oAuth2ImplicitGranter.js';
|
|
18
|
+
export type * from './services/oAuth2ImplicitGranter.js';
|
|
19
|
+
import initOAuth2AuthorizationCodeGranter from './services/oAuth2AuthorizationCodeGranter.js';
|
|
20
|
+
export type * from './services/oAuth2AuthorizationCodeGranter.js';
|
|
12
21
|
import initPostAuthLogin, { definition as postAuthLoginDefinition } from './routes/postAuthLogin.js';
|
|
13
22
|
import initPostAuthLogout, { definition as postAuthLogoutDefinition } from './routes/postAuthLogout.js';
|
|
14
23
|
import initPostAuthRefresh, { authCookieHeaderParameter, definition as postAuthRefreshDefinition } from './routes/postAuthRefresh.js';
|
|
15
|
-
import initAuthCookiesService
|
|
16
|
-
import { type
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
import initAuthCookiesService from './services/authCookies.js';
|
|
25
|
+
import { type OAuth2YErrorRegistry } from './libs/errors.js';
|
|
26
|
+
export * from './services/authCookies.js';
|
|
27
|
+
export type * from './services/authCookies.js';
|
|
28
|
+
import initOAuth2AuthorizationRequests from './services/oAuth2AuthorizationRequests.js';
|
|
29
|
+
export * from './services/oAuth2AuthorizationRequests.js';
|
|
30
|
+
export type * from './services/oAuth2AuthorizationRequests.js';
|
|
31
|
+
export * from './libs/schemas.js';
|
|
32
|
+
export type * from './libs/schemas.js';
|
|
33
|
+
export * from './libs/errors.js';
|
|
34
|
+
export type * from './libs/errors.js';
|
|
35
|
+
export * from './libs/scopes.js';
|
|
36
|
+
export type * from './libs/scopes.js';
|
|
37
|
+
export * from './libs/grants.js';
|
|
38
|
+
export type * from './libs/grants.js';
|
|
39
|
+
export * from './libs/redirectURI.js';
|
|
40
|
+
export type * from './libs/redirectURI.js';
|
|
41
|
+
export * from './libs/verifier.js';
|
|
42
|
+
export type * from './libs/verifier.js';
|
|
19
43
|
declare module 'yerror' {
|
|
20
44
|
interface YErrorRegistry extends OAuth2YErrorRegistry {
|
|
21
45
|
E_UNEXPECTED: unknown[];
|
|
22
46
|
}
|
|
23
47
|
}
|
|
24
|
-
export
|
|
25
|
-
export { initGetOAuth2Authorize, getOAuth2AuthorizeDefinition, getOAuth2AuthorizeResponseTypeParameter, getOAuth2AuthorizeClientIdParameter, getOAuth2AuthorizeRedirectURIParameter, getOAuth2AuthorizeScopeParameter, getOAuth2AuthorizeStateParameter, getOAuth2AuthorizeCodeChallengeSchema, getOAuth2AuthorizeCodeChallengeMethodSchema, getOAuth2AuthorizeCodeChallengeParameter, getOAuth2AuthorizeCodeChallengeMethodParameter, initGetOAuth2WellKnown, getOAuth2WellKnownDefinition, getOAuth2WellKnownEndpointAuthenticationMethodsSchema, getOAuth2WellKnownJsonWebAlgorithmsSchema, getOAuth2WellKnownJsonWebEncryptionsSchema, getOAuth2WellKnownHTTPSProtocolURISchema, getOAuth2WellKnownOAuth2MetadataSchema, initGetOAuth2WellKnownProtectedResource, getOAuth2WellKnownProtectedResourceDefinition, getOAuth2WellKnownProtectedResourceBearerMethodSchema, getOAuth2WellKnownProtectedResourceSchema, 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, collectScopesFromAPI, };
|
|
48
|
+
export { initGetOAuth2Authorize, getOAuth2AuthorizeDefinition, getOAuth2AuthorizeResponseTypeParameter, getOAuth2AuthorizeClientIdParameter, getOAuth2AuthorizeRedirectURIParameter, getOAuth2AuthorizeScopeParameter, getOAuth2AuthorizeStateParameter, getOAuth2AuthorizeRequestURIParameter, getOAuth2AuthorizeScopeSchema, getOAuth2AuthorizeCodeChallengeSchema, getOAuth2AuthorizeCodeChallengeMethodSchema, getOAuth2AuthorizeCodeChallengeParameter, getOAuth2AuthorizeCodeChallengeMethodParameter, getOAuth2AuthorizeRequestURISchema, initGetOAuth2WellKnown, getOAuth2WellKnownDefinition, getOAuth2WellKnownEndpointAuthenticationMethodsSchema, getOAuth2WellKnownJsonWebAlgorithmsSchema, getOAuth2WellKnownJsonWebEncryptionsSchema, getOAuth2WellKnownHTTPSProtocolURISchema, getOAuth2WellKnownOAuth2MetadataSchema, getOAuth2WellKnownScopeTokenSchema, getOAuth2WellKnownScopeTokensSchema, initGetOAuth2WellKnownProtectedResource, getOAuth2WellKnownProtectedResourceDefinition, getOAuth2WellKnownProtectedResourceBearerMethodSchema, getOAuth2WellKnownProtectedResourceSchema, initPostOAuth2Revoke, postOAuth2RevokeDefinition, postOAuth2RevokeTokenTypeHintSchema, postOAuth2RevokeTokenRequestBodySchema, initPostOAuth2Acknowledge, postOAuth2AcknowledgeDefinition, initPostOAuth2Token, postOAuth2TokenDefinition, postOAuth2TokenCodeVerifierSchema, postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, postOAuth2TokenPasswordTokenRequestBodySchema, postOAuth2TokenClientCredentialsTokenRequestBodySchema, postOAuth2TokenRefreshTokenRequestBodySchema, postOAuth2TokenTokenBodySchema, initPostOAuth2PushedAuthorizationRequest, postOAuth2PushedAuthorizationRequestDefinition, postOAuth2PushedAuthorizationRequestBodySchema, postOAuth2PushedAuthorizationRequestRequestURISchema, initOAuth2Granters, initOAuth2ClientCredentialsGranter, initOAuth2AuthorizationCodeGranter, initOAuth2PasswordGranter, initOAuth2RefreshTokenGranter, initOAuth2ImplicitGranter, authCookieHeaderParameter, initPostAuthLogin, postAuthLoginDefinition, initPostAuthLogout, postAuthLogoutDefinition, initPostAuthRefresh, postAuthRefreshDefinition, initAuthCookiesService, initOAuth2AuthorizationRequests, };
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
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';
|
|
1
|
+
import initGetOAuth2Authorize, { definition as getOAuth2AuthorizeDefinition, responseTypeParameter as getOAuth2AuthorizeResponseTypeParameter, clientIdParameter as getOAuth2AuthorizeClientIdParameter, redirectURIParameter as getOAuth2AuthorizeRedirectURIParameter, scopeParameter as getOAuth2AuthorizeScopeParameter, stateParameter as getOAuth2AuthorizeStateParameter, requestURIParameter as getOAuth2AuthorizeRequestURIParameter, codeChallengeSchema as getOAuth2AuthorizeCodeChallengeSchema, codeChallengeParameter as getOAuth2AuthorizeCodeChallengeParameter, codeChallengeMethodSchema as getOAuth2AuthorizeCodeChallengeMethodSchema, codeChallengeMethodParameter as getOAuth2AuthorizeCodeChallengeMethodParameter, requestURISchema as getOAuth2AuthorizeRequestURISchema, scopeSchema as getOAuth2AuthorizeScopeSchema, } from './routes/getOAuth2Authorize.js';
|
|
2
2
|
import initPostOAuth2Acknowledge, { definition as postOAuth2AcknowledgeDefinition, } from './routes/postOAuth2Acknowledge.js';
|
|
3
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
|
|
4
|
+
import initPostOAuth2PushedAuthorizationRequest, { definition as postOAuth2PushedAuthorizationRequestDefinition, pushedAuthorizationRequestBodySchema as postOAuth2PushedAuthorizationRequestBodySchema, requestURISchema as postOAuth2PushedAuthorizationRequestRequestURISchema, } from './routes/postOAuth2PushedAuthorizationRequest.js';
|
|
5
|
+
import initGetOAuth2WellKnown, { definition as getOAuth2WellKnownDefinition, endpointAuthenticationMethodsSchema as getOAuth2WellKnownEndpointAuthenticationMethodsSchema, jsonWebAlgorithmsSchema as getOAuth2WellKnownJsonWebAlgorithmsSchema, jsonWebEncryptionsSchema as getOAuth2WellKnownJsonWebEncryptionsSchema, httpsProtocolURISchema as getOAuth2WellKnownHTTPSProtocolURISchema, oAuth2MetadataSchema as getOAuth2WellKnownOAuth2MetadataSchema, scopeTokenSchema as getOAuth2WellKnownScopeTokenSchema, scopeTokensSchema as getOAuth2WellKnownScopeTokensSchema, } from './routes/getOAuth2WellKnownMetadata.js';
|
|
5
6
|
import initGetOAuth2WellKnownProtectedResource, { definition as getOAuth2WellKnownProtectedResourceDefinition, bearerMethodSchema as getOAuth2WellKnownProtectedResourceBearerMethodSchema, oAuth2ProtectedResourceMetadataSchema as getOAuth2WellKnownProtectedResourceSchema, } from './routes/getOAuth2WellKnownProtectedResourceMetadata.js';
|
|
6
|
-
import
|
|
7
|
+
import initPostOAuth2Revoke, { definition as postOAuth2RevokeDefinition, tokenTypeHintSchema as postOAuth2RevokeTokenTypeHintSchema, revokeTokenRequestBodySchema as postOAuth2RevokeTokenRequestBodySchema, } from './routes/postOAuth2Revoke.js';
|
|
8
|
+
import initOAuth2Granters from './services/oAuth2Granters.js';
|
|
7
9
|
import initOAuth2ClientCredentialsGranter from './services/oAuth2ClientCredentialsGranter.js';
|
|
8
10
|
import initOAuth2PasswordGranter from './services/oAuth2PasswordGranter.js';
|
|
9
11
|
import initOAuth2RefreshTokenGranter from './services/oAuth2RefreshTokenGranter.js';
|
|
10
|
-
import
|
|
12
|
+
import initOAuth2ImplicitGranter from './services/oAuth2ImplicitGranter.js';
|
|
13
|
+
import initOAuth2AuthorizationCodeGranter from './services/oAuth2AuthorizationCodeGranter.js';
|
|
11
14
|
import initPostAuthLogin, { definition as postAuthLoginDefinition, } from './routes/postAuthLogin.js';
|
|
12
15
|
import initPostAuthLogout, { definition as postAuthLogoutDefinition, } from './routes/postAuthLogout.js';
|
|
13
16
|
import initPostAuthRefresh, { authCookieHeaderParameter, definition as postAuthRefreshDefinition, } from './routes/postAuthRefresh.js';
|
|
14
|
-
import initAuthCookiesService
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
export
|
|
17
|
+
import initAuthCookiesService from './services/authCookies.js';
|
|
18
|
+
export * from './services/authCookies.js';
|
|
19
|
+
import initOAuth2AuthorizationRequests from './services/oAuth2AuthorizationRequests.js';
|
|
20
|
+
export * from './services/oAuth2AuthorizationRequests.js';
|
|
21
|
+
export * from './libs/schemas.js';
|
|
22
|
+
export * from './libs/errors.js';
|
|
23
|
+
export * from './libs/scopes.js';
|
|
24
|
+
export * from './libs/grants.js';
|
|
25
|
+
export * from './libs/redirectURI.js';
|
|
26
|
+
export * from './libs/verifier.js';
|
|
27
|
+
export { initGetOAuth2Authorize, getOAuth2AuthorizeDefinition, getOAuth2AuthorizeResponseTypeParameter, getOAuth2AuthorizeClientIdParameter, getOAuth2AuthorizeRedirectURIParameter, getOAuth2AuthorizeScopeParameter, getOAuth2AuthorizeStateParameter, getOAuth2AuthorizeRequestURIParameter, getOAuth2AuthorizeScopeSchema, getOAuth2AuthorizeCodeChallengeSchema, getOAuth2AuthorizeCodeChallengeMethodSchema, getOAuth2AuthorizeCodeChallengeParameter, getOAuth2AuthorizeCodeChallengeMethodParameter, getOAuth2AuthorizeRequestURISchema, initGetOAuth2WellKnown, getOAuth2WellKnownDefinition, getOAuth2WellKnownEndpointAuthenticationMethodsSchema, getOAuth2WellKnownJsonWebAlgorithmsSchema, getOAuth2WellKnownJsonWebEncryptionsSchema, getOAuth2WellKnownHTTPSProtocolURISchema, getOAuth2WellKnownOAuth2MetadataSchema, getOAuth2WellKnownScopeTokenSchema, getOAuth2WellKnownScopeTokensSchema, initGetOAuth2WellKnownProtectedResource, getOAuth2WellKnownProtectedResourceDefinition, getOAuth2WellKnownProtectedResourceBearerMethodSchema, getOAuth2WellKnownProtectedResourceSchema, initPostOAuth2Revoke, postOAuth2RevokeDefinition, postOAuth2RevokeTokenTypeHintSchema, postOAuth2RevokeTokenRequestBodySchema, initPostOAuth2Acknowledge, postOAuth2AcknowledgeDefinition, initPostOAuth2Token, postOAuth2TokenDefinition, postOAuth2TokenCodeVerifierSchema, postOAuth2TokenAuthorizationCodeTokenRequestBodySchema, postOAuth2TokenPasswordTokenRequestBodySchema, postOAuth2TokenClientCredentialsTokenRequestBodySchema, postOAuth2TokenRefreshTokenRequestBodySchema, postOAuth2TokenTokenBodySchema, initPostOAuth2PushedAuthorizationRequest, postOAuth2PushedAuthorizationRequestDefinition, postOAuth2PushedAuthorizationRequestBodySchema, postOAuth2PushedAuthorizationRequestRequestURISchema, initOAuth2Granters, initOAuth2ClientCredentialsGranter, initOAuth2AuthorizationCodeGranter, initOAuth2PasswordGranter, initOAuth2RefreshTokenGranter, initOAuth2ImplicitGranter, authCookieHeaderParameter, initPostAuthLogin, postAuthLoginDefinition, initPostAuthLogout, postAuthLogoutDefinition, initPostAuthRefresh, postAuthRefreshDefinition, initAuthCookiesService, initOAuth2AuthorizationRequests, };
|
|
18
28
|
//# 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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