@whook/oauth2 9.0.0 → 10.0.1

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 (131) hide show
  1. package/README.md +90 -68
  2. package/dist/handlers/getOAuth2Authorize.d.ts +4 -4
  3. package/dist/handlers/getOAuth2Authorize.js +122 -165
  4. package/dist/handlers/getOAuth2Authorize.js.map +1 -1
  5. package/dist/handlers/getOAuth2Authorize.test.js +117 -103
  6. package/dist/handlers/getOAuth2Authorize.test.js.map +1 -1
  7. package/dist/handlers/postAuthLogin.d.ts +1 -1
  8. package/dist/handlers/postAuthLogin.js +83 -121
  9. package/dist/handlers/postAuthLogin.js.map +1 -1
  10. package/dist/handlers/postAuthLogin.test.js +42 -44
  11. package/dist/handlers/postAuthLogin.test.js.map +1 -1
  12. package/dist/handlers/postAuthLogout.d.ts +1 -1
  13. package/dist/handlers/postAuthLogout.js +26 -42
  14. package/dist/handlers/postAuthLogout.js.map +1 -1
  15. package/dist/handlers/postAuthLogout.test.js +19 -21
  16. package/dist/handlers/postAuthLogout.test.js.map +1 -1
  17. package/dist/handlers/postAuthRefresh.d.ts +1 -1
  18. package/dist/handlers/postAuthRefresh.js +93 -132
  19. package/dist/handlers/postAuthRefresh.js.map +1 -1
  20. package/dist/handlers/postAuthRefresh.test.js +47 -49
  21. package/dist/handlers/postAuthRefresh.test.js.map +1 -1
  22. package/dist/handlers/postOAuth2Acknowledge.d.ts +5 -5
  23. package/dist/handlers/postOAuth2Acknowledge.js +119 -151
  24. package/dist/handlers/postOAuth2Acknowledge.js.map +1 -1
  25. package/dist/handlers/postOAuth2Acknowledge.test.js +139 -125
  26. package/dist/handlers/postOAuth2Acknowledge.test.js.map +1 -1
  27. package/dist/handlers/postOAuth2Token.d.ts +1 -1
  28. package/dist/handlers/postOAuth2Token.js +200 -232
  29. package/dist/handlers/postOAuth2Token.js.map +1 -1
  30. package/dist/handlers/postOAuth2Token.test.js +156 -153
  31. package/dist/handlers/postOAuth2Token.test.js.map +1 -1
  32. package/dist/index.d.ts +16 -16
  33. package/dist/index.js +14 -229
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.test.js +697 -619
  36. package/dist/index.test.js.map +1 -1
  37. package/dist/services/authCookies.d.ts +8 -4
  38. package/dist/services/authCookies.js +40 -71
  39. package/dist/services/authCookies.js.map +1 -1
  40. package/dist/services/authCookies.test.js +57 -62
  41. package/dist/services/authCookies.test.js.map +1 -1
  42. package/dist/services/oAuth2ClientCredentialsGranter.d.ts +2 -2
  43. package/dist/services/oAuth2ClientCredentialsGranter.js +34 -52
  44. package/dist/services/oAuth2ClientCredentialsGranter.js.map +1 -1
  45. package/dist/services/oAuth2CodeGranter.d.ts +1 -1
  46. package/dist/services/oAuth2CodeGranter.js +66 -109
  47. package/dist/services/oAuth2CodeGranter.js.map +1 -1
  48. package/dist/services/oAuth2CodeGranter.test.js +65 -66
  49. package/dist/services/oAuth2CodeGranter.test.js.map +1 -1
  50. package/dist/services/oAuth2Granters.js +131 -138
  51. package/dist/services/oAuth2Granters.js.map +1 -1
  52. package/dist/services/oAuth2PasswordGranter.d.ts +1 -1
  53. package/dist/services/oAuth2PasswordGranter.js +27 -52
  54. package/dist/services/oAuth2PasswordGranter.js.map +1 -1
  55. package/dist/services/oAuth2RefreshTokenGranter.d.ts +1 -1
  56. package/dist/services/oAuth2RefreshTokenGranter.js +34 -58
  57. package/dist/services/oAuth2RefreshTokenGranter.js.map +1 -1
  58. package/dist/services/oAuth2TokenGranter.d.ts +1 -1
  59. package/dist/services/oAuth2TokenGranter.js +50 -86
  60. package/dist/services/oAuth2TokenGranter.js.map +1 -1
  61. package/package.json +48 -89
  62. package/src/__snapshots__/index.test.ts.snap +23 -22
  63. package/src/handlers/__snapshots__/postOAuth2Acknowledge.test.ts.snap +1 -1
  64. package/src/handlers/getOAuth2Authorize.test.ts +49 -13
  65. package/src/handlers/getOAuth2Authorize.ts +2 -2
  66. package/src/handlers/postAuthLogin.test.ts +9 -5
  67. package/src/handlers/postAuthLogin.ts +4 -4
  68. package/src/handlers/postAuthLogout.test.ts +8 -4
  69. package/src/handlers/postAuthLogout.ts +2 -2
  70. package/src/handlers/postAuthRefresh.test.ts +10 -6
  71. package/src/handlers/postAuthRefresh.ts +4 -4
  72. package/src/handlers/postOAuth2Acknowledge.test.ts +83 -35
  73. package/src/handlers/postOAuth2Acknowledge.ts +18 -8
  74. package/src/handlers/postOAuth2Token.test.ts +77 -17
  75. package/src/handlers/postOAuth2Token.ts +3 -3
  76. package/src/index.test.ts +110 -65
  77. package/src/index.ts +21 -19
  78. package/src/services/authCookies.test.ts +2 -2
  79. package/src/services/authCookies.ts +10 -5
  80. package/src/services/oAuth2ClientCredentialsGranter.ts +3 -3
  81. package/src/services/oAuth2CodeGranter.test.ts +27 -4
  82. package/src/services/oAuth2CodeGranter.ts +2 -2
  83. package/src/services/oAuth2PasswordGranter.ts +2 -2
  84. package/src/services/oAuth2RefreshTokenGranter.ts +2 -2
  85. package/src/services/oAuth2TokenGranter.ts +1 -1
  86. package/dist/handlers/getOAuth2Authorize.mjs +0 -160
  87. package/dist/handlers/getOAuth2Authorize.mjs.map +0 -1
  88. package/dist/handlers/getOAuth2Authorize.test.mjs +0 -114
  89. package/dist/handlers/getOAuth2Authorize.test.mjs.map +0 -1
  90. package/dist/handlers/postAuthLogin.mjs +0 -109
  91. package/dist/handlers/postAuthLogin.mjs.map +0 -1
  92. package/dist/handlers/postAuthLogin.test.mjs +0 -85
  93. package/dist/handlers/postAuthLogin.test.mjs.map +0 -1
  94. package/dist/handlers/postAuthLogout.mjs +0 -33
  95. package/dist/handlers/postAuthLogout.mjs.map +0 -1
  96. package/dist/handlers/postAuthLogout.test.mjs +0 -30
  97. package/dist/handlers/postAuthLogout.test.mjs.map +0 -1
  98. package/dist/handlers/postAuthRefresh.mjs +0 -122
  99. package/dist/handlers/postAuthRefresh.mjs.map +0 -1
  100. package/dist/handlers/postAuthRefresh.test.mjs +0 -94
  101. package/dist/handlers/postAuthRefresh.test.mjs.map +0 -1
  102. package/dist/handlers/postOAuth2Acknowledge.mjs +0 -150
  103. package/dist/handlers/postOAuth2Acknowledge.mjs.map +0 -1
  104. package/dist/handlers/postOAuth2Acknowledge.test.mjs +0 -140
  105. package/dist/handlers/postOAuth2Acknowledge.test.mjs.map +0 -1
  106. package/dist/handlers/postOAuth2Token.mjs +0 -231
  107. package/dist/handlers/postOAuth2Token.mjs.map +0 -1
  108. package/dist/handlers/postOAuth2Token.test.mjs +0 -160
  109. package/dist/handlers/postOAuth2Token.test.mjs.map +0 -1
  110. package/dist/index.mjs +0 -15
  111. package/dist/index.mjs.map +0 -1
  112. package/dist/index.test.mjs +0 -747
  113. package/dist/index.test.mjs.map +0 -1
  114. package/dist/services/authCookies.mjs +0 -58
  115. package/dist/services/authCookies.mjs.map +0 -1
  116. package/dist/services/authCookies.test.mjs +0 -77
  117. package/dist/services/authCookies.test.mjs.map +0 -1
  118. package/dist/services/oAuth2ClientCredentialsGranter.mjs +0 -41
  119. package/dist/services/oAuth2ClientCredentialsGranter.mjs.map +0 -1
  120. package/dist/services/oAuth2CodeGranter.mjs +0 -98
  121. package/dist/services/oAuth2CodeGranter.mjs.map +0 -1
  122. package/dist/services/oAuth2CodeGranter.test.mjs +0 -83
  123. package/dist/services/oAuth2CodeGranter.test.mjs.map +0 -1
  124. package/dist/services/oAuth2Granters.mjs +0 -127
  125. package/dist/services/oAuth2Granters.mjs.map +0 -1
  126. package/dist/services/oAuth2PasswordGranter.mjs +0 -40
  127. package/dist/services/oAuth2PasswordGranter.mjs.map +0 -1
  128. package/dist/services/oAuth2RefreshTokenGranter.mjs +0 -47
  129. package/dist/services/oAuth2RefreshTokenGranter.mjs.map +0 -1
  130. package/dist/services/oAuth2TokenGranter.mjs +0 -78
  131. package/dist/services/oAuth2TokenGranter.mjs.map +0 -1
