@whook/oauth2 25.2.1 → 26.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 (173) hide show
  1. package/README.md +147 -98
  2. package/dist/index.d.ts +30 -11
  3. package/dist/index.js +15 -8
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.test.js +1258 -399
  6. package/dist/index.test.js.map +1 -1
  7. package/dist/libs/clients.d.ts +2 -0
  8. package/dist/libs/clients.js +13 -0
  9. package/dist/libs/clients.js.map +1 -0
  10. package/dist/libs/errors.d.ts +113 -0
  11. package/dist/libs/errors.js +178 -0
  12. package/dist/libs/errors.js.map +1 -0
  13. package/dist/libs/grants.d.ts +2 -0
  14. package/dist/libs/grants.js +10 -0
  15. package/dist/libs/grants.js.map +1 -0
  16. package/dist/libs/redirectURI.d.ts +7 -0
  17. package/dist/libs/redirectURI.js +78 -0
  18. package/dist/libs/redirectURI.js.map +1 -0
  19. package/dist/libs/schemas.d.ts +23 -0
  20. package/dist/libs/schemas.js +25 -0
  21. package/dist/libs/schemas.js.map +1 -0
  22. package/dist/libs/scopes.d.ts +16 -0
  23. package/dist/libs/scopes.js +37 -0
  24. package/dist/libs/scopes.js.map +1 -1
  25. package/dist/libs/utils.d.ts +2 -0
  26. package/dist/libs/utils.js +17 -0
  27. package/dist/libs/utils.js.map +1 -0
  28. package/dist/libs/verifier.d.ts +7 -0
  29. package/dist/libs/verifier.js +37 -0
  30. package/dist/libs/verifier.js.map +1 -0
  31. package/dist/libs/verifier.test.js +21 -0
  32. package/dist/libs/verifier.test.js.map +1 -0
  33. package/dist/routes/getOAuth2Authorize.d.ts +13 -50
  34. package/dist/routes/getOAuth2Authorize.js +60 -86
  35. package/dist/routes/getOAuth2Authorize.js.map +1 -1
  36. package/dist/routes/getOAuth2Authorize.test.js +147 -68
  37. package/dist/routes/getOAuth2Authorize.test.js.map +1 -1
  38. package/dist/routes/getOAuth2WellKnownMetadata.d.ts +8 -8
  39. package/dist/routes/getOAuth2WellKnownMetadata.js +15 -8
  40. package/dist/routes/getOAuth2WellKnownMetadata.js.map +1 -1
  41. package/dist/routes/getOAuth2WellKnownMetadata.test.js +37 -37
  42. package/dist/routes/getOAuth2WellKnownMetadata.test.js.map +1 -1
  43. package/dist/routes/getOAuth2WellKnownProtectedResourceMetadata.d.ts +3 -6
  44. package/dist/routes/getOAuth2WellKnownProtectedResourceMetadata.js +3 -6
  45. package/dist/routes/getOAuth2WellKnownProtectedResourceMetadata.js.map +1 -1
  46. package/dist/routes/postAuthLogin.d.ts +14 -9
  47. package/dist/routes/postAuthLogin.js +10 -5
  48. package/dist/routes/postAuthLogin.js.map +1 -1
  49. package/dist/routes/postAuthLogin.test.js +79 -55
  50. package/dist/routes/postAuthLogin.test.js.map +1 -1
  51. package/dist/routes/postAuthLogout.d.ts +5 -2
  52. package/dist/routes/postAuthLogout.js +12 -7
  53. package/dist/routes/postAuthLogout.js.map +1 -1
  54. package/dist/routes/postAuthLogout.test.js +35 -17
  55. package/dist/routes/postAuthLogout.test.js.map +1 -1
  56. package/dist/routes/postAuthRefresh.d.ts +14 -9
  57. package/dist/routes/postAuthRefresh.js +10 -6
  58. package/dist/routes/postAuthRefresh.js.map +1 -1
  59. package/dist/routes/postAuthRefresh.test.js +90 -59
  60. package/dist/routes/postAuthRefresh.test.js.map +1 -1
  61. package/dist/routes/postOAuth2Acknowledge.d.ts +11 -10
  62. package/dist/routes/postOAuth2Acknowledge.js +43 -37
  63. package/dist/routes/postOAuth2Acknowledge.js.map +1 -1
  64. package/dist/routes/postOAuth2Acknowledge.test.js +135 -70
  65. package/dist/routes/postOAuth2Acknowledge.test.js.map +1 -1
  66. package/dist/routes/postOAuth2Revoke.d.ts +99 -0
  67. package/dist/routes/postOAuth2Revoke.js +102 -0
  68. package/dist/routes/postOAuth2Revoke.js.map +1 -0
  69. package/dist/routes/postOAuth2Revoke.test.d.ts +1 -0
  70. package/dist/routes/postOAuth2Revoke.test.js +161 -0
  71. package/dist/routes/postOAuth2Revoke.test.js.map +1 -0
  72. package/dist/routes/postOAuth2Token.d.ts +35 -108
  73. package/dist/routes/postOAuth2Token.js +53 -114
  74. package/dist/routes/postOAuth2Token.js.map +1 -1
  75. package/dist/routes/postOAuth2Token.test.js +493 -61
  76. package/dist/routes/postOAuth2Token.test.js.map +1 -1
  77. package/dist/services/authCookies.d.ts +9 -13
  78. package/dist/services/authCookies.js +1 -1
  79. package/dist/services/authCookies.js.map +1 -1
  80. package/dist/services/authCookies.test.js.map +1 -1
  81. package/dist/services/oAuth2AuthorizationCodeGranter.d.ts +129 -0
  82. package/dist/services/oAuth2AuthorizationCodeGranter.js +221 -0
  83. package/dist/services/oAuth2AuthorizationCodeGranter.js.map +1 -0
  84. package/dist/services/oAuth2AuthorizationCodeGranter.test.d.ts +1 -0
  85. package/dist/services/oAuth2AuthorizationCodeGranter.test.js +474 -0
  86. package/dist/services/oAuth2AuthorizationCodeGranter.test.js.map +1 -0
  87. package/dist/services/oAuth2ClientCredentialsGranter.d.ts +28 -12
  88. package/dist/services/oAuth2ClientCredentialsGranter.js +39 -21
  89. package/dist/services/oAuth2ClientCredentialsGranter.js.map +1 -1
  90. package/dist/services/oAuth2ClientCredentialsGranter.test.d.ts +1 -0
  91. package/dist/services/oAuth2ClientCredentialsGranter.test.js +265 -0
  92. package/dist/services/oAuth2ClientCredentialsGranter.test.js.map +1 -0
  93. package/dist/services/oAuth2Granters.d.ts +81 -86
  94. package/dist/services/oAuth2Granters.js +2 -67
  95. package/dist/services/oAuth2Granters.js.map +1 -1
  96. package/dist/services/oAuth2ImplicitGranter.d.ts +38 -0
  97. package/dist/services/oAuth2ImplicitGranter.js +72 -0
  98. package/dist/services/oAuth2ImplicitGranter.js.map +1 -0
  99. package/dist/services/oAuth2ImplicitGranter.test.d.ts +1 -0
  100. package/dist/services/oAuth2ImplicitGranter.test.js +727 -0
  101. package/dist/services/oAuth2ImplicitGranter.test.js.map +1 -0
  102. package/dist/services/oAuth2PasswordGranter.d.ts +43 -10
  103. package/dist/services/oAuth2PasswordGranter.js +53 -18
  104. package/dist/services/oAuth2PasswordGranter.js.map +1 -1
  105. package/dist/services/oAuth2PasswordGranter.test.d.ts +1 -0
  106. package/dist/services/oAuth2PasswordGranter.test.js +455 -0
  107. package/dist/services/oAuth2PasswordGranter.test.js.map +1 -0
  108. package/dist/services/oAuth2RefreshTokenGranter.d.ts +42 -9
  109. package/dist/services/oAuth2RefreshTokenGranter.js +60 -21
  110. package/dist/services/oAuth2RefreshTokenGranter.js.map +1 -1
  111. package/dist/services/oAuth2RefreshTokenGranter.test.d.ts +1 -0
  112. package/dist/services/oAuth2RefreshTokenGranter.test.js +403 -0
  113. package/dist/services/oAuth2RefreshTokenGranter.test.js.map +1 -0
  114. package/package.json +11 -11
  115. package/src/index.test.ts +1314 -404
  116. package/src/index.ts +46 -53
  117. package/src/libs/clients.ts +22 -0
  118. package/src/libs/errors.ts +325 -0
  119. package/src/libs/grants.ts +15 -0
  120. package/src/libs/redirectURI.ts +120 -0
  121. package/src/libs/schemas.ts +27 -0
  122. package/src/libs/scopes.ts +49 -0
  123. package/src/libs/utils.ts +24 -0
  124. package/src/libs/verifier.test.ts +37 -0
  125. package/src/libs/verifier.ts +57 -0
  126. package/src/routes/getOAuth2Authorize.test.ts +179 -96
  127. package/src/routes/getOAuth2Authorize.ts +97 -124
  128. package/src/routes/getOAuth2WellKnownMetadata.test.ts +57 -60
  129. package/src/routes/getOAuth2WellKnownMetadata.ts +21 -10
  130. package/src/routes/getOAuth2WellKnownProtectedResourceMetadata.ts +4 -6
  131. package/src/routes/postAuthLogin.test.ts +86 -57
  132. package/src/routes/postAuthLogin.ts +24 -14
  133. package/src/routes/postAuthLogout.test.ts +42 -18
  134. package/src/routes/postAuthLogout.ts +22 -8
  135. package/src/routes/postAuthRefresh.test.ts +98 -61
  136. package/src/routes/postAuthRefresh.ts +25 -13
  137. package/src/routes/postOAuth2Acknowledge.test.ts +167 -108
  138. package/src/routes/postOAuth2Acknowledge.ts +90 -64
  139. package/src/routes/postOAuth2Revoke.test.ts +179 -0
  140. package/src/routes/postOAuth2Revoke.ts +156 -0
  141. package/src/routes/postOAuth2Token.test.ts +570 -108
  142. package/src/routes/postOAuth2Token.ts +92 -136
  143. package/src/services/authCookies.test.ts +5 -5
  144. package/src/services/authCookies.ts +16 -18
  145. package/src/services/oAuth2AuthorizationCodeGranter.test.ts +564 -0
  146. package/src/services/oAuth2AuthorizationCodeGranter.ts +388 -0
  147. package/src/services/oAuth2ClientCredentialsGranter.test.ts +303 -0
  148. package/src/services/oAuth2ClientCredentialsGranter.ts +68 -43
  149. package/src/services/oAuth2Granters.ts +101 -195
  150. package/src/services/oAuth2ImplicitGranter.test.ts +811 -0
  151. package/src/services/oAuth2ImplicitGranter.ts +163 -0
  152. package/src/services/oAuth2PasswordGranter.test.ts +493 -0
  153. package/src/services/oAuth2PasswordGranter.ts +116 -40
  154. package/src/services/oAuth2RefreshTokenGranter.test.ts +441 -0
  155. package/src/services/oAuth2RefreshTokenGranter.ts +118 -51
  156. package/src/types.d.ts +1 -0
  157. package/dist/services/oAuth2CodeGranter.d.ts +0 -41
  158. package/dist/services/oAuth2CodeGranter.js +0 -105
  159. package/dist/services/oAuth2CodeGranter.js.map +0 -1
  160. package/dist/services/oAuth2CodeGranter.test.js +0 -123
  161. package/dist/services/oAuth2CodeGranter.test.js.map +0 -1
  162. package/dist/services/oAuth2TokenGranter.d.ts +0 -22
  163. package/dist/services/oAuth2TokenGranter.js +0 -64
  164. package/dist/services/oAuth2TokenGranter.js.map +0 -1
  165. package/src/__snapshots__/index.test.ts.snap +0 -401
  166. package/src/routes/__snapshots__/getOAuth2Authorize.test.ts.snap +0 -37
  167. package/src/routes/__snapshots__/postOAuth2Acknowledge.test.ts.snap +0 -61
  168. package/src/routes/__snapshots__/postOAuth2Token.test.ts.snap +0 -52
  169. package/src/services/__snapshots__/oAuth2CodeGranter.test.ts.snap +0 -52
  170. package/src/services/oAuth2CodeGranter.test.ts +0 -176
  171. package/src/services/oAuth2CodeGranter.ts +0 -210
  172. package/src/services/oAuth2TokenGranter.ts +0 -119
  173. /package/dist/{services/oAuth2CodeGranter.test.d.ts → libs/verifier.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 code flow, it
17
- requires a server side rendered frontend that brings the UI that allows users to
18
- authenticate and allow client applications to act on behalf of them.
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
  ![Code Flow Overview](./code_flow_overview.svg)
21
22
 
22
23
  The module provides:
23
24
 
24
- - 2 OAuth2 routes definitions implementing the 2 OAuth2 standard endpoints
25
- (`getOAuth2authorize`, `postOAuth2Tokentoken`) to be used by OAuth2 client
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
- - `checkApplication` service that is supposed to check whether an application
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
- - `OAuth2CodeService` aimed to check the `code` grant type with your own logic
44
- (if you use it). Note that it is your responsibility to implement the PKCE
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 OAuth2Config,
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
- + AuthCookiesConfig,
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
- + OAuth2Config,
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 OAuth2GranterService,
143
- type CheckApplicationService,
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
- checkApplication: CheckApplicationService;
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
- const USER_VERIFY_QUERY = `
167
- UPDATE users
168
- SET roles = ARRAY['user'::role]
169
- WHERE id = $$userId
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
- checkApplication,
168
+ readClientGrants,
174
169
  jwtToken,
175
170
  pg,
176
171
  log = noop,
177
172
  }: OAuth2VerifyTokenGranterDependencies): Promise<OAuth2VerifyTokenGranterService> {
178
- const authenticateWithVerifyToken: OAuth2VerifyTokenGranterService['authenticator']['authenticate'] =
179
- async ({ verifyToken }, authenticationData) => {
173
+ const authenticateWithVerifyToken: OAuth2VerifyTokenGranterService['authenticate'] =
174
+ async ({ verifyToken }, optionalAuthenticationData) => {
180
175
  try {
181
- // The client must be authenticated
182
- if (!authenticationData) {
183
- throw new YError('E_UNAUTHORIZED');
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
- const newAuthenticationData = await jwtToken.verify(verifyToken);
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
- await checkApplication({
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(USER_VERIFY_QUERY, {
195
- userId: newAuthenticationData.userId,
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', authenticationData.userId);
206
+ throw new YError('E_ALREADY_VERIFIED', [
207
+ tokenAuthenticationData.userId,
208
+ ]);
200
209
  }
201
210
 
202
- return newAuthenticationData;
211
+ return tokenAuthenticationData;
203
212
  } catch (err) {
204
- if (err.code === 'E_BAD_TOKEN') {
205
- throw YError.wrap(err as Error, 'E_BAD_REFRESH_TOKEN');
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
- type: 'verify',
215
- authenticator: {
216
- grantType: 'verify_token',
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 `postLogin`,
226
- `postLogout` and `postRefresh`.
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 `ROOT_AUTHENTICATION_DATA` and `COOKIES` configurations:
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 `postLogin`, `postLogout` and `postRefresh` routes like so:
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: WhookRouteDefinition = {
288
+ export const definition = {
255
289
  ...postAuthRefreshDefinition,
256
290
  operation: {
257
291
  ...postAuthRefreshDefinition.operation,
258
- 'x-whook': {
259
- disabled: false,
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: WhookRouteDefinition = {
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.requestBodyt.content[
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 { type WhookRouteDefinition } from '@whook/whook';
346
-
347
- export default initPostOAuth2Token;
379
+ import {
380
+ type WhookAPISchemaDefinition,
381
+ type WhookRouteDefinition,
382
+ refersTo,
383
+ } from '@whook/whook';
348
384
 
349
- export const definition: WhookRouteDefinition = {
385
+ export const definition = {
350
386
  ...postOAuth2TokenDefinition,
351
387
  operation: {
352
388
  ...postOAuth2TokenDefinition.operation,
353
389
  security: [
354
390
  {
355
- basicAuth: ['admin'],
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' grant type
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,44 @@
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, codeChallengeSchema as getOAuth2AuthorizeCodeChallengeSchema, codeChallengeParameter as getOAuth2AuthorizeCodeChallengeParameter, codeChallengeMethodSchema as getOAuth2AuthorizeCodeChallengeMethodSchema, codeChallengeMethodParameter as getOAuth2AuthorizeCodeChallengeMethodParameter, 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 initGetOAuth2WellKnown, { definition as getOAuth2WellKnownDefinition, endpointAuthenticationMethodsSchema as getOAuth2WellKnownEndpointAuthenticationMethodsSchema, jsonWebAlgorithmsSchema as getOAuth2WellKnownJsonWebAlgorithmsSchema, jsonWebEncryptionsSchema as getOAuth2WellKnownJsonWebEncryptionsSchema, httpsProtocolURISchema as getOAuth2WellKnownHTTPSProtocolURISchema, oAuth2MetadataSchema as getOAuth2WellKnownOAuth2MetadataSchema } from './routes/getOAuth2WellKnownMetadata.js';
4
+ 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
5
  import initGetOAuth2WellKnownProtectedResource, { definition as getOAuth2WellKnownProtectedResourceDefinition, bearerMethodSchema as getOAuth2WellKnownProtectedResourceBearerMethodSchema, oAuth2ProtectedResourceMetadataSchema as getOAuth2WellKnownProtectedResourceSchema } from './routes/getOAuth2WellKnownProtectedResourceMetadata.js';
6
- import initOAuth2Granters, { type OAuth2YErrorRegistry, OAUTH2_ERRORS_DESCRIPTORS } from './services/oAuth2Granters.js';
6
+ import initPostOAuth2Revoke, { definition as postOAuth2RevokeDefinition, tokenTypeHintSchema as postOAuth2RevokeTokenTypeHintSchema, revokeTokenRequestBodySchema as postOAuth2RevokeTokenRequestBodySchema } from './routes/postOAuth2Revoke.js';
7
+ export type * from './routes/postOAuth2Revoke.js';
8
+ import initOAuth2Granters from './services/oAuth2Granters.js';
9
+ export type * from './services/oAuth2Granters.js';
7
10
  import initOAuth2ClientCredentialsGranter from './services/oAuth2ClientCredentialsGranter.js';
11
+ export type * from './services/oAuth2ClientCredentialsGranter.js';
8
12
  import initOAuth2PasswordGranter from './services/oAuth2PasswordGranter.js';
13
+ export type * from './services/oAuth2PasswordGranter.js';
9
14
  import initOAuth2RefreshTokenGranter from './services/oAuth2RefreshTokenGranter.js';
10
- import initOAuth2TokenGranter from './services/oAuth2TokenGranter.js';
11
- import { type OAuth2PasswordService, type OAuth2AccessTokenService, type OAuth2RefreshTokenService, type CheckApplicationService, type OAuth2GranterService, type OAuth2Options, type OAuth2Config } from './services/oAuth2Granters.js';
15
+ export type * from './services/oAuth2RefreshTokenGranter.js';
16
+ import initOAuth2ImplicitGranter from './services/oAuth2ImplicitGranter.js';
17
+ export type * from './services/oAuth2ImplicitGranter.js';
18
+ import initOAuth2AuthorizationCodeGranter from './services/oAuth2AuthorizationCodeGranter.js';
19
+ export type * from './services/oAuth2AuthorizationCodeGranter.js';
12
20
  import initPostAuthLogin, { definition as postAuthLoginDefinition } from './routes/postAuthLogin.js';
13
21
  import initPostAuthLogout, { definition as postAuthLogoutDefinition } from './routes/postAuthLogout.js';
14
22
  import initPostAuthRefresh, { authCookieHeaderParameter, definition as postAuthRefreshDefinition } from './routes/postAuthRefresh.js';
15
- import initAuthCookiesService, { AUTH_API_PREFIX } from './services/authCookies.js';
16
- import { type AuthCookiesConfig, type AuthCookiesService, type AuthCookiesData, type AuthHandlersConfig } from './services/authCookies.js';
17
- import initOAuth2CodeGranter, { base64UrlEncode, hashCodeVerifier, type CodeChallengeMethod, type OAuth2CodeService } from './services/oAuth2CodeGranter.js';
18
- import { collectScopesFromAPI } from './libs/scopes.js';
23
+ import initAuthCookiesService from './services/authCookies.js';
24
+ import { type OAuth2YErrorRegistry } from './libs/errors.js';
25
+ export * from './services/authCookies.js';
26
+ export type * from './services/authCookies.js';
27
+ export * from './libs/schemas.js';
28
+ export type * from './libs/schemas.js';
29
+ export * from './libs/errors.js';
30
+ export type * from './libs/errors.js';
31
+ export * from './libs/scopes.js';
32
+ export type * from './libs/scopes.js';
33
+ export * from './libs/grants.js';
34
+ export type * from './libs/grants.js';
35
+ export * from './libs/redirectURI.js';
36
+ export type * from './libs/redirectURI.js';
37
+ export * from './libs/verifier.js';
38
+ export type * from './libs/verifier.js';
19
39
  declare module 'yerror' {
20
40
  interface YErrorRegistry extends OAuth2YErrorRegistry {
21
41
  E_UNEXPECTED: unknown[];
22
42
  }
23
43
  }
24
- export type { OAuth2YErrorRegistry, CodeChallengeMethod, OAuth2CodeService, OAuth2PasswordService, OAuth2AccessTokenService, OAuth2RefreshTokenService, CheckApplicationService, OAuth2GranterService, OAuth2Options, OAuth2Config, AuthCookiesConfig, AuthCookiesService, AuthCookiesData, AuthHandlersConfig, };
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, };
44
+ export { initGetOAuth2Authorize, getOAuth2AuthorizeDefinition, getOAuth2AuthorizeResponseTypeParameter, getOAuth2AuthorizeClientIdParameter, getOAuth2AuthorizeRedirectURIParameter, getOAuth2AuthorizeScopeParameter, getOAuth2AuthorizeStateParameter, getOAuth2AuthorizeScopeSchema, getOAuth2AuthorizeCodeChallengeSchema, getOAuth2AuthorizeCodeChallengeMethodSchema, getOAuth2AuthorizeCodeChallengeParameter, getOAuth2AuthorizeCodeChallengeMethodParameter, 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, initOAuth2Granters, initOAuth2ClientCredentialsGranter, initOAuth2AuthorizationCodeGranter, initOAuth2PasswordGranter, initOAuth2RefreshTokenGranter, initOAuth2ImplicitGranter, authCookieHeaderParameter, initPostAuthLogin, postAuthLoginDefinition, initPostAuthLogout, postAuthLogoutDefinition, initPostAuthRefresh, postAuthRefreshDefinition, initAuthCookiesService, };
package/dist/index.js CHANGED
@@ -1,18 +1,25 @@
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, codeChallengeSchema as getOAuth2AuthorizeCodeChallengeSchema, codeChallengeParameter as getOAuth2AuthorizeCodeChallengeParameter, codeChallengeMethodSchema as getOAuth2AuthorizeCodeChallengeMethodSchema, codeChallengeMethodParameter as getOAuth2AuthorizeCodeChallengeMethodParameter, 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 initGetOAuth2WellKnown, { definition as getOAuth2WellKnownDefinition, endpointAuthenticationMethodsSchema as getOAuth2WellKnownEndpointAuthenticationMethodsSchema, jsonWebAlgorithmsSchema as getOAuth2WellKnownJsonWebAlgorithmsSchema, jsonWebEncryptionsSchema as getOAuth2WellKnownJsonWebEncryptionsSchema, httpsProtocolURISchema as getOAuth2WellKnownHTTPSProtocolURISchema, oAuth2MetadataSchema as getOAuth2WellKnownOAuth2MetadataSchema, } from './routes/getOAuth2WellKnownMetadata.js';
4
+ 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
5
  import initGetOAuth2WellKnownProtectedResource, { definition as getOAuth2WellKnownProtectedResourceDefinition, bearerMethodSchema as getOAuth2WellKnownProtectedResourceBearerMethodSchema, oAuth2ProtectedResourceMetadataSchema as getOAuth2WellKnownProtectedResourceSchema, } from './routes/getOAuth2WellKnownProtectedResourceMetadata.js';
6
- import initOAuth2Granters, { OAUTH2_ERRORS_DESCRIPTORS, } from './services/oAuth2Granters.js';
6
+ import initPostOAuth2Revoke, { definition as postOAuth2RevokeDefinition, tokenTypeHintSchema as postOAuth2RevokeTokenTypeHintSchema, revokeTokenRequestBodySchema as postOAuth2RevokeTokenRequestBodySchema, } from './routes/postOAuth2Revoke.js';
7
+ import initOAuth2Granters from './services/oAuth2Granters.js';
7
8
  import initOAuth2ClientCredentialsGranter from './services/oAuth2ClientCredentialsGranter.js';
8
9
  import initOAuth2PasswordGranter from './services/oAuth2PasswordGranter.js';
9
10
  import initOAuth2RefreshTokenGranter from './services/oAuth2RefreshTokenGranter.js';
10
- import initOAuth2TokenGranter from './services/oAuth2TokenGranter.js';
11
+ import initOAuth2ImplicitGranter from './services/oAuth2ImplicitGranter.js';
12
+ import initOAuth2AuthorizationCodeGranter from './services/oAuth2AuthorizationCodeGranter.js';
11
13
  import initPostAuthLogin, { definition as postAuthLoginDefinition, } from './routes/postAuthLogin.js';
12
14
  import initPostAuthLogout, { definition as postAuthLogoutDefinition, } from './routes/postAuthLogout.js';
13
15
  import initPostAuthRefresh, { authCookieHeaderParameter, definition as postAuthRefreshDefinition, } from './routes/postAuthRefresh.js';
14
- import initAuthCookiesService, { AUTH_API_PREFIX, } from './services/authCookies.js';
15
- import initOAuth2CodeGranter, { base64UrlEncode, hashCodeVerifier, } from './services/oAuth2CodeGranter.js';
16
- import { collectScopesFromAPI } from './libs/scopes.js';
17
- 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, };
16
+ import initAuthCookiesService from './services/authCookies.js';
17
+ export * from './services/authCookies.js';
18
+ export * from './libs/schemas.js';
19
+ export * from './libs/errors.js';
20
+ export * from './libs/scopes.js';
21
+ export * from './libs/grants.js';
22
+ export * from './libs/redirectURI.js';
23
+ export * from './libs/verifier.js';
24
+ export { initGetOAuth2Authorize, getOAuth2AuthorizeDefinition, getOAuth2AuthorizeResponseTypeParameter, getOAuth2AuthorizeClientIdParameter, getOAuth2AuthorizeRedirectURIParameter, getOAuth2AuthorizeScopeParameter, getOAuth2AuthorizeStateParameter, getOAuth2AuthorizeScopeSchema, getOAuth2AuthorizeCodeChallengeSchema, getOAuth2AuthorizeCodeChallengeMethodSchema, getOAuth2AuthorizeCodeChallengeParameter, getOAuth2AuthorizeCodeChallengeMethodParameter, 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, initOAuth2Granters, initOAuth2ClientCredentialsGranter, initOAuth2AuthorizationCodeGranter, initOAuth2PasswordGranter, initOAuth2RefreshTokenGranter, initOAuth2ImplicitGranter, authCookieHeaderParameter, initPostAuthLogin, postAuthLoginDefinition, initPostAuthLogout, postAuthLogoutDefinition, initPostAuthRefresh, postAuthRefreshDefinition, initAuthCookiesService, };
18
25
  //# 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,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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