package/README.md CHANGED
@@ -19,18 +19,21 @@ authenticate and allow client applications to act on behalf of them.
19
19
 
20
20
  ![Code Flow Overview](./code_flow_overview.svg)
21
21
 
22
- The module provides :
22
+ The module provides:
23
23
 
24
- - 3 handlers : the 2 OAuth2 standard endpoints (`getOAuth2authorize` and
25
- `postOAuth2Tokentoken`) plus the `postOAuth2Acknowledge` to be used by the SSR
26
- frontend,
27
- - the 5 OAuth2 standard grant types implemented through plug and play services.
28
- You can create your own granter services to create additional grant types.
24
+ - 2 OAuth2 handlers implementing the 2 OAuth2 standard endpoints
25
+ (`getOAuth2authorize`, `postOAuth2Tokentoken`) to be used by OAuth2 client
26
+ applications,
27
+ - 4 authentication endpoints to be used by the authorization server directly to
28
+ authenticate users (`postAuthLogin`, `postAuthRefresh`, `postAuthLogout`) and
29
+ acknowledge the client requests (`postOAuth2Acknowledge`),
30
+ - 5 OAuth2 services implementing the standard grant types. You can create your
31
+ own granter services to create additional grant types.
29
32
 
30
33
  This module requires you to implement some services it relies on:
31
34
 
32
35
  - `oAuth2AccessToken` that generates and checks the `access_token` and the
33
- `oAuth2RefreshToken` for the `refresh_token` both have the same interface,
36
+ `oAuth2RefreshToken` for the `refresh_token`, both have the same interface,
34
37
  - `checkApplication` service that is supposed to check whether an application
35
38
  can be used or not for a given grant type, a given scope and redirect URI,
36
39
  - `oAuth2PasswordService` aimed to check the `password` grant type with your own
@@ -48,7 +51,7 @@ Install the module in your project:
48
51
  npm i @whook/oauth2
49
52
  ```
50
53
 
51
- Declare the plugin into your `index.ts` file:
54
+ Declare the plugin into your `src/index.ts` file:
52
55
 
53
56
  ```diff
54
57
  // (...)
@@ -60,18 +63,29 @@ Declare the plugin into your `index.ts` file:
60
63
  // (...)
61
64
  ```
62
65
 
63
- Declare this module types in your `src/whook.d.ts` type
64
- definitions:
66
+ Declare this module types in your `src/whook.d.ts` type definitions:
67
+
65
68
  ```diff
66
- + import type { OAuth2Config } from '@whook/oauth2';
69
+ +import type {
70
+ + AuthCookiesEnv,
71
+ + OAuth2Config,
72
+ +} from '@whook/oauth2';
67
73
 
68
74
  declare module '@whook/whook' {
69
75
 
76
+ export interface WhookEnv
77
+ extends WhookBaseEnv,
78
+ // (...)
79
+ + AuthCookiesEnv,
80
+ WhookSwaggerUIEnv {}
81
+
70
82
  // ...
71
83
 
72
84
  export interface WhookConfigs
73
85
  - extends WhookBaseConfigs {}
74
- + extends WhookBaseConfigs, OAuth2Config {}
86
+ + extends WhookBaseConfigs,
87
+ + AuthCookiesConfig,
88
+ + OAuth2Config {}
75
89
 
76
90
  // ...
77
91
 
@@ -112,15 +126,15 @@ The `oAuth2Granters` service gather the various granters services you can use in
112
126
  your application but you can write your own that uses a subset or a superset of
113
127
  these granters.
114
128
 
115
- Here, for example an handler that implement a verify token mechanism in order to
129
+ Here, for example a handler that implement a verify token mechanism in order to
116
130
  validate a user subscription:
117
131
 
118
132
  ```ts
119
133
  import { autoService } from 'knifecycle';
120
134
  import { noop } from '@whook/whook';
121
- import YError from 'yerror';
135
+ import { YError } from 'yerror';
122
136
  import type { LogService } from 'common-services';
123
- import type { AuthenticationData } from './authentication';
137
+ import type { AuthenticationData } from './authentication.js';
124
138
  import type {
125
139
  OAuth2GranterService,
126
140
  CheckApplicationService,
@@ -157,43 +171,39 @@ async function initOAuth2VerifyTokenGranter({
157
171
  jwtToken,
158
172
  pg,
159
173
  log = noop,
160
- }: OAuth2VerifyTokenGranterDependencies): Promise<
161
- OAuth2VerifyTokenGranterService
162
- > {
163
- const authenticateWithVerifyToken: OAuth2VerifyTokenGranterService['authenticator']['authenticate'] = async (
164
- { verifyToken },
165
- authenticationData,
166
- ) => {
167
- try {
168
- // The client must be authenticated
169
- if (!authenticationData) {
170
- throw new YError('E_UNAUTHORIZED');
171
- }
172
-
173
- const newAuthenticationData = await jwtToken.verify(verifyToken);
174
-
175
- await checkApplication({
176
- applicationId: authenticationData.applicationId,
177
- type: 'verify',
178
- scope: newAuthenticationData.scope,
179
- });
180
-
181
- const result = await pg.query(USER_VERIFY_QUERY, {
182
- userId: newAuthenticationData.userId,
183
- });
184
-
185
- if (result.rowCount === 0) {
186
- throw new YError('E_ALREADY_VERIFIED', authenticationData.userId);
187
- }
188
-
189
- return newAuthenticationData;
190
- } catch (err) {
191
- if (err.code === 'E_BAD_TOKEN') {
192
- throw YError.wrap(err as Error, 'E_BAD_REFRESH_TOKEN');
174
+ }: OAuth2VerifyTokenGranterDependencies): Promise<OAuth2VerifyTokenGranterService> {
175
+ const authenticateWithVerifyToken: OAuth2VerifyTokenGranterService['authenticator']['authenticate'] =
176
+ async ({ verifyToken }, authenticationData) => {
177
+ try {
178
+ // The client must be authenticated
179
+ if (!authenticationData) {
180
+ throw new YError('E_UNAUTHORIZED');
181
+ }
182
+
183
+ const newAuthenticationData = await jwtToken.verify(verifyToken);
184
+
185
+ await checkApplication({
186
+ applicationId: authenticationData.applicationId,
187
+ type: 'verify',
188
+ scope: newAuthenticationData.scope,
189
+ });
190
+
191
+ const result = await pg.query(USER_VERIFY_QUERY, {
192
+ userId: newAuthenticationData.userId,
193
+ });
194
+
195
+ if (result.rowCount === 0) {
196
+ throw new YError('E_ALREADY_VERIFIED', authenticationData.userId);
197
+ }
198
+
199
+ return newAuthenticationData;
200
+ } catch (err) {
201
+ if (err.code === 'E_BAD_TOKEN') {
202
+ throw YError.wrap(err as Error, 'E_BAD_REFRESH_TOKEN');
203
+ }
204
+ throw err;
193
205
  }
194
- throw err;
195
- }
196
- };
206
+ };
197
207
 
198
208
  log('debug', '👫 - OAuth2VerifyTokenGranter Service Initialized!');
199
209
 
@@ -213,6 +223,7 @@ For internal use, you may prefer use cookies based auth handlers like
213
223
  `postLogin`, `postLogout` and `postRefresh`.
214
224
 
215
225
  To do so, configure the `ROOT_AUTHENTICATION_DATA` and `COOKIES` configurations:
226
+
216
227
  ```diff
217
228
  // src/production/config.ts
218
229
  + COOKIES: {
@@ -225,8 +236,9 @@ To do so, configure the `ROOT_AUTHENTICATION_DATA` and `COOKIES` configurations:
225
236
  ```
226
237
 
227
238
  Than import the `postLogin`, `postLogout` and `postRefresh` handlers like so:
239
+
228
240
  ```ts
229
- // src/handlers/postRefresh.ts
241
+ // src/handlers/postRefresh.ts
230
242
  import {
231
243
  initPostAuthRefresh,
232
244
  postAuthRefreshDefinition,
@@ -249,15 +261,17 @@ export const definition: WhookAPIHandlerDefinition = {
249
261
  export default initPostAuthRefresh;
250
262
  ```
251
263
 
252
- Additionnaly, you could create any handler in the `/auth` path in order to receive the auth cookies.
264
+ Additionnaly, you could create any handler in the `/auth` path in order to
265
+ receive the auth cookies. For example, you may want to serve user profiles
266
+ there.
253
267
 
254
268
  ## Customizing handlers
255
269
 
256
270
  The endpoints definitions are designed to support the standard OAuth2
257
271
  definitions but can be easily overriden.
258
272
 
259
- You will have to protect the `postOAuth2Acknowledge` with your own security
260
- mechanism :
273
+ You will also have to protect the `postOAuth2Acknowledge` with your own security
274
+ mechanism:
261
275
 
262
276
  ```ts
263
277
  import {
@@ -273,6 +287,7 @@ export const definition: WhookAPIHandlerDefinition = {
273
287
  ...postOAuth2AcknowledgeDefinition,
274
288
  operation: {
275
289
  ...postOAuth2AcknowledgeDefinition.operation,
290
+ // Complete the definition to protect the endpoint
276
291
  security: [
277
292
  {
278
293
  bearerAuth: ['user'],
@@ -285,22 +300,29 @@ export const definition: WhookAPIHandlerDefinition = {
285
300
  content: {
286
301
  'application/json': {
287
302
  schema: {
288
- ...((postOAuth2AcknowledgeDefinition.operation
289
- .requestBody as OpenAPIV3.RequestBodyObject).content[
290
- 'application/json'
291
- ].schema as OpenAPIV3.NonArraySchemaObject),
303
+ ...((
304
+ postOAuth2AcknowledgeDefinition.operation
305
+ .requestBody as OpenAPIV3.RequestBodyObject
306
+ ).content['application/json']
307
+ .schema as OpenAPIV3.NonArraySchemaObject),
292
308
  required: [
293
309
  'userId',
294
- ...((postOAuth2AcknowledgeDefinition.operation
295
- .requestBody as OpenAPIV3.RequestBodyObject).content[
296
- 'application/json'
297
- ].schema as OpenAPIV3.NonArraySchemaObject).required,
310
+ ...(
311
+ (
312
+ postOAuth2AcknowledgeDefinition.operation
313
+ .requestBody as OpenAPIV3.RequestBodyObject
314
+ ).content['application/json']
315
+ .schema as OpenAPIV3.NonArraySchemaObject
316
+ ).required,
298
317
  ],
299
318
  properties: {
300
- ...((postOAuth2AcknowledgeDefinition.operation
301
- .requestBody as OpenAPIV3.RequestBodyObject).content[
302
- 'application/json'
303
- ].schema as OpenAPIV3.NonArraySchemaObject).properties,
319
+ ...(
320
+ (
321
+ postOAuth2AcknowledgeDefinition.operation
322
+ .requestBody as OpenAPIV3.RequestBodyObject
323
+ ).content['application/json']
324
+ .schema as OpenAPIV3.NonArraySchemaObject
325
+ ).properties,
304
326
  userId: {
305
327
  type: 'string',
306
328
  },
@@ -314,7 +336,7 @@ export const definition: WhookAPIHandlerDefinition = {
314
336
  ```
315
337
 
316
338
  You will probably need to also protect the `postOAuth2Token` endpoint with your
317
- own security mecanism :
339
+ own security mecanism:
318
340
 
319
341
  ```ts
320
342
  // In a `src/handlers/postOAuth2Token.ts` fileimport {
@@ -1,7 +1,7 @@
1
- /// <reference types="node" />
2
- import YError from 'yerror';
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { YError } from 'yerror';
3
3
  import type { WhookAPIHandlerDefinition, WhookAPIParameterDefinition, WhookResponse, WhookErrorsDescriptors, WhookErrorDescriptor } from '@whook/whook';
4
- import type { OAuth2Options, OAuth2GranterService } from '../services/oAuth2Granters';
4
+ import type { OAuth2Options, OAuth2GranterService } from '../services/oAuth2Granters.js';
5
5
  import type { LogService } from 'common-services';
6
6
  export declare const responseTypeParameter: WhookAPIParameterDefinition;
7
7
  export declare const clientIdParameter: WhookAPIParameterDefinition;
@@ -22,7 +22,7 @@ declare const _default: import("knifecycle").ServiceInitializer<{
22
22
  state: string;
23
23
  } & Record<string, unknown>) => Promise<WhookResponse<302, {
24
24
  location: string;
25
- }, void | import("type-fest").JsonValue | import("stream").Readable>>>;
25
+ }, void | import("stream").Readable | import("type-fest").JsonValue>>>;
26
26
  export default _default;
27
27
  export declare function camelCaseObjectProperties<T>(object: Record<string, T>): Record<string, T>;
28
28
  export declare function setURLError(url: URL, err: YError | Error, oAuth2Error: WhookErrorDescriptor): void;
@@ -1,185 +1,142 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.camelCaseObjectProperties = camelCaseObjectProperties;
7
- exports.scopeParameter = exports.responseTypeParameter = exports.redirectURIParameter = exports.definition = exports.default = exports.clientIdParameter = void 0;
8
- exports.setURLError = setURLError;
9
- exports.stateParameter = void 0;
10
-
11
- var _knifecycle = require("knifecycle");
12
-
13
- var _camelcase = _interopRequireDefault(require("camelcase"));
14
-
15
- var _yerror = _interopRequireDefault(require("yerror"));
16
-
17
- var _whook = require("@whook/whook");
18
-
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
1
+ import { autoHandler } from 'knifecycle';
2
+ import camelCase from 'camelcase';
3
+ import { YError } from 'yerror';
4
+ import { refersTo } from '@whook/whook';
21
5
  /* Architecture Note #1: OAuth2 authorize
22
6
  This endpoint simply redirect the user to the authentication
23
7
  server page by first checking the application details are
24
8
  fine.
25
9
  */
26
- const responseTypeParameter = {
27
- name: 'responseType',
28
- parameter: {
29
- in: 'query',
30
- name: 'response_type',
31
- required: true,
32
- schema: {
33
- type: 'string',
34
- enum: ['code', 'token']
35
- }
36
- }
10
+ export const responseTypeParameter = {
11
+ name: 'responseType',
12
+ parameter: {
13
+ in: 'query',
14
+ name: 'response_type',
15
+ required: true,
16
+ schema: {
17
+ type: 'string',
18
+ enum: ['code', 'token'],
19
+ },
20
+ },
37
21
  };
38
- exports.responseTypeParameter = responseTypeParameter;
39
- const clientIdParameter = {
40
- name: 'clientId',
41
- parameter: {
42
- in: 'query',
43
- name: 'client_id',
44
- required: true,
45
- schema: {
46
- type: 'string'
47
- }
48
- }
22
+ export const clientIdParameter = {
23
+ name: 'clientId',
24
+ parameter: {
25
+ in: 'query',
26
+ name: 'client_id',
27
+ required: true,
28
+ schema: {
29
+ type: 'string',
30
+ },
31
+ },
49
32
  };
50
- exports.clientIdParameter = clientIdParameter;
51
- const redirectURIParameter = {
52
- name: 'redirectURI',
53
- parameter: {
54
- in: 'query',
55
- name: 'redirect_uri',
56
- required: false,
57
- schema: {
58
- type: 'string',
59
- pattern: '^https?://',
60
- format: 'uri'
61
- }
62
- }
33
+ export const redirectURIParameter = {
34
+ name: 'redirectURI',
35
+ parameter: {
36
+ in: 'query',
37
+ name: 'redirect_uri',
38
+ required: false,
39
+ schema: {
40
+ type: 'string',
41
+ pattern: '^https?://',
42
+ format: 'uri',
43
+ },
44
+ },
63
45
  };
64
- exports.redirectURIParameter = redirectURIParameter;
65
- const scopeParameter = {
66
- name: 'scope',
67
- parameter: {
68
- in: 'query',
46
+ export const scopeParameter = {
69
47
  name: 'scope',
70
- description: 'See https://tools.ietf.org/html/rfc6749#section-3.3',
71
- required: false,
72
- schema: {
73
- type: 'string'
74
- }
75
- }
48
+ parameter: {
49
+ in: 'query',
50
+ name: 'scope',
51
+ description: 'See https://tools.ietf.org/html/rfc6749#section-3.3',
52
+ required: false,
53
+ schema: {
54
+ type: 'string',
55
+ },
56
+ },
76
57
  };
77
- exports.scopeParameter = scopeParameter;
78
- const stateParameter = {
79
- name: 'state',
80
- parameter: {
81
- in: 'query',
58
+ export const stateParameter = {
82
59
  name: 'state',
83
- required: true,
84
- schema: {
85
- type: 'string'
86
- }
87
- }
60
+ parameter: {
61
+ in: 'query',
62
+ name: 'state',
63
+ required: true,
64
+ schema: {
65
+ type: 'string',
66
+ },
67
+ },
88
68
  };
89
- exports.stateParameter = stateParameter;
90
- const definition = {
91
- method: 'get',
92
- path: '/oauth2/authorize',
93
- operation: {
94
- operationId: 'getOAuth2Authorize',
95
- summary: `Implements the [Authorization Endpoint](https://tools.ietf.org/html/rfc6749#section-3.1)
69
+ export const definition = {
70
+ method: 'get',
71
+ path: '/oauth2/authorize',
72
+ operation: {
73
+ operationId: 'getOAuth2Authorize',
74
+ summary: `Implements the [Authorization Endpoint](https://tools.ietf.org/html/rfc6749#section-3.1)
96
75
  as defined per the OAuth2 RFC.`,
97
- tags: ['oauth2'],
98
- parameters: [(0, _whook.refersTo)(responseTypeParameter), (0, _whook.refersTo)(clientIdParameter), (0, _whook.refersTo)(redirectURIParameter), (0, _whook.refersTo)(scopeParameter), (0, _whook.refersTo)(stateParameter)],
99
- responses: {
100
- '302': {
101
- description: 'Redirects the user to the authorization interface.'
102
- }
103
- }
104
- }
76
+ tags: ['oauth2'],
77
+ parameters: [
78
+ refersTo(responseTypeParameter),
79
+ refersTo(clientIdParameter),
80
+ refersTo(redirectURIParameter),
81
+ refersTo(scopeParameter),
82
+ refersTo(stateParameter),
83
+ ],
84
+ responses: {
85
+ '302': {
86
+ description: 'Redirects the user to the authorization interface.',
87
+ },
88
+ },
89
+ },
105
90
  };
106
- exports.definition = definition;
107
-
108
- var _default = (0, _knifecycle.handler)(getOAuth2Authorize, "getOAuth2Authorize", ["OAUTH2", "ERRORS_DESCRIPTORS", "oAuth2Granters", "log"]);
109
-
110
- exports.default = _default;
111
-
112
- async function getOAuth2Authorize({
113
- OAUTH2,
114
- ERRORS_DESCRIPTORS,
115
- oAuth2Granters,
116
- log
117
- }, {
118
- response_type: responseType,
119
- client_id: clientId,
120
- redirect_uri: demandedRedirectURI = '',
121
- scope: demandedScope = '',
122
- state,
123
- ...authorizeParameters
124
- }) {
125
- const url = new URL(OAUTH2.authenticateURL);
126
-
127
- try {
128
- const granter = oAuth2Granters.find(granter => granter.authorizer && granter.authorizer.responseType === responseType);
129
-
130
- if (!granter) {
131
- throw new _yerror.default('E_UNKNOWN_AUTHORIZER_TYPE', responseType);
91
+ export default autoHandler(getOAuth2Authorize);
92
+ async function getOAuth2Authorize({ OAUTH2, ERRORS_DESCRIPTORS, oAuth2Granters, log, }, { response_type: responseType, client_id: clientId, redirect_uri: demandedRedirectURI = '', scope: demandedScope = '', state, ...authorizeParameters }) {
93
+ const url = new URL(OAUTH2.authenticateURL);
94
+ try {
95
+ const granter = oAuth2Granters.find((granter) => granter.authorizer && granter.authorizer.responseType === responseType);
96
+ if (!granter) {
97
+ throw new YError('E_UNKNOWN_AUTHORIZER_TYPE', responseType);
98
+ }
99
+ const { applicationId, redirectURI, scope } = await granter.authorizer.authorize({
100
+ clientId,
101
+ redirectURI: demandedRedirectURI,
102
+ scope: demandedScope,
103
+ }, camelCaseObjectProperties(authorizeParameters));
104
+ url.searchParams.set('type', responseType);
105
+ url.searchParams.set('redirect_uri', redirectURI);
106
+ url.searchParams.set('scope', scope);
107
+ url.searchParams.set('client_id', applicationId);
108
+ }
109
+ catch (err) {
110
+ log('debug', '👫 - OAuth2 initialization error', err.code);
111
+ log('debug-stack', err.stack || 'no_stack_trace');
112
+ url.searchParams.set('redirect_uri', demandedRedirectURI);
113
+ setURLError(url, err, ERRORS_DESCRIPTORS[err.code] || ERRORS_DESCRIPTORS.E_OAUTH2);
132
114
  }
133
-
134
- const {
135
- applicationId,
136
- redirectURI,
137
- scope
138
- } = await granter.authorizer.authorize({
139
- clientId,
140
- redirectURI: demandedRedirectURI,
141
- scope: demandedScope
142
- }, camelCaseObjectProperties(authorizeParameters));
143
- url.searchParams.set('type', responseType);
144
- url.searchParams.set('redirect_uri', redirectURI);
145
- url.searchParams.set('scope', scope);
146
- url.searchParams.set('client_id', applicationId);
147
- } catch (err) {
148
- log('debug', '👫 - OAuth2 initialization error', err.code);
149
- log('debug-stack', err.stack || 'no_stack_trace');
150
- url.searchParams.set('redirect_uri', demandedRedirectURI);
151
- setURLError(url, err, ERRORS_DESCRIPTORS[err.code] || ERRORS_DESCRIPTORS.E_OAUTH2);
152
- }
153
-
154
- if (state) {
155
- url.searchParams.set('state', state);
156
- }
157
-
158
- return {
159
- status: 302,
160
- headers: {
161
- location: url.href
115
+ if (state) {
116
+ url.searchParams.set('state', state);
162
117
  }
163
- };
164
- } // The OAuth2 standard uses snake case names so we are
118
+ return {
119
+ status: 302,
120
+ headers: {
121
+ location: url.href,
122
+ },
123
+ };
124
+ }
125
+ // The OAuth2 standard uses snake case names so we are
165
126
  // converting them to the project standards asap
166
-
167
-
168
- function camelCaseObjectProperties(object) {
169
- return Object.keys(object).reduce((camelCasedObject, key) => {
170
- const newKey = key === 'redirect_uri' ? 'redirectURI' : (0, _camelcase.default)(key);
171
- camelCasedObject[newKey] = object[key];
172
- return camelCasedObject;
173
- }, {});
127
+ export function camelCaseObjectProperties(object) {
128
+ return Object.keys(object).reduce((camelCasedObject, key) => {
129
+ const newKey = key === 'redirect_uri' ? 'redirectURI' : camelCase(key);
130
+ camelCasedObject[newKey] = object[key];
131
+ return camelCasedObject;
132
+ }, {});
174
133
  }
175
-
176
- function setURLError(url, err, oAuth2Error) {
177
- url.searchParams.set('error', oAuth2Error.code);
178
-
179
- if (oAuth2Error.description) {
180
- url.searchParams.set('error_decription', oAuth2Error.description.replace(/\$([0-9]+)/g, (_, paramIndex) => {
181
- return (err.params || [])[parseInt(paramIndex, 10)];
182
- }));
183
- }
134
+ export function setURLError(url, err, oAuth2Error) {
135
+ url.searchParams.set('error', oAuth2Error.code);
136
+ if (oAuth2Error.description) {
137
+ url.searchParams.set('error_decription', oAuth2Error.description.replace(/\$([0-9]+)/g, (_, paramIndex) => {
138
+ return (err.params || [])[parseInt(paramIndex, 10)];
139
+ }));
140
+ }
184
141
  }
185
142
  //# sourceMappingURL=getOAuth2Authorize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getOAuth2Authorize.js","names":["responseTypeParameter","name","parameter","in","required","schema","type","enum","clientIdParameter","redirectURIParameter","pattern","format","scopeParameter","description","stateParameter","definition","method","path","operation","operationId","summary","tags","parameters","refersTo","responses","autoHandler","getOAuth2Authorize","OAUTH2","ERRORS_DESCRIPTORS","oAuth2Granters","log","response_type","responseType","client_id","clientId","redirect_uri","demandedRedirectURI","scope","demandedScope","state","authorizeParameters","url","URL","authenticateURL","granter","find","authorizer","YError","applicationId","redirectURI","authorize","camelCaseObjectProperties","searchParams","set","err","code","stack","setURLError","E_OAUTH2","status","headers","location","href","object","Object","keys","reduce","camelCasedObject","key","newKey","camelCase","oAuth2Error","replace","_","paramIndex","params","parseInt"],"sources":["../../src/handlers/getOAuth2Authorize.ts"],"sourcesContent":["import { autoHandler } from 'knifecycle';\nimport camelCase from 'camelcase';\nimport YError from 'yerror';\nimport { refersTo } from '@whook/whook';\nimport type {\n WhookAPIHandlerDefinition,\n WhookAPIParameterDefinition,\n WhookResponse,\n WhookErrorsDescriptors,\n WhookErrorDescriptor,\n} from '@whook/whook';\nimport type {\n OAuth2Options,\n OAuth2GranterService,\n} from '../services/oAuth2Granters';\nimport type { LogService } from 'common-services';\n\n/* Architecture Note #1: OAuth2 authorize\nThis endpoint simply redirect the user to the authentication\n server page by first checking the application details are\n fine.\n*/\n\nexport const responseTypeParameter: WhookAPIParameterDefinition = {\n name: 'responseType',\n parameter: {\n in: 'query',\n name: 'response_type',\n required: true,\n schema: {\n type: 'string',\n enum: ['code', 'token'],\n },\n },\n};\nexport const clientIdParameter: WhookAPIParameterDefinition = {\n name: 'clientId',\n parameter: {\n in: 'query',\n name: 'client_id',\n required: true,\n schema: {\n type: 'string',\n },\n },\n};\nexport const redirectURIParameter: WhookAPIParameterDefinition = {\n name: 'redirectURI',\n parameter: {\n in: 'query',\n name: 'redirect_uri',\n required: false,\n schema: {\n type: 'string',\n pattern: '^https?://',\n format: 'uri',\n },\n },\n};\nexport const scopeParameter: WhookAPIParameterDefinition = {\n name: 'scope',\n parameter: {\n in: 'query',\n name: 'scope',\n description: 'See https://tools.ietf.org/html/rfc6749#section-3.3',\n required: false,\n schema: {\n type: 'string',\n },\n },\n};\nexport const stateParameter: WhookAPIParameterDefinition = {\n name: 'state',\n parameter: {\n in: 'query',\n name: 'state',\n required: true,\n schema: {\n type: 'string',\n },\n },\n};\n\nexport const definition: WhookAPIHandlerDefinition = {\n method: 'get',\n path: '/oauth2/authorize',\n operation: {\n operationId: 'getOAuth2Authorize',\n summary: `Implements the [Authorization Endpoint](https://tools.ietf.org/html/rfc6749#section-3.1)\n as defined per the OAuth2 RFC.`,\n tags: ['oauth2'],\n parameters: [\n refersTo(responseTypeParameter),\n refersTo(clientIdParameter),\n refersTo(redirectURIParameter),\n refersTo(scopeParameter),\n refersTo(stateParameter),\n ],\n responses: {\n '302': {\n description: 'Redirects the user to the authorization interface.',\n },\n },\n },\n};\n\nexport default autoHandler(getOAuth2Authorize);\n\nasync function getOAuth2Authorize(\n {\n OAUTH2,\n ERRORS_DESCRIPTORS,\n oAuth2Granters,\n log,\n }: {\n OAUTH2: OAuth2Options;\n ERRORS_DESCRIPTORS: WhookErrorsDescriptors;\n oAuth2Granters: OAuth2GranterService[];\n log: LogService;\n },\n {\n response_type: responseType,\n client_id: clientId,\n redirect_uri: demandedRedirectURI = '',\n scope: demandedScope = '',\n state,\n ...authorizeParameters\n }: {\n response_type: string;\n client_id: string;\n redirect_uri?: string;\n scope?: string;\n state: string;\n } & Record<string, unknown>,\n): Promise<WhookResponse<302, { location: string }>> {\n const url = new URL(OAUTH2.authenticateURL);\n\n try {\n const granter = oAuth2Granters.find(\n (granter) =>\n granter.authorizer && granter.authorizer.responseType === responseType,\n );\n\n if (!granter) {\n throw new YError('E_UNKNOWN_AUTHORIZER_TYPE', responseType);\n }\n\n const { applicationId, redirectURI, scope } = await (\n granter.authorizer as NonNullable<OAuth2GranterService['authorizer']>\n ).authorize(\n {\n clientId,\n redirectURI: demandedRedirectURI,\n scope: demandedScope,\n },\n camelCaseObjectProperties(authorizeParameters),\n );\n\n url.searchParams.set('type', responseType);\n url.searchParams.set('redirect_uri', redirectURI);\n url.searchParams.set('scope', scope);\n url.searchParams.set('client_id', applicationId);\n } catch (err) {\n log('debug', '👫 - OAuth2 initialization error', (err as YError).code);\n log('debug-stack', (err as Error).stack || 'no_stack_trace');\n\n url.searchParams.set('redirect_uri', demandedRedirectURI);\n setURLError(\n url,\n err as YError,\n ERRORS_DESCRIPTORS[(err as YError).code] || ERRORS_DESCRIPTORS.E_OAUTH2,\n );\n }\n\n if (state) {\n url.searchParams.set('state', state);\n }\n\n return {\n status: 302,\n headers: {\n location: url.href,\n },\n };\n}\n\n// The OAuth2 standard uses snake case names so we are\n// converting them to the project standards asap\nexport function camelCaseObjectProperties<T>(\n object: Record<string, T>,\n): Record<string, T> {\n return Object.keys(object).reduce((camelCasedObject, key) => {\n const newKey = key === 'redirect_uri' ? 'redirectURI' : camelCase(key);\n\n camelCasedObject[newKey] = object[key];\n return camelCasedObject;\n }, {});\n}\n\nexport function setURLError(\n url: URL,\n err: YError | Error,\n oAuth2Error: WhookErrorDescriptor,\n): void {\n url.searchParams.set('error', oAuth2Error.code);\n if (oAuth2Error.description) {\n url.searchParams.set(\n 'error_decription',\n oAuth2Error.description.replace(/\\$([0-9]+)/g, (_, paramIndex) => {\n return ((err as YError).params || [])[parseInt(paramIndex, 10)];\n }),\n );\n }\n}\n"],"mappings":";;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAcA;AACA;AACA;AACA;AACA;AAEO,MAAMA,qBAAkD,GAAG;EAChEC,IAAI,EAAE,cAD0D;EAEhEC,SAAS,EAAE;IACTC,EAAE,EAAE,OADK;IAETF,IAAI,EAAE,eAFG;IAGTG,QAAQ,EAAE,IAHD;IAITC,MAAM,EAAE;MACNC,IAAI,EAAE,QADA;MAENC,IAAI,EAAE,CAAC,MAAD,EAAS,OAAT;IAFA;EAJC;AAFqD,CAA3D;;AAYA,MAAMC,iBAA8C,GAAG;EAC5DP,IAAI,EAAE,UADsD;EAE5DC,SAAS,EAAE;IACTC,EAAE,EAAE,OADK;IAETF,IAAI,EAAE,WAFG;IAGTG,QAAQ,EAAE,IAHD;IAITC,MAAM,EAAE;MACNC,IAAI,EAAE;IADA;EAJC;AAFiD,CAAvD;;AAWA,MAAMG,oBAAiD,GAAG;EAC/DR,IAAI,EAAE,aADyD;EAE/DC,SAAS,EAAE;IACTC,EAAE,EAAE,OADK;IAETF,IAAI,EAAE,cAFG;IAGTG,QAAQ,EAAE,KAHD;IAITC,MAAM,EAAE;MACNC,IAAI,EAAE,QADA;MA